feat(mobile): add complete consent flow (banner, health modal, privacy, i18n)

This commit is contained in:
Antoni Nuñez Romeu
2026-08-26 15:24:09 +02:00
parent 1f918be99d
commit 80c473e439
9 changed files with 350 additions and 2 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { Image, StyleSheet, View } from 'react-native';
@@ -10,6 +10,8 @@ import { registerForPushNotifications, addNotificationListener, addNotificationR
import { ThemeProvider, useThemeContext } from '../components/ThemeProvider';
import { LanguageProvider, useTranslation } from '../src/i18n';
import { initFaro } from '../services/faro';
import { hasConsentChoice } from '../services/consent';
import CookieBanner from '../components/CookieBanner';
// Boot Faro RUM once, as early as possible.
initFaro();
@@ -23,6 +25,7 @@ function RootLayoutInner() {
const { checkAuth } = useAuthStore();
const { colors, isDark } = useThemeContext();
const { t } = useTranslation();
const [showCookieBanner, setShowCookieBanner] = useState(false);
const notificationListener = useRef<ReturnType<typeof addNotificationListener>>();
const responseListener = useRef<ReturnType<typeof addNotificationResponseListener>>();
@@ -31,6 +34,11 @@ function RootLayoutInner() {
registerForPushNotifications();
(async () => {
const consentChoice = await hasConsentChoice();
if (!consentChoice) setShowCookieBanner(true);
})();
notificationListener.current = addNotificationListener((notification) => {
console.log('Notification received:', notification);
});
@@ -85,7 +93,18 @@ function RootLayoutInner() {
headerShown: false,
}}
/>
<Stack.Screen name="privacy" options={{ title: 'Política de Privacidad' }} />
</Stack>
{showCookieBanner && (
<CookieBanner
onConsent={async (consents) => {
const { saveConsents } = await import('../services/consent');
await saveConsents(consents);
setShowCookieBanner(false);
}}
onPrivacyPress={() => setShowCookieBanner(false)}
/>
)}
<StatusBar style={isDark ? 'light' : 'auto'} />
</>
);