From a4179a46f4d3d1eecfff6af99ae86a1768dee33a Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 17 Jul 2024 01:02:56 +0300 Subject: [PATCH 1/8] v1.0.53 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db3f0d1..af1aefe 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.51", + "version": "1.0.53", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js", From 7a10673d8a41c7b7e92437f6ac05768040f75d34 Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 17 Jul 2024 03:08:20 +0300 Subject: [PATCH 2/8] =?UTF-8?q?=D0=A1=D1=82=D0=B0=D1=80=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0?= =?UTF-8?q?=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=B8=D0=B7=D0=B8=D1=80=D1=83=D0=B5?= =?UTF-8?q?=D1=82=20=D0=B1=D1=80=D0=B0=D1=82=D1=8C=20=D0=BB=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D1=80=D0=B5=D0=B2=D1=8C=D1=8E=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=B8=D0=BB=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api/hooks.ts | 4 ++-- lib/components/QuizAnswerer.tsx | 6 +++--- lib/components/ViewPublicationPage/ApologyPage.tsx | 1 + lib/components/ViewPublicationPage/ViewPublicationPage.tsx | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/api/hooks.ts b/lib/api/hooks.ts index 633b773..e54c8c1 100644 --- a/lib/api/hooks.ts +++ b/lib/api/hooks.ts @@ -1,8 +1,8 @@ import useSWR from "swr"; import { getQuizData } from "./quizRelase"; -export function useQuizData(quizId: string) { - return useSWR(["quizData", quizId], (params) => getQuizData(params[1]), { +export function useQuizData(quizId: string, preview: boolean = false) { + return useSWR(preview ? null : ["quizData", quizId], (params) => getQuizData(params[1]), { revalidateOnFocus: false, revalidateOnReconnect: false, shouldRetryOnError: false, diff --git a/lib/components/QuizAnswerer.tsx b/lib/components/QuizAnswerer.tsx index d632a8b..4328b76 100644 --- a/lib/components/QuizAnswerer.tsx +++ b/lib/components/QuizAnswerer.tsx @@ -43,7 +43,7 @@ function QuizAnswererInner({ const [quizViewStore] = useState(createQuizViewStore); const [rootContainerWidth, setRootContainerWidth] = useState(() => window.innerWidth); const rootContainerRef = useRef(null); - const { data, error, isLoading } = useQuizData(quizId); + const { data, error, isLoading } = useQuizData(quizId, preview); const vkMetrics = useVkMetricsGoals(quizSettings?.settings.cfg.vkMetricsNumber); const yandexMetrics = useYandexMetricsGoals(quizSettings?.settings.cfg.yandexMetricsNumber); @@ -74,10 +74,10 @@ function QuizAnswererInner({ if (isLoading) return ; if (error) return ; - if (!data) return ; + // if (!data) return ; quizSettings ??= data; - if (!quizSettings) throw new Error("Quiz data is null"); + if (!quizSettings) return ; if (quizSettings.questions.length === 0) return ; if (!quizId) return ; diff --git a/lib/components/ViewPublicationPage/ApologyPage.tsx b/lib/components/ViewPublicationPage/ApologyPage.tsx index a7c3e6b..8633053 100644 --- a/lib/components/ViewPublicationPage/ApologyPage.tsx +++ b/lib/components/ViewPublicationPage/ApologyPage.tsx @@ -10,6 +10,7 @@ export const ApologyPage = ({ error }: Props) => { if (error.message === "No questions found") message = "Нет созданных вопросов"; if (error.message === "Quiz already completed") message = "Вы уже прошли этот опрос"; if (error.message === "No quiz id") message = "Отсутствует id квиза"; + if (error.message === "Quiz data is null") message = "Не были переданы параметры квиза"; if (error.response?.data === "Invalid request data") message = "Такого квиза не существует"; return ( diff --git a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx index b4c22cd..8bf9e27 100644 --- a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx +++ b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx @@ -34,8 +34,8 @@ export default function ViewPublicationPage() { showResultAfterContactForm, setQuestion, } = useQuestionFlowControl(); - useYandexMetrics(settings?.cfg?.yandexMetricsNumber); - useVKMetrics(settings?.cfg?.vkMetricsNumber); + // useYandexMetrics(settings?.cfg?.yandexMetricsNumber); + // useVKMetrics(settings?.cfg?.vkMetricsNumber); useEffect( function setFaviconAndTitle() { From 4bf0211694d88341fc0a3a5b81ef96109435153f Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 17 Jul 2024 03:10:19 +0300 Subject: [PATCH 3/8] v1.0.54 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af1aefe..f6ec41e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.53", + "version": "1.0.54", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js", From 9505f6e21c721a6bbfa55eb1a2b1bdfc346b7f39 Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 17 Jul 2024 03:49:56 +0300 Subject: [PATCH 4/8] =?UTF-8?q?=D0=98=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D0=BA=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D1=85=20=D0=BF=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewPublicationPage/ViewPublicationPage.tsx | 4 ++-- lib/utils/hooks/metrics/useVKMetrics.ts | 4 ++-- lib/utils/hooks/metrics/useYandexMetrics.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx index 8bf9e27..f6fe595 100644 --- a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx +++ b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx @@ -34,8 +34,8 @@ export default function ViewPublicationPage() { showResultAfterContactForm, setQuestion, } = useQuestionFlowControl(); - // useYandexMetrics(settings?.cfg?.yandexMetricsNumber); - // useVKMetrics(settings?.cfg?.vkMetricsNumber); + useYandexMetrics(settings?.cfg?.yandexMetricsNumber, preview); + useVKMetrics(settings?.cfg?.vkMetricsNumber, preview); useEffect( function setFaviconAndTitle() { diff --git a/lib/utils/hooks/metrics/useVKMetrics.ts b/lib/utils/hooks/metrics/useVKMetrics.ts index fa339c8..31d21a7 100644 --- a/lib/utils/hooks/metrics/useVKMetrics.ts +++ b/lib/utils/hooks/metrics/useVKMetrics.ts @@ -1,8 +1,8 @@ import { useEffect } from "react"; -export const useVKMetrics = (vkMetricsNumber: number | undefined) => { +export const useVKMetrics = (vkMetricsNumber: number | undefined, preview: boolean = false) => { useEffect(() => { - if (vkMetricsNumber && typeof vkMetricsNumber === "number" && !Number.isNaN(vkMetricsNumber)) { + if (vkMetricsNumber && typeof vkMetricsNumber === "number" && !Number.isNaN(vkMetricsNumber) && !preview) { const script = document.createElement("script"); script.type = "text/javascript"; script.innerHTML = ` diff --git a/lib/utils/hooks/metrics/useYandexMetrics.ts b/lib/utils/hooks/metrics/useYandexMetrics.ts index 35ecbf3..bc772e5 100644 --- a/lib/utils/hooks/metrics/useYandexMetrics.ts +++ b/lib/utils/hooks/metrics/useYandexMetrics.ts @@ -1,8 +1,13 @@ import { useEffect } from "react"; -export const useYandexMetrics = (yandexMetricsNumber: number | undefined) => { +export const useYandexMetrics = (yandexMetricsNumber: number | undefined, preview: boolean = false) => { useEffect(() => { - if (yandexMetricsNumber && typeof yandexMetricsNumber === "number" && !Number.isNaN(yandexMetricsNumber)) { + if ( + yandexMetricsNumber && + typeof yandexMetricsNumber === "number" && + !Number.isNaN(yandexMetricsNumber) && + !preview + ) { const script = document.createElement("script"); script.type = "text/javascript"; script.innerHTML = ` From 2610680b978097332357c493291950c2f6f4e3ea Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 17 Jul 2024 03:50:51 +0300 Subject: [PATCH 5/8] v1.0.55 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f6ec41e..5c88c7e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.54", + "version": "1.0.55", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js", From 90a967a8e605b52aea5a8d47e22fd3d51ac3066e Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 28 Aug 2024 03:18:19 +0300 Subject: [PATCH 6/8] replice filename space to _ --- lib/api/quizRelase.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index 99fb4a9..5dbc126 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -189,15 +189,18 @@ export function sendFile({ questionId, body, qid }: SendFileParams) { if (body.preview) return; const formData = new FormData(); + const file = new File([body.file], body.file.name.replace(/\s/g, "_")); + const nameImage = body.name.replace(/\s/g, "_"); + const answers: Answer[] = [ { question_id: questionId, - content: "file:" + body.name, + content: "file:" + nameImage, }, ]; formData.append("answers", JSON.stringify(answers)); - formData.append(body.name, body.file); + formData.append(nameImage, file); formData.append("qid", qid); return publicationMakeRequest({ From eb33e495f30238c05e8a9efd636078db5859f7ba Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 28 Aug 2024 10:02:48 +0300 Subject: [PATCH 7/8] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B8=20=D0=BA=20=D1=83=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8E=20=D0=BA=D0=B2=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/hooks/useQuestionFlowControl.ts | 56 +++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/utils/hooks/useQuestionFlowControl.ts b/lib/utils/hooks/useQuestionFlowControl.ts index 6a6393a..f8feaff 100644 --- a/lib/utils/hooks/useQuestionFlowControl.ts +++ b/lib/utils/hooks/useQuestionFlowControl.ts @@ -11,29 +11,44 @@ import { useVkMetricsGoals } from "@/utils/hooks/metrics/useVkMetricsGoals"; import { useYandexMetricsGoals } from "@/utils/hooks/metrics/useYandexMetricsGoals"; export function useQuestionFlowControl() { + //Получаем инфо о квизе и список вопросов. const { settings, questions } = useQuizSettings(); + //Когда квиз линейный, не ветвящийся, мы идём по вопросам по их порядковому номеру. Это их page. + //За корректность page отвечает конструктор квизов. Интересный факт, если в конструкторе удалить из середины вопрос, то случится куча запросов изменения вопросов с изменением этого page const sortedQuestions = useMemo(() => { return [...questions].sort((a, b) => a.page - b.page); }, [questions]); + //React сам будет менять визуал - главное говорить из какого вопроса ему брать инфо. Изменение этой переменной меняет визуал. const [currentQuestionId, setCurrentQuestionId] = useState(getFirstQuestionId); + //Список ответов на вопрос. Мы записываем ответы локально, параллельно отправляя на бек информацию о ответах const answers = useQuizViewStore((state) => state.answers); + //Список засчитанных баллов для балловых квизов const pointsSum = useQuizViewStore((state) => state.pointsSum); + //Текущий шаг "startpage" | "question" | "contactform" const setCurrentQuizStep = useQuizViewStore((state) => state.setCurrentQuizStep); + //Получение возможности управлять состоянием метрик const vkMetrics = useVkMetricsGoals(settings.cfg.vkMetricsNumber); const yandexMetrics = useYandexMetricsGoals(settings.cfg.yandexMetricsNumber); + //Изменение стейта (переменной currentQuestionId) ведёт к пересчёту что же за объект сейчас используется. Мы каждый раз просто ищем в списке const currentQuestion = sortedQuestions.find((question) => question.id === currentQuestionId) ?? sortedQuestions[0]; - const linearQuestionIndex = + //Индекс текущего вопроса только если квиз линейный + const linearQuestionIndex = //: number | null currentQuestion && sortedQuestions.every(({ content }) => content.rule.parentId !== "root") // null when branching enabled ? sortedQuestions.indexOf(currentQuestion) : null; + //Индекс первого вопроса function getFirstQuestionId() { - if (sortedQuestions.length === 0) return null; + //: string | null + if (sortedQuestions.length === 0) return null; //Если нету сортированного списка, то и не рыпаемся if (settings.cfg.haveRoot) { + // Если есть ветвление, то settings.cfg.haveRoot будет заполнен + //Если заполнен, то дерево растёт с root и это 1 вопрос :) const nextQuestion = sortedQuestions.find( + //Функция ищет первое совпадение по массиву (question) => question.id === settings.cfg.haveRoot || question.content.id === settings.cfg.haveRoot ); if (!nextQuestion) return null; @@ -41,6 +56,7 @@ export function useQuestionFlowControl() { return nextQuestion.id; } + //Если не возникло исключительных ситуаций - первый вопрос - нулевой элемент сортированного массива return sortedQuestions[0].id; } @@ -48,21 +64,31 @@ export function useQuestionFlowControl() { return sortedQuestions.find((question) => question.type === "result" && question.content.rule.parentId === "line"); }, [sortedQuestions]); + //Анализируем какой вопрос должен быть следующим. Это главная логика const nextQuestionIdMainLogic = useCallback(() => { + //Список ответов данных этому вопросу. Вернёт QuestionAnswer | undefined const questionAnswer = answers.find(({ questionId }) => questionId === currentQuestion.id); + //Если questionAnswer не undefined и ответ на вопрос не является временем: if (questionAnswer && !moment.isMoment(questionAnswer.answer)) { + //Вопрос типизации. Получаем список строк ответов на этот вопрос const userAnswers = Array.isArray(questionAnswer.answer) ? questionAnswer.answer : [questionAnswer.answer]; + //цикл. Перебираем список условий .main и обзываем их переменной branchingRule for (const branchingRule of currentQuestion.content.rule.main) { + // Перебираем список ответов. Если хоть один ответ из списка совпадает с прописанным правилом из условий - этот вопрос нужный нам. Его и дадимкак следующий if (userAnswers.some((answer) => branchingRule.rules[0].answers.includes(answer))) { return branchingRule.next; } } } + //Не помню что это, но чёт при первом взгляде оно true только у результатов if (!currentQuestion.required) { + //Готовим себе дефолтный путь const defaultNextQuestionId = currentQuestion.content.rule.default; + + //Если строка не пустая и не пробел. (Обычно при получении данных мы сразу чистим пустые строки только с пробелом на просто пустые строки. Это прост доп защита) if (defaultNextQuestionId.length > 1 && defaultNextQuestionId !== " ") return defaultNextQuestionId; //Вопросы типа страница, ползунок, своё поле для ввода и дата не могут иметь больше 1 ребёнка. Пользователь не может настроить там дефолт //Кинуть на ребёнка надо даже если там нет дефолта @@ -79,6 +105,7 @@ export function useQuestionFlowControl() { })?.id; }, [answers, currentQuestion, sortedQuestions]); + //Анализ следующего вопроса. Это логика для вопроса с баллами const nextQuestionId = useMemo(() => { if (settings.cfg.score) { return nextQuestionIdPointsLogic(); @@ -86,6 +113,7 @@ export function useQuestionFlowControl() { return nextQuestionIdMainLogic(); }, [nextQuestionIdMainLogic, nextQuestionIdPointsLogic, settings.cfg.score]); + //Поиск предыдущго вопроса либо по индексу либо по id родителя const prevQuestion = linearQuestionIndex !== null ? sortedQuestions[linearQuestionIndex - 1] @@ -94,31 +122,42 @@ export function useQuestionFlowControl() { q.id === currentQuestion?.content.rule.parentId || q.content.id === currentQuestion?.content.rule.parentId ); + //Анализ результата по количеству баллов const findResultPointsLogic = useCallback(() => { + //Отбираем из массива только тип резулт И результы с информацией о ожидаемых баллах И те результы, чьи суммы баллов меньше или равны насчитанным баллам юзера const results = sortedQuestions.filter( (e) => e.type === "result" && e.content.rule.minScore !== undefined && e.content.rule.minScore <= pointsSum ); + //Создаём массив строк из результатов. У кого есть инфо о баллах - дают свои, остальные 0 const numbers = results.map((e) => e.type === "result" && e.content.rule.minScore !== undefined ? e.content.rule.minScore : 0 ); + //Извлекаем самое большое число const indexOfNext = Math.max(...numbers); + //Отдаём индекс нужного нам результата return results[numbers.indexOf(indexOfNext)]; }, [pointsSum, sortedQuestions]); + //Ищем следующий вопрос (не его индекс, или id). Сам вопрос const nextQuestion = useMemo(() => { let next; + if (settings.cfg.score) { + //Ессли квиз балловый if (linearQuestionIndex !== null) { - next = sortedQuestions[linearQuestionIndex + 1]; - if (next?.type === "result" || next == undefined) next = findResultPointsLogic(); + next = sortedQuestions[linearQuestionIndex + 1]; //ищем по индексу + if (next?.type === "result" || next == undefined) next = findResultPointsLogic(); //если в поисках пришли к результату - считаем нужный } } else { + //иначе if (linearQuestionIndex !== null) { + //для линейных ищем по индексу next = sortedQuestions[linearQuestionIndex + 1] ?? sortedQuestions.find((question) => question.type === "result" && question.content.rule.parentId === "line"); } else { + // для нелинейных ищем по вычесленному id next = sortedQuestions.find((q) => q.id === nextQuestionId || q.content.id === nextQuestionId); } } @@ -126,10 +165,13 @@ export function useQuestionFlowControl() { return next; }, [nextQuestionId, findResultPointsLogic, linearQuestionIndex, sortedQuestions, settings.cfg.score]); + //Показать визуалом юзеру результат const showResult = useCallback(() => { if (nextQuestion?.type !== "result") throw new Error("Current question is not result"); + //Записать в переменную ид текущего вопроса setCurrentQuestionId(nextQuestion.id); + //Смотрим по настройкам показывать ли вообще форму контактов. Показывать ли страницу результатов до или после формы контактов (ФК) if ( settings.cfg.showfc !== false && (settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion)) @@ -137,6 +179,7 @@ export function useQuestionFlowControl() { setCurrentQuizStep("contactform"); }, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm, settings.cfg.showfc]); + //рычаг управления из визуала в эту функцию const showResultAfterContactForm = useCallback(() => { if (currentQuestion?.type !== "result") throw new Error("Current question is not result"); if (isResultQuestionEmpty(currentQuestion)) { @@ -147,12 +190,14 @@ export function useQuestionFlowControl() { setCurrentQuizStep("question"); }, [currentQuestion, setCurrentQuizStep]); + //рычаг управления из визуала в эту функцию const moveToPrevQuestion = useCallback(() => { if (!prevQuestion) throw new Error("Previous question not found"); setCurrentQuestionId(prevQuestion.id); }, [prevQuestion]); + //рычаг управления из визуала в эту функцию const moveToNextQuestion = useCallback(() => { if (!nextQuestion) throw new Error("Next question not found"); @@ -165,6 +210,7 @@ export function useQuestionFlowControl() { setCurrentQuestionId(nextQuestion.id); }, [currentQuestion.id, nextQuestion, showResult, vkMetrics, yandexMetrics]); + //рычаг управления из визуала в эту функцию const setQuestion = useCallback( (questionId: string) => { const question = sortedQuestions.find((q) => q.id === questionId); @@ -175,8 +221,10 @@ export function useQuestionFlowControl() { [sortedQuestions] ); + //Анализ дисаблить ли кнопки навигации const isPreviousButtonEnabled = Boolean(prevQuestion); + //Анализ дисаблить ли кнопки навигации const isNextButtonEnabled = useMemo(() => { const hasAnswer = answers.some(({ questionId }) => questionId === currentQuestion.id); From 7d5bc54325308077b93011330cce482dd9e880ef Mon Sep 17 00:00:00 2001 From: Nastya Date: Sat, 31 Aug 2024 04:57:26 +0300 Subject: [PATCH 8/8] =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=B2=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/QuizAnswerer.tsx | 5 +++-- lib/components/ViewPublicationPage/ApologyPage.tsx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/components/QuizAnswerer.tsx b/lib/components/QuizAnswerer.tsx index 4328b76..83e20c3 100644 --- a/lib/components/QuizAnswerer.tsx +++ b/lib/components/QuizAnswerer.tsx @@ -75,11 +75,12 @@ function QuizAnswererInner({ if (isLoading) return ; if (error) return ; // if (!data) return ; - quizSettings ??= data; if (!quizSettings) return ; - if (quizSettings.questions.length === 0) return ; + if (quizSettings.questions.length === 1 && quizSettings?.settings.cfg.noStartPage) + return ; + // if (quizSettings.questions.length === 1) return ; if (!quizId) return ; const quizContainer = ( diff --git a/lib/components/ViewPublicationPage/ApologyPage.tsx b/lib/components/ViewPublicationPage/ApologyPage.tsx index 8633053..52d7cc1 100644 --- a/lib/components/ViewPublicationPage/ApologyPage.tsx +++ b/lib/components/ViewPublicationPage/ApologyPage.tsx @@ -8,6 +8,7 @@ export const ApologyPage = ({ error }: Props) => { if (error.response?.data === "quiz is inactive") message = "Квиз не активирован"; if (error.message === "No questions found") message = "Нет созданных вопросов"; + if (error.message === "Quiz is empty") message = "Квиз пуст"; if (error.message === "Quiz already completed") message = "Вы уже прошли этот опрос"; if (error.message === "No quiz id") message = "Отсутствует id квиза"; if (error.message === "Quiz data is null") message = "Не были переданы параметры квиза";