Add ettempts in contests

This commit is contained in:
Виталий Лавшонок
2025-12-03 21:15:42 +03:00
parent 8f337e6f7b
commit 358c7def78
14 changed files with 377 additions and 260 deletions

View File

@@ -9,6 +9,7 @@ import { fetchMissionById, setMissionsStatus } from '../redux/slices/missions';
import Header from '../views/mission/statement/Header';
import MissionSubmissions from '../views/mission/statement/MissionSubmissions';
import { useQuery } from '../hooks/useQuery';
import { fetchMyAttemptsInContest } from '../redux/slices/contests';
const Mission = () => {
const dispatch = useAppDispatch();
@@ -20,6 +21,10 @@ const Mission = () => {
const missionStatus = useAppSelector(
(state) => state.missions.statuses.fetchById,
);
const attempt = useAppSelector(
(state) => state.contests.fetchMyAttemptsInContest.attempts[0],
);
const missionIdNumber = Number(missionId);
const query = useQuery();
@@ -44,6 +49,9 @@ const Mission = () => {
if (pollingRef.current) return;
pollingRef.current = setInterval(async () => {
if (contestId) {
dispatch(fetchMyAttemptsInContest(contestId));
}
dispatch(fetchMySubmitsByMission(missionIdNumber));
const hasWaiting = submissionsRef.current.some(
@@ -63,6 +71,12 @@ const Mission = () => {
}, 5000); // 10 секунд
};
useEffect(() => {
if (contestId) {
dispatch(fetchMyAttemptsInContest(contestId));
}
}, [contestId]);
useEffect(() => {
dispatch(fetchMissionById(missionIdNumber));
dispatch(fetchMySubmitsByMission(missionIdNumber));
@@ -194,7 +208,8 @@ const Mission = () => {
language: language,
languageVersion: 'latest',
sourceCode: code,
contestId: contestId,
contestAttemptId:
attempt?.attemptId,
}),
).unwrap();
dispatch(