Merge branch 'dev' into 'staging'
Dev See merge request frontend/squzanswerer!99
This commit is contained in:
commit
2d668f01d7
@ -6,18 +6,33 @@ import device from "current-device";
|
||||
import type { AxiosError } from "axios";
|
||||
import { replaceSpacesToEmptyLines } from "../components/ViewPublicationPage/tools/replaceSpacesToEmptyLines";
|
||||
import { QuizSettings } from "@model/settingsData";
|
||||
|
||||
import * as Bowser from "bowser";
|
||||
let SESSIONS = "";
|
||||
|
||||
const domain = location.hostname === "hbpn.link" ? "" : "https://s.hbpn.link";
|
||||
|
||||
const md = new MobileDetect(window.navigator.userAgent);
|
||||
|
||||
const userAgent = navigator.userAgent
|
||||
let OSDevice = md.os()
|
||||
if (OSDevice === null) {OSDevice = userAgent}
|
||||
//операционная система
|
||||
let OSDevice:string | undefined
|
||||
if (userAgent.toLowerCase().includes("linux")) {OSDevice = "Linux"}
|
||||
if (userAgent.toLowerCase().includes("windows")) {OSDevice = "Windows"}
|
||||
if (/iPad|iPhone|iPod/.test(userAgent)){OSDevice = "IOS"}
|
||||
if (userAgent.toLowerCase().includes("macintosh")) {OSDevice = "Mac OS"}
|
||||
if (OSDevice === undefined) {OSDevice = userAgent}
|
||||
|
||||
//браузер
|
||||
let browserUser:string
|
||||
if(Bowser.name === "Chrome") {
|
||||
browserUser = "Chrome"
|
||||
} else if(Bowser.name === "Firefox") {
|
||||
browserUser = "Firefox"
|
||||
}else if(Bowser.name === "Safari") {
|
||||
browserUser = "Safari"
|
||||
}else{browserUser = userAgent}
|
||||
|
||||
const DeviceType = device.type
|
||||
|
||||
let Device = md.mobile()
|
||||
if (Device === null) {Device = userAgent}
|
||||
|
||||
@ -30,7 +45,7 @@ export const publicationMakeRequest = ({ url, body }: any) => {
|
||||
"DeviceType" : DeviceType,
|
||||
"Device" : Device,
|
||||
"OS": OSDevice,
|
||||
"Browser" : userAgent
|
||||
"Browser" : browserUser
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
@ -99,7 +114,8 @@ export async function getQuizData(quizId: string) {
|
||||
return res;
|
||||
}
|
||||
|
||||
export function sendAnswer({ questionId, body, qid }: any) {
|
||||
export function sendAnswer({ questionId, body, qid, preview }: any) {
|
||||
if (preview) return
|
||||
const formData = new FormData();
|
||||
|
||||
const answers = [
|
||||
@ -120,7 +136,8 @@ export function sendAnswer({ questionId, body, qid }: any) {
|
||||
}
|
||||
|
||||
//body ={file, filename}
|
||||
export function sendFile({ questionId, body, qid }: any) {
|
||||
export function sendFile({ questionId, body, qid, preview }: any) {
|
||||
if (preview) return
|
||||
const formData = new FormData();
|
||||
|
||||
const answers: any = [
|
||||
@ -143,7 +160,8 @@ export function sendFile({ questionId, body, qid }: any) {
|
||||
}
|
||||
|
||||
//форма контактов
|
||||
export function sendFC({ questionId, body, qid }: any) {
|
||||
export function sendFC({ questionId, body, qid, preview }: any) {
|
||||
if (preview) return
|
||||
const formData = new FormData();
|
||||
|
||||
// const keysBody = Object.keys(body)
|
||||
|
||||
@ -13,19 +13,22 @@ import { ApologyPage } from "./ViewPublicationPage/ApologyPage";
|
||||
import ViewPublicationPage from "./ViewPublicationPage/ViewPublicationPage";
|
||||
import { RootContainerWidthContext } from "@contexts/RootContainerWidthContext";
|
||||
import { startTransition, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import { getQuizData } from "@/api/quizRelase";
|
||||
import LoadingSkeleton from "@/ui_kit/LoadingSkeleton";
|
||||
|
||||
|
||||
moment.locale("ru");
|
||||
const localeText = ruRU.components.MuiLocalizationProvider.defaultProps.localeText;
|
||||
|
||||
type Props = {
|
||||
quizSettings: QuizSettings;
|
||||
quizSettings?: QuizSettings | {};
|
||||
quizId: string;
|
||||
preview?: boolean;
|
||||
};
|
||||
|
||||
export default function QuizAnswerer({ quizSettings, quizId, preview = false }: Props) {
|
||||
export default function QuizAnswerer({ quizSettings = {}, quizId, preview = false }: Props) {
|
||||
const [rootContainerWidth, setRootContainerWidth] = useState<number>(() => window.innerWidth);
|
||||
const [quizData, setQuizData] = useState<QuizSettings | {}>(quizSettings);
|
||||
const rootContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
@ -33,6 +36,10 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false }:
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.values(quizSettings).length === 0) {
|
||||
const data = (async()=>await getQuizData(quizId))()
|
||||
setQuizData(data)
|
||||
}
|
||||
const handleWindowResize = () => {
|
||||
startTransition(() => {
|
||||
if (rootContainerRef.current) setRootContainerWidth(rootContainerRef.current.clientWidth);
|
||||
@ -45,9 +52,10 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false }:
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (Object.values(quizData).length === 0) return <LoadingSkeleton />;
|
||||
return (
|
||||
<RootContainerWidthContext.Provider value={rootContainerWidth}>
|
||||
<QuizDataContext.Provider value={{ ...quizSettings, quizId, preview }}>
|
||||
<QuizDataContext.Provider value={{ ...quizData, quizId, preview }}>
|
||||
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="ru" localeText={localeText}>
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<SnackbarProvider
|
||||
|
||||
@ -38,7 +38,7 @@ type Props = {
|
||||
|
||||
export const ContactForm = ({currentQuestion, onShowResult}: Props) => {
|
||||
const theme = useTheme();
|
||||
const {settings, questions, quizId, show_badge} = useQuizData();
|
||||
const {settings, questions, quizId, show_badge, preview} = useQuizData();
|
||||
|
||||
const [ready, setReady] = useState(false);
|
||||
const [name, setName] = useState("");
|
||||
@ -68,7 +68,7 @@ export const ContactForm = ({currentQuestion, onShowResult}: Props) => {
|
||||
});
|
||||
|
||||
if (!resultQuestion) throw new Error("Result question not found");
|
||||
|
||||
console.log("yfcnhjqrb", settings.cfg.resultInfo.showResultForm)
|
||||
const inputHC = async () => {
|
||||
const FC = settings.cfg.formContact.fields || settings.cfg.formContact;
|
||||
const body = {} as any;
|
||||
@ -84,6 +84,7 @@ export const ContactForm = ({currentQuestion, onShowResult}: Props) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: body,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
const sessions = JSON.parse(localStorage.getItem("sessions") || "{}");
|
||||
@ -141,8 +142,10 @@ export const ContactForm = ({currentQuestion, onShowResult}: Props) => {
|
||||
} catch (e) {
|
||||
enqueueSnackbar("повторите попытку позже");
|
||||
}
|
||||
if(settings.cfg.resultInfo.showResultForm === "after"){
|
||||
onShowResult();
|
||||
}
|
||||
|
||||
onShowResult();
|
||||
}
|
||||
|
||||
setFire(false);
|
||||
@ -322,7 +325,9 @@ export const ContactForm = ({currentQuestion, onShowResult}: Props) => {
|
||||
<Box
|
||||
component={Link}
|
||||
target={"_blank"}
|
||||
href={"https://quiz.pena.digital"}
|
||||
href={
|
||||
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
|
||||
}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
||||
@ -23,7 +23,7 @@ export const ResultForm = ({resultQuestion}: ResultFormProps) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useRootContainerSize() < 650;
|
||||
const isTablet = useRootContainerSize() < 1000;
|
||||
const {settings, show_badge} = useQuizData();
|
||||
const {settings, show_badge, quizId} = useQuizData();
|
||||
const spec = settings.cfg.spec
|
||||
console.log(quizThemes[settings.cfg.theme].isLight)
|
||||
|
||||
@ -190,7 +190,9 @@ export const ResultForm = ({resultQuestion}: ResultFormProps) => {
|
||||
<Box
|
||||
component={Link}
|
||||
target={"_blank"}
|
||||
href={"https://quiz.pena.digital"}
|
||||
href={
|
||||
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
|
||||
}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
||||
@ -25,7 +25,7 @@ import PenaLogo from "@icons/PenaLogo.png";
|
||||
|
||||
export const StartPageViewPublication = () => {
|
||||
const theme = useTheme();
|
||||
const { settings, show_badge } = useQuizData();
|
||||
const { settings, show_badge, quizId } = useQuizData();
|
||||
const { isMobileDevice } = useUADevice();
|
||||
const isMobile = useRootContainerSize() < 700;
|
||||
const isTablet = useRootContainerSize() < 800;
|
||||
@ -330,7 +330,9 @@ export const StartPageViewPublication = () => {
|
||||
<Box
|
||||
component={Link}
|
||||
target={"_blank"}
|
||||
href={"https://quiz.pena.digital"}
|
||||
href={
|
||||
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
|
||||
}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {Button, ThemeProvider, useTheme} from "@mui/material";
|
||||
import { Button, ThemeProvider, useTheme } from "@mui/material";
|
||||
import { useQuizViewStore } from "@stores/quizView";
|
||||
import { useQuestionFlowControl } from "@utils/hooks/useQuestionFlowControl";
|
||||
import { useQuizData } from "@contexts/QuizDataContext";
|
||||
@ -12,11 +12,12 @@ import { ResultForm } from "./ResultForm";
|
||||
import { StartPageViewPublication } from "./StartPageViewPublication";
|
||||
import PrevButton from "./tools/PrevButton";
|
||||
import NextButton from "./tools/NextButton";
|
||||
import {enqueueSnackbar} from "notistack";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { sendAnswer } from "@api/quizRelase";
|
||||
import LoadingSkeleton from "@/ui_kit/LoadingSkeleton";
|
||||
|
||||
export default function ViewPublicationPage() {
|
||||
const { settings, recentlyCompleted, quizId } = useQuizData();
|
||||
const { settings, recentlyCompleted, quizId, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
let currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
|
||||
const isMobileMini = useRootContainerSize() < 382;
|
||||
@ -34,12 +35,15 @@ export default function ViewPublicationPage() {
|
||||
|
||||
useEffect(
|
||||
function setFaviconAndTitle() {
|
||||
const link = document.querySelector('link[rel="icon"]');
|
||||
if (link && settings.cfg.startpage.favIcon) {
|
||||
link.setAttribute("href", settings.cfg.startpage.favIcon);
|
||||
if (settings.cfg !== undefined) {
|
||||
const link = document.querySelector('link[rel="icon"]');
|
||||
if (link && settings.cfg.startpage.favIcon) {
|
||||
link.setAttribute("href", settings.cfg.startpage.favIcon);
|
||||
}
|
||||
|
||||
document.title = settings.name;
|
||||
}
|
||||
|
||||
document.title = settings.name;
|
||||
},
|
||||
[settings]
|
||||
);
|
||||
@ -64,24 +68,25 @@ export default function ViewPublicationPage() {
|
||||
<Question
|
||||
currentQuestion={currentQuestion}
|
||||
currentQuestionStepNumber={currentQuestionStepNumber}
|
||||
prevButton={ <PrevButton isPreviousButtonEnabled={isPreviousButtonEnabled} moveToPrevQuestion={moveToPrevQuestion}/>}
|
||||
prevButton={<PrevButton isPreviousButtonEnabled={isPreviousButtonEnabled} moveToPrevQuestion={moveToPrevQuestion} />}
|
||||
nextButton={
|
||||
<NextButton
|
||||
isNextButtonEnabled={isNextButtonEnabled}
|
||||
moveToNextQuestion={async () => {
|
||||
if (!isAnswer) {
|
||||
try {
|
||||
await sendAnswer({
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
}
|
||||
isNextButtonEnabled={isNextButtonEnabled}
|
||||
moveToNextQuestion={async () => {
|
||||
if (!isAnswer) {
|
||||
try {
|
||||
await sendAnswer({
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
}
|
||||
moveToNextQuestion()
|
||||
}}
|
||||
}
|
||||
moveToNextQuestion()
|
||||
}}
|
||||
/>}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -19,7 +19,7 @@ type DateProps = {
|
||||
|
||||
export const Date = ({ currentQuestion }: DateProps) => {
|
||||
const theme = useTheme();
|
||||
const { settings, quizId } = useQuizData();
|
||||
const { settings, quizId, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
const answer = answers.find(
|
||||
({ questionId }) => questionId === currentQuestion.id
|
||||
@ -65,6 +65,7 @@ export const Date = ({ currentQuestion }: DateProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: moment(date).format("YYYY.MM.DD"),
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(currentQuestion.id, date, 0);
|
||||
|
||||
@ -30,7 +30,7 @@ type EmojiProps = {
|
||||
|
||||
export const Emoji = ({ currentQuestion }: EmojiProps) => {
|
||||
const theme = useTheme();
|
||||
const { quizId, settings } = useQuizData();
|
||||
const { quizId, settings, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
const { answer } =
|
||||
answers.find(({ questionId }) => questionId === currentQuestion.id) ?? {};
|
||||
@ -103,6 +103,7 @@ export const Emoji = ({ currentQuestion }: EmojiProps) => {
|
||||
" " +
|
||||
currentQuestion.content.variants[index].answer,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(
|
||||
@ -121,6 +122,7 @@ export const Emoji = ({ currentQuestion }: EmojiProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
|
||||
@ -30,7 +30,7 @@ type FileProps = {
|
||||
export const File = ({ currentQuestion }: FileProps) => {
|
||||
const theme = useTheme();
|
||||
const { answers } = useQuizViewStore();
|
||||
const { quizId } = useQuizData();
|
||||
const { quizId, preview } = useQuizData();
|
||||
const [modalWarningType, setModalWarningType] = useState<ModalWarningType>(null);
|
||||
const [isSending, setIsSending] = useState<boolean>(false);
|
||||
const [isDropzoneHighlighted, setIsDropzoneHighlighted] = useState<boolean>(false);
|
||||
@ -59,7 +59,8 @@ export const File = ({ currentQuestion }: FileProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: {
|
||||
file: file,
|
||||
name: file.name
|
||||
name: file.name,
|
||||
preview
|
||||
},
|
||||
qid: quizId,
|
||||
});
|
||||
@ -67,8 +68,9 @@ export const File = ({ currentQuestion }: FileProps) => {
|
||||
|
||||
await sendAnswer({
|
||||
questionId: currentQuestion.id,
|
||||
body: `https://storage.yandexcloud.net/squizanswer/${quizId}/${currentQuestion.id}/${data.data.fileIDMap[currentQuestion.id]}`,
|
||||
body: `https://storage.yandexcloud.net/squizanswer/${quizId}/${currentQuestion.id}/${data!.data.fileIDMap[currentQuestion.id]}`,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(currentQuestion.id, `${file.name}|${URL.createObjectURL(file)}`, 0);
|
||||
@ -137,6 +139,7 @@ export const File = ({ currentQuestion }: FileProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
}
|
||||
console.log(answer);
|
||||
|
||||
@ -24,7 +24,7 @@ type ImagesProps = {
|
||||
};
|
||||
|
||||
export const Images = ({ currentQuestion }: ImagesProps) => {
|
||||
const { quizId } = useQuizData();
|
||||
const { quizId, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
const theme = useTheme();
|
||||
const answer = answers.find(
|
||||
@ -96,6 +96,7 @@ export const Images = ({ currentQuestion }: ImagesProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: `${currentQuestion.content.variants[index].answer} <img style="width:100%; max-width:250px; max-height:250px" src="${currentQuestion.content.variants[index].extendedText}"/>`,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
updateAnswer(
|
||||
currentQuestion.id,
|
||||
@ -113,6 +114,7 @@ export const Images = ({ currentQuestion }: ImagesProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
|
||||
@ -22,7 +22,7 @@ type NumberProps = {
|
||||
};
|
||||
|
||||
export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
const { settings, quizId } = useQuizData();
|
||||
const { settings, quizId, preview } = useQuizData();
|
||||
const [inputValue, setInputValue] = useState<string>("0");
|
||||
const [minRange, setMinRange] = useState<string>("0");
|
||||
const [maxRange, setMaxRange] = useState<string>("100000000000");
|
||||
@ -53,6 +53,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: value,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
if (!noUpdate) {
|
||||
|
||||
@ -58,7 +58,7 @@ const buttonRatingForm = [
|
||||
];
|
||||
|
||||
export const Rating = ({ currentQuestion }: RatingProps) => {
|
||||
const { quizId } = useQuizData();
|
||||
const { quizId, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
const theme = useTheme();
|
||||
const isMobile = useRootContainerSize() < 650;
|
||||
@ -102,6 +102,7 @@ export const Rating = ({ currentQuestion }: RatingProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: String(value) + " из " + currentQuestion.content.steps,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(currentQuestion.id, String(value), 0);
|
||||
|
||||
@ -17,7 +17,7 @@ type SelectProps = {
|
||||
|
||||
export const Select = ({ currentQuestion }: SelectProps) => {
|
||||
const theme = useTheme();
|
||||
const { quizId, settings } = useQuizData();
|
||||
const { quizId, settings, preview } = useQuizData();
|
||||
const [isSending, setIsSending] = useState<boolean>(false);
|
||||
const { answers } = useQuizViewStore();
|
||||
const { answer } =
|
||||
@ -65,6 +65,7 @@ export const Select = ({ currentQuestion }: SelectProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
@ -79,6 +80,7 @@ export const Select = ({ currentQuestion }: SelectProps) => {
|
||||
currentQuestion.content.variants[Number(value)].answer
|
||||
),
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(currentQuestion.id, String(value), 0);
|
||||
|
||||
@ -55,7 +55,7 @@ const Orientation = [
|
||||
|
||||
export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
|
||||
const theme = useTheme();
|
||||
const { settings } = useQuizData();
|
||||
const { settings, preview } = useQuizData();
|
||||
const spec = settings.cfg.spec;
|
||||
const { quizId } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
@ -71,6 +71,7 @@ export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: text,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
|
||||
@ -161,7 +161,7 @@ const VariantItem = ({
|
||||
setIsSending: (a: boolean) => void;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const { settings, quizId } = useQuizData();
|
||||
const { settings, quizId, preview } = useQuizData();
|
||||
|
||||
return (
|
||||
<FormControlLabel
|
||||
@ -244,6 +244,7 @@ const VariantItem = ({
|
||||
? currentAnswer?.filter((item) => item !== variantId)
|
||||
: [...currentAnswer, variantId],
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(
|
||||
@ -267,6 +268,7 @@ const VariantItem = ({
|
||||
questionId: currentQuestion.id,
|
||||
body: currentQuestion.content.variants[index].answer,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(
|
||||
@ -287,6 +289,7 @@ const VariantItem = ({
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
||||
@ -25,7 +25,7 @@ type VarimgProps = {
|
||||
};
|
||||
|
||||
export const Varimg = ({ currentQuestion }: VarimgProps) => {
|
||||
const { settings, quizId } = useQuizData();
|
||||
const { settings, quizId, preview } = useQuizData();
|
||||
const { answers } = useQuizViewStore();
|
||||
const theme = useTheme();
|
||||
const isMobile = useRootContainerSize() < 650;
|
||||
@ -130,6 +130,7 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: `${currentQuestion.content.variants[index].answer} <img style="width:100%; max-width:250px; max-height:250px" src="${currentQuestion.content.variants[index].extendedText}"/>`,
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
|
||||
updateAnswer(
|
||||
@ -147,6 +148,7 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
|
||||
questionId: currentQuestion.id,
|
||||
body: "",
|
||||
qid: quizId,
|
||||
preview
|
||||
});
|
||||
} catch (e) {
|
||||
enqueueSnackbar("ответ не был засчитан");
|
||||
|
||||
@ -1,13 +1,19 @@
|
||||
import { QuizSettings } from "@model/settingsData";
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
type QuizData = QuizSettings & { quizId: string; preview: boolean; };
|
||||
type QuizSettingsFull = QuizSettings | {};
|
||||
type QuizData = QuizSettingsFull & { quizId: string; preview: boolean; };
|
||||
type QuizDataClean = QuizSettings & { quizId: string; preview: boolean; };
|
||||
|
||||
export const QuizDataContext = createContext<QuizData | null>(null);
|
||||
|
||||
export const useQuizData = () => {
|
||||
export const useQuizData = ():QuizDataClean => {
|
||||
const quizData = useContext(QuizDataContext);
|
||||
if (quizData === null) throw new Error("QuizData context is null");
|
||||
if (
|
||||
quizData === null ||
|
||||
!("settings" in quizData) ||
|
||||
!("recentlyCompleted" in quizData)
|
||||
) throw new Error("QuizData context is null");
|
||||
|
||||
return quizData;
|
||||
};
|
||||
|
||||
@ -85,6 +85,7 @@
|
||||
"zustand": "^4.3.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"bowser": "1.9.4",
|
||||
"country-flag-emoji-polyfill": "^0.1.8",
|
||||
"current-device": "^0.10.2",
|
||||
"hex-rgb": "^5.0.0",
|
||||
|
||||
@ -1337,6 +1337,11 @@ bluebird@^3.7.2:
|
||||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
|
||||
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
|
||||
|
||||
bowser@1.9.4:
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/bowser/-/bowser-1.9.4.tgz#890c58a2813a9d3243704334fa81b96a5c150c9a"
|
||||
integrity sha512-9IdMmj2KjigRq6oWhmwv1W36pDuA4STQZ8q6YO9um+x07xgYNCD3Oou+WP/3L1HNz7iqythGet3/p4wvc8AAwQ==
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user