import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
  Button,
} from "@/ui";
import { t } from "i18next";
import { SendIcon } from "lucide-react";

export const QuoteSentToEditor = ({
  id,
  onSentTo,
  disabled,
}: {
  id: string;
  onSentTo: (quoteId: string) => void;
  disabled?: boolean;
}) => {
  const handleSentTo = () => {
    onSentTo(id);
  };

  return (
    <AlertDialog>
      <AlertDialogTrigger asChild disabled={disabled}>
        <Button
          variant='ghost'
          className='h-10 gap-1 text-primary disabled:text-secondary-foreground'
        >
          <SendIcon className='w-4 h-4' />
          {t("quotes.quote_sent_to_editor.trigger_button")}
        </Button>
      </AlertDialogTrigger>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>{t("quotes.quote_sent_to_editor.title")}</AlertDialogTitle>
          <AlertDialogDescription>
            {t("quotes.quote_sent_to_editor.description")}
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel>{t("common.cancel")}</AlertDialogCancel>
          <AlertDialogAction asChild>
            <Button onClick={handleSentTo}>{t("common.continue")}</Button>
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
};
