fix(mobile): samtyckesgrinden hämtar om status efter accept (fastnade annars)
CI / Typecheck, test & build (push) Successful in 1m35s
CI / Typecheck, test & build (push) Successful in 1m35s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Redirect, Tabs } from "expo-router";
|
||||
import { Text } from "react-native";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { api, getConsent, type ConsentStatus } from "@/lib/api";
|
||||
import { persistLanguageTag, useAuth } from "@/lib/auth";
|
||||
import { colors } from "@/lib/theme";
|
||||
@@ -40,6 +40,7 @@ export default function TabsLayout() {
|
||||
const onboardingCompleted = useAuth((s) => s.onboardingCompleted);
|
||||
const onboardingStep = useAuth((s) => s.onboardingStep);
|
||||
useApplyLocalePreferences(Boolean(accessToken));
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data: consent, isLoading: consentLoading } = useQuery<ConsentStatus>({
|
||||
queryKey: ["consent"],
|
||||
@@ -51,7 +52,11 @@ export default function TabsLayout() {
|
||||
if (!accessToken) return <Redirect href="/(auth)/login" />;
|
||||
if (consentLoading) return null;
|
||||
if (!consent?.accepted || consent.version !== TERMS_VERSION) {
|
||||
return <ConsentScreen onAccepted={() => {}} />;
|
||||
return (
|
||||
<ConsentScreen
|
||||
onAccepted={() => void queryClient.invalidateQueries({ queryKey: ["consent"] })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
// Progressive onboarding (FAS 1b): only block if step A not done
|
||||
if (!onboardingCompleted && onboardingStep === "a") return <Redirect href="/onboarding" />;
|
||||
|
||||
Reference in New Issue
Block a user