Skip to content
Snippets Groups Projects
Commit 3b6a3dbe authored by Gaeon Kim's avatar Gaeon Kim
Browse files

feat: update calendar

parents d197f2c3 697672f4
No related branches found
No related tags found
No related merge requests found
......@@ -83,35 +83,34 @@ const MySchedulerApp = () => {
setIsDeModalOpen(false);
console.log('isDeModalOpen:', isDeModalOpen);
};
const handleSaveEvent = (formData) => {
const handleSaveEvent = async(formData) => {
try{
// 일정 저장 및 모달 닫기
const jsonData=JSON.stringify(formData);
console.log('Sending data to the server:', jsonData);
// 백엔드로 데이터 전송 (Fetch API 사용)
fetch('api/schedules', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: jsonData,
})
.then(response => response.json())
.then(data => {
// 성공 시 처리
console.log(data);
})
.catch(error => {
// 실패 시 처리
console.error(error);
const jsonData=JSON.stringify(formData);
console.log('Sending data to the server:', jsonData);
// 백엔드로 데이터 전송 (Fetch API 사용)
const response = await fetch('api/schedules', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: jsonData,
});
// 모달 닫기
setScheduleData((prevData) => [...prevData, formData])
closeModal();
setUpdateCounter((prevCounter) => prevCounter + 1);
const data = await response.json();
// 성공 시 처리
console.log(data);
// setScheduleData를 사용하여 상태를 업데이트
setScheduleData((prevData) => [...prevData, formData]);
closeModal();
} catch (error) {
// 실패 시 처리
console.error(error);
}
};
const handleInquiryEvent=async(date)=>{
try {
......@@ -146,10 +145,10 @@ const MySchedulerApp = () => {
description: backendData.Description
});
}
setScheduleData(processedDataArray);
console.log('와다다',processedDataArray);
console.log(selectedDate);
setUpdateCounter((prevCounter) => prevCounter + 1);
setScheduleData(processedDataArray);
} catch (error) {
console.error('Error fetching weekly schedules:', error);
}
......@@ -172,35 +171,8 @@ const MySchedulerApp = () => {
// 성공 시 처리
const backendDataArray = data.schedules;
console.log(data.schedules);
// const backendDataArray =
// [{
// "id":23423,
// "date":"2023-11-19",
// "startTime":"10:00",
// "endTime":"11:30",
// "title":"뇨끼 먹기",
// "color":"#8393BE",
// "Description":"맛있게 먹기"
// },{
// "id":1923,
// "date":"2023-11-23",
// "startTime":"17:00",
// "endTime":"19:00",
// "title":"까르보나라 만들기",
// "color":"#8393BE"
// },{
// "id":777,
// "date":"2023-11-24",
// "startTime":"09:00",
// "endTime":"12:00",
// "title":"강의 듣기",
// "color":"#8393BE"
// }];
// 만약 backendDataArray가 undefined인지 확인
console.log(data.schedules);
// 받아온 여러 개의 데이터를 가공하여 사용할 형식으로 변환
const processedDataArray = [];
for (const backendData of backendDataArray) {
......@@ -230,7 +202,7 @@ const MySchedulerApp = () => {
}
// 변환된 데이터 배열을 JSON 문자열로 변환
console.log('dd',processedDataArray);
setScheduleData(processedDataArray)
setScheduleData(prevData => [...prevData, ...processedDataArray]);
console.log('kk', scheduleData);
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment