@@ -8,12 +8,13 @@ import {
88import { MedicalReport } from '../models/medicalReport' ;
99import { QueryKey } from 'common/utils/constants' ;
1010
11+ export const LATEST_REPORTS_LIMIT = 3 ;
1112/**
1213 * Hook to fetch the latest reports.
1314 * @param limit - Maximum number of reports to fetch
1415 * @returns Query result with the latest reports
1516 */
16- export const useGetLatestReports = ( limit = 3 ) => {
17+ export const useGetLatestReports = ( limit = LATEST_REPORTS_LIMIT ) => {
1718 return useQuery ( {
1819 queryKey : [ QueryKey . LatestReports , limit ] ,
1920 queryFn : ( ) => fetchLatestReports ( limit ) ,
@@ -53,12 +54,15 @@ export const useMarkReportAsRead = () => {
5354 } ) ;
5455
5556 // Update the latest reports cache
56- queryClient . setQueryData < MedicalReport [ ] > ( [ QueryKey . LatestReports ] , ( oldReports ) => {
57- if ( ! oldReports ) return undefined ;
58- return oldReports . map ( ( report ) =>
59- report . id === updatedReport . id ? updatedReport : report ,
60- ) ;
61- } ) ;
57+ queryClient . setQueryData < MedicalReport [ ] > (
58+ [ QueryKey . LatestReports , LATEST_REPORTS_LIMIT ] ,
59+ ( oldReports ) => {
60+ if ( ! oldReports ) return undefined ;
61+ return oldReports . map ( ( report ) =>
62+ report . id === updatedReport . id ? updatedReport : report ,
63+ ) ;
64+ } ,
65+ ) ;
6266 } ,
6367 } ) ;
6468} ;
@@ -83,12 +87,15 @@ export const useToggleReportBookmark = () => {
8387 } ) ;
8488
8589 // Update the latest reports cache
86- queryClient . setQueryData < MedicalReport [ ] > ( [ QueryKey . LatestReports ] , ( oldReports ) => {
87- if ( ! oldReports ) return undefined ;
88- return oldReports . map ( ( report ) =>
89- report . id === updatedReport . id ? updatedReport : report ,
90- ) ;
91- } ) ;
90+ queryClient . setQueryData < MedicalReport [ ] > (
91+ [ QueryKey . LatestReports , LATEST_REPORTS_LIMIT ] ,
92+ ( oldReports ) => {
93+ if ( ! oldReports ) return undefined ;
94+ return oldReports . map ( ( report ) =>
95+ report . id === updatedReport . id ? updatedReport : report ,
96+ ) ;
97+ } ,
98+ ) ;
9299
93100 // Update the bookmark status in the report detail page
94101 queryClient . setQueryData < MedicalReport | undefined > (
0 commit comments