diff --git a/src/features/receipts/components/receipts-client.tsx b/src/features/receipts/components/receipts-client.tsx
index 6de34de..e0ee442 100644
--- a/src/features/receipts/components/receipts-client.tsx
+++ b/src/features/receipts/components/receipts-client.tsx
@@ -2,6 +2,8 @@
import { Printer, Tags } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
+import JsBarcode from "jsbarcode";
+import QRCode from "qrcode";
import { useLocale } from "@/components/providers/locale-provider";
import { composeGradeLabel } from "@/lib/grade-display";
@@ -264,7 +266,7 @@ export function ReceiptsClient() {
}
}
- function printLotLabels(detail: ReceiptDetail) {
+ async function printLotLabels(detail: ReceiptDetail) {
setError(null);
if (detail.generated_lots.length === 0) {
setError(locale === "id" ? "Belum ada lot yang bisa dicetak. Buat lot terlebih dahulu." : "No lot labels to print yet. Generate lots first.");
@@ -279,7 +281,29 @@ export function ReceiptsClient() {
try {
printWindow.document.open();
- printWindow.document.write(buildLotLabelsPrintHtml(detail, locale));
+ printWindow.document.write(`
Menyiapkan Label${locale === "id" ? "Menyiapkan label lot..." : "Preparing lot labels..."}`);
+ printWindow.document.close();
+
+ const printableLots = await Promise.all(
+ detail.generated_lots.map(async (lot) => {
+ const qrValue = lot.qr_code_value || lot.barcode_value || lot.lot_code;
+ const barcodeValue = lot.barcode_value || lot.qr_code_value || lot.lot_code;
+ return {
+ lot,
+ qrValue,
+ barcodeValue,
+ qrDataUrl: await QRCode.toDataURL(qrValue, {
+ width: 160,
+ margin: 1,
+ errorCorrectionLevel: "M"
+ }),
+ barcodeSvg: buildBarcodeSvg(barcodeValue)
+ };
+ })
+ );
+
+ printWindow.document.open();
+ printWindow.document.write(buildLotLabelsPrintHtml(detail, locale, printableLots));
printWindow.document.close();
} catch (err) {
if (!printWindow.closed) {
@@ -452,7 +476,7 @@ export function ReceiptsClient() {
{locale === "id" ? "Cetak receipt" : "Print receipt"}
{selectedReceipt.generated_lots.length > 0 ? (
-