import React, { useState, useEffect } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; import CODE from 'constants/code'; import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin'; function SchedulesDetail(props) { console.group("EgovAdminScheduleDetail"); console.log("[Start] EgovAdminScheduleDetail ------------------------------"); console.log("EgovAdminScheduleDetail [props] : ", props); const navigate = useNavigate(); const location = useLocation(); console.log("EgovAdminScheduleDetail [location] : ", location); const [scheduleDetail, setScheduleDetail] = useState({}); const retrieveDetail = () => { const retrieveDetailURL = `/schedule/${location.state?.schdulId}`; const requestOptions = { method: "GET", headers: { 'Content-type': 'application/json', } } EgovNet.requestFetch(retrieveDetailURL, requestOptions, function (resp) { setScheduleDetail(resp.result); } ); } const convertDate = (str) => { if( !str ) { return null; } let year = str.substring(0, 4); let month = str.substring(5, 7); let date = str.substring(8, 10); let hour = str.substring(11, 13); let minute = str.substring(14, 16); return { year: year, month: month, date: date, hour: hour, minute: minute, dateForm: year + "-" + month + "-" + date + " " + hour + ":" + minute + "" } } const onClickDeleteSchedule = (schdulId) => { const deleteBoardURL = `/schedule/${schdulId}`; const requestOptions = { method: "DELETE", headers: { 'Content-type': 'application/json', } } EgovNet.requestFetch(deleteBoardURL, requestOptions, (resp) => { console.log("====>>> Schdule delete= ", resp); if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) { alert("게시글이 삭제되었습니다.") navigate(URL.ADMIN__COMMITTEE__SCHEDULES ,{ replace: true }); } else { // alert("ERR : " + resp.message); navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}}); } } ); } useEffect(function () { retrieveDetail(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); console.log("------------------------------EgovAdminScheduleDetail [End]"); console.groupEnd("EgovAdminScheduleDetail"); return (