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:
@@ -64,11 +64,7 @@ export function FlashcardGenerateDialog({
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) {
|
||||
if (data.errorKey) {
|
||||
toast.error(t(data.errorKey) || data.error)
|
||||
} else {
|
||||
toast.error(data.error || t('flashcards.generateFailed'))
|
||||
}
|
||||
toast.error(data.errorKey ? t(data.errorKey) : (data.error || t('flashcards.generateFailed')))
|
||||
return
|
||||
}
|
||||
setCards(data.cards || [])
|
||||
|
||||
@@ -353,7 +353,7 @@ export function RevisionView() {
|
||||
const res = await fetch(`/api/flashcards/decks/${deckId}`)
|
||||
const data = await res.json()
|
||||
if (!res.ok) {
|
||||
toast.error(data.error || t('flashcards.loadDeckFailed'))
|
||||
toast.error(data.errorKey ? t(data.errorKey) : (data.error || t('flashcards.loadDeckFailed')))
|
||||
return
|
||||
}
|
||||
setActiveDeckId(deckId)
|
||||
@@ -432,7 +432,7 @@ export function RevisionView() {
|
||||
const res = await fetch(`/api/flashcards/decks/${deckId}`)
|
||||
const data = await res.json()
|
||||
if (!res.ok) {
|
||||
toast.error(data.error || t('flashcards.loadDeckFailed'))
|
||||
toast.error(data.errorKey ? t(data.errorKey) : (data.error || t('flashcards.loadDeckFailed')))
|
||||
setExpandedDeckId(null)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user