feat(resources): warn before switching a resource off, and pick dates in Jalali

The deactivation warning was blocked on task 07: there was no way to count "the
appointments on this resource" until occupancy rows linked the two. They do
now, so GET /resource/{uuid} returns upcoming_appointments. It stays off the
list endpoint, where it would be one count query per row.

It is a warning, not a block, and the wording says so: switching a resource off
does not cancel anything, it only removes the resource from future searches.
The panel shows it the moment the "active" box is unticked.

The calendar's exception range still used <input type="date">, which is
Gregorian. Operators say dates in Jalali, and the mental conversion is exactly
where an exception gets recorded a day off. PersianDateInput takes the same
YYYY-MM-DD string, so this is a drop-in swap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-01 13:45:25 +03:30
co-authored by Claude Opus 5
parent ba7cf7edc9
commit 000cf70761
9 changed files with 164 additions and 5 deletions
+23
View File
@@ -180,3 +180,26 @@ export function useResourcePools() {
return { pools: query.data?.data ?? [], loading: query.isLoading, create, update, remove, setMembers };
}
/**
* جزئیات یک منبع — تنها جایی که شمار نوبت‌های آیندهٔ آن می‌آید.
*
* در فهرست نمی‌آید چون آنجا یک کوئری per ردیف می‌شد؛ اینجا فقط وقتی لازم است که
* کاربر دارد همان یک منبع را ویرایش می‌کند.
*/
export function useResourceDetail(uuid: string | undefined) {
const query = useQuery({
queryKey: ['resource-detail', uuid],
queryFn: () =>
api.get<ApiResponse<ClinicResource & { upcoming_appointments: number }>>(
`/api/v1/resource/${uuid}`,
),
enabled: !!uuid,
});
return {
resource: query.data?.data,
upcomingAppointments: query.data?.data?.upcoming_appointments ?? 0,
loading: query.isLoading,
};
}