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:
24
memento-note/lib/consent/ai-consent-redirect.ts
Normal file
24
memento-note/lib/consent/ai-consent-redirect.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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'
|
||||
}
|
||||
Reference in New Issue
Block a user