feat: paginate customer orders and polish the dashboard hero
Add paged orders API and infinite scroll, short order numbers, and align the guest invite card with the logged-in hero shell. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
const counts = await prisma.order.groupBy({
|
||||
by: ['status'],
|
||||
_count: { _all: true },
|
||||
where: { orderNumber: { startsWith: 'MOCK-ORD' } },
|
||||
})
|
||||
const total = counts.reduce((s, c) => s + c._count._all, 0)
|
||||
const sample = await prisma.order.findFirst({
|
||||
where: { orderNumber: { startsWith: 'MOCK-ORD' } },
|
||||
select: {
|
||||
orderNumber: true,
|
||||
status: true,
|
||||
customer: { select: { mobile: true, fullName: true } },
|
||||
},
|
||||
})
|
||||
console.log(JSON.stringify({ total, byStatus: Object.fromEntries(counts.map((c) => [c.status, c._count._all])), sample }, null, 2))
|
||||
await prisma.$disconnect()
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user