feat: Branching Data logic
This commit is contained in:
parent
7573f7a3e3
commit
0890d5a67c
@ -10,7 +10,7 @@ import { AnyTypedQuizQuestion } from "../../../model/questionTypes/shared"
|
|||||||
import { SelectChangeEvent } from '@mui/material/Select';
|
import { SelectChangeEvent } from '@mui/material/Select';
|
||||||
import CalendarIcon from "@icons/CalendarIcon";
|
import CalendarIcon from "@icons/CalendarIcon";
|
||||||
import { DatePicker } from "@mui/x-date-pickers";
|
import { DatePicker } from "@mui/x-date-pickers";
|
||||||
import * as dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
|
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
|
||||||
import InfoIcon from "@icons/Info";
|
import InfoIcon from "@icons/Info";
|
||||||
import { DeleteIcon } from "@icons/questionsPage/deleteIcon";
|
import { DeleteIcon } from "@icons/questionsPage/deleteIcon";
|
||||||
@ -289,12 +289,12 @@ const DateInputsType = ({ parentQuestion, targetQuestion, ruleIndex, setParentQu
|
|||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
value={parentQuestion.content.rule.main[ruleIndex].rules[0].answers[0]}
|
defaultValue={dayjs(new Date(parentQuestion.content.rule.main[ruleIndex].rules[0].answers[0]).toLocaleDateString())}
|
||||||
onChange={(dateString) => {
|
onChange={(dateString) => {
|
||||||
const date = dateString?.$d?.toLocaleDateString("ru-RU", { year: "numeric", month: "2-digit", day: "2-digit" });
|
const date = dateString?.toDate().toLocaleDateString("ru-RU", { year: "numeric", month: "2-digit", day: "2-digit" });
|
||||||
let newParentQuestion = JSON.parse(JSON.stringify(parentQuestion))
|
let newParentQuestion = JSON.parse(JSON.stringify(parentQuestion))
|
||||||
newParentQuestion.content.rule.main[ruleIndex].rules[0].answers = [date]
|
newParentQuestion.content.rule.main[ruleIndex].rules[0].answers = [date]
|
||||||
// setParentQuestion(newParentQuestion)
|
setParentQuestion(newParentQuestion)
|
||||||
}}
|
}}
|
||||||
slots={{
|
slots={{
|
||||||
openPickerIcon: () => <CalendarIcon />,
|
openPickerIcon: () => <CalendarIcon />,
|
||||||
|
|||||||
@ -56,7 +56,8 @@ const {openBranchingPanel} = useQuestionsStore.getState()
|
|||||||
return enqueueSnackbar("У корня нет условий ветвления")
|
return enqueueSnackbar("У корня нет условий ветвления")
|
||||||
}
|
}
|
||||||
if (parentId.length !== 0) {
|
if (parentId.length !== 0) {
|
||||||
updateOpenBranchingPanel(value)
|
// updateOpenBranchingPanel(value)
|
||||||
|
openedModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export const Date = ({ currentQuestion }: DateProps) => {
|
|||||||
answers.find(
|
answers.find(
|
||||||
({ questionId }) => questionId === currentQuestion.content.id
|
({ questionId }) => questionId === currentQuestion.content.id
|
||||||
) ?? {};
|
) ?? {};
|
||||||
|
const [day, month, year] = answer?.split(".") || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@ -30,7 +31,11 @@ export const Date = ({ currentQuestion }: DateProps) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
selected={answer ? new window.Date(answer) : new window.Date()}
|
selected={
|
||||||
|
answer
|
||||||
|
? new window.Date(`${month}.${day}.${year}`)
|
||||||
|
: new window.Date()
|
||||||
|
}
|
||||||
onChange={(date) =>
|
onChange={(date) =>
|
||||||
updateAnswer(
|
updateAnswer(
|
||||||
currentQuestion.content.id,
|
currentQuestion.content.id,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user