import { useState } from "react"; import { Link, useHistory } from "react-router-dom"; import planApi from "../../apis/plan.api"; import { useAuth } from "../../utils/context"; import catchErrors from "../../utils/catchErrors"; import styles from "../Schedule/schedule.module.scss"; import styles2 from "./studyplan.module.scss"; import moment from 'moment'; const PlanItem = ({ planList = [], subjectId, getPlanList }) => { const { user } = useAuth() const [error, setError] = useState("") const history = useHistory() async function delPlan(planId) { try { setError("") await planApi.remove(planId, user.id) alert("해당 계획을 성공적으로 삭제했습니다.") history.push("/studyplan") } catch (error) { catchErrors(error, setError) } } async function checkFn(e, planId, planCk) { try { setError("") e.preventDefault(); const result = await planApi.saveCheck(planId, planCk) console.log('check save result', result) if (result === "success") { getPlanList() } } catch (error) { catchErrors(error, setError) } } return ( <> {planList.length !== 0 ? planList.map((plan, idx) =>
등록된 학업 계획이 없습니다.
} > ) } export default PlanItem;