diff --git a/apps/st/src/components/statistics/verification/RejectReasonInputDialog.tsx b/apps/st/src/components/statistics/verification/RejectReasonInputDialog.tsx new file mode 100644 index 000000000..8d72df8aa --- /dev/null +++ b/apps/st/src/components/statistics/verification/RejectReasonInputDialog.tsx @@ -0,0 +1,113 @@ +"use client"; + +import { useEffect, useState } from "react"; + +import { + Button, + Dialog, + DialogClose, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + Label, + Textarea, +} from "@common/components"; + +export interface RejectReasonInputDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; + onConfirm?: (reason: string) => void | Promise; +} + +export function RejectReasonInputDialog({ + open, + onOpenChange, + onConfirm, +}: RejectReasonInputDialogProps) { + const [reason, setReason] = useState(""); + const [reasonError, setReasonError] = useState(false); + const [isSubmitting, setIsSubmitting] = useState(false); + + const resetForm = () => { + setReason(""); + setReasonError(false); + }; + + const handleDialogOpenChange = (nextOpen: boolean) => { + if (!nextOpen) resetForm(); + onOpenChange(nextOpen); + }; + + useEffect(() => { + if (!open) resetForm(); + }, [open]); + + const handleConfirm = async () => { + const trimmed = reason.trim(); + if (!trimmed) { + setReasonError(true); + return; + } + try { + setIsSubmitting(true); + await onConfirm?.(trimmed); + } finally { + setIsSubmitting(false); + } + }; + + const canSubmit = reason.trim().length > 0 && !isSubmitting; + + return ( + + + + 반려 + +
+
+ +