Spaces:
Running

axeronis commited on
Commit
0d30dd4
Β·
1 Parent(s): c781ddc

fix: force appointments to always refetch on page mount

Browse files
Files changed (1) hide show
  1. frontend/app/appointments/page.tsx +4 -2
frontend/app/appointments/page.tsx CHANGED
@@ -21,16 +21,18 @@ export default function AppointmentsPage() {
21
  // Debug: check if user is loaded
22
  console.log('πŸ“… AppointmentsPage: user=', user?.id, 'authLoading=', authLoading)
23
 
24
- // React Query for appointments - cached!
25
  const { data: appointments = [], isLoading } = useQuery({
26
  queryKey: ['appointments', user?.tenant_id],
27
  queryFn: async () => {
28
  console.log('πŸ“… Fetching appointments...')
29
  const result = await bookingsApi.getAppointments()
30
- console.log('πŸ“… Got appointments:', result?.length || 0)
31
  return result
32
  },
33
  enabled: !!user && !authLoading,
 
 
34
  })
35
 
36
  // When date changes, try to find an appointment on that day to select automatically, or clear selection
 
21
  // Debug: check if user is loaded
22
  console.log('πŸ“… AppointmentsPage: user=', user?.id, 'authLoading=', authLoading)
23
 
24
+ // React Query for appointments - ALWAYS fetch fresh data
25
  const { data: appointments = [], isLoading } = useQuery({
26
  queryKey: ['appointments', user?.tenant_id],
27
  queryFn: async () => {
28
  console.log('πŸ“… Fetching appointments...')
29
  const result = await bookingsApi.getAppointments()
30
+ console.log('πŸ“… Got appointments:', result?.length || 0, result)
31
  return result
32
  },
33
  enabled: !!user && !authLoading,
34
+ staleTime: 0, // Always consider data stale
35
+ refetchOnMount: 'always', // Always refetch when component mounts
36
  })
37
 
38
  // When date changes, try to find an appointment on that day to select automatically, or clear selection