feat: implement dashboard page for QR code listing, statistics, and management.

This commit is contained in:
Timo
2026-01-02 20:38:57 +01:00
parent 49673e84b6
commit eea8c8b33a
3 changed files with 22 additions and 10 deletions

View File

@@ -20,6 +20,10 @@ export async function GET(request: NextRequest) {
_count: {
select: { scans: true },
},
scans: {
where: { isUnique: true },
select: { id: true },
},
},
orderBy: { createdAt: 'desc' },
});
@@ -28,6 +32,7 @@ export async function GET(request: NextRequest) {
const transformed = qrCodes.map(qr => ({
...qr,
scans: qr._count.scans,
uniqueScans: qr.scans.length, // Count of scans where isUnique=true
_count: undefined,
}));
@@ -138,9 +143,9 @@ export async function POST(request: NextRequest) {
);
}
}
let enrichedContent = body.content;
// For STATIC QR codes, calculate what the QR should contain
if (isStatic) {
let qrContent = '';
@@ -180,7 +185,7 @@ END:VCARD`;
default:
qrContent = body.content.url || 'https://example.com';
}
// Add qrContent to the content object
enrichedContent = {
...body.content,