diff --git a/src/components/call-desk/appointment-form.tsx b/src/components/call-desk/appointment-form.tsx index 5bfbfb6..b19f886 100644 --- a/src/components/call-desk/appointment-form.tsx +++ b/src/components/call-desk/appointment-form.tsx @@ -35,11 +35,8 @@ type AppointmentFormProps = { type DoctorRecord = { id: string; name: string; department: string; clinic: string }; -const clinicItems = [ - { id: 'koramangala', label: 'Global Hospital - Koramangala' }, - { id: 'whitefield', label: 'Global Hospital - Whitefield' }, - { id: 'indiranagar', label: 'Global Hospital - Indiranagar' }, -]; +// Clinics are fetched dynamically from the platform — no hardcoded list. +// If the workspace has no clinics configured, the dropdown shows empty. const genderItems = [ { id: 'male', label: 'Male' }, @@ -97,6 +94,7 @@ export const AppointmentForm = ({ const [age, setAge] = useState(''); const [gender, setGender] = useState(null); const [clinic, setClinic] = useState(null); + const [clinicItems, setClinicItems] = useState>([]); const [department, setDepartment] = useState(existingAppointment?.department ?? null); const [doctor, setDoctor] = useState(existingAppointment?.doctorId ?? null); const [date, setDate] = useState(() => { @@ -125,6 +123,18 @@ export const AppointmentForm = ({ // `clinic` field anymore. We pull the full visit-slot list via the // doctorVisitSlots reverse relation so the agent can see which // clinics + days this doctor covers in the picker. + // Fetch clinics from platform + useEffect(() => { + if (!isOpen) return; + apiClient.graphql<{ clinics: { edges: Array<{ node: { id: string; clinicName: string } }> } }>( + `{ clinics(first: 50) { edges { node { id clinicName } } } }`, + ).then(data => { + setClinicItems( + data.clinics.edges.map(e => ({ id: e.node.id, label: e.node.clinicName || 'Unnamed Clinic' })), + ); + }).catch(() => {}); + }, [isOpen]); + useEffect(() => { if (!isOpen) return; apiClient.graphql<{ doctors: { edges: Array<{ node: any }> } }>(