Skip to content

Commit

Permalink
Feat: #164 active된 캘린더의 이벤트 정보 API 연결
Browse files Browse the repository at this point in the history
-왼쪽 사이드바 active petch 수정
-캘린더 제목 데이터 필요
  • Loading branch information
sujinnn committed Dec 10, 2024
1 parent 72c0d5a commit 855ea76
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/pages/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,21 @@ export default function Calendar() {
try {
const token = localStorage.getItem("token"); // 로컬 스토리지에서 토큰 가져오기

//isactive인 캘린더의 이벤트(바뀐 API)
const response = await instance.get(`/api/events/public/list/`, {
const response = await instance.get(`/api/events/active/`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
// const start_date = new Date(response.data.start_time);
// const end_date = new Date(response.data.end_time);
const eventData = response.data.admin_events.concat(
response.data.subscription_events,
);
console.log("aaa", response.data);

// const formattedStartDate = start_date.toLocaleDateString("ko");
// const formattedEndDate = end_date.toLocaleDateString("ko");
const eventMockData = response.data.map((event) => {
const eventList = eventData.map((event) => {
const calendar = calInfo.find(
(cal) => cal.calId === event.calendar_id,
);

console.log("fff", calendar);
return {
displayEventEnd: true,
allDay: false,
Expand All @@ -137,11 +136,11 @@ export default function Calendar() {
},
calId: event.calendar_id,
calTitle: calendar ? calendar.calendarName : "", // calId와 일치하는 calendarName을 설정
color: calendar ? calendar.calendarColor : "gray", // 기본 색상 지정
color: event.calendar_color,
editable: true, // 이벤트 편집 가능
};
});
setEvents(eventMockData);
setEvents(eventList);
} catch (error) {
console.error("이벤트 정보를 가져오는 중 오류 발생:", error);
}
Expand Down

0 comments on commit 855ea76

Please sign in to comment.