страница ошибок + переводы

This commit is contained in:
Nastya 2025-10-21 21:40:20 +03:00
parent 59d03a9a64
commit 1bb7ceb750
6 changed files with 70 additions and 9 deletions

@ -13,7 +13,7 @@ import { handleComponentError } from "@utils/handleComponentError";
import lightTheme from "@utils/themes/light";
import moment from "moment";
import { SnackbarProvider } from "notistack";
import { startTransition, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import React, { startTransition, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { ApologyPage } from "./ViewPublicationPage/ApologyPage";
import ViewPublicationPage from "./ViewPublicationPage/ViewPublicationPage";
@ -51,6 +51,16 @@ function QuizAnswererInner({
const yandexMetrics = useYandexMetricsGoals(quizSettings?.settings.cfg.yandexMetricsNumber);
const r = useQuizStore();
const { settings, questions } = useQuizStore();
const [currentTime, setCurrentTime] = React.useState(moment());
// Реактивный таймер для отслеживания времени
React.useEffect(() => {
const interval = setInterval(() => {
setCurrentTime(moment());
}, 1000);
return () => clearInterval(interval);
}, []);
useEffect(() => {
addquizid(quizId);
@ -114,6 +124,19 @@ function QuizAnswererInner({
return <ApologyPage error={new Error("no quiz id")} />;
}
// Проверяем, истекло ли время для overTime
const overTimeConfig = settings?.cfg?.overTime;
const isOverTimeEnabled = overTimeConfig?.enabled;
const isTimeExpired =
isOverTimeEnabled && overTimeConfig?.endsAt
? currentTime.isAfter(moment(overTimeConfig.endsAt)) || currentTime.isSame(moment(overTimeConfig.endsAt))
: false;
// Если время истекло и нет стартовой страницы, показываем ApologyPage
if (isTimeExpired && settings?.cfg?.noStartPage) {
return <ApologyPage error={new Error("quiz time expired")} />;
}
const quizContainer = (
<Box
ref={rootContainerRef}

@ -2,10 +2,12 @@ import { Box, Typography, useTheme } from "@mui/material";
import { useQuizStore } from "@stores/useQuizStore";
import moment from "moment";
import React from "react";
import { useTranslation } from "react-i18next";
export const OverTime = () => {
const theme = useTheme();
const { settings } = useQuizStore();
const { t } = useTranslation();
const [currentTime, setCurrentTime] = React.useState(moment());
// Реактивный таймер с useEffect
@ -66,7 +68,7 @@ export const OverTime = () => {
textAlign: "center",
}}
>
{overTimeConfig?.description || "Квиз станет недоступен через"}
{overTimeConfig?.description || t("Quiz will become unavailable in")}
</Typography>
<Box
sx={{
@ -105,7 +107,7 @@ export const OverTime = () => {
lineHeight: 1.2,
}}
>
дней
{t("days")}
</Typography>
</Box>
:
@ -136,7 +138,7 @@ export const OverTime = () => {
lineHeight: 1.2,
}}
>
часов
{t("hours")}
</Typography>
</Box>
:
@ -167,7 +169,7 @@ export const OverTime = () => {
lineHeight: 1.2,
}}
>
мин.
{t("minutes")}
</Typography>
</Box>
:
@ -198,7 +200,7 @@ export const OverTime = () => {
lineHeight: 1.2,
}}
>
сек.
{t("seconds")}
</Typography>
</Box>
</Box>

@ -56,5 +56,11 @@
"Step": "Step",
"questions are not ready yet": "There are no questions for the audience yet. Please wait",
"Add your image": "Add your image",
"select emoji": "select emoji"
"select emoji": "select emoji",
"quiz time expired": "Quiz time has expired",
"Quiz will become unavailable in": "Quiz will become unavailable in",
"days": "days",
"hours": "hours",
"minutes": "min.",
"seconds": "sec."
}

@ -59,5 +59,11 @@
"select emoji": "выберите смайлик",
"Please complete the phone number": "Пожалуйста, завершите номер телефона",
"Please enter a valid email": "Пожалуйста, введите корректную почту",
"Please enter a valid phone number": "Пожалуйста, введите корректный номер телефона"
"Please enter a valid phone number": "Пожалуйста, введите корректный номер телефона",
"quiz time expired": "Время квиза истекло",
"Quiz will become unavailable in": "Квиз станет недоступен через",
"days": "дней",
"hours": "часов",
"minutes": "мин.",
"seconds": "сек."
}

@ -56,5 +56,11 @@
"Step": "Qadam",
"questions are not ready yet": "Tomoshabinlar uchun hozircha savollar yo'q. Iltimos kuting",
"Add your image": "Rasmingizni qo'shing",
"select emoji": "emoji tanlang"
"select emoji": "emoji tanlang",
"quiz time expired": "Test vaqti tugadi",
"Quiz will become unavailable in": "Test quyidagi vaqtda mavjud bo'lmaydi",
"days": "kun",
"hours": "soat",
"minutes": "daq.",
"seconds": "son."
}

@ -73,6 +73,12 @@ const r = {
"Add your image": "Добавьте своё изображение",
"select emoji": "выберите смайлик",
"Please complete the phone number": "Пожалуйста, заполните номер телефона до конца",
"quiz time expired": "Время квиза истекло",
"Quiz will become unavailable in": "Квиз станет недоступен через",
days: "дней",
hours: "часов",
minutes: "мин.",
seconds: "сек.",
"": "", // Пустой ключ для fallback
},
},
@ -137,6 +143,12 @@ const r = {
"Add your image": "Add your image",
"select emoji": "select emoji",
"Please complete the phone number": "Please complete the phone number",
"quiz time expired": "Quiz time has expired",
"Quiz will become unavailable in": "Quiz will become unavailable in",
days: "days",
hours: "hours",
minutes: "min.",
seconds: "sec.",
"": "", // Пустой ключ для fallback
},
},
@ -201,6 +213,12 @@ const r = {
"Add your image": "Rasmingizni qo'shing",
"select emoji": "emoji tanlang",
"Please complete the phone number": "Iltimos, telefon raqamini to'liq kiriting",
"quiz time expired": "Test vaqti tugadi",
"Quiz will become unavailable in": "Test quyidagi vaqtda mavjud bo'lmaydi",
days: "kun",
hours: "soat",
minutes: "daq.",
seconds: "son.",
"": "", // Пустой ключ для fallback
},
},