fix(loyalty-terminal): localise cooldown toast (was raw English)
Some checks failed
Some checks failed
When earn-points or add-stamp was rejected by the new cooldown
enforcement, the terminal showed the raw English error message from
the backend in the toast, even on FR / DE / LB locales:
"Transaction failed: Please wait 15 minutes between point-earning..."
Two-part fix:
1. static/shared/js/api-client.js — when raising apiError on non-OK
responses, also propagate the `details` payload from the response
body (alongside the existing errorCode). Without this the catch
sites had no structured access to e.g. cooldown_minutes.
2. loyalty-terminal.js — in the catch around the transaction dispatch,
when error.errorCode is POINTS_COOLDOWN or STAMP_COOLDOWN, render a
new localised key loyalty.store.terminal.cooldown_wait_minutes with
{minutes} interpolated from error.details.cooldown_minutes (with a
fallback to this.program.cooldown_minutes). Toast type switches to
'warning' since the rejection is soft (try again later) rather than
a hard failure. Other errors keep the existing 'transaction_failed'
path so nothing else regresses.
Added the new key in en / fr / de / lb under the existing
loyalty.store.terminal.* namespace (sibling of the existing
cooldown_active label).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -171,6 +171,10 @@ class APIClient {
|
||||
const apiError = new Error(errorMessage);
|
||||
apiError.status = response.status;
|
||||
apiError.errorCode = data.error_code;
|
||||
// Propagate the details payload so callers can localise the
|
||||
// toast (e.g. "cooldown_ends" / "cooldown_minutes" for
|
||||
// POINTS_COOLDOWN / STAMP_COOLDOWN).
|
||||
apiError.details = data.details || null;
|
||||
throw apiError;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user