Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/pages/Appointments/AppointmentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export default function AppointmentsPage({ resourceType, resourceId }: Props) {
const practitioners = schedulableUserResources?.filter((r) =>
practitionerIds.includes(r.id),
);
const resourceIds =
resourceId ?? practitioners?.map((p) => p.id).join(",") ?? "";

// Enabled only if filtered by a practitioner and a single day
const slotsFilterEnabled =
Expand All @@ -236,15 +238,20 @@ export default function AppointmentsPage({ resourceType, resourceId }: Props) {
(qParams.date_from === qParams.date_to || !qParams.date_to);

const slotsQuery = useQuery({
queryKey: ["slots", facilityId, qParams.practitioners, qParams.date_from],
queryKey: [
"slots",
facilityId,
resourceType,
resourceIds,
qParams.date_from,
],
queryFn: query(scheduleApis.slots.getSlotsForDay, {
pathParams: { facilityId },
body: {
// voluntarily coalesce to empty string since we know query would be
// enabled only if practitioner and date_from are present
resource_type: resourceType,
resource_id:
resourceId ?? practitioners?.map((p) => p.id).join(",") ?? "",
resource_id: resourceIds,
day: qParams.date_from ?? "",
},
}),
Expand Down
Loading