import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { surveyApi } from "../apis"; import { SurveyType } from "../types"; import { MySurveyCard } from "./MySurveyCard"; const testData = [ { id: 0, name: "이름1", description: "설명1" }, { id: 1, name: "이름2", description: "설명2" }, { id: 2, name: "이름3", description: "설명3" }, ]; 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 ; })}
); };