contest submisssions

This commit is contained in:
Виталий Лавшонок
2025-11-07 12:57:27 +03:00
parent 046e5d1693
commit 93a5366fd5
12 changed files with 329 additions and 28 deletions

View File

@@ -1,9 +1,11 @@
import { useEffect } from 'react';
import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
import { setMenuActivePage } from '../../../redux/slices/store';
import { Navigate, Route, Routes, useParams } from 'react-router-dom';
import { Navigate, Route, Routes, useNavigate, useParams } from 'react-router-dom';
import { fetchContestById } from '../../../redux/slices/contests';
import ContestMissions from './Missions';
import { PrimaryButton } from '../../../components/button/PrimaryButton';
import Submissions from './Submissions';
export interface Article {
id: number;
@@ -12,14 +14,15 @@ export interface Article {
}
const Contest = () => {
const navigate = useNavigate();
const { contestId } = useParams<{ contestId: string }>();
const contestIdNumber =
contestId && /^\d+$/.test(contestId) ? parseInt(contestId, 10) : null;
if (contestIdNumber === null) {
if (!contestIdNumber) {
return <Navigate to="/home/contests" replace />;
}
const dispatch = useAppDispatch();
const contest = useAppSelector((state) => state.contests.selectedContest);
const contest = useAppSelector((state) => state.contests.fetchContestById.contest);
useEffect(() => {
dispatch(setMenuActivePage('contest'));
@@ -31,12 +34,19 @@ const Contest = () => {
return (
<div>
<PrimaryButton onClick={() => {navigate(`/contest/${contestIdNumber}/submissions`)}} text='Мои посылки' />
<Routes>
<Route
path="submissions"
element={<Submissions contestId={contestIdNumber} />}
/>
<Route
path="*"
element={<ContestMissions contest={contest} />}
/>
</Routes>
</div>
);
};