/** * Scheduler - Main wrapper component that renders appropriate scheduler view * Refactored to avoid conditional hooks issue */ import React from 'react'; import { useOutletContext } from 'react-router-dom'; import { User, Business } from '../types'; import { useAppointments, useUpdateAppointment, useDeleteAppointment } from '../hooks/useAppointments'; import { useResources } from '../hooks/useResources'; import { useServices } from '../hooks/useServices'; import ResourceScheduler from './ResourceScheduler'; import OwnerScheduler from './OwnerScheduler'; const Scheduler: React.FC = () => { const { user, business } = useOutletContext<{ user: User, business: Business }>(); // Fetch data from API (shared across both views) const { data: appointments = [], isLoading: appointmentsLoading } = useAppointments(); const { data: resources = [], isLoading: resourcesLoading } = useResources(); const { data: services = [], isLoading: servicesLoading } = useServices(); // Show loading state if (appointmentsLoading || resourcesLoading || servicesLoading) { return (