diff --git a/src/pages/Questions/DraggableList/QuestionPageCard.tsx b/src/pages/Questions/DraggableList/QuestionPageCard.tsx index fe033bd0..385c27e0 100644 --- a/src/pages/Questions/DraggableList/QuestionPageCard.tsx +++ b/src/pages/Questions/DraggableList/QuestionPageCard.tsx @@ -1,4 +1,3 @@ -import { useState } from "react"; import { Box, Checkbox, @@ -136,8 +135,7 @@ export default function QuestionsPageCard({ }: Props) { const theme = useTheme(); const { listQuestions } = questionStore(); - const [isExpanded, setIsExpanded] = useState(false); - const switchState = listQuestions[totalIndex].type; + const { type: switchState, expanded: isExpanded } = listQuestions[totalIndex]; return ( + <>{isExpanded && console.log(listQuestions[totalIndex])} - setIsExpanded((prev) => !prev)}> + + updateQuestionsList(totalIndex, { expanded: !isExpanded }) + } + > {isExpanded ? : } {isExpanded ? ( diff --git a/src/stores/questions.ts b/src/stores/questions.ts index 6b80d10c..812db495 100644 --- a/src/stores/questions.ts +++ b/src/stores/questions.ts @@ -24,6 +24,7 @@ export interface Question { parent_ids: number[]; created_at: string; updated_at: string; + expanded: boolean; } interface QuestionStore { @@ -81,6 +82,7 @@ export const createQuestion = (id: number) => { parent_ids: [0], created_at: "", updated_at: "", + expanded: false, }); questionStore.setState({ listQuestions: newData }); };