Nouvelle app Vite/React independante (workspace apps/*), calquee sur apps/web : port 5174, sa propre image Docker (nginx statique), son propre domaine/deploiement. - AdminApiClient (VITE_ADMIN_API_URL, credentials: include) + ApiError. - AdminAuthContext / RequireAdmin : restaure la session admin via GET /admin/auth/me, garde de route (miroir de AuthContext/RequireAuth). - LoginPage (/login) : validation cliente via adminLoginSchema partage, erreurs traduites via ErrorMessageService. - AdminLayout : sidebar (Tableau de bord / Monitoring / Corrections) + deconnexion, rendu une fois autour du groupe RequireAdmin. - Pages Dashboard / Monitoring / Corrections en placeholder (remplies aux PR 3-5). - i18n fr (bloc admin.* + sous-ensemble errors.*), tokens _theme.scss copies de apps/web (extraction en package partage : suivi separe). - Dockerfile multi-stage (node build -> nginx:alpine) + nginx.conf (SPA fallback). Service admin-web dans docker-compose.yml (port ADMIN_WEB_PORT, VITE_ADMIN_API_URL en build arg). - Cypress : login.feature (KO -> message, OK -> dashboard) + admin-layout .cy.ts (redirection /login sans session, nav entre sections, logout). Job "Run admin-web E2E tests" ajoute a ci.yml. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
19 lines
764 B
TypeScript
19 lines
764 B
TypeScript
import { ErrorCode } from "@batch-cooking/shared";
|
|
import i18n from "../i18n/i18n";
|
|
|
|
/**
|
|
* Localized label for an {@link ErrorCode} returned by the admin API —
|
|
* verbatim behaviour of apps/web's `ErrorMessageService`: reverse-maps the
|
|
* numeric enum value to its member name (`4010` → `"INVALID_CREDENTIALS"`)
|
|
* and looks it up under the `errors` namespace, falling back to
|
|
* `INTERNAL_ERROR` for a code this client doesn't recognise.
|
|
*/
|
|
export class ErrorMessageService {
|
|
public getLabel(code: ErrorCode): string {
|
|
const memberName = ErrorCode[code] ?? ErrorCode[ErrorCode.INTERNAL_ERROR];
|
|
return i18n.t(`errors.${memberName}`);
|
|
}
|
|
}
|
|
|
|
/** Single shared instance — stateless. */
|
|
export const errorMessageService = new ErrorMessageService();
|