Spaces:
Running
Running
axeronis commited on
Commit Β·
0d30dd4
1
Parent(s): c781ddc
fix: force appointments to always refetch on page mount
Browse files
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 -
|
| 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
|