- Replaced direct API calls with React Query hooks in ChoreView, ChoreCard, CompactChoreCard, and TimerDetails components for better state management and error handling. - Updated ArchivedTasks to utilize useUnArchiveChore hook for restoring archived chores. - Enhanced NotificationSetting to include device registration logic and improved user feedback for push notifications. - Refactored TimerEditModal and TimerDetails to streamline timer session updates and deletions using hooks. - Improved ChoreActionMenu to handle archiving and unarchiving chores with hooks. - Adjusted various components to use getSafeBottomStyles for consistent bottom padding. - Cleaned up unused imports and optimized loading states across components.
17 lines
476 B
JavaScript
17 lines
476 B
JavaScript
import { useQuery } from '@tanstack/react-query'
|
|
import { GetResource } from '../utils/Fetcher'
|
|
|
|
export const useResource = () => {
|
|
const { data, isLoading, error } = useQuery({
|
|
queryKey: ['resource'],
|
|
queryFn: async () => {
|
|
const response = await GetResource()
|
|
return response
|
|
},
|
|
staleTime: 6 * 60 * 60 * 1000, // 6 hours in milliseconds
|
|
refetchOnWindowFocus: false,
|
|
refetchOnReconnect: false,
|
|
})
|
|
return { data, isLoading, error }
|
|
}
|