Files
Momento/memento-note/lib/consent/ai-consent-redirect.ts
Antigravity f385d43d5d
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 7m27s
CI / Deploy production (on server) (push) Successful in 23s
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
2026-07-18 17:52:40 +00:00

25 lines
756 B
TypeScript

import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime'
/**
* Redirects the user to General Settings with the AI consent section highlighted.
* Call this when an AI feature is blocked because the user has not granted consent.
*/
export function redirectToAiConsentSettings(
router: AppRouterInstance | ReturnType<typeof import('next/navigation').useRouter>,
options?: { replace?: boolean }
) {
const url = '/settings/general?highlight=aiConsent'
if (options?.replace) {
router.replace(url)
} else {
router.push(url)
}
}
/**
* Returns the settings URL that highlights the AI consent section.
*/
export function getAiConsentSettingsUrl() {
return '/settings/general?highlight=aiConsent'
}