import React, { useState, useRef, useEffect } from "react"; import { IQuestionData } from "../types"; // import { // REssay, // RCheckbox, // RRadio, // RDropdown, // RFile, // RRating, // RDate, // } from "../forms"; import { getResultElementByType } from "../helpers/question.helper"; type AccordionProps = { question: IQuestionData; }; export const Accordion = ({ question }: AccordionProps) => { const [isOpened, setOpened] = useState(false); const [height, setHeight] = useState("0px"); const contentElement = useRef(null); const HandleOpening = () => { setOpened(!isOpened); setHeight(!isOpened ? `${contentElement.current?.scrollHeight}px` : "0px"); }; // function getContent(question: IQuestionData) { // switch (question.type) { // case "singletext": // return ; // case "radio": // return ; // case "checkbox": // return ; // case "dropdown": // return ; // case "file": // return ; // case "rating": // return ; // case "date": // return ; // default: // return <>; // } // } // console.log(question); return (

{question.title}

{isOpened ? "△" : "▽"}
{question.answers && getResultElementByType(question)}
); }; export default Accordion;