feat: ResultCard title
This commit is contained in:
parent
f44950333b
commit
ee87a5d7a8
@ -1,6 +1,9 @@
|
|||||||
import * as React from "react";
|
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";
|
import CustomTextField from "@ui_kit/CustomTextField";
|
||||||
|
|
||||||
@ -31,7 +34,11 @@ interface Props {
|
|||||||
resultData: QuizQuestionResult;
|
resultData: QuizQuestionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const checkEmptyData = ({ resultData }: { resultData: QuizQuestionResult }) => {
|
export const checkEmptyData = ({
|
||||||
|
resultData,
|
||||||
|
}: {
|
||||||
|
resultData: QuizQuestionResult;
|
||||||
|
}) => {
|
||||||
let check = true;
|
let check = true;
|
||||||
if (
|
if (
|
||||||
resultData.title.length > 0 ||
|
resultData.title.length > 0 ||
|
||||||
@ -50,7 +57,9 @@ export const checkEmptyData = ({ resultData }: { resultData: QuizQuestionResult
|
|||||||
const InfoView = ({ resultData }: { resultData: QuizQuestionResult }) => {
|
const InfoView = ({ resultData }: { resultData: QuizQuestionResult }) => {
|
||||||
const checkEmpty = checkEmptyData({ resultData });
|
const checkEmpty = checkEmptyData({ resultData });
|
||||||
const question = getQuestionByContentId(resultData.content.rule.parentId);
|
const question = getQuestionByContentId(resultData.content.rule.parentId);
|
||||||
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);
|
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
@ -96,9 +105,15 @@ const InfoView = ({ resultData }: { resultData: QuizQuestionResult }) => {
|
|||||||
<Typography>
|
<Typography>
|
||||||
{resultData?.content.rule.parentId === "line"
|
{resultData?.content.rule.parentId === "line"
|
||||||
? "Единый результат в конце прохождения опросника без ветвления"
|
? "Единый результат в конце прохождения опросника без ветвления"
|
||||||
: `Заголовок вопроса, после которого появится результат: "${question?.title || "нет заголовка"}"`}
|
: `Заголовок вопроса, после которого появится результат: "${
|
||||||
|
question?.title || "нет заголовка"
|
||||||
|
}"`}
|
||||||
</Typography>
|
</Typography>
|
||||||
{checkEmpty && <Typography color="red">Вы не заполнили этот результат никакими данными</Typography>}
|
{checkEmpty && (
|
||||||
|
<Typography color="red">
|
||||||
|
Вы не заполнили этот результат никакими данными
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
</Paper>
|
</Paper>
|
||||||
</Popover>
|
</Popover>
|
||||||
</>
|
</>
|
||||||
@ -114,6 +129,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
const [expand, setExpand] = React.useState(true);
|
const [expand, setExpand] = React.useState(true);
|
||||||
const [resultCardSettings, setResultCardSettings] = React.useState(false);
|
const [resultCardSettings, setResultCardSettings] = React.useState(false);
|
||||||
const [buttonPlus, setButtonPlus] = React.useState(true);
|
const [buttonPlus, setButtonPlus] = React.useState(true);
|
||||||
|
const question = getQuestionByContentId(resultData.content.rule.parentId);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setExpand(true);
|
setExpand(true);
|
||||||
@ -132,11 +148,18 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
m: "20px 0",
|
m: "20px 0",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Typography sx={{ color: theme.palette.grey2.main, padding: "5px 20px" }}>
|
||||||
|
{resultData?.content.rule.parentId === "line"
|
||||||
|
? "Единый результат в конце прохождения опросника без ветвления"
|
||||||
|
: `Заголовок вопроса, после которого появится результат: "${
|
||||||
|
question?.title || "нет заголовка"
|
||||||
|
}"`}
|
||||||
|
</Typography>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: expand ? "none" : "flex",
|
display: expand ? "none" : "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
padding: isMobile ? "10px" : "20px",
|
padding: isMobile ? "10px" : "0 20px 20px",
|
||||||
flexDirection: isMobile ? "column" : null,
|
flexDirection: isMobile ? "column" : null,
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
minHeight: "40px",
|
minHeight: "40px",
|
||||||
@ -155,13 +178,18 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
value={resultData.title}
|
value={resultData.title}
|
||||||
placeholder={"Заголовок результата"}
|
placeholder={"Заголовок результата"}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.title = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) => (question.title = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
margin: isMobile ? "10px 0" : 0,
|
margin: isMobile ? "10px 0" : 0,
|
||||||
"& .MuiInputBase-root": {
|
"& .MuiInputBase-root": {
|
||||||
color: "#000000",
|
color: "#000000",
|
||||||
backgroundColor: expand ? theme.palette.background.default : "transparent",
|
backgroundColor: expand
|
||||||
|
? theme.palette.background.default
|
||||||
|
: "transparent",
|
||||||
height: "48px",
|
height: "48px",
|
||||||
borderRadius: "10px",
|
borderRadius: "10px",
|
||||||
".MuiOutlinedInput-notchedOutline": {
|
".MuiOutlinedInput-notchedOutline": {
|
||||||
@ -228,7 +256,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
boxShadow: "0px 10px 30px #e7e7e7",
|
boxShadow: "0px 10px 30px #e7e7e7",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box sx={{ p: "0 20px", pt: "30px" }}>
|
<Box sx={{ p: "0 20px", pt: "10px" }}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@ -243,7 +271,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
value={resultData.title}
|
value={resultData.title}
|
||||||
placeholder={"Заголовок результата"}
|
placeholder={"Заголовок результата"}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.title = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) => (question.title = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
@ -265,7 +296,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
<CustomTextField
|
<CustomTextField
|
||||||
value={resultData.description}
|
value={resultData.description}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.description = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) => (question.description = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
placeholder={"Заголовок пожирнее"}
|
placeholder={"Заголовок пожирнее"}
|
||||||
sx={{
|
sx={{
|
||||||
@ -279,7 +313,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
<TextField
|
<TextField
|
||||||
value={resultData.content.text}
|
value={resultData.content.text}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.content.text = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) => (question.content.text = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Описание"
|
placeholder="Описание"
|
||||||
@ -335,13 +372,19 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component={"span"} sx={{ weight: "500", fontSize: "18px", mb: "10px" }}>
|
<Typography
|
||||||
|
component={"span"}
|
||||||
|
sx={{ weight: "500", fontSize: "18px", mb: "10px" }}
|
||||||
|
>
|
||||||
Призыв к действию
|
Призыв к действию
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setButtonPlus(true);
|
setButtonPlus(true);
|
||||||
updateQuestion(resultData.id, (q) => (q.content.hint.text = ""));
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(q) => (q.content.hint.text = "")
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Trash />
|
<Trash />
|
||||||
@ -351,7 +394,11 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
<TextField
|
<TextField
|
||||||
value={resultData.content.hint.text}
|
value={resultData.content.hint.text}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.content.hint.text = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) =>
|
||||||
|
(question.content.hint.text = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Например: узнать подробнее"
|
placeholder="Например: узнать подробнее"
|
||||||
@ -397,15 +444,25 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
setResultCardSettings(!resultCardSettings);
|
setResultCardSettings(!resultCardSettings);
|
||||||
}}
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: resultCardSettings ? theme.palette.brightPurple.main : "transparent",
|
backgroundColor: resultCardSettings
|
||||||
color: resultCardSettings ? "#ffffff" : theme.palette.grey3.main,
|
? theme.palette.brightPurple.main
|
||||||
|
: "transparent",
|
||||||
|
color: resultCardSettings
|
||||||
|
? "#ffffff"
|
||||||
|
: theme.palette.grey3.main,
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: resultCardSettings ? "#581CA7" : "#7E2AEA",
|
backgroundColor: resultCardSettings
|
||||||
|
? "#581CA7"
|
||||||
|
: "#7E2AEA",
|
||||||
color: "white",
|
color: "white",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SettingIcon color={resultCardSettings ? "#ffffff" : theme.palette.grey3.main} />
|
<SettingIcon
|
||||||
|
color={
|
||||||
|
resultCardSettings ? "#ffffff" : theme.palette.grey3.main
|
||||||
|
}
|
||||||
|
/>
|
||||||
{!isTablet && "Настройки"}
|
{!isTablet && "Настройки"}
|
||||||
</MiniButtonSetting>
|
</MiniButtonSetting>
|
||||||
</Box>
|
</Box>
|
||||||
@ -423,7 +480,10 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
|||||||
placeholder={"Внутреннее описание вопроса"}
|
placeholder={"Внутреннее описание вопроса"}
|
||||||
value={resultData.innerName}
|
value={resultData.innerName}
|
||||||
onChange={({ target }: { target: HTMLInputElement }) =>
|
onChange={({ target }: { target: HTMLInputElement }) =>
|
||||||
updateQuestion(resultData.id, (question) => (question.content.innerName = target.value))
|
updateQuestion(
|
||||||
|
resultData.id,
|
||||||
|
(question) => (question.content.innerName = target.value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user