initial commit

This commit is contained in:
2026-05-28 13:23:53 +00:00
commit 4269bc8d89
56 changed files with 13703 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import { ApiError, ApiErrorItem } from '../services/api.service';
export function getErrorMessage(err: ApiError, fallback: string): string {
const errors = err?.errors;
if (!errors) return fallback;
// Array format: [{ propertyName, errorMessage }]
if (Array.isArray(errors)) {
return errors[0]?.errorMessage ?? fallback;
}
// Dictionary format: { field: string[] }
const first = Object.values(errors).flat()[0];
return (typeof first === 'string' ? first : null) ?? fallback;
}