import { useEffect } from 'react'; import { SecondaryButton } from '../../../components/button/SecondaryButton'; import { cn } from '../../../lib/cn'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import ContestsBlock from './ContestsBlock'; import { setMenuActivePage } from '../../../redux/slices/store'; import { fetchContests } from '../../../redux/slices/contests'; const Contests = () => { const dispatch = useAppDispatch(); const now = new Date(); // Берём данные из Redux const contests = useAppSelector((state) => state.contests.contests); const loading = useAppSelector((state) => state.contests.status); const error = useAppSelector((state) => state.contests.error); // При загрузке страницы — выставляем активную вкладку и подгружаем контесты useEffect(() => { dispatch(setMenuActivePage('contests')); dispatch(fetchContests({})); }, []); if (loading == 'loading') { return (
Загрузка контестов...
); } if (error) { return
Ошибка: {error}
; } return (
Контесты
{}} text="Создать группу" className="absolute right-0" />
{ const endTime = new Date(contest.endsAt).getTime(); return endTime >= now.getTime(); })} /> { const endTime = new Date(contest.endsAt).getTime(); return endTime < now.getTime(); })} />
); }; export default Contests;