From 1bb7ceb750a8069b903d00cc806b20bbaf5bfd10 Mon Sep 17 00:00:00 2001 From: Nastya Date: Tue, 21 Oct 2025 21:40:20 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20+=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/QuizAnswerer.tsx | 25 ++++++++++++++++++- .../StartPageViewPublication/OverTime.tsx | 12 +++++---- public/locales/en.json | 8 +++++- public/locales/ru.json | 8 +++++- public/locales/uz.json | 8 +++++- src/i18n/i18nWidget.ts | 18 +++++++++++++ 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/lib/components/QuizAnswerer.tsx b/lib/components/QuizAnswerer.tsx index 19dc1e9..8a8c040 100644 --- a/lib/components/QuizAnswerer.tsx +++ b/lib/components/QuizAnswerer.tsx @@ -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 ; } + // Проверяем, истекло ли время для 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 ; + } + const quizContainer = ( { 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")} { lineHeight: 1.2, }} > - дней + {t("days")} : @@ -136,7 +138,7 @@ export const OverTime = () => { lineHeight: 1.2, }} > - часов + {t("hours")} : @@ -167,7 +169,7 @@ export const OverTime = () => { lineHeight: 1.2, }} > - мин. + {t("minutes")} : @@ -198,7 +200,7 @@ export const OverTime = () => { lineHeight: 1.2, }} > - сек. + {t("seconds")} diff --git a/public/locales/en.json b/public/locales/en.json index b6d0001..1fe038b 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -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." } diff --git a/public/locales/ru.json b/public/locales/ru.json index d346874..f17f6b6 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -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": "сек." } diff --git a/public/locales/uz.json b/public/locales/uz.json index a272df0..222c163 100644 --- a/public/locales/uz.json +++ b/public/locales/uz.json @@ -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." } diff --git a/src/i18n/i18nWidget.ts b/src/i18n/i18nWidget.ts index 50f581e..3289860 100644 --- a/src/i18n/i18nWidget.ts +++ b/src/i18n/i18nWidget.ts @@ -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 }, },