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
+33 -1
View File
@@ -3,12 +3,16 @@ import { View, StyleSheet } from 'react-native';
import { useRouter } from 'expo-router';
import { BarcodeScanner } from '../components/BarcodeScanner';
import { searchMedicines } from '../services/medicines';
import { hasConsent } from '../services/consent';
import HealthConsentModal from '../components/HealthConsentModal';
export default function ScannerScreen() {
const router = useRouter();
const [isSearching, setIsSearching] = useState(false);
const [showHealthConsent, setShowHealthConsent] = useState(false);
const [pendingBarcode, setPendingBarcode] = useState<string | null>(null);
const handleBarcodeScanned = async (barcode: string) => {
const processBarcode = async (barcode: string) => {
setIsSearching(true);
try {
const results = await searchMedicines(barcode);
@@ -25,6 +29,16 @@ export default function ScannerScreen() {
}
};
const handleBarcodeScanned = async (barcode: string) => {
const healthConsent = await hasConsent('health_data');
if (!healthConsent) {
setPendingBarcode(barcode);
setShowHealthConsent(true);
return;
}
await processBarcode(barcode);
};
const handleClose = () => {
router.back();
};
@@ -35,6 +49,24 @@ export default function ScannerScreen() {
onBarcodeScanned={handleBarcodeScanned}
onClose={handleClose}
/>
{showHealthConsent && (
<HealthConsentModal
onAccept={async () => {
setShowHealthConsent(false);
if (pendingBarcode) {
const { saveConsents, getLocalConsents } = await import('../services/consent');
const current = await getLocalConsents();
await saveConsents({ ...current, health_data: true });
await processBarcode(pendingBarcode);
setPendingBarcode(null);
}
}}
onCancel={() => {
setShowHealthConsent(false);
setPendingBarcode(null);
}}
/>
)}
</View>
);
}