feat: redirect to AI consent settings when consent is missing
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 7m27s
CI / Deploy production (on server) (push) Successful in 23s

- requestAiConsent now redirects to /settings/general?highlight=aiConsent
  instead of opening the modal when called outside the settings page
- Settings page highlights the consent section and scrolls to it
- Adds consent.ai.settingsBanner i18n key (fr/en)
- Keeps inline modal on /settings/general so the grant button still works
This commit is contained in:
Antigravity
2026-07-18 17:52:40 +00:00
parent 324bf40658
commit f385d43d5d
6 changed files with 81 additions and 9 deletions

View File

@@ -1,11 +1,11 @@
'use client'
import { useState } from 'react'
import { useState, useEffect, useRef } from 'react'
import Link from 'next/link'
import { useLanguage } from '@/lib/i18n'
import { updateAISettings } from '@/app/actions/ai-settings'
import { toast } from 'sonner'
import { useRouter } from 'next/navigation'
import { useRouter, useSearchParams } from 'next/navigation'
import { Globe, Bell, Shield, Brain, HelpCircle } from 'lucide-react'
import { motion } from 'motion/react'
import { openCookiePreferences } from '@/lib/consent/cookie-consent'
@@ -27,6 +27,20 @@ export function GeneralSettingsClient({ initialSettings }: GeneralSettingsClient
const { t, setLanguage: setContextLanguage } = useLanguage()
const { hasAiConsent, revokeConsent, requestAiConsent } = useAiConsent()
const router = useRouter()
const searchParams = useSearchParams()
const aiConsentSectionRef = useRef<HTMLDivElement>(null)
const highlightAiConsent = searchParams?.get('highlight') === 'aiConsent'
const [showConsentHighlight, setShowConsentHighlight] = useState(highlightAiConsent)
useEffect(() => {
if (highlightAiConsent && aiConsentSectionRef.current) {
setShowConsentHighlight(true)
aiConsentSectionRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' })
const timer = setTimeout(() => setShowConsentHighlight(false), 4000)
return () => clearTimeout(timer)
}
}, [highlightAiConsent])
const [language, setLanguage] = useState(initialSettings.preferredLanguage || 'auto')
const [emailNotifications, setEmailNotifications] = useState(initialSettings.emailNotifications ?? false)
const [desktopNotifications, setDesktopNotifications] = useState(initialSettings.desktopNotifications ?? false)
@@ -76,6 +90,12 @@ export function GeneralSettingsClient({ initialSettings }: GeneralSettingsClient
{t('generalSettings.description')}
</h3>
{highlightAiConsent && (
<div className="rounded-xl border border-brand-accent/30 bg-brand-accent/10 p-4 text-sm font-medium text-ink">
{t('consent.ai.settingsBanner')}
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="bg-white/40 dark:bg-white/5 border border-border rounded-xl p-8 space-y-6">
<div className="flex items-center gap-5">
@@ -202,7 +222,15 @@ export function GeneralSettingsClient({ initialSettings }: GeneralSettingsClient
</div>
</div>
<div className="bg-white/40 dark:bg-white/5 border border-border rounded-xl p-8 space-y-6 md:col-span-2">
<div
ref={aiConsentSectionRef}
className={cn(
'bg-white/40 dark:bg-white/5 border rounded-xl p-8 space-y-6 md:col-span-2 transition-all duration-500',
showConsentHighlight
? 'border-brand-accent ring-2 ring-brand-accent/40 shadow-lg shadow-brand-accent/10'
: 'border-border'
)}
>
<div className="flex items-start justify-between gap-4">
<div className="flex items-center gap-5">
<div className="p-3 bg-paper dark:bg-white/10 rounded-2xl text-concrete border border-border">