Skip to content

Commit

Permalink
mod: INIT data 중복 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
halionaz committed Sep 22, 2024
1 parent d6f2cbd commit 805ccca
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/api/hooks/timetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ export const useGetUserTimetableList = () => {
})
}

const INITIAL_TIMETABLE: GetTimetableByTimetableIdResponse = {
courses: [],
schedules: [],
color: 'Red',
}

const getTimetableByID = async ({ timetableId }: GetTimetableByTimetableIdRequest) => {
if (timetableId === -1)
return {
courses: [],
schedules: [],
color: 'Red',
} as GetTimetableByTimetableIdResponse
if (timetableId === -1) return INITIAL_TIMETABLE

const response = await apiInterface.get<GetTimetableByTimetableIdResponse>(`/timetable/${timetableId}`)
return response.data
Expand All @@ -48,11 +49,7 @@ export const useGetTimetable = ({ timetableId }: GetTimetableByTimetableIdReques
return useQuery({
queryKey: ['timetable', timetableId],
queryFn: () => getTimetableByID({ timetableId }),
initialData: {
courses: [],
schedules: [],
color: 'Red',
},
initialData: INITIAL_TIMETABLE,
})
}

Expand Down

0 comments on commit 805ccca

Please sign in to comment.