From 7d0fca0dad968b25f96d3079f7b6c7333747e71c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 23:03:21 +0000 Subject: [PATCH] feat(recept): bladdra-skarm med maltidskategorier + fritextsok - Ny skarm /recipes: kategori-chips (Alla/Frukost/Lunch/Middag/Mellanmal/ Efterratt) + sok. Backend: befintliga GET /v1/recipes (mealType, search). - Kategorierna ar de RIKTIGA MEAL_TYPES (1:1 mot datan) - inga pahittade filter. Etiketter ateranvander myday.mealType.* (redan 12 sprak). - Tomma kategorier visar arligt tomt-lage (katalogen ar idag middagstung: ~240 middag, 8 frukost, 3 efterratt, 0 mellanmal) i stallet for att gommas. - Ingang fran hemskarmen bredvid Sparade recept. Query-strang byggs som resten av appen (template + encodeURIComponent). - Ingen ny tabb (baren har redan 5). Mobil typecheck gron. --- apps/mobile/src/app/(tabs)/home.tsx | 15 ++- apps/mobile/src/app/_layout.tsx | 1 + apps/mobile/src/app/recipes.tsx | 137 ++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 apps/mobile/src/app/recipes.tsx diff --git a/apps/mobile/src/app/(tabs)/home.tsx b/apps/mobile/src/app/(tabs)/home.tsx index 2d9092e..0bc2492 100644 --- a/apps/mobile/src/app/(tabs)/home.tsx +++ b/apps/mobile/src/app/(tabs)/home.tsx @@ -125,9 +125,18 @@ export default function HomeScreen() { router.push("/profile")} /> - router.push("/saved-recipes")}> - ⭐ Dina sparade recept - + + + router.push("/recipes")}> + 📖 Bläddra bland recept + + + + router.push("/saved-recipes")}> + ⭐ Sparade recept + + + {/* Matlager – städat, öppnas per plats eller som helhet (spec §8). */} diff --git a/apps/mobile/src/app/_layout.tsx b/apps/mobile/src/app/_layout.tsx index 3835b19..d13cf2c 100644 --- a/apps/mobile/src/app/_layout.tsx +++ b/apps/mobile/src/app/_layout.tsx @@ -86,6 +86,7 @@ export default function RootLayout() { + ("all"); + const [search, setSearch] = useState(""); + const term = search.trim(); + + const query = useQuery({ + queryKey: ["browse-recipes", category, term], + queryFn: () => { + // Bygg query-strängen som resten av appen (template + encodeURIComponent). + let path = "/v1/recipes?limit=50"; + if (category !== "all") path += `&mealType=${category}`; + if (term) path += `&search=${encodeURIComponent(term)}`; + return api<{ recipes: BrowseRecipe[] }>(path); + }, + // Behåll föregående lista medan en ny kategori/sökning laddar – ingen blink. + placeholderData: keepPreviousData, + }); + + const recipes = query.data?.recipes ?? []; + + return ( + + + + + {CATEGORIES.map((c) => ( +