'use client'; import { useMutation } from '@tanstack/react-query'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Switch } from '@/components/ui/switch'; import { Link, useRouter } from '@/i18n/navigation'; import { useT } from '@/i18n/t'; import { api } from '@/lib/api'; /** * Flow A4. Plain language, two switches, one screen. Data processing is required to * continue; notifications are genuinely optional and nothing nags about them later. */ export function ConsentForm() { const t = useT(); const router = useRouter(); const [dataProcessing, setDataProcessing] = useState(false); const [notifications, setNotifications] = useState(true); const grant = useMutation({ mutationFn: async () => { await api.postConsent({ kind: 'data_processing', granted: true }); await api.postConsent({ kind: 'notifications', granted: notifications }); }, onSuccess: () => router.push('/configuracion'), }); return (

{t('consent.title')}

{t('consent.intro')}

{!dataProcessing ? (

{t('consent.required')}

) : null} {grant.isError ? (

{t('common.error.generic')}

) : null}
{t('consent.policyLink')}
); }