import React, { useState } from 'react'; import ConfirmDialog from './ui/ConfirmDialog'; import { useCancelAppointment } from '../hooks/useCancellation'; interface Props { open: boolean; appointmentUuid: string; /** چه کسی لغو می‌کند — وضعیت نهایی نوبت از همین می‌آید. */ by?: 'user' | 'doctor'; onClose: () => void; onCancelled?: () => void; } /** لغو نوبت با تأیید و دلیل اختیاری. */ export default function CancelAppointmentDialog({ open, appointmentUuid, by = 'doctor', onClose, onCancelled, }: Props) { const [reason, setReason] = useState(''); const cancel = useCancelAppointment(); const close = () => { setReason(''); onClose(); }; return ( cancel.mutate( { uuid: appointmentUuid, by, reason }, { onSuccess: () => { close(); onCancelled?.(); }, }, ) } onCancel={close} >