diff --git a/frontend/src/routes/LunchPage.svelte b/frontend/src/routes/LunchPage.svelte index b010425..40b1dc9 100644 --- a/frontend/src/routes/LunchPage.svelte +++ b/frontend/src/routes/LunchPage.svelte @@ -16,6 +16,24 @@ const child = $derived(kids.find((c) => c.id === childId)); const hasMenu = $derived(app.household!.sources.some((s) => s.layout_type === 'menu' && s.child_ids.includes(childId ?? -1))); const picked = $derived(days?.filter((d) => d.picked).length ?? 0); + const open = $derived(days?.filter((d) => !d.greyed) ?? []); // days that can be picked + const allPicked = $derived(open.length > 0 && open.every((d) => d.picked)); + let bulkBusy = $state(false); + + async function pickAll() { + // Select all picks every open day; when they're all picked already, it clears every pick instead. + const dates = allPicked ? days!.filter((d) => d.picked).map((d) => d.date) : open.filter((d) => !d.picked).map((d) => d.date); + if (!dates.length) return; + bulkBusy = true; + try { + days = await api('/lunch/bulk', { method: 'POST', json: { child_id: childId, dates, picked: !allPicked } }); + toast(allPicked ? `Cleared ${dates.length} days` : `Picked ${dates.length} days`); + } catch (e: any) { + toast(e.message); + } finally { + bulkBusy = false; + } + } async function load() { if (childId === null) return; @@ -72,7 +90,10 @@ {:else if !days.length}

No published menu for {monthLabel(month)} yet. Scan it from the Scans tab.

{:else} -

{child?.display_name}: tap the days to pack lunch. {picked} picked. Each pick goes on the calendar as “Pack lunch”.

+
+

{child?.display_name}: tap the days to pack lunch. {picked} picked. Each pick goes on the calendar as “Pack lunch”.

+ +