feat(manual print options): added in block for printing and new log type

This commit is contained in:
2025-04-17 18:42:08 -05:00
parent 5cdca0a41f
commit af8d53cac1

View File

@@ -30,6 +30,7 @@ import { toast } from "sonner";
const printReason = [ const printReason = [
{ key: "printerIssue", label: "Printer Related" }, { key: "printerIssue", label: "Printer Related" },
{ key: "missingRfidTag", label: "Missing or incorrect tag" }, { key: "missingRfidTag", label: "Missing or incorrect tag" },
{ key: "rfidMissScan", label: "Missed Scan from RFID reader" },
{ key: "strapper", label: "Strapper Error" }, { key: "strapper", label: "Strapper Error" },
{ key: "manualCheck", label: "20th pallet check" }, { key: "manualCheck", label: "20th pallet check" },
{ key: "outOfSync", label: "Labeler Out of Sync" }, { key: "outOfSync", label: "Labeler Out of Sync" },
@@ -39,6 +40,7 @@ export default function ManualPrintForm() {
const token = localStorage.getItem("auth_token"); const token = localStorage.getItem("auth_token");
const { settings } = useSettingStore(); const { settings } = useSettingStore();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const server = settings.filter((n) => n.name === "server")[0]?.value; const server = settings.filter((n) => n.name === "server")[0]?.value;
// const serverPort = settings.filter((n) => n.name === "serverPort")[0]?.value; // const serverPort = settings.filter((n) => n.name === "serverPort")[0]?.value;
// const serverUrl = `http://${server}:${serverPort}`; // const serverUrl = `http://${server}:${serverPort}`;
@@ -57,6 +59,7 @@ export default function ManualPrintForm() {
const handleManualPrintLog = async (logData: any) => { const handleManualPrintLog = async (logData: any) => {
// toast.success(`A new label was sent to printer: ${lot.PrinterName} for line ${lot.MachineDescription} `); // toast.success(`A new label was sent to printer: ${lot.PrinterName} for line ${lot.MachineDescription} `);
const logdataUrl = `/api/ocp/manuallabellog`; const logdataUrl = `/api/ocp/manuallabellog`;
setIsSubmitting(true);
axios axios
.post(logdataUrl, logData, { .post(logdataUrl, logData, {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
@@ -70,16 +73,19 @@ export default function ManualPrintForm() {
} }
reset(); reset();
setOpen(false); setOpen(false);
setIsSubmitting(false);
}) })
.catch((e) => { .catch((e) => {
if (e.response.status === 500) { if (e.response.status === 500) {
toast.error(`Internal Server error please try again.`); toast.error(`Internal Server error please try again.`);
setIsSubmitting(false);
return { sucess: false }; return { sucess: false };
} }
if (e.response.status === 401) { if (e.response.status === 401) {
//console.log(e.response); //console.log(e.response);
toast.error(`You are not authorized to do this.`); toast.error(`You are not authorized to do this.`);
setIsSubmitting(false);
return { sucess: false }; return { sucess: false };
} }
}); });
@@ -250,7 +256,11 @@ export default function ManualPrintForm() {
> >
Close Close
</Button> </Button>
<Button color="primary" type="submit"> <Button
color="primary"
type="submit"
disabled={isSubmitting}
>
Print Print
</Button> </Button>
</div> </div>