diff --git a/apps/mobile/src/components/ConsentScreen.tsx b/apps/mobile/src/components/ConsentScreen.tsx new file mode 100644 index 0000000..01e009c --- /dev/null +++ b/apps/mobile/src/components/ConsentScreen.tsx @@ -0,0 +1,112 @@ +import { useState } from "react"; +import { + Linking, + Pressable, + StyleSheet, + Text, + View, +} from "react-native"; +import { Body, Button, Screen, Small, Title } from "@/components/ui"; +import type { TextStyle } from "react-native"; +import { acceptConsent } from "@/lib/api"; +import { t } from "@/lib/i18n"; +import { colors, spacing, typography } from "@/lib/theme"; + +interface ConsentScreenProps { + onAccepted: () => void; +} + +export function ConsentScreen({ onAccepted }: ConsentScreenProps) { + const [checked, setChecked] = useState(false); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + + const openUrl = (url: string) => { + void Linking.openURL(url); + }; + + const submit = async () => { + if (!checked) return; + setBusy(true); + setError(null); + try { + await acceptConsent(); + onAccepted(); + } catch (err) { + setError(err instanceof Error ? err.message : t("common.error")); + } finally { + setBusy(false); + } + }; + + return ( + + + {t("consent.title")} + {t("consent.body")} + + openUrl("https://cibello.app/villkor.html")}> + {t("consent.termsLink")} + + openUrl("https://cibello.app/integritet.html")}> + {t("consent.privacyLink")} + + + + + + setChecked((v) => !v)} + style={styles.checkboxRow} + > + + {checked && } + + {t("consent.checkbox")} + + + {error && {error}} + +