diff --git a/apps/mobile/src/app/(tabs)/plan.tsx b/apps/mobile/src/app/(tabs)/plan.tsx index 6162138..2463bdb 100644 --- a/apps/mobile/src/app/(tabs)/plan.tsx +++ b/apps/mobile/src/app/(tabs)/plan.tsx @@ -1,5 +1,6 @@ import { useEffect, useMemo, useState } from "react"; import { Alert, Pressable, Text, View } from "react-native"; +import { router } from "expo-router"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { api } from "@/lib/api"; import { getLanguageTag, t } from "@/lib/i18n"; @@ -89,6 +90,7 @@ export default function PlanScreen() { const plan = query.data?.plans?.[0] ?? null; const planId = plan?.id ?? null; const draftPlanId = plan && plan.status === "draft" ? plan.id : null; + const hasEntries = (plan?.entries?.length ?? 0) > 0; const entriesByDate = useMemo(() => { const map: Record = {}; @@ -147,6 +149,16 @@ export default function PlanScreen() { onError: onMutationError, }); + const createList = useMutation({ + mutationFn: (weekPlanId: string) => + api("/v1/shopping-lists", { + method: "POST", + body: { weekPlanId, generateFromPlan: true }, + }), + onSuccess: () => router.push("/shopping"), + onError: onMutationError, + }); + const openActions = (entry: WeekPlanEntry) => { if (!planId) return; Alert.alert(entry.titleSv, undefined, [ @@ -306,6 +318,18 @@ export default function PlanScreen() { )} )} + + {hasEntries ? ( + <> + +