restaurant-admin-web/src/api/client.ts
José René White Enciso d84faf0348 feat(admin-web): add web baseline
Why: establish baseline web runtime scaffold before wave implementation.

What: add react app structure, docker runtime assets, docs runbooks, and ignore policy updates.

Rule: keep technical intent and repository workflow compliance.
2026-03-08 15:53:49 -06:00

26 lines
623 B
TypeScript

declare global {
interface Window {
__APP_CONFIG__?: {
API_BASE_URL?: string;
};
}
}
export function getApiBaseUrl(): string {
const runtimeValue = window.__APP_CONFIG__?.API_BASE_URL;
if (runtimeValue && runtimeValue.length > 0) {
return runtimeValue;
}
return import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8080';
}
export async function getJson<T>(path: string): Promise<T> {
const response = await fetch(`${getApiBaseUrl()}${path}`);
if (!response.ok) {
throw new Error(`GET ${path} failed with status ${response.status}`);
}
return (await response.json()) as T;
}