-
Notifications
You must be signed in to change notification settings - Fork 0
Mini challenge 5 routing #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8cc4c26
d40b158
01ee58c
ecdb29e
f5f05c3
af685e7
17babce
c5cc39b
89c2e49
106ff77
69da0a6
b21a2a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| REACT_APP_API_YOUTUBE_KEY = AIzaSyAOsyZMq5msH04OZ9W7Y_fQX--TictP_v8 | ||
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import React, { useReducer } from 'react'; | ||
| import { Switch, Route, BrowserRouter } from 'react-router-dom'; | ||
| import styled from 'styled-components'; | ||
| import AuthProvider from '../../providers/Auth/Auth.provider'; | ||
| import VideoDetail from '../VideoDetail'; | ||
| import NavBar from '../NavBar'; | ||
| import HomePage from '../../pages/Home'; | ||
| import SearchContext from '../../state/SearchContext'; | ||
| import SearchReducer from '../../state/SearchReducer'; | ||
| import LocalThemeProvider from '../../state/ThemeContext.provider'; | ||
| import VideoProvider from '../../providers/Video/Video.provider'; | ||
| import Login from '../../pages/Login/Login'; | ||
| import FavoritesProvider from '../../providers/Favorites/Favorites'; | ||
| import FavoriteVideos from '../../pages/FavoriteVideos/FavoriteVideos'; | ||
| import FavoriteVideoDetail from '../../pages/FavoriteVideoDetail/FavoriteVideoDetail'; | ||
| import Private from '../Private/Private.component'; | ||
| import NotFound from '../../pages/NotFound/NotFound'; | ||
|
|
||
| function App() { | ||
| const [state, dispatch] = useReducer(SearchReducer, { | ||
| search: 'Wizeline', | ||
| video: null, | ||
| }); | ||
|
|
||
| const AppStyled = styled.div` | ||
| width: 100%; | ||
| height: 100vh; | ||
| `; | ||
|
|
||
| return ( | ||
| <BrowserRouter> | ||
| <AuthProvider> | ||
| <AppStyled> | ||
| <VideoProvider> | ||
| <LocalThemeProvider> | ||
| <FavoritesProvider> | ||
| <SearchContext.Provider value={{ state, dispatch }}> | ||
| <NavBar /> | ||
| <Switch> | ||
| <Route exact path="/"> | ||
| <HomePage /> | ||
| </Route> | ||
| <Route exact path="/video"> | ||
| <VideoDetail /> | ||
| </Route> | ||
| <Route exact path="/login"> | ||
| <Login /> | ||
| </Route> | ||
| <Private exact path="/favorites"> | ||
| <FavoriteVideos /> | ||
| </Private> | ||
| <Private exact path="/favoritedetails"> | ||
| <FavoriteVideoDetail /> | ||
| </Private> | ||
|
Comment on lines
+43
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the routes import { useParams } from 'react-router-dom';
....
function Component () {
...
const { id } = useParams();
} |
||
| <Route path="*"> | ||
| <NotFound /> | ||
| </Route> | ||
| </Switch> | ||
| </SearchContext.Provider> | ||
| </FavoritesProvider> | ||
| </LocalThemeProvider> | ||
| </VideoProvider> | ||
| </AppStyled> | ||
| </AuthProvider> | ||
| </BrowserRouter> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| export { default } from './App.component'; | ||
| export { default } from './App'; |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React, { useContext } from 'react'; | ||
| import styled from 'styled-components'; | ||
| import { VideoContext } from '../../providers/Video/Video.provider'; | ||
|
|
||
| const InputSearchStyled = styled.div` | ||
| margin-left: 50px; | ||
| `; | ||
|
|
||
| export default function InputSearch() { | ||
| const { searchTerm, setSearchTerm } = useContext(VideoContext); | ||
|
|
||
| const handleChangeSearchInput = (value) => { | ||
| setSearchTerm(value); | ||
| }; | ||
|
|
||
| return ( | ||
| <InputSearchStyled> | ||
| <input | ||
| type="text" | ||
| placeholder="Search" | ||
| onChange={(event) => handleChangeSearchInput(event.target.value)} | ||
| value={searchTerm} | ||
| /> | ||
| </InputSearchStyled> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './InputSearch'; |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import React from 'react'; | ||
| import { Link, useHistory } from 'react-router-dom'; | ||
| import { FcManager, FcHome, FcLike } from 'react-icons/fc'; | ||
| import { GiExitDoor } from 'react-icons/gi'; | ||
| import InputSearch from '../InputSearch'; | ||
| import { useAuth } from '../../providers/Auth/Auth.provider'; | ||
| import { NavBarStyled, LinkText } from './NavBar.styles'; | ||
|
|
||
| function NavBar() { | ||
| const { authenticated, logout } = useAuth(); | ||
| const history = useHistory(); | ||
|
|
||
| function RemoveAuth(event) { | ||
| event.preventDefault(); | ||
| logout(); | ||
| history.push('/'); | ||
| } | ||
|
|
||
| return ( | ||
| <NavBarStyled> | ||
| <InputSearch /> | ||
| <div> | ||
| {authenticated ? ( | ||
| <> | ||
| <Link to="/"> | ||
| <FcHome size="50" /> | ||
| </Link> | ||
|
|
||
| <Link to="/favorites"> | ||
| <LinkText> | ||
| <FcLike size="50" /> | ||
| </LinkText> | ||
| </Link> | ||
| <Link to="/" onClick={RemoveAuth}> | ||
| <LinkText> | ||
| <GiExitDoor size="60" /> | ||
| </LinkText> | ||
| </Link> | ||
| </> | ||
| ) : ( | ||
| <div> | ||
| <Link to="/"> | ||
| <FcHome size="50" /> | ||
| </Link> | ||
| <Link to="/login"> | ||
| <FcManager size="60" /> | ||
| </Link> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </NavBarStyled> | ||
| ); | ||
| } | ||
|
|
||
| export default NavBar; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const NavBarStyled = styled.div` | ||
| background-color: ${(props) => props.theme.navBar}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| height: 60px; | ||
| `; | ||
|
|
||
| export const LinkText = styled.span` | ||
| cursor: hand; | ||
| color: ${(props) => props.theme.cardBg}; | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './NavBar'; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import React from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
| import { Container, Title } from './VideoCard.styles'; | ||
|
|
||
| const VideoCard = ({ video, handleVideoSelected, isFavorite }) => { | ||
| if (!video) { | ||
| return <div>No video </div>; | ||
| } | ||
|
|
||
| return ( | ||
| <Container> | ||
| <Link | ||
| to={isFavorite ? '/favoritedetails' : '/video'} | ||
| onClick={() => handleVideoSelected(video)} | ||
| > | ||
| <div> | ||
| <img alt="" src={video.snippet.thumbnails.default.url} /> | ||
| <div> | ||
| <Title>{video.snippet.title}</Title> | ||
| </div> | ||
| </div> | ||
| </Link> | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default VideoCard; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const Container = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| border-bottom: 1px solid #cccccc; | ||
| border-radius: 5px; | ||
| padding: 20px; | ||
| max-width: 320px; | ||
| min-width: 320px; | ||
| margin: 20px; | ||
| background-color: ${(props) => props.theme.cardBg}; | ||
| a { | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| :hover { | ||
| background-color: ${(props) => props.theme.overBg}; | ||
| } | ||
| box-shadow: 0px 0px 5px 1px black; | ||
| `; | ||
|
|
||
| export const Title = styled.p` | ||
| color: ${(props) => props.theme.textcolor}; | ||
| text-decoration: none; | ||
| font-style: normal; | ||
| font-size: 20px; | ||
| align-items: left; | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: bold; | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './VideoCard'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing this file from git, you should never upload secrets to your git repository and, I suggest creating a file called
.env.examplewith all the needed variables