Skip to content

Commit

Permalink
feat: 일정 상세 모달 api 쿼리 동기적 실행 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy979 committed Oct 9, 2022
1 parent e28d36e commit 35cb362
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 2 additions & 5 deletions frontend/src/components/ScheduleModal/ScheduleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useTheme } from '@emotion/react';

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,15 +45,13 @@ function ScheduleModal({
toggleScheduleModifyModalOpen,
closeModal,
}: ScheduleModalProps) {
const { user } = useUserValue();

const theme = useTheme();

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

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

const { mutate } = useDeleteSchedule({
scheduleId: scheduleInfo.id,
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/hooks/@queries/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ function useGetSchedulesWithCategory({
}

function useGetSingleCategory({ categoryId }: useGetSingleCategoryProps) {
const { data } = useQuery<AxiosResponse<CategoryType>, AxiosError>(CACHE_KEY.CATEGORY, () =>
categoryApi.getSingle(categoryId)
const { data, isSuccess } = useQuery<AxiosResponse<CategoryType>, AxiosError>(
CACHE_KEY.CATEGORY,
() => categoryApi.getSingle(categoryId)
);

return { data };
return { data, isSuccess };
}

function useGetSubscribers({ categoryId }: useGetSubscribersProps) {
Expand Down

0 comments on commit 35cb362

Please sign in to comment.