-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Egor Podolskiy
committed
Oct 6, 2024
1 parent
d9ee4c0
commit 0115f99
Showing
8 changed files
with
405 additions
and
316 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import { BrowserRouter, Route, Routes } from 'react-router-dom'; | ||
import { MainPage } from '../pages/main-page'; | ||
import { LoginPage } from '../pages/login-page'; | ||
import { FavoritesPage } from '../pages/favorites-page'; | ||
import { OfferPage } from '../pages/offer-page'; | ||
import { PrivateRoute } from '../shared/routes/private-route'; | ||
import { Page404 } from '../pages/errors'; | ||
|
||
const OFFERS_AMOUNT = 555; | ||
|
||
export const App = () => ( | ||
<MainPage offersAmount={OFFERS_AMOUNT} /> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path='/'> | ||
<Route index element={<MainPage offersAmount={OFFERS_AMOUNT} />} /> | ||
<Route path='login' element={<LoginPage />} /> | ||
<Route path='favorites' element={( | ||
<PrivateRoute isAuthenticated={false}> | ||
<FavoritesPage /> | ||
</PrivateRoute> | ||
)} | ||
/> | ||
<Route path='offer/:id' element={<OfferPage />} /> | ||
</Route> | ||
<Route path='*' element={<Page404 />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import styles from './styles.module.css'; | ||
|
||
export const Page404 = () => { | ||
const navigate = useNavigate(); | ||
|
||
const handleButtonClick = () => { | ||
navigate('/', { replace: true }); | ||
}; | ||
|
||
return ( | ||
<div className={styles.page}> | ||
<h1 className={styles.title}>Page Not Found</h1> | ||
<p className={styles.description}>Sorry we find no one page with this path, return to the main page</p> | ||
<button className={styles.backButton} onClick={handleButtonClick}>Go to main page</button> | ||
</div> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.page { | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
/* TODO: подключить normalize.css */ | ||
.title { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.backButton { | ||
margin-top: 20px; | ||
background-color: #0d0d0d; | ||
border: none; | ||
color: white; | ||
padding: 15px 20px; | ||
border-radius: 15px; | ||
cursor: pointer; | ||
} | ||
|
||
.backButton:hover { | ||
opacity: 0.7; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Page404 } from './404'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { OfferCard } from '../../components'; | ||
import {Link} from 'react-router-dom'; | ||
|
||
type Props = { | ||
offersAmount: number; | ||
|
@@ -20,12 +21,12 @@ export const MainPage = (props: Props) => { | |
<nav className="header__nav"> | ||
<ul className="header__nav-list"> | ||
<li className="header__nav-item user"> | ||
<a className="header__nav-link header__nav-link--profile" href="#"> | ||
<Link className="header__nav-link header__nav-link--profile" to='/favorites'> | ||
<div className="header__avatar-wrapper user__avatar-wrapper"> | ||
</div> | ||
<span className="header__user-name user__name">[email protected]</span> | ||
<span className="header__favorite-count">3</span> | ||
</a> | ||
</Link> | ||
</li> | ||
<li className="header__nav-item"> | ||
<a className="header__nav-link" href="#"> | ||
|
Oops, something went wrong.