layouts schick gemacht und packagelimits weiter implementiert

This commit is contained in:
Codex Agent
2025-11-01 22:55:13 +01:00
parent 79b209de9a
commit 8e6c66f0db
16 changed files with 756 additions and 422 deletions

View File

@@ -33,3 +33,34 @@ export function getApiErrorMessage(error: unknown, fallback: string): string {
return fallback;
}
export type ApiErrorEventDetail = {
message: string;
status?: number;
code?: string;
meta?: Record<string, unknown>;
};
export const API_ERROR_EVENT = 'admin:api:error';
export function emitApiErrorEvent(detail: ApiErrorEventDetail): void {
if (typeof window === 'undefined') {
return;
}
window.dispatchEvent(new CustomEvent<ApiErrorEventDetail>(API_ERROR_EVENT, { detail }));
}
export function registerApiErrorListener(handler: (detail: ApiErrorEventDetail) => void): () => void {
if (typeof window === 'undefined') {
return () => {};
}
const listener = (event: Event) => {
const customEvent = event as CustomEvent<ApiErrorEventDetail>;
handler(customEvent.detail);
};
window.addEventListener(API_ERROR_EVENT, listener as EventListener);
return () => window.removeEventListener(API_ERROR_EVENT, listener as EventListener);
}