diff --git a/src/components/CalendarInfoModal.jsx b/src/components/CalendarInfoModal.jsx
index 6fe3188..e12fd38 100644
--- a/src/components/CalendarInfoModal.jsx
+++ b/src/components/CalendarInfoModal.jsx
@@ -16,13 +16,17 @@ import {
export default function CalendarInfo({ calendar, onClose, userId }) {
// 통합 상태 관리
const [calendarState, setCalendarState] = useState({
- title: calendar.calendar_name,
- detailMemo: calendar.calendar_description,
+ name: calendar.name,
+ description: calendar.description,
isPublic: calendar.is_public,
- calColor: calendar.calendar_color,
- visitCode: calendar.invitation_code,
+ color: calendar.color,
+ invitation_code: calendar.invitation_code,
+ admins: calendar.admins,
});
- const { loggedIn, userInfo, setLoggedIn } = useAuth();
+ const { userInfo } = useAuth();
+ {
+ calendar?.admins?.length > 0 ? calendar.admins.join(", ") : "나만의 캘린더";
+ }
const [isEdit, setIsEdit] = useState(false);
// 상태 변경 핸들러
@@ -36,20 +40,21 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
// 상태 초기화 함수
const resetState = () => {
setCalendarState({
- title: calendar.calendar_name,
- detailMemo: calendar.calendar_description,
+ name: calendar.name,
+ description: calendar.description,
isPublic: calendar.is_public,
- calColor: calendar.calendar_color,
- visitCode: calendar.invitation_code,
+ color: calendar.color,
+ invitation_code: calendar.invitation_code,
+ admins: calendar.admins,
});
setIsEdit(false);
};
- // 컴포넌트가 마운트될 때 creator_id와 userId 확인
+ // creator_id와 userId 확인
useEffect(() => {
- // console.log("Calendar Creator ID:", calendar.creator);
- // console.log("Current User ID:", userInfo.user_id);
- // console.log(calendar);
+ console.log("Calendar Creator ID:", calendar.creator);
+ console.log("Current User ID:", userInfo.user_id);
+ console.log(calendar);
}, [calendar.creator_id, userId]);
// 저장
@@ -59,10 +64,11 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
const response = await instance.patch(
`/api/calendars/${calendar.calendar_id}/`,
{
- calendar_name: calendarState.title,
- calendar_description: calendarState.detailMemo,
+ name: calendarState.name,
+ description: calendarState.description,
is_public: calendarState.isPublic,
- calendar_color: calendarState.calColor,
+ color: calendarState.color,
+ creator: calendarState.creator_id,
},
{
@@ -108,6 +114,10 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
}
};
+ //관리자 +a 계산
+ const visibleAdmins = calendar?.admins?.slice(0, 3) || [];
+ const remainingAdminsCount = calendar?.admins?.length - visibleAdmins.length;
+
return (
-
+
{isEdit ? (
updateState("title", e.target.value)}
+ onChange={(e) => updateState("name", e.target.value)}
/>
) : (
- {calendarState.title}
+ {calendarState.name}
)}
@@ -138,9 +148,9 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
멤버
-
- {calendar?.members?.length > 0
- ? calendar.members.map((member) => member.nickname).join(", ")
+
+ {calendar?.admins?.length > 0
+ ? calendar.admins.join(", ")
: "나만의 캘린더"}
@@ -157,9 +167,9 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
updateState("detailMemo", e.target.value)}
+ onChange={(e) => updateState("description", e.target.value)}
/>
{[
@@ -173,11 +183,11 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
].map(({ color, label }) => (
@@ -187,11 +197,11 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
) : (
- {calendarState.detailMemo}
+ {calendarState.description}
)}
@@ -225,7 +235,7 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
)}
- {calendarState.visitCode}
+ {calendarState.invitation_code}
) : (
@@ -234,11 +244,11 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
{calendarState.isPublic ? "공개" : "비공개"}
- {calendarState.visitCode}
+ {calendarState.invitation_code}
@@ -266,7 +276,7 @@ export default function CalendarInfo({ calendar, onClose, userId }) {
className="cursor-pointer text-[1.5rem] text-darkGray"
onClick={() => setIsEdit(true)}
/>
- {calendar.creator === userInfo.user_id && (
+ {calendar.creator_id === userInfo.user_id && (
) : (
)}
))}
@@ -230,9 +231,9 @@ export default function SideBarLeft() {
htmlFor={calendar.calendar_id}
className="flex items-center text-[0.9rem] font-medium text-eventoPurpleBase"
>
- {calendar.calendar_name}
+ {calendar.name}
- {calendar.calendar_description}
+ {calendar.description}
@@ -257,11 +258,11 @@ export default function SideBarLeft() {
setCalendarInfoOpen(false)}
- onSave={handleSaveCalendar}
userId={userInfo?.user_id}
/>
)}
+
{(Array.isArray(dday) ? dday : []).map((item, index) => {
diff --git a/src/pages/Calendar.jsx b/src/pages/Calendar.jsx
index 9644376..88f5f77 100644
--- a/src/pages/Calendar.jsx
+++ b/src/pages/Calendar.jsx
@@ -98,7 +98,7 @@ export default function Calendar() {
async function fetchCalInfo() {
try {
const token = localStorage.getItem("token"); // 로컬 스토리지에서 토큰 가져오기
- const response = await instance.get("/api/calendars/admins", {
+ const response = await instance.get("/api/calendars/admin", {
headers: {
Authorization: `Bearer ${token}`,
},