diff --git a/src/pages/ResultPage/cards/ResultCard.tsx b/src/pages/ResultPage/cards/ResultCard.tsx index 404b92a5..8227739c 100644 --- a/src/pages/ResultPage/cards/ResultCard.tsx +++ b/src/pages/ResultPage/cards/ResultCard.tsx @@ -1,6 +1,9 @@ import * as React from "react"; -import { getQuestionByContentId, updateQuestion } from "@root/questions/actions"; +import { + getQuestionByContentId, + updateQuestion, +} from "@root/questions/actions"; import CustomTextField from "@ui_kit/CustomTextField"; @@ -31,7 +34,11 @@ interface Props { resultData: QuizQuestionResult; } -export const checkEmptyData = ({ resultData }: { resultData: QuizQuestionResult }) => { +export const checkEmptyData = ({ + resultData, +}: { + resultData: QuizQuestionResult; +}) => { let check = true; if ( resultData.title.length > 0 || @@ -50,7 +57,9 @@ export const checkEmptyData = ({ resultData }: { resultData: QuizQuestionResult const InfoView = ({ resultData }: { resultData: QuizQuestionResult }) => { const checkEmpty = checkEmptyData({ resultData }); const question = getQuestionByContentId(resultData.content.rule.parentId); - const [anchorEl, setAnchorEl] = React.useState(null); + const [anchorEl, setAnchorEl] = React.useState( + null + ); const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); @@ -96,9 +105,15 @@ const InfoView = ({ resultData }: { resultData: QuizQuestionResult }) => { {resultData?.content.rule.parentId === "line" ? "Единый результат в конце прохождения опросника без ветвления" - : `Заголовок вопроса, после которого появится результат: "${question?.title || "нет заголовка"}"`} + : `Заголовок вопроса, после которого появится результат: "${ + question?.title || "нет заголовка" + }"`} - {checkEmpty && Вы не заполнили этот результат никакими данными} + {checkEmpty && ( + + Вы не заполнили этот результат никакими данными + + )} @@ -114,6 +129,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { const [expand, setExpand] = React.useState(true); const [resultCardSettings, setResultCardSettings] = React.useState(false); const [buttonPlus, setButtonPlus] = React.useState(true); + const question = getQuestionByContentId(resultData.content.rule.parentId); React.useEffect(() => { setExpand(true); @@ -132,11 +148,18 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { m: "20px 0", }} > + + {resultData?.content.rule.parentId === "line" + ? "Единый результат в конце прохождения опросника без ветвления" + : `Заголовок вопроса, после которого появится результат: "${ + question?.title || "нет заголовка" + }"`} + { value={resultData.title} placeholder={"Заголовок результата"} onChange={({ target }: { target: HTMLInputElement }) => - updateQuestion(resultData.id, (question) => (question.title = target.value)) + updateQuestion( + resultData.id, + (question) => (question.title = target.value) + ) } sx={{ margin: isMobile ? "10px 0" : 0, "& .MuiInputBase-root": { color: "#000000", - backgroundColor: expand ? theme.palette.background.default : "transparent", + backgroundColor: expand + ? theme.palette.background.default + : "transparent", height: "48px", borderRadius: "10px", ".MuiOutlinedInput-notchedOutline": { @@ -228,7 +256,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { boxShadow: "0px 10px 30px #e7e7e7", }} > - + { value={resultData.title} placeholder={"Заголовок результата"} onChange={({ target }: { target: HTMLInputElement }) => - updateQuestion(resultData.id, (question) => (question.title = target.value)) + updateQuestion( + resultData.id, + (question) => (question.title = target.value) + ) } /> { - updateQuestion(resultData.id, (question) => (question.description = target.value)) + updateQuestion( + resultData.id, + (question) => (question.description = target.value) + ) } placeholder={"Заголовок пожирнее"} sx={{ @@ -279,7 +313,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { - updateQuestion(resultData.id, (question) => (question.content.text = target.value)) + updateQuestion( + resultData.id, + (question) => (question.content.text = target.value) + ) } fullWidth placeholder="Описание" @@ -335,13 +372,19 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { }} > - + Призыв к действию { setButtonPlus(true); - updateQuestion(resultData.id, (q) => (q.content.hint.text = "")); + updateQuestion( + resultData.id, + (q) => (q.content.hint.text = "") + ); }} > @@ -351,7 +394,11 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { - updateQuestion(resultData.id, (question) => (question.content.hint.text = target.value)) + updateQuestion( + resultData.id, + (question) => + (question.content.hint.text = target.value) + ) } fullWidth placeholder="Например: узнать подробнее" @@ -397,15 +444,25 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { setResultCardSettings(!resultCardSettings); }} sx={{ - backgroundColor: resultCardSettings ? theme.palette.brightPurple.main : "transparent", - color: resultCardSettings ? "#ffffff" : theme.palette.grey3.main, + backgroundColor: resultCardSettings + ? theme.palette.brightPurple.main + : "transparent", + color: resultCardSettings + ? "#ffffff" + : theme.palette.grey3.main, "&:hover": { - backgroundColor: resultCardSettings ? "#581CA7" : "#7E2AEA", + backgroundColor: resultCardSettings + ? "#581CA7" + : "#7E2AEA", color: "white", }, }} > - + {!isTablet && "Настройки"} @@ -423,7 +480,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => { placeholder={"Внутреннее описание вопроса"} value={resultData.innerName} onChange={({ target }: { target: HTMLInputElement }) => - updateQuestion(resultData.id, (question) => (question.content.innerName = target.value)) + updateQuestion( + resultData.id, + (question) => (question.content.innerName = target.value) + ) } />