Skip to content

Commit

Permalink
feat: 일정 모달의 삭제 및 편집 권한 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy979 committed Oct 9, 2022
1 parent 8656cdb commit 8d1d0ab
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions frontend/src/components/ScheduleModal/ScheduleModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useTheme } from '@emotion/react';

import { useGetSingleCategory } from '@/hooks/@queries/category';
import { useGetEditableCategories, useGetSingleCategory } from '@/hooks/@queries/category';
import { useDeleteSchedule } from '@/hooks/@queries/schedule';
import useUserValue from '@/hooks/useUserValue';

import { ModalPosType } from '@/@types';
import { ScheduleType } from '@/@types/schedule';
Expand Down Expand Up @@ -46,14 +45,14 @@ function ScheduleModal({
toggleScheduleModifyModalOpen,
closeModal,
}: ScheduleModalProps) {
const { user } = useUserValue();

const theme = useTheme();

const { data: categoryGetResponse } = useGetSingleCategory({
categoryId: scheduleInfo.categoryId,
});

const { data: editableCategoryGetResponse } = useGetEditableCategories({});

const { mutate } = useDeleteSchedule({
scheduleId: scheduleInfo.id,
onSuccess: () => closeModal(),
Expand All @@ -78,10 +77,10 @@ function ScheduleModal({
return dateTime.replace('T', ' ');
};

const canEditSchedule =
(scheduleInfo.categoryType === CATEGORY_TYPE.NORMAL ||
scheduleInfo.categoryType === CATEGORY_TYPE.PERSONAL) &&
user.id === categoryGetResponse?.data.creator.id;
const canEditSchedule = editableCategoryGetResponse?.data.find(
(category) =>
category.id === scheduleInfo.categoryId && category.categoryType !== CATEGORY_TYPE.GOOGLE
);

return (
<div css={scheduleModalStyle(theme, scheduleModalPos)}>
Expand Down

0 comments on commit 8d1d0ab

Please sign in to comment.