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:
24
frontend/src/routes/(app)/planner/+server.ts
Normal file
24
frontend/src/routes/(app)/planner/+server.ts
Normal 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 });
|
||||
};
|
||||
Reference in New Issue
Block a user