test(ocp): more work on the dashboard

This commit is contained in:
2025-03-19 17:11:00 -05:00
parent 354f3260a5
commit 8324fffeb6
12 changed files with 814 additions and 11 deletions

View File

@@ -0,0 +1,44 @@
import {LotType} from "@/types/lots";
import axios from "axios";
export const manualPrintLabels = async (lot: LotType, user: any) => {
//console.log(lot);
const labelUrl = `/ocp/manualPrintAndFollow`;
try {
const res = await axios.post(
labelUrl,
{line: lot.MachineLocation, printerName: lot.PrinterName},
{headers: {Authorization: `Basic ${user?.prod}`}}
);
if (res.data.success) {
return {
success: true,
message: `A new label was printed for ${lot.MachineDescription} to printer: ${lot.PrinterName}`,
};
} else {
return {
success: true,
message: `Line ${lot.MachineDescription} encountered an error printing labels: ${res.data.message}`,
};
}
} catch (error: any) {
if (error.response.status === 500) {
//toast.error(`Internal Server error please try again.`);
return {
success: false,
message: `Internal Server error please try again.`,
};
}
if (error.response.status === 401) {
//console.log(e.response);
//toast.error(`You are not authorized to do this.`);
return {
success: false,
message: `You are not authorized to do this.`,
};
}
}
};