"use client";

import { useTranslations } from "next-intl";
import { Printer } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";

export function PrintButton({ recipeId }: { recipeId: string }) {
  const t = useTranslations("recipe");
  function handlePrint() {
    const win = window.open(`/print/${recipeId}`, "_blank", "width=800,height=900");
    win?.focus();
  }

  return (
    <TooltipProvider>
      <Tooltip>
        <TooltipTrigger render={
          <Button variant="ghost" size="icon" onClick={handlePrint}>
            <Printer className="h-4 w-4" />
          </Button>
        } />
        <TooltipContent>{t("print")}</TooltipContent>
      </Tooltip>
    </TooltipProvider>
  );
}
