fix: View Date(WIP)
This commit is contained in:
parent
5c5ef3fac2
commit
bd36307e86
@ -290,7 +290,12 @@ const DateInputsType = ({ parentQuestion, targetQuestion, ruleIndex, setParentQu
|
||||
}
|
||||
<DatePicker
|
||||
value={parentQuestion.content.rule.main[ruleIndex].rules[0].answers[0]}
|
||||
onChange={(e) => console.log(e)}
|
||||
onChange={(dateString) => {
|
||||
const date = dateString?.$d?.toLocaleDateString("ru-RU", { year: "numeric", month: "2-digit", day: "2-digit" });
|
||||
let newParentQuestion = JSON.parse(JSON.stringify(parentQuestion))
|
||||
newParentQuestion.content.rule.main[ruleIndex].rules[0].answers = [date]
|
||||
// setParentQuestion(newParentQuestion)
|
||||
}}
|
||||
slots={{
|
||||
openPickerIcon: () => <CalendarIcon />,
|
||||
}}
|
||||
|
@ -13,7 +13,10 @@ type DateProps = {
|
||||
|
||||
export const Date = ({ currentQuestion }: DateProps) => {
|
||||
const { answers } = useQuizViewStore();
|
||||
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.content.id) ?? {};
|
||||
const { answer } =
|
||||
answers.find(
|
||||
({ questionId }) => questionId === currentQuestion.content.id
|
||||
) ?? {};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@ -28,7 +31,18 @@ export const Date = ({ currentQuestion }: DateProps) => {
|
||||
>
|
||||
<DatePicker
|
||||
selected={answer ? new window.Date(answer) : new window.Date()}
|
||||
onChange={(date) => updateAnswer(currentQuestion.content.id, String(date))}
|
||||
onChange={(date) =>
|
||||
updateAnswer(
|
||||
currentQuestion.content.id,
|
||||
String(
|
||||
date?.toLocaleDateString("ru-RU", {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
|
Loading…
Reference in New Issue
Block a user