This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const citTag = '123456789'; | |
const store = { | |
order_attributes: [ | |
'citNumberId' | |
] | |
} | |
const storeOrderData = { | |
attributes: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type JavaScript here and click "Run Code" or press Ctrl + s | |
console.log('Hello, world!'); | |
// CHALLENGE 1 | |
function sumFunc(arr) { | |
// YOUR CODE HERE | |
let sum = 0 | |
for (let i = 0; i < arr.length; i++) { | |
sum += arr[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = () => { | |
return ( | |
<AuthenticationProvider> | |
<Router> | |
<Home path="/" /> | |
<UserProfile path="/myProfile" /> | |
<Dashboard path="/dashboard" /> | |
</Router> | |
</AuthenticationProvider> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { v4 as uuidv4 } from 'uuid'; | |
import { initialMovies } from './initialState'; | |
const MoviesContext = React.createContext(); | |
const ADD_MOVIE = 'ADD_MOVIE'; | |
const MARK_WATCHED_MOVIE = 'MARK_WATCHED_MOVIE'; | |
const moviesReducer = (state, action) => { | |
switch (action.type) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useMoviesContext } from './MoviesContext'; | |
const getInitialMovieForm = () => { | |
return { | |
title: '', | |
year: '', | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MoviesContext = React.createContext(); | |
const MARK_WATCHED_MOVIE = 'MARK_WATCHED_MOVIE'; | |
const moviesReducer = (state, action) => { | |
switch (action.type) { | |
case MARK_WATCHED_MOVIE: { | |
const movies = state.movies.map(movie => { | |
if (movie.id === action.payload.id) { | |
return { ...movie, watched: !movie.watched }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useMoviesContext } from './MoviesContext'; | |
export const Movie = ({ movie }) => { | |
const { markWatchedMovie } = useMoviesContext(); | |
const handleCheckboxChange = () => { | |
markWatchedMovie(movie.id); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Movie } from './Movie'; | |
import { useMoviesContext } from './MoviesContext'; | |
export const Movies = () => { | |
const { movies } = useMoviesContext(); | |
return ( | |
<section className="Movies"> | |
<h2>My Movies</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Movies } from './Movies'; | |
import { MoviesProvider } from './MoviesContext'; | |
import { NewMovie } from './NewMovie'; | |
import './App.scss'; | |
export const App = () => { | |
return ( | |
<div className="App"> | |
<MoviesProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
initialMovies = [ | |
{ | |
id: uuidv4(), | |
title: 'The Godfather', | |
year: 1972, | |
watched: false, | |
}, | |
{ | |
id: uuidv4(), |
NewerOlder