use showfc flag from quiz config

This commit is contained in:
nflnkr 2024-06-02 14:08:09 +03:00
parent dc0e15ebbb
commit b3dfe40563
3 changed files with 24 additions and 19 deletions

@ -229,19 +229,21 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
bottom: 0, bottom: 0,
}} }}
> >
{settings.cfg.resultInfo.showResultForm === "before" && !settings.cfg.score && ( {settings.cfg.resultInfo.showResultForm === "before" &&
<Button settings.cfg.showfc !== false &&
onClick={() => setCurrentQuizStep("contactform")} !settings.cfg.score && (
variant="contained" <Button
sx={{ onClick={() => setCurrentQuizStep("contactform")}
p: "10px 20px", variant="contained"
width: "auto", sx={{
height: "50px", p: "10px 20px",
}} width: "auto",
> height: "50px",
{resultQuestion.content.hint.text || "Узнать подробнее"} }}
</Button> >
)} {resultQuestion.content.hint.text || "Узнать подробнее"}
</Button>
)}
{settings.cfg.resultInfo.showResultForm === "after" && resultQuestion.content.redirect && ( {settings.cfg.resultInfo.showResultForm === "after" && resultQuestion.content.redirect && (
<Button <Button
onClick={() => { onClick={() => {

@ -110,10 +110,10 @@ export interface QuizConfig {
law?: string; law?: string;
}; };
meta: string; meta: string;
antifraud: boolean; antifraud?: boolean;
showfc: boolean; showfc?: boolean;
yandexMetricsNumber: number | undefined; yandexMetricsNumber?: number;
vkMetricsNumber: number | undefined; vkMetricsNumber?: number;
} }
export type FormContactFieldName = "name" | "email" | "phone" | "text" | "address"; export type FormContactFieldName = "name" | "email" | "phone" | "text" | "address";

@ -130,9 +130,12 @@ export function useQuestionFlowControl() {
if (nextQuestion?.type !== "result") throw new Error("Current question is not result"); if (nextQuestion?.type !== "result") throw new Error("Current question is not result");
setCurrentQuestionId(nextQuestion.id); setCurrentQuestionId(nextQuestion.id);
if (settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion)) if (
settings.cfg.showfc !== false &&
(settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion))
)
setCurrentQuizStep("contactform"); setCurrentQuizStep("contactform");
}, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm]); }, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm, settings.cfg.showfc]);
const showResultAfterContactForm = useCallback(() => { const showResultAfterContactForm = useCallback(() => {
if (currentQuestion?.type !== "result") throw new Error("Current question is not result"); if (currentQuestion?.type !== "result") throw new Error("Current question is not result");