diff --git a/app/[locale]/print/[year]/[month]/page.tsx b/app/[locale]/print/[year]/[month]/page.tsx index 0d2e0c6..ef8fe7c 100644 --- a/app/[locale]/print/[year]/[month]/page.tsx +++ b/app/[locale]/print/[year]/[month]/page.tsx @@ -1,6 +1,7 @@ import { fetchBarcodeDataForPrint } from '@/app/lib/actions/printActions'; import { notFound } from 'next/navigation'; import { PrintPreview } from '@/app/ui/PrintPreview'; +import { getTranslations } from 'next-intl/server'; interface PrintPageProps { params: { @@ -20,7 +21,7 @@ export default async function PrintPage({ params }: PrintPageProps) { } let printData; - + try { printData = await fetchBarcodeDataForPrint(year, month); } catch (error) { @@ -28,6 +29,19 @@ export default async function PrintPage({ params }: PrintPageProps) { notFound(); } + // Get translations for the current locale + const t = await getTranslations("home-page.print-preview"); + const translations = { + title: t("title"), + barcodesFound: t("barcodes-found"), + barcodeSingular: t("barcode-singular"), + printButton: t("print-button"), + printFooter: t("print-footer"), + tableHeaderIndex: t("table-header-index"), + tableHeaderBillInfo: t("table-header-bill-info"), + tableHeaderBarcode: t("table-header-barcode") + }; + // If no barcode data found, show empty state if (!printData || printData.length === 0) { return ( @@ -42,5 +56,5 @@ export default async function PrintPage({ params }: PrintPageProps) { ); } - return ; + return ; } \ No newline at end of file diff --git a/app/ui/PrintPreview.tsx b/app/ui/PrintPreview.tsx index 112ac8b..ff38b52 100644 --- a/app/ui/PrintPreview.tsx +++ b/app/ui/PrintPreview.tsx @@ -6,58 +6,93 @@ export interface PrintPreviewProps { data: PrintBarcodeData[]; year: number; month: number; + translations: { + title: string; + barcodesFound: string; + barcodeSingular: string; + printButton: string; + printFooter: string; + tableHeaderIndex: string; + tableHeaderBillInfo: string; + tableHeaderBarcode: string; + }; } -export const PrintPreview: React.FC = ({ data, year, month }) => { +export const PrintPreview: React.FC = ({ data, year, month, translations }) => { + return ( -
-

- Print Preview - {year}-{month.toString().padStart(2, '0')} -

- -
-

Found {data.length} barcode(s) for printing

+
+ {/* Header section - hidden in print */} +
+

+ {translations.title} +

+

+ {year}-{month.toString().padStart(2, '0')} • {data.length} {data.length === 1 ? translations.barcodeSingular : translations.barcodesFound} +

+
- {/* Basic table structure - will be enhanced in US-3 */} - - - - - - - - - - {data.map((item, index) => ( - - - - + {/* Print content */} +
+
IndexBill InfoBarcode
{index + 1} -
-
{item.yearMonth}
-
{item.locationName}
-
{item.billName}
-
-
- {`Barcode -
+ + + + + - ))} - -
+ {translations.tableHeaderIndex} + + {translations.tableHeaderBillInfo} + + {translations.tableHeaderBarcode} +
- - {/* Print button - will be enhanced in US-4 */} - + + + {data.map((item, index) => ( + + + {(index + 1).toString().padStart(2, '0')} + + +
+
+ 📅 {item.yearMonth} +
+
+ 🏠 {item.locationName} +
+
+ 📋 {item.billName} +
+
+ + +
+ {`Barcode +
+ + + ))} + + + + {/* Print footer - only visible when printing */} +
+

{translations.printFooter.replace('{date}', new Date().toLocaleDateString())}

+
+
); }; \ No newline at end of file diff --git a/messages/en.json b/messages/en.json index ebf8c07..1dd7618 100644 --- a/messages/en.json +++ b/messages/en.json @@ -61,6 +61,16 @@ "payed-total-label": "Total monthly expenditure:", "print-codes-tooltip": "Print 2D codes", "print-codes-label": "Print codes" + }, + "print-preview": { + "title": "2D Barcode Print Preview", + "barcodes-found": "barcodes found", + "barcode-singular": "barcode found", + "print-button": "Print Barcodes", + "print-footer": "Generated on {date} • Evidencija Režija Print System", + "table-header-index": "#", + "table-header-bill-info": "Bill Information", + "table-header-barcode": "2D Barcode" } }, "bill-delete-form": { diff --git a/messages/hr.json b/messages/hr.json index d3f008d..2db0fc6 100644 --- a/messages/hr.json +++ b/messages/hr.json @@ -61,6 +61,16 @@ "payed-total-label": "Ukupni mjesečni trošak:", "print-codes-tooltip": "Ispis 2d kodova", "print-codes-label": "Ispis kodova" + }, + "print-preview": { + "title": "Pregled Ispisa 2D Barkodova", + "barcodes-found": "barkodova pronađeno", + "barcode-singular": "barkod pronađen", + "print-button": "Ispis Barkodova", + "print-footer": "Generirano {date} • Evidencija Režija Sustav Ispisa", + "table-header-index": "#", + "table-header-bill-info": "Informacije o Računu", + "table-header-barcode": "2D Barkod" } }, "bill-delete-form": {