- Removed package consumption flags and related properties from PriceQuote. - Eliminated unused domain event publishing for policies and waitlist in Schedule. - Cleaned up BookingEngineSeeder by removing package and policy related logic. - Updated SeedScenariosCommand to reflect removal of policies from output. - Dropped policy, package, treatment course, cancellation, waitlist, and domain event tables in migration. - Removed domain event assertions from tests related to resource blocking.
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { toast } from 'sonner';
|
|
import { api, ApiError, type ApiResponse } from '../lib/api';
|
|
|
|
/**
|
|
* لغو نوبت — فقط انتقال وضعیت.
|
|
*
|
|
* سیاست لغو، جریمه و لیست انتظار از محصول حذف شدهاند، پس پیشنمایش مالی هم وجود ندارد:
|
|
* چیزی برای پیشنمایش نمانده. لغو همان `PATCH /api/v1/appointment/{uuid}/status` است که
|
|
* تایملاین نوبت و دلیل را هم ثبت میکند.
|
|
*/
|
|
export function useCancelAppointment() {
|
|
const qc = useQueryClient();
|
|
|
|
return useMutation({
|
|
mutationFn: ({ uuid, by, reason }: { uuid: string; by: 'user' | 'doctor'; reason?: string }) =>
|
|
api.patch<ApiResponse<unknown>>(`/api/v1/appointment/${uuid}/status`, {
|
|
status: by === 'user' ? 'cancelled_by_user' : 'cancelled_by_doctor',
|
|
...(reason?.trim() ? { reason: reason.trim() } : {}),
|
|
}),
|
|
onSuccess: () => {
|
|
toast.success('نوبت لغو شد');
|
|
qc.invalidateQueries({ queryKey: ['appointments'] });
|
|
},
|
|
onError: (e: unknown) => toast.error(e instanceof ApiError ? e.message : 'لغو نوبت ناموفق بود'),
|
|
});
|
|
}
|