diff --git a/apps/mobile/src/app/(tabs)/_layout.tsx b/apps/mobile/src/app/(tabs)/_layout.tsx index fb321dd..e24bf2a 100644 --- a/apps/mobile/src/app/(tabs)/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/_layout.tsx @@ -1,12 +1,14 @@ import { Redirect, Tabs } from "expo-router"; import { Text } from "react-native"; import { useQuery } from "@tanstack/react-query"; -import { api } from "@/lib/api"; +import { api, getConsent, type ConsentStatus } from "@/lib/api"; import { persistLanguageTag, useAuth } from "@/lib/auth"; import { colors } from "@/lib/theme"; import { getLanguageTag, t } from "@/lib/i18n"; import { setMeasurementSystem, setUnitLanguage } from "@/lib/units"; +import { ConsentScreen } from "@/components/ConsentScreen"; import type { MeasurementSystem } from "@app/shared-types"; +import { TERMS_VERSION } from "@app/shared-types"; function TabIcon({ glyph, focused }: { glyph: string; focused: boolean }) { return {glyph}; @@ -39,7 +41,18 @@ export default function TabsLayout() { const onboardingStep = useAuth((s) => s.onboardingStep); useApplyLocalePreferences(Boolean(accessToken)); + const { data: consent, isLoading: consentLoading } = useQuery({ + queryKey: ["consent"], + queryFn: getConsent, + enabled: Boolean(accessToken), + staleTime: 60_000, + }); + if (!accessToken) return ; + if (consentLoading) return null; + if (!consent?.accepted || consent.version !== TERMS_VERSION) { + return {}} />; + } // Progressive onboarding (FAS 1b): only block if step A not done if (!onboardingCompleted && onboardingStep === "a") return ;