feat: redirect to AI consent settings when consent is missing
- 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:
@@ -6,6 +6,7 @@ import { useReducedMotion } from 'motion/react'
|
||||
import { Inbox, Send, Bell, Mail } from 'lucide-react'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import { useAiConsent } from '@/components/legal/ai-consent-provider'
|
||||
import { redirectToAiConsentSettings } from '@/lib/consent/ai-consent-redirect'
|
||||
import { createNote } from '@/app/actions/notes'
|
||||
import { emitNoteChange } from '@/lib/note-change-sync'
|
||||
import { toast } from 'sonner'
|
||||
@@ -519,7 +520,10 @@ export function DashboardView({ onNoteSelect }: DashboardViewProps) {
|
||||
try {
|
||||
const res = await fetch('/api/ai/echo')
|
||||
const json = await res.json()
|
||||
if (res.status === 403 && json.code === 'ai_consent_required') { await requestAiConsent(); return }
|
||||
if (res.status === 403 && json.code === 'ai_consent_required') {
|
||||
redirectToAiConsentSettings(router)
|
||||
return
|
||||
}
|
||||
if (!res.ok) throw new Error(json.error)
|
||||
if (json.insight) {
|
||||
await reloadBriefingAndPaths()
|
||||
@@ -533,7 +537,7 @@ export function DashboardView({ onNoteSelect }: DashboardViewProps) {
|
||||
} finally {
|
||||
setEchoRefreshing(false)
|
||||
}
|
||||
}, [requestAiConsent, reloadBriefingAndPaths, t])
|
||||
}, [requestAiConsent, reloadBriefingAndPaths, t, router])
|
||||
|
||||
const handleEnableAi = useCallback(async () => {
|
||||
await requestAiConsent()
|
||||
|
||||
Reference in New Issue
Block a user