import { useTranslation } from "react-i18next";

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from "@/components/ui/alert-dialog";

interface ConfirmSignalDialogProps {
  open: boolean;
  onOpenChange: (next: boolean) => void;
  latitudeLabel: string;
  longitudeLabel: string;
  radiusKm: number;
  isConfirming: boolean;
  isDisabled: boolean;
  onConfirm: () => void;
}

export function ConfirmSignalDialog({
  open,
  onOpenChange,
  latitudeLabel,
  longitudeLabel,
  radiusKm,
  isConfirming,
  isDisabled,
  onConfirm,
}: ConfirmSignalDialogProps) {
  const { t } = useTranslation();

  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>{t("dialog.confirmSignal.title")}</AlertDialogTitle>
          <AlertDialogDescription>{t("dialog.confirmSignal.description")}</AlertDialogDescription>
        </AlertDialogHeader>
        <div className="rounded-2xl border border-border/60 bg-muted/40 p-4 text-sm">
          <div className="flex items-center justify-between">
            <span className="text-muted-foreground">{t("dialog.confirmSignal.latitude")}</span>
            <span className="font-medium text-foreground">{latitudeLabel}°</span>
          </div>
          <div className="mt-3 flex items-center justify-between">
            <span className="text-muted-foreground">{t("dialog.confirmSignal.longitude")}</span>
            <span className="font-medium text-foreground">{longitudeLabel}°</span>
          </div>
          <p className="mt-4 text-xs text-muted-foreground">{t("dialog.confirmSignal.reach", { radius: radiusKm })}</p>
        </div>
        <AlertDialogFooter>
          <AlertDialogCancel disabled={isConfirming}>{t("dialog.confirmSignal.cancel")}</AlertDialogCancel>
          <AlertDialogAction onClick={onConfirm} disabled={isDisabled}>
            {isConfirming ? t("dialog.confirmSignal.sending") : t("dialog.confirmSignal.confirm")}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
