import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { surveyApi } from "../apis"; import { SurveyType } from "../types"; import { MySurveyCard } from "./MySurveyCard"; export const Profile = () => { const navigate = useNavigate(); const [survey, setSurvey] = useState({ user: {}, title: "", comment: "", questions: [], }); const [cardDatas, setCardDatas] = useState([]); useEffect(() => { getSurveys(); }, []); async function createSurvey() { const newSurvey: SurveyType = await surveyApi.createSurvey(survey); navigate(`/surveys/edit/${newSurvey._id}`, { replace: true, }); } async function getSurveys() { const surveys: SurveyType[] = await surveyApi.getSurveys(); console.log(surveys); setCardDatas(surveys); } // let surveys = getSurvey(_id); return (
나의 설문조사
{cardDatas.map((data, index) => { return ; })}
); };