This commit is contained in:
root
2025-12-21 17:36:44 +01:00
parent bb1c5b43d6
commit 8a0835c564
15 changed files with 1124 additions and 193 deletions

View File

@@ -9,7 +9,7 @@ export async function GET(request: NextRequest) {
)
const drops = rows as any[]
// Calculate fill from sales for each drop
// Calculate fill from sales for each drop and fetch images
const dropsWithFill = await Promise.all(
drops.map(async (drop) => {
// Calculate fill from sales records
@@ -27,9 +27,17 @@ export async function GET(request: NextRequest) {
fill = totalFillInGrams / 1000
}
// Fetch images for this drop
const [imageRows] = await pool.execute(
'SELECT image_url FROM drop_images WHERE drop_id = ? ORDER BY display_order ASC',
[drop.id]
)
const images = (imageRows as any[]).map((row) => row.image_url)
return {
...drop,
fill: fill,
images: images.length > 0 ? images : (drop.image_url ? [drop.image_url] : []),
}
})
)