feat: implement US-2 - create print route with barcode data fetching
- Add Next.js print route at /[locale]/print/[year]/[month] - Implement fetchBarcodeDataForPrint function with user authentication - Create PrintPreview component with basic table layout - Add proper 404 handling with not-found.tsx - Fix barcode image display with flexible data URL handling - Filter and sort bills with barcode data for consistent display 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
6
app/[locale]/print/[year]/[month]/not-found.tsx
Normal file
6
app/[locale]/print/[year]/[month]/not-found.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { NotFoundPage } from '@/app/ui/NotFoundPage';
|
||||
|
||||
const PrintPageNotFound = () =>
|
||||
<NotFoundPage title="404 Print Page Not Found" description="Could not find the requested print preview page." />;
|
||||
|
||||
export default PrintPageNotFound;
|
||||
46
app/[locale]/print/[year]/[month]/page.tsx
Normal file
46
app/[locale]/print/[year]/[month]/page.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { fetchBarcodeDataForPrint } from '@/app/lib/actions/printActions';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { PrintPreview } from '@/app/ui/PrintPreview';
|
||||
|
||||
interface PrintPageProps {
|
||||
params: {
|
||||
year: string;
|
||||
month: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function PrintPage({ params }: PrintPageProps) {
|
||||
const year = parseInt(params.year);
|
||||
const month = parseInt(params.month);
|
||||
|
||||
// Validate year and month parameters
|
||||
if (isNaN(year) || isNaN(month) || month < 1 || month > 12) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
let printData;
|
||||
|
||||
try {
|
||||
printData = await fetchBarcodeDataForPrint(year, month);
|
||||
} catch (error) {
|
||||
console.error('Error fetching print data:', error);
|
||||
notFound();
|
||||
}
|
||||
|
||||
// If no barcode data found, show empty state
|
||||
if (!printData || printData.length === 0) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<h1 className="text-2xl font-bold mb-4">No Barcode Data Found</h1>
|
||||
<p className="text-gray-600">
|
||||
No bills with 2D barcodes found for {year}-{month.toString().padStart(2, '0')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <PrintPreview data={printData} year={year} month={month} />;
|
||||
}
|
||||
Reference in New Issue
Block a user