import { Form, Switch } from "antd"; import { IFilament } from "../../pages/filaments/model"; import { ISpool } from "../../pages/spools/model"; import QRCodePrintingDialog from "./qrCodePrintingDialog"; import { useSavedState } from "../../utils/saveload"; import { useTranslate } from "@refinedev/core"; interface SpoolQRCodePrintingDialog { visible: boolean; items: ISpool[]; onCancel: () => void; } const SpoolQRCodePrintingDialog: React.FC = ({ visible, items, onCancel }) => { const t = useTranslate(); const [showVendor, setShowVendor] = useSavedState("print-showVendor", true); const [showLotNr, setShowLotNr] = useSavedState("print-showLotNr", true); const [showSpoolWeight, setShowSpoolWeight] = useSavedState("print-showSpoolWeight", true); const [showTemperatures, setShowTemperatures] = useSavedState("print-showTemperatures", true); const [showSpoolComment, setShowSpoolComment] = useSavedState("print-showSpoolComment", false); const [showFilamentComment, setShowFilamentComment] = useSavedState("print-showFilamentComment", false); const [showVendorComment, setShowVendorComment] = useSavedState("print-showVendorComment", false); const formatFilament = (filament: IFilament) => { let vendorPrefix = ""; if (showVendor && filament.vendor) { vendorPrefix = `${filament.vendor.name} - `; } let name = filament.name; if (!name) { name = `Filament #${filament.id}`; } return `${vendorPrefix}${name}`; }; return ( {formatFilament(spool.filament)}
#{spool.id} {spool.filament.material && <> - {spool.filament.material}} {showSpoolWeight && ( <>
{t("printing.qrcode.spoolWeight", { weight: `${spool.filament.spool_weight ?? "?"} g` })} )} {showTemperatures && tempLine && ( <>
{tempLine} )} {showLotNr && ( <>
{t("printing.qrcode.lotNr", { lot: spool.lot_nr ?? "?" })} )} {showSpoolComment && spool.comment && ( <>
{spool.comment} )} {showFilamentComment && spool.filament.comment && ( <>
{spool.filament.comment} )} {showVendorComment && spool.filament.vendor?.comment && ( <>
{spool.filament.vendor.comment} )}

), errorLevel: "H", }; })} extraSettings={ <> setShowVendor(checked)} /> setShowSpoolWeight(checked)} /> setShowTemperatures(checked)} /> setShowLotNr(checked)} /> setShowSpoolComment(checked)} /> setShowFilamentComment(checked)} /> setShowVendorComment(checked)} /> } /> ); }; export default SpoolQRCodePrintingDialog;