From 05de50f796981b4b2b46d5d6c3cc5aa5cd16c87b Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Fri, 10 Apr 2026 16:46:30 +0530 Subject: [PATCH] fix: remove hardcoded clinic list, fetch from platform dynamically Appointment form clinic dropdown was hardcoded to 3 "Global Hospital" branches. Replaced with a GraphQL query to { clinics } so each workspace shows its own clinics. If no clinics are configured, the dropdown is empty instead of showing wrong data. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/call-desk/appointment-form.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 }> } }>(