diff --git a/src/components/App.tsx b/src/components/App.tsx index bb1f2c0..e693b57 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,11 +1,41 @@ -import {MainScreen} from './pages/MainScreen'; +import { BrowserRouter, Route, Routes } from 'react-router-dom'; +import { HelmetProvider } from 'react-helmet-async'; +import MainScreen from './pages/MainScreen'; +import Login from './pages/Login'; +import Favorites from './pages/Favorites'; +import Offer from './pages/Offer'; +import NotFound from './NotFound'; +import AppRoute, { AuthorizationStatus } from '../const'; +import PrivateRoute from './private-route'; +import { OffersType } from '../types/offer'; type AppScreenProps = { placesCount: number; + offers: OffersType[]; + favorites: OffersType[]; } -function App({placesCount}: AppScreenProps){ +function App({placesCount, offers, favorites}: AppScreenProps){ return ( - + + + + } /> + }/> + + + + } + /> + }/> + }/> + + + ); } export default App; diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx new file mode 100644 index 0000000..527daa1 --- /dev/null +++ b/src/components/Logo.tsx @@ -0,0 +1,17 @@ +import { Link } from 'react-router-dom'; + +function Logo(){ + return( + + 6 cities logo + + ); +} + +export default Logo; diff --git a/src/components/NotFound.tsx b/src/components/NotFound.tsx new file mode 100644 index 0000000..493c6c1 --- /dev/null +++ b/src/components/NotFound.tsx @@ -0,0 +1,12 @@ +import { Link } from 'react-router-dom'; + +function NotFound() { + return ( +
+

404 Not Found

+ Go to Home Page +
+ ); +} + +export default NotFound; diff --git a/src/components/commentForm.tsx b/src/components/commentForm.tsx new file mode 100644 index 0000000..3ee8b25 --- /dev/null +++ b/src/components/commentForm.tsx @@ -0,0 +1,120 @@ +import { useState } from 'react'; + +function CommentForm() { + const [text, setText] = useState(''); + return ( +
+ +
+ + + + + + + + + + +
+ +
+

+ To submit review please make sure to set{' '} + rating and describe your stay + with at least 50 characters. +

+ +
+
+ ); +} + +export default CommentForm; diff --git a/src/components/favoritesList.tsx b/src/components/favoritesList.tsx new file mode 100644 index 0000000..52ffc60 --- /dev/null +++ b/src/components/favoritesList.tsx @@ -0,0 +1,18 @@ +import { OffersType } from '../types/offer'; +import Card from './pages/Card'; + +type FavoritesListProps = { + favorites: OffersType[]; +}; + +function FavoritesList({ favorites }: FavoritesListProps) { + return ( +
+ {favorites.map((favorite) => ( + + ))} +
+ ); +} + +export default FavoritesList; diff --git a/src/components/offersList.tsx b/src/components/offersList.tsx new file mode 100644 index 0000000..1571d73 --- /dev/null +++ b/src/components/offersList.tsx @@ -0,0 +1,18 @@ +import Card from './pages/Card'; +import { OffersType } from '../types/offer'; + +interface OffersListProps { + offers: OffersType[]; +} + +function OffersList({ offers }: OffersListProps) { + return ( +
+ {offers.map((offer) => ( + + ))} +
+ ); +} + +export default OffersList; diff --git a/src/components/pages/Card.tsx b/src/components/pages/Card.tsx index 32c05b8..584c91f 100644 --- a/src/components/pages/Card.tsx +++ b/src/components/pages/Card.tsx @@ -1,62 +1,67 @@ -import React from 'react'; +import { useState } from 'react'; +import { OffersType } from '../../types/offer'; +import { Link } from 'react-router-dom'; -interface CardProps { - premium: boolean; - imageUrl: string; - price: string; - bookmarked: boolean; - rating: number; - title: string; - type: string; -} +type CardProps = { + offer: OffersType; +}; -const Card: React.FC = ({ premium, imageUrl, price, bookmarked, rating, title, type }) => ( -
- {premium && ( -
- Premium -
- )} -
- - Place image - -
-
-
-
- {price} - /night +function Card({ offer }: CardProps) { + const { id, title, imageUrl, type, rating, price, favorite, premium } = offer; + const [, setActive] = useState(''); + return ( +
setActive(id.toString())} + > + {premium && ( +
+ Premium
- + )} + -
-
- - Rating +
+
+
+ €{price} + / night +
+ +
+
+
+ + Rating +
+

+ + {title} + +

+

{type}

-

- {title} -

-

{type}

-
-
-); - +
+ ); +} export default Card; + diff --git a/src/components/pages/Favorites.tsx b/src/components/pages/Favorites.tsx index 3b51022..2afd508 100644 --- a/src/components/pages/Favorites.tsx +++ b/src/components/pages/Favorites.tsx @@ -1,19 +1,26 @@ -function Favorites(){ +import { Link } from 'react-router-dom'; +import { OffersType } from '../../types/offer'; +import FavoritesList from '../favoritesList'; +import Logo from '../Logo'; +import { Helmet } from 'react-helmet-async'; + +type FavoritesProps = { + favorites: OffersType[]; +}; + +function Favorites({favorites}: FavoritesProps){ return (
+ + Избранное +
- - 6 cities logo - + + +
-
-

Saved listing

- -
+