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 { Redirect, Tabs } from "expo-router";
|
||||||
import { Text } from "react-native";
|
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 { api, getConsent, type ConsentStatus } from "@/lib/api";
|
||||||
import { persistLanguageTag, useAuth } from "@/lib/auth";
|
import { persistLanguageTag, useAuth } from "@/lib/auth";
|
||||||
import { colors } from "@/lib/theme";
|
import { colors } from "@/lib/theme";
|
||||||
@@ -40,6 +40,7 @@ export default function TabsLayout() {
|
|||||||
const onboardingCompleted = useAuth((s) => s.onboardingCompleted);
|
const onboardingCompleted = useAuth((s) => s.onboardingCompleted);
|
||||||
const onboardingStep = useAuth((s) => s.onboardingStep);
|
const onboardingStep = useAuth((s) => s.onboardingStep);
|
||||||
useApplyLocalePreferences(Boolean(accessToken));
|
useApplyLocalePreferences(Boolean(accessToken));
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const { data: consent, isLoading: consentLoading } = useQuery<ConsentStatus>({
|
const { data: consent, isLoading: consentLoading } = useQuery<ConsentStatus>({
|
||||||
queryKey: ["consent"],
|
queryKey: ["consent"],
|
||||||
@@ -51,7 +52,11 @@ export default function TabsLayout() {
|
|||||||
if (!accessToken) return <Redirect href="/(auth)/login" />;
|
if (!accessToken) return <Redirect href="/(auth)/login" />;
|
||||||
if (consentLoading) return null;
|
if (consentLoading) return null;
|
||||||
if (!consent?.accepted || consent.version !== TERMS_VERSION) {
|
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
|
// Progressive onboarding (FAS 1b): only block if step A not done
|
||||||
if (!onboardingCompleted && onboardingStep === "a") return <Redirect href="/onboarding" />;
|
if (!onboardingCompleted && onboardingStep === "a") return <Redirect href="/onboarding" />;
|
||||||
|
|||||||
Reference in New Issue
Block a user