Polish UI, harden company creation, and add error pages

This commit is contained in:
cesnimda
2026-03-23 19:34:29 +01:00
parent 8f5eab2fe4
commit fcafda6f52
38 changed files with 2293 additions and 1269 deletions
+21
View File
@@ -2,6 +2,27 @@ import axios from "axios";
import { getAuthToken } from "./auth";
import { clearAuthToken } from "./auth";
export function getApiErrorMessage(error: any, fallback = "Request failed.") {
const data = error?.response?.data;
if (typeof data === "string" && data.trim()) return data.trim();
if (typeof data?.message === "string" && data.message.trim()) return data.message.trim();
if (Array.isArray(data?.errors)) {
const first = data.errors.find((value: unknown) => typeof value === "string" && value.trim());
if (first) return first;
}
if (data?.errors && typeof data.errors === "object") {
for (const value of Object.values(data.errors)) {
if (Array.isArray(value)) {
const first = value.find((item: unknown) => typeof item === "string" && item.trim());
if (first) return first;
}
if (typeof value === "string" && value.trim()) return value.trim();
}
}
if (typeof error?.message === "string" && error.message.trim()) return error.message.trim();
return fallback;
}
const envBaseUrl = process.env.REACT_APP_API_BASE_URL;
const defaultBaseUrl =
window.location.hostname === "localhost"