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 ( +