Spaces:
Running

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

debug: add logging to appointments page to diagnose API call issue

Browse files
Files changed (1) hide show
  1. frontend/app/appointments/page.tsx +11 -3
frontend/app/appointments/page.tsx CHANGED
@@ -13,16 +13,24 @@ import { motion, AnimatePresence } from 'framer-motion'
13
  import { useTranslation } from '@/lib/i18n'
14
 
15
  export default function AppointmentsPage() {
16
- const { user } = useAuth()
17
  const queryClient = useQueryClient()
18
  const [selectedDate, setSelectedDate] = useState<Date>(new Date())
19
  const [selectedAppointment, setSelectedAppointment] = useState<any>(null)
20
 
 
 
 
21
  // React Query for appointments - cached!
22
  const { data: appointments = [], isLoading } = useQuery({
23
  queryKey: ['appointments', user?.tenant_id],
24
- queryFn: () => bookingsApi.getAppointments(),
25
- enabled: !!user,
 
 
 
 
 
26
  })
27
 
28
  // When date changes, try to find an appointment on that day to select automatically, or clear selection
 
13
  import { useTranslation } from '@/lib/i18n'
14
 
15
  export default function AppointmentsPage() {
16
+ const { user, isLoading: authLoading } = useAuth()
17
  const queryClient = useQueryClient()
18
  const [selectedDate, setSelectedDate] = useState<Date>(new Date())
19
  const [selectedAppointment, setSelectedAppointment] = useState<any>(null)
20
 
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