diff --git a/src/pages/Favorites/index.tsx b/src/pages/Favorites/index.tsx new file mode 100644 index 0000000..c21c589 --- /dev/null +++ b/src/pages/Favorites/index.tsx @@ -0,0 +1,77 @@ +import react, { useEffect, useRef, useState } from 'react' +import { useNavigate } from 'react-router-dom'; +import { backend, updateBackend } from '../../consts'; + +import { RusPassHeader } from '../../elements/Header'; +// import './style.css' + +import { EventCard } from '../../elements/EventCard'; +import { Spin } from 'antd'; + +export const Favorites: react.FC = () => { + const [favorites, setFavorites] = useState([]) + let navigate = useNavigate() + + + const queried = useRef(false); + + useEffect(()=>{ + updateBackend() + + const dataLoad = async () =>{ + const favorites = await backend.get('user/favorite') + return { + favorites + } + } + + if (!queried.current && localStorage.getItem('token') != null && localStorage.getItem('firstAuth') != 'true') { + queried.current = true; + dataLoad().then((data) => { + setFavorites(data.favorites.data as any); + }) + } + + if (null == localStorage.getItem('token')){ + navigate('/login') + } + }) + + return ( +
+ + +
+

Избранное

+
+ { + favorites.length == 0? + : + favorites.map((favorite:any, index)=>{ + return + + }) + } +
+
+ + Документация + +
+ + + + + +
+ +
© 2023 A project of the Government of Moscow
+
+ + ); +} \ No newline at end of file diff --git a/src/pages/Main/index.tsx b/src/pages/Main/index.tsx index 70d17c7..1cc8756 100644 --- a/src/pages/Main/index.tsx +++ b/src/pages/Main/index.tsx @@ -112,7 +112,7 @@ export const Main: react.FC = () => { }
- +
diff --git a/src/router.tsx b/src/router.tsx index 73a5ff3..2022b0a 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -9,6 +9,7 @@ import { EventMatch } from './pages/EventMatch'; import { GenerateTour } from './pages/GenerateTour'; import { SearchPage } from './pages/SearchPage'; import { Prefernces } from './elements/Prefernces'; +import { Favorites } from './pages/Favorites'; const routes = [ @@ -43,6 +44,10 @@ const routes = [ { path: '/prefs', element: + }, + { + path:'/favorites', + element: } ]