import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import { surveyApi } from "../apis"; import { catchErrors } from "../helpers"; import { SpinnerIcon } from "../icons"; import { ISurvey } from "../types"; export const AnswerSurvey = () => { let { surveyId } = useParams<{ surveyId: string }>(); const [survey, setSurvey] = useState(); const [error, setError] = useState(""); useEffect(() => { surveyId && getSurvey(surveyId); }, [surveyId]); const handleSubmit = () => {}; async function getSurvey(surveyId: string) { try { setError(""); const survey: any = await surveyApi.getSurveyById(surveyId); console.log("survey가져옴ㅎㅎ", survey); // answerSurvey.current._id = survey._id; // answerSurvey.current.questions = survey.questions; setSurvey(survey); // setSuccess(true); } catch (error) { catchErrors(error, setError); } finally { // setLoading(false); } } if (!survey) { return (
); } return (

{survey.title}

{survey.comment}

{/* {survey.questions.map((question, index) => { return ( ); })} */}
); };