import React, { useState } from 'react' import type { OrderDialogBaseProps } from '@packages/shared' import { p as P, BottomDialog, pInput as PInput } from 'web-components' import { trpc } from '@/lib/trpc-client' import { XCircle } from 'lucide-react' interface CancelOrderDialogProps extends OrderDialogBaseProps { onSuccess?: () => void } export default function CancelOrderDialog({ orderId, open, onClose, onSuccess }: CancelOrderDialogProps) { const [cancelReason, setCancelReason] = useState('') const cancelOrderMutation = trpc.admin.order.cancelOrder.useMutation() const handleCancel = () => { if (!cancelReason.trim()) { window.alert('Error: Please enter a cancellation reason') return } const confirmed = window.confirm( 'Cancel Order? Are you sure you want to cancel this order? This action cannot be undone.' ) if (!confirmed) return cancelOrderMutation.mutate( { orderId, reason: cancelReason }, { onSuccess: () => { onClose() setCancelReason('') onSuccess?.() }, onError: (error: any) => { window.alert(`Error: ${error.message || 'Failed to cancel order'}`) }, } ) } return (

Cancel Order

This will cancel the order and mark it as cancelled by admin. A refund record will be created.

setCancelReason(e.target.value)} placeholder="Enter reason for cancellation..." multiline className="h-24" />
) }