import {Button} from "@/components/ui/button";
import {useSessionStore} from "@/lib/store/sessionStore";
//import {useSettingStore} from "@/lib/store/useSettings";
import {LotType} from "@/types/lots";
import {Tag} from "lucide-react";
import {toast} from "sonner";
import {manualPrintLabels} from "./ManualPrintLabel";

export default function ManualPrint({lot}: {lot: LotType}) {
    const {user} = useSessionStore();
    //const {settings} = useSettingStore();
    //const server = settings.filter((n) => n.name === "server")[0]?.value;
    //const serverPort = settings.filter((n) => n.name === "serverPort")[0]?.value;
    //const serverUrl = `http://${server}:${serverPort}`;

    const handlePrintLabel = async (lot: LotType) => {
        //console.log(lot);

        const labels: any = await manualPrintLabels(lot, user);

        if (labels.success) {
            toast.success(labels.message);
        } else {
            toast.error(labels.message);
        }
    };
    return (
        <Button variant="outline" size="icon" onClick={() => handlePrintLabel(lot)}>
            <Tag className="h-[16px] w-[16px]" />
        </Button>
    );
}
