fix: replace raw ai_consent_required code with translatable message and consent prompt
- Centralize AI consent 403 responses in server-consent helpers - Return human-readable message + code + i18n errorKey from all AI APIs - Update dashboard and AI clients to detect code/errorKey and translate - Add consent.ai.requiredToast i18n keys (fr/en)
This commit is contained in:
@@ -25,6 +25,19 @@ export async function hasUserAiConsent(): Promise<boolean> {
|
||||
return settings?.aiProcessingConsent ?? false
|
||||
}
|
||||
|
||||
export function aiConsentForbiddenResponse() {
|
||||
return NextResponse.json({ error: 'ai_consent_required' }, { status: 403 })
|
||||
const DEFAULT_AI_CONSENT_MESSAGE = 'AI processing consent is required to use this feature.'
|
||||
const AI_CONSENT_ERROR_KEY = 'consent.ai.requiredToast'
|
||||
|
||||
export function aiConsentForbiddenResponse(message?: string) {
|
||||
return NextResponse.json(
|
||||
{ error: message ?? DEFAULT_AI_CONSENT_MESSAGE, code: 'ai_consent_required', errorKey: AI_CONSENT_ERROR_KEY },
|
||||
{ status: 403 }
|
||||
)
|
||||
}
|
||||
|
||||
export function aiConsentForbiddenJson(message?: string) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: message ?? DEFAULT_AI_CONSENT_MESSAGE, code: 'ai_consent_required', errorKey: AI_CONSENT_ERROR_KEY },
|
||||
{ status: 403 }
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user