feat(planner): add RecipePicker component (C4) and suggestions API endpoint

C4 sheet content: Empfohlen section with variety delta badges,
Alle Rezepte with client-side search filter. GET /planner endpoint
proxies suggestions to backend for lazy client-side loading.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 22:42:10 +02:00
parent 36ae82af5d
commit 25c575c167
3 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { apiClient } from '$lib/server/api';
// GET /planner?planId=&date= — returns suggestions JSON for C4 recipe picker
export const GET: RequestHandler = async ({ fetch, url }) => {
const planId = url.searchParams.get('planId');
const date = url.searchParams.get('date');
if (!planId || !date) {
return json({ suggestions: [] });
}
const api = apiClient(fetch);
const { data } = await api.GET('/v1/week-plans/{id}/suggestions', {
params: { path: { id: planId }, query: { slotDate: date } }
});
const suggestions = (data?.suggestions ?? []).sort(
(a: any, b: any) => (b.simulatedScore ?? 0) - (a.simulatedScore ?? 0)
);
return json({ suggestions });
};