diff --git a/frontend/src/api/alarm.ts b/frontend/src/api/alarm.ts index d5f5e273f..e6ec017c6 100644 --- a/frontend/src/api/alarm.ts +++ b/frontend/src/api/alarm.ts @@ -29,13 +29,15 @@ export interface ReportAlarmList { interface ReportAlarm { id: number; isRead: boolean; - info: { - id: number; - type: ReportType; - reason: ReportMessage[]; - content: string; - createAt: StringDate; - }; + info: ReportConfirmResult; +} + +export interface ReportConfirmResult { + id: number; + type: ReportType; + reason: ReportMessage[]; + content: string; + createAt: StringDate; } export const getContentAlarmList = async (page: number): Promise => { @@ -55,3 +57,11 @@ export const getReportAlarmList = async (page: number): Promise alarmList, }; }; + +export const getReportConfirmResult = async (reportId: number): Promise => { + const reportConfirmResult = await getFetch( + `${BASE_URL}/alarms/report/${reportId}` + ); + + return reportConfirmResult; +}; diff --git a/frontend/src/constants/queryKey.ts b/frontend/src/constants/queryKey.ts index 23dd8558e..cdcf4b700 100644 --- a/frontend/src/constants/queryKey.ts +++ b/frontend/src/constants/queryKey.ts @@ -9,4 +9,5 @@ export const QUERY_KEY = { VOTE_STATISTICS: 'voteStatistics', ALARM_CONTENT: 'contentAlarm', ALARM_REPORT: 'reportAlarm', + REPORT_CONFIRM_RESULT: 'reportConfirmResult', }; diff --git a/frontend/src/hooks/query/useReportConfirmResult.tsx b/frontend/src/hooks/query/useReportConfirmResult.tsx new file mode 100644 index 000000000..7a995f172 --- /dev/null +++ b/frontend/src/hooks/query/useReportConfirmResult.tsx @@ -0,0 +1,28 @@ +import { useQuery } from '@tanstack/react-query'; + +import { ReportConfirmResult, getReportConfirmResult } from '@api/alarm'; + +import { QUERY_KEY } from '@constants/queryKey'; + +export const useReportConfirmResult = (reportId: number) => { + const { data } = useQuery( + [QUERY_KEY.REPORT_CONFIRM_RESULT, reportId], + () => getReportConfirmResult(reportId), + { + cacheTime: 60 * 60 * 1000, + staleTime: 60 * 60 * 1000, + suspense: true, + + retry: (failCount, error) => { + // const fetchError = error as Error; + // const status = JSON.parse(fetchError.message).status; + // if (status === 404) { + // return false; + // } + return failCount <= 3; + }, + } + ); + + return { data }; +};