'use client';

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from '@/components/ui/overlays/AlertDialog';
import { Label } from '@/components/ui/primitives/Label';
import { Textarea } from '@/components/ui/primitives/Textarea';

interface BulkFreezeDialogProps {
  t: (key: string) => string;
  tCommon: (key: string) => string;
  bulkFreezeOpen: boolean;
  setBulkFreezeOpen: (open: boolean) => void;
  selectedCount: number;
  bulkFreezeReason: string;
  setBulkFreezeReason: (value: string) => void;
  actionLoading: string | null;
  onConfirm: () => void | Promise<void>;
}

export function BulkFreezeDialog({
  t,
  tCommon,
  bulkFreezeOpen,
  setBulkFreezeOpen,
  selectedCount,
  bulkFreezeReason,
  setBulkFreezeReason,
  actionLoading,
  onConfirm,
}: BulkFreezeDialogProps) {
  return (
    <AlertDialog open={bulkFreezeOpen} onOpenChange={setBulkFreezeOpen}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>
            {t('bulk_freeze_confirm_title').replace('{n}', String(selectedCount))}
          </AlertDialogTitle>
          <AlertDialogDescription>{t('bulk_freeze_confirm_desc')}</AlertDialogDescription>
        </AlertDialogHeader>
        <div className="flex flex-col gap-1 py-2">
          <Label htmlFor="bulk-freeze-reason">{t('reason_label')}</Label>
          <Textarea
            id="bulk-freeze-reason"
            rows={3}
            value={bulkFreezeReason}
            onChange={(e) => setBulkFreezeReason(e.target.value)}
            placeholder={t('freeze_reason_placeholder')}
          />
        </div>
        <AlertDialogFooter>
          <AlertDialogCancel>{tCommon('cancel')}</AlertDialogCancel>
          <AlertDialogAction
            disabled={!bulkFreezeReason.trim() || actionLoading === 'freeze'}
            onClick={() => void onConfirm()}
          >
            {t('confirm_freeze')}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
