'use client';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useEffect, useState } from 'react';
import { Loader2 } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '../../ui/alert-dialog.js';
import { Textarea } from '../../ui/textarea.js';
export function RejectFeedbackDialog({ open, onOpenChange, onConfirm, isSubmitting, title, description, }) {
    const { t } = useTranslation('web');
    const resolvedTitle = title ?? t('rejectFeedback.defaultTitle');
    const resolvedDescription = description ?? t('rejectFeedback.defaultDescription');
    const [feedback, setFeedback] = useState('');
    // Reset feedback when dialog opens
    useEffect(() => {
        if (open) {
            setFeedback('');
        }
    }, [open]);
    const isFeedbackEmpty = feedback.trim().length === 0;
    return (_jsx(AlertDialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: resolvedTitle }), _jsx(AlertDialogDescription, { children: resolvedDescription })] }), _jsx(Textarea, { "aria-label": t('rejectFeedback.ariaLabel'), placeholder: t('rejectFeedback.placeholder'), value: feedback, onChange: (e) => setFeedback(e.target.value), disabled: isSubmitting, rows: 4, className: "max-h-[35dvh] overflow-y-auto" }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: isSubmitting, onClick: () => onOpenChange(false), children: t('rejectFeedback.cancel') }), _jsx(AlertDialogAction, { variant: "destructive", disabled: isFeedbackEmpty || isSubmitting, onClick: () => onConfirm(feedback.trim()), children: isSubmitting ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "me-2 h-4 w-4 animate-spin" }), t('rejectFeedback.rejecting')] })) : (t('rejectFeedback.confirmReject')) })] })] }) }));
}
