From cc938525acc4d155477a7af3010d438e329268cc Mon Sep 17 00:00:00 2001 From: Nastya Date: Mon, 18 Dec 2023 04:29:22 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D1=82=D0=B8=D0=BF=D0=BE=D0=B2=20=D0=B8=D0=B7=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B8=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/settingsData.ts | 126 +++++++++++++++++++++++++++++++++++--- 1 file changed, 118 insertions(+), 8 deletions(-) diff --git a/src/model/settingsData.ts b/src/model/settingsData.ts index da97f32..fd205f1 100644 --- a/src/model/settingsData.ts +++ b/src/model/settingsData.ts @@ -1,5 +1,39 @@ import { AnyTypedQuizQuestion } from "@model/questionTypes/shared"; -import { QuizConfig } from "@model/quizSettings"; +// import { QuizConfig } from "@model/quizSettings"; + +export type QuizStartpageType = "standard" | "expanded" | "centered" | null; + +export type QuizStartpageAlignType = "left" | "right" | "center"; + +export type QuizType = "quiz" | "form"; + +export type QuizResultsType = true | null; + +export type QuizResultInfoWhen = 'before' | 'after' | 'email'; + +export type FCField = { + text: string + innerText: string + key: string + required: boolean + used: boolean +} +export interface GetDataResponse { + cnt: number; + settings: { + fp: boolean; + rep: boolean; + name: string; + cfg: string; + lim: number; + due: number; + delay: number; + pausable: boolean; + }; + items: GetItems[]; +} + + export type QuestionsStore = { items: (AnyTypedQuizQuestion)[]; @@ -9,12 +43,88 @@ export type QuestionsStore = { export interface Settings { - fp: boolean, - rep: boolean, - name: string, - lim: number, - due: number, - delay: number, - pausable: boolean, + fp: boolean; + rep: boolean; + name: string; + lim: number; + due: number; + delay: number; + pausable: boolean; cfg: QuizConfig +} + +export interface QuizConfig { + type: QuizType; + noStartPage: boolean; + startpageType: QuizStartpageType; + results: QuizResultsType; + haveRoot: string; + resultInfo: { + when: QuizResultInfoWhen; + share: boolean; + replay: boolean; + theme: string; + reply: string; + replname: string; + }; + startpage: { + description: string; + button: string; + position: QuizStartpageAlignType; + favIcon: string | null; + logo: string | null; + originalLogo: string | null; + background: { + type: null | "image" | "video"; + desktop: string | null; + originalDesktop: string | null; + mobile: string | null; + originalMobile: string | null; + video: string | null; + cycle: boolean; + }; + }; + + formContact: { + title: string; + desc: string; + name: FCField; + email: FCField; + phone: FCField; + text: FCField; + address: FCField; + button: string + }; + info: { + phonenumber: string; + clickable: boolean; + orgname: string; + site: string; + law?: string; + }; + meta: string; +} + +export interface GetItems { + id: number; + title: string; + desc: string; + typ: string; + req: boolean; + p: number; + c: string; +} + +export interface QuizItems { + + description: string; + id: number; + page: number; + required: boolean; + title: string; + type: string; + content: QuizItemsContent +} +export interface QuizItemsContent { + } \ No newline at end of file From b0e5041a0af2f82af7ce036160118804e6b5f1a2 Mon Sep 17 00:00:00 2001 From: ArtChaos189 Date: Mon, 18 Dec 2023 14:56:32 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=88=D0=B8=D0=BB=D1=8C=D0=B4=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/NameplateLogo.tsx | 18 + src/pages/ViewPublicationPage/Footer.tsx | 111 ++--- .../StartPageViewPublication.tsx | 451 ++++++++++-------- 3 files changed, 314 insertions(+), 266 deletions(-) create mode 100644 src/assets/icons/NameplateLogo.tsx diff --git a/src/assets/icons/NameplateLogo.tsx b/src/assets/icons/NameplateLogo.tsx new file mode 100644 index 0000000..a977b2f --- /dev/null +++ b/src/assets/icons/NameplateLogo.tsx @@ -0,0 +1,18 @@ +import { FC, SVGProps } from "react"; + +export const NameplateLogo: FC> = (props) => ( + + + + + + +); diff --git a/src/pages/ViewPublicationPage/Footer.tsx b/src/pages/ViewPublicationPage/Footer.tsx index 90998df..a7ebca2 100644 --- a/src/pages/ViewPublicationPage/Footer.tsx +++ b/src/pages/ViewPublicationPage/Footer.tsx @@ -1,14 +1,12 @@ import { useState, useEffect } from "react"; -import { Box, Button, useTheme } from "@mui/material"; +import { Box, Button, Typography, useTheme } from "@mui/material"; -import type { - AnyTypedQuizQuestion, - QuizQuestionBase, -} from "../../model/questionTypes/shared"; +import type { AnyTypedQuizQuestion, QuizQuestionBase } from "../../model/questionTypes/shared"; import { useQuestionsStore } from "@root/quizData/store"; import { getQuestionById } from "@root/quizData/actions"; import { useQuizViewStore } from "@root/quizView/store"; import { enqueueSnackbar } from "notistack"; +import { NameplateLogo } from "@icons/NameplateLogo"; type FooterProps = { setCurrentQuestion: (step: AnyTypedQuizQuestion) => void; @@ -17,12 +15,7 @@ type FooterProps = { setShowResultForm: (show: boolean) => void; }; -export const Footer = ({ - setCurrentQuestion, - question, - setShowContactForm, - setShowResultForm, -}: FooterProps) => { +export const Footer = ({ setCurrentQuestion, question, setShowContactForm, setShowResultForm }: FooterProps) => { const theme = useTheme(); const { settings, items } = useQuestionsStore(); @@ -30,10 +23,8 @@ export const Footer = ({ const [disablePreviousButton, setDisablePreviousButton] = useState(false); const [disableNextButton, setDisableNextButton] = useState(false); - - const linear = !items.find( - ({ content }) => content.rule.parentId === "root" - ); + + const linear = !items.find(({ content }) => content.rule.parentId === "root"); useEffect(() => { // Логика для аргумента disabled у кнопки "Назад" @@ -56,9 +47,7 @@ export const Footer = ({ } // Логика для аргумента disabled у кнопки "Далее" - const answer = answers.find( - ({ questionId }) => questionId === question.id - ); + const answer = answers.find(({ questionId }) => questionId === question.id); if ("required" in question.content && question.content.required && answer) { setDisableNextButton(false); @@ -66,11 +55,7 @@ export const Footer = ({ return; } - if ( - "required" in question.content && - question.content.required && - !answer - ) { + if ("required" in question.content && question.content.required && !answer) { setDisableNextButton(true); return; @@ -84,9 +69,7 @@ export const Footer = ({ if (nextQuestionId) { setDisableNextButton(false); } else { - const nextQuestion = getQuestionById( - question.content.rule.default - ); + const nextQuestion = getQuestionById(question.content.rule.default); if (nextQuestion?.type) { setDisableNextButton(false); @@ -94,9 +77,8 @@ export const Footer = ({ } }, [question, answers]); - const showResult = (nextQuestion:any) => { - - console.log(nextQuestion) + const showResult = (nextQuestion: any) => { + console.log(nextQuestion); if (nextQuestion && settings?.cfg.resultInfo.when === "before") { setShowResultForm(true); @@ -107,44 +89,34 @@ export const Footer = ({ const getNextQuestionId = () => { if (answers.length) { - const answer = answers.find( - ({ questionId }) => questionId === question.id - ); + const answer = answers.find(({ questionId }) => questionId === question.id); let readyBeNextQuestion = ""; - (question as QuizQuestionBase).content.rule.main.forEach( - ({ next, rules }) => { - let longerArray = Math.max( - rules[0].answers.length, - answer?.answer && Array.isArray(answer?.answer) - ? answer?.answer.length - : [answer?.answer].length - ); + (question as QuizQuestionBase).content.rule.main.forEach(({ next, rules }) => { + let longerArray = Math.max( + rules[0].answers.length, + answer?.answer && Array.isArray(answer?.answer) ? answer?.answer.length : [answer?.answer].length + ); - for ( - var i = 0; - i < longerArray; - i++ // Цикл по всем эле­мен­там бОльшего массива - ) { - if (Array.isArray(answer?.answer)) { - if ( - answer?.answer.find((item) => - String(item === rules[0].answers[i]) - ) - ) { - readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны - } - - return; - } - - if (String(rules[0].answers[i]) === answer?.answer) { + for ( + var i = 0; + i < longerArray; + i++ // Цикл по всем эле­мен­там бОльшего массива + ) { + if (Array.isArray(answer?.answer)) { + if (answer?.answer.find((item) => String(item === rules[0].answers[i]))) { readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны } + + return; + } + + if (String(rules[0].answers[i]) === answer?.answer) { + readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны } } - ); + }); return readyBeNextQuestion; } @@ -180,7 +152,7 @@ export const Footer = ({ const questionIndex = items.findIndex(({ id }) => id === question.id); const nextQuestion = items[questionIndex + 1]; - console.log(nextQuestion) + console.log(nextQuestion); if (nextQuestion && nextQuestion.type !== "result") { setCurrentQuestion(nextQuestion); } else { @@ -202,9 +174,7 @@ export const Footer = ({ enqueueSnackbar("не могу получить последующий вопрос"); } } else { - const nextQuestion = getQuestionById( - question.content.rule.default - ); + const nextQuestion = getQuestionById(question.content.rule.default); if (nextQuestion?.type && nextQuestion.type !== "result") { setCurrentQuestion(nextQuestion); } else { @@ -216,10 +186,25 @@ export const Footer = ({ return ( + + + Сделано на PenaQuiz + void + setVisualStartPage: (a: boolean) => void; } export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { const theme = useTheme(); const { isMobileDevice } = useUADevice(); - const { settings } = useQuestionsStore() + const { settings } = useQuestionsStore(); if (!settings) return null; @@ -30,9 +22,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { navigator.clipboard.writeText(settings?.cfg.info.phonenumber); }; - const background = settings?.cfg.startpage.background.type === "image" - ? settings?.cfg.startpage.background.desktop - ? ( + const background = + settings?.cfg.startpage.background.type === "image" ? ( + settings?.cfg.startpage.background.desktop ? ( { width: "100%", height: "100%", objectFit: "cover", - overflow: "hidden" + overflow: "hidden", }} /> - ) - : null - : settings?.cfg.startpage.background.type === "video" - ? settings?.cfg.startpage.background.video - ? ( - - ) - : null - : null; + ) : null + ) : settings?.cfg.startpage.background.type === "video" ? ( + settings?.cfg.startpage.background.video ? ( + + ) : null + ) : null; return ( - + background: + settings?.cfg.startpageType === "expanded" + ? settings?.cfg.startpage.position === "left" + ? "linear-gradient(90deg,#272626,transparent)" + : settings?.cfg.startpage.position === "center" + ? "linear-gradient(180deg,transparent,#272626)" + : "linear-gradient(270deg,#272626,transparent)" + : "", + color: settings?.cfg.startpageType === "expanded" ? "white" : "black", + }} + > - - {settings?.cfg.startpage.logo && ( - - )} - - {settings?.cfg.info.orgname} - + quizHeaderBlock={ + + + {settings?.cfg.startpage.logo && ( + + )} + {settings?.cfg.info.orgname} + + + + {settings?.cfg.info.site} + + - - - {settings?.cfg.info.site} - - - } - quizMainBlock={<> - - {settings.name} - - {settings?.cfg.startpage.description} - - - - - - - {settings?.cfg.info.clickable ? ( - isMobileDevice ? ( - - - {settings?.cfg.info.phonenumber} - - - ) : ( - - - {settings?.cfg.info.phonenumber} - - - ) - ) : ( - - {settings?.cfg.info.phonenumber} + {settings?.cfg.startpage.description} - )} - - {settings?.cfg.info.law} - - - } + + + + + + + {settings?.cfg.info.clickable ? ( + isMobileDevice ? ( + + + {settings?.cfg.info.phonenumber} + + + ) : ( + + + {settings?.cfg.info.phonenumber} + + + ) + ) : ( + + {settings?.cfg.info.phonenumber} + + )} + {settings?.cfg.info.law} + + + + + Сделано на PenaQuiz + + + + + } backgroundBlock={background} startpageType={settings?.cfg.startpageType} alignType={settings?.cfg.startpage.position} /> ); -} +}; -function QuizPreviewLayoutByType({ quizHeaderBlock, quizMainBlock, backgroundBlock, startpageType, alignType }: { +function QuizPreviewLayoutByType({ + quizHeaderBlock, + quizMainBlock, + backgroundBlock, + startpageType, + alignType, +}: { quizHeaderBlock: JSX.Element; quizMainBlock: JSX.Element; backgroundBlock: JSX.Element | null; @@ -202,28 +236,34 @@ function QuizPreviewLayoutByType({ quizHeaderBlock, quizMainBlock, backgroundBlo case null: case "standard": { return ( - - + flexDirection: alignType === "left" ? "row" : "row-reverse", + flexGrow: 1, + height: "100vh", + "&::-webkit-scrollbar": { width: 0 }, + }} + > + {quizHeaderBlock} {quizMainBlock} - + {backgroundBlock} @@ -231,36 +271,42 @@ function QuizPreviewLayoutByType({ quizHeaderBlock, quizMainBlock, backgroundBlo } case "expanded": { return ( - - + justifyContent: startpageAlignTypeToJustifyContent[alignType], + flexGrow: 1, + height: "100%", + "&::-webkit-scrollbar": { width: 0 }, + }} + > + {quizHeaderBlock} {quizMainBlock} - + {backgroundBlock} @@ -268,27 +314,26 @@ function QuizPreviewLayoutByType({ quizHeaderBlock, quizMainBlock, backgroundBlo } case "centered": { return ( - + {quizHeaderBlock} - {backgroundBlock && - - {backgroundBlock} - - } + {backgroundBlock && {backgroundBlock}} {quizMainBlock} ); } - default: notReachable(startpageType); + default: + notReachable(startpageType); } } From 7df3bc3b31ce42cb5b422b696fa68bc749676b70 Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 20 Dec 2023 00:59:35 +0300 Subject: [PATCH 3/3] =?UTF-8?q?qid=20=D0=B2=20=D0=BF=D0=B0=D1=80=D1=81?= =?UTF-8?q?=D0=B5=20=D0=B1=D0=B5=D1=80=D1=91=D1=82=D1=81=D1=8F=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D1=83=D1=80=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ViewPublicationPage/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/ViewPublicationPage/index.tsx b/src/pages/ViewPublicationPage/index.tsx index 33d3a83..9d67802 100644 --- a/src/pages/ViewPublicationPage/index.tsx +++ b/src/pages/ViewPublicationPage/index.tsx @@ -16,7 +16,7 @@ const QID = process.env.NODE_ENV === "production" ? window.location.pathname.replace(/\//g, '') : - "c1ee11d2-ed5a-47d1-b500-bda6fd442114" + "e593a043-8ad2-4e16-9bf2-afb4f28385eb" export const ViewPage = () => { @@ -32,9 +32,11 @@ export const ViewPage = () => { //@ts-ignore const settings = data.settings console.log(data) + console.log(window.location.pathname.replace(/\//g, '')) const parseData = { settings: { - qid: "c1ee11d2-ed5a-47d1-b500-bda6fd442114", + //@ts-ignore + qid: window.location.pathname.replace(/\//g, '') || "e593a043-8ad2-4e16-9bf2-afb4f28385eb", fp: settings.fp, rep: settings.rep, name: settings.name, @@ -95,7 +97,7 @@ console.log(items) if (errormessage) return if (visualStartPage === undefined) return ; - if (cnt === 0) return + if (cnt === 0 || (cnt === 1 && items[0].type === "result")) return return ( {