Bugfix: what-to-eat utan hushall ger forslag; onboarding mal kan valjas multi
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
||||
Spacer,
|
||||
Title,
|
||||
} from "@/components/ui";
|
||||
import { colors, spacing } from "@/lib/theme";
|
||||
import { colors, spacing, typography } from "@/lib/theme";
|
||||
|
||||
/**
|
||||
* Progressive onboarding (FAS 1b): 3-layer flow.
|
||||
@@ -73,8 +73,9 @@ export default function OnboardingScreen() {
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Step A state
|
||||
const [goal, setGoal] = useState<string | null>(null);
|
||||
const [goals, setGoals] = useState<string[]>([]);
|
||||
const [mode, setMode] = useState<"simple" | "exact">("simple");
|
||||
const primaryGoal = goals[0] ?? null;
|
||||
|
||||
// Step B state
|
||||
const [diet, setDiet] = useState<string>("omnivore");
|
||||
@@ -94,6 +95,13 @@ export default function OnboardingScreen() {
|
||||
const toggleAllergen = (id: string) =>
|
||||
setAllergens((prev) => (prev.includes(id) ? prev.filter((a) => a !== id) : [...prev, id]));
|
||||
|
||||
const toggleGoal = (id: string) =>
|
||||
setGoals((prev) => {
|
||||
if (prev.includes(id)) return prev.filter((g) => g !== id);
|
||||
// Keep the first-selected goal as primary by appending at the end.
|
||||
return [...prev, id];
|
||||
});
|
||||
|
||||
const finishStepA = async () => {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
@@ -101,11 +109,11 @@ export default function OnboardingScreen() {
|
||||
const res = await api<{ step: "a" | "b" | "c" }>("/v1/onboarding/quick-start", {
|
||||
method: "POST",
|
||||
body: {
|
||||
...(goal ? { primaryGoal: goal } : {}),
|
||||
...(goals.length ? { goals } : {}),
|
||||
precisionMode: mode,
|
||||
},
|
||||
});
|
||||
track(onboardingStepCompleted({ properties: { step: "a", goal, precisionMode: mode } }));
|
||||
track(onboardingStepCompleted({ properties: { step: "a", goals, primaryGoal, precisionMode: mode } }));
|
||||
setOnboardingStep(res.step);
|
||||
setLayer("b");
|
||||
// Let user into the app – Step B will be shown contextually later
|
||||
@@ -201,14 +209,26 @@ export default function OnboardingScreen() {
|
||||
|
||||
<Heading>{t("onboarding.goal")}</Heading>
|
||||
<View style={{ gap: spacing.sm }}>
|
||||
{GOALS.map((id) => (
|
||||
<SelectRow
|
||||
key={id}
|
||||
label={t(`onboarding.goal.${id}`)}
|
||||
selected={goal === id}
|
||||
onPress={() => setGoal(id)}
|
||||
/>
|
||||
))}
|
||||
{GOALS.map((id) => {
|
||||
const index = goals.indexOf(id);
|
||||
const selected = index >= 0;
|
||||
return (
|
||||
<SelectRow
|
||||
key={id}
|
||||
label={t(`onboarding.goal.${id}`)}
|
||||
selected={selected}
|
||||
onPress={() => toggleGoal(id)}
|
||||
>
|
||||
{selected && index === 0 && (
|
||||
<View style={{ marginTop: 4 }}>
|
||||
<Text style={[typography.small, { color: colors.primary, fontWeight: "600" }]}>
|
||||
{t("onboarding.primaryGoal")}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</SelectRow>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
<Spacer size={spacing.sm} />
|
||||
@@ -367,10 +387,12 @@ function SelectRow({
|
||||
label,
|
||||
selected,
|
||||
onPress,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
selected: boolean;
|
||||
onPress: () => void;
|
||||
children?: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Pressable
|
||||
@@ -384,6 +406,7 @@ function SelectRow({
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: colors.text, fontWeight: selected ? "700" : "400" }}>{label}</Text>
|
||||
{children}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nye forslag",
|
||||
"wte.subtitle": "Ud fra hvad I har derhjemme, hvad der snart skal bruges, og hvad I kan lide.",
|
||||
"wte.title": "Hvad skal vi spise?",
|
||||
"wte.whyTitle": "Hvorfor dette forslag?"
|
||||
"wte.whyTitle": "Hvorfor dette forslag?",
|
||||
"onboarding.primaryGoal": "Primært"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Neue Vorschläge",
|
||||
"wte.subtitle": "Basierend auf dem, was ihr zuhause habt, was bald verbraucht werden sollte und was ihr mögt.",
|
||||
"wte.title": "Was essen wir?",
|
||||
"wte.whyTitle": "Warum dieser Vorschlag?"
|
||||
"wte.whyTitle": "Warum dieser Vorschlag?",
|
||||
"onboarding.primaryGoal": "Primär"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "New suggestions",
|
||||
"wte.subtitle": "Based on what you have at home, what should be used up, and what you like.",
|
||||
"wte.title": "What's for dinner?",
|
||||
"wte.whyTitle": "Why this suggestion?"
|
||||
"wte.whyTitle": "Why this suggestion?",
|
||||
"onboarding.primaryGoal": "Primary"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nuevas sugerencias",
|
||||
"wte.subtitle": "Según lo que tenéis en casa, lo que conviene usar pronto y lo que os gusta.",
|
||||
"wte.title": "¿Qué comemos?",
|
||||
"wte.whyTitle": "¿Por qué esta sugerencia?"
|
||||
"wte.whyTitle": "¿Por qué esta sugerencia?",
|
||||
"onboarding.primaryGoal": "Principal"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Uudet ehdotukset",
|
||||
"wte.subtitle": "Sen mukaan mitä kotona on, mikä pitäisi käyttää pian ja mistä pidätte.",
|
||||
"wte.title": "Mitä syödään?",
|
||||
"wte.whyTitle": "Miksi tämä ehdotus?"
|
||||
"wte.whyTitle": "Miksi tämä ehdotus?",
|
||||
"onboarding.primaryGoal": "Ensisijainen"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nouvelles suggestions",
|
||||
"wte.subtitle": "Selon ce que vous avez chez vous, ce qu'il faut consommer vite et vos goûts.",
|
||||
"wte.title": "On mange quoi ?",
|
||||
"wte.whyTitle": "Pourquoi cette suggestion ?"
|
||||
"wte.whyTitle": "Pourquoi cette suggestion ?",
|
||||
"onboarding.primaryGoal": "Principal"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nuovi suggerimenti",
|
||||
"wte.subtitle": "In base a ciò che avete in casa, a cosa va consumato presto e ai vostri gusti.",
|
||||
"wte.title": "Cosa mangiamo?",
|
||||
"wte.whyTitle": "Perché questo suggerimento?"
|
||||
"wte.whyTitle": "Perché questo suggerimento?",
|
||||
"onboarding.primaryGoal": "Primario"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nye forslag",
|
||||
"wte.subtitle": "Basert på hva dere har hjemme, hva som snart bør brukes, og hva dere liker.",
|
||||
"wte.title": "Hva skal vi spise?",
|
||||
"wte.whyTitle": "Hvorfor dette forslaget?"
|
||||
"wte.whyTitle": "Hvorfor dette forslaget?",
|
||||
"onboarding.primaryGoal": "Primært"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nieuwe suggesties",
|
||||
"wte.subtitle": "Op basis van wat jullie in huis hebben, wat snel op moet en wat jullie lekker vinden.",
|
||||
"wte.title": "Wat eten we?",
|
||||
"wte.whyTitle": "Waarom deze suggestie?"
|
||||
"wte.whyTitle": "Waarom deze suggestie?",
|
||||
"onboarding.primaryGoal": "Primair"
|
||||
}
|
||||
|
||||
@@ -359,5 +359,6 @@
|
||||
"wte.refresh": "Nowe propozycje",
|
||||
"wte.subtitle": "Na podstawie tego, co macie w domu, co trzeba wkrótce zużyć i co lubicie.",
|
||||
"wte.title": "Co jemy?",
|
||||
"wte.whyTitle": "Dlaczego ta propozycja?"
|
||||
"wte.whyTitle": "Dlaczego ta propozycja?",
|
||||
"onboarding.primaryGoal": "Główny"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Novas sugestões",
|
||||
"wte.subtitle": "Com base no que têm em casa, no que deve ser usado em breve e no que gostam.",
|
||||
"wte.title": "O que vamos comer?",
|
||||
"wte.whyTitle": "Porquê esta sugestão?"
|
||||
"wte.whyTitle": "Porquê esta sugestão?",
|
||||
"onboarding.primaryGoal": "Principal"
|
||||
}
|
||||
|
||||
@@ -345,5 +345,6 @@
|
||||
"wte.refresh": "Nya förslag",
|
||||
"wte.subtitle": "Utifrån vad ni har hemma, vad som bör användas och vad ni gillar.",
|
||||
"wte.title": "Vad ska vi äta?",
|
||||
"wte.whyTitle": "Varför detta förslag?"
|
||||
"wte.whyTitle": "Varför detta förslag?",
|
||||
"onboarding.primaryGoal": "Primärt"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user