Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaeon Kim
client
Commits
3b6a3dbe
Commit
3b6a3dbe
authored
1 year ago
by
Gaeon Kim
Browse files
Options
Downloads
Plain Diff
feat: update calendar
parents
d197f2c3
697672f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pages/calendar.js
+31
-59
31 additions, 59 deletions
src/pages/calendar.js
with
31 additions
and
59 deletions
src/pages/calendar.js
+
31
−
59
View file @
3b6a3dbe
...
...
@@ -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
);
set
UpdateCounter
((
prevCounter
)
=>
prevCounter
+
1
);
set
ScheduleData
(
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
);
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment