feat(layout): finalize p01 and p02 changes
Complete UI foundation and app layout implementation, stabilize container health checks, and archive both OpenSpec changes after verification.
This commit is contained in:
@@ -140,13 +140,24 @@ export async function apiRequest<T>(endpoint: string, options: ApiRequestOptions
|
||||
|
||||
// Prepare request options
|
||||
const requestOptions: RequestInit = {
|
||||
...options,
|
||||
method: options.method,
|
||||
headers,
|
||||
};
|
||||
|
||||
// Handle request body
|
||||
if (options.body && typeof options.body === 'object') {
|
||||
requestOptions.body = JSON.stringify(options.body);
|
||||
if (options.body !== undefined) {
|
||||
const body = options.body;
|
||||
|
||||
const isJsonObject =
|
||||
typeof body === 'object' &&
|
||||
body !== null &&
|
||||
!(body instanceof FormData) &&
|
||||
!(body instanceof URLSearchParams) &&
|
||||
!(body instanceof Blob) &&
|
||||
!(body instanceof ArrayBuffer) &&
|
||||
!ArrayBuffer.isView(body);
|
||||
|
||||
requestOptions.body = isJsonObject ? JSON.stringify(body) : (body as BodyInit);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -213,12 +224,12 @@ async function handleResponse<T>(response: Response): Promise<T> {
|
||||
export const api = {
|
||||
get: <T>(endpoint: string, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, { ...options, method: 'GET' }),
|
||||
post: <T>(endpoint: string, body: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, { ...options, method: 'POST', body }),
|
||||
put: <T>(endpoint: string, body: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, { ...options, method: 'PUT', body }),
|
||||
patch: <T>(endpoint: string, body: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, { ...options, method: 'PATCH', body }),
|
||||
post: <T>(endpoint: string, body?: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, body === undefined ? { ...options, method: 'POST' } : { ...options, method: 'POST', body }),
|
||||
put: <T>(endpoint: string, body?: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, body === undefined ? { ...options, method: 'PUT' } : { ...options, method: 'PUT', body }),
|
||||
patch: <T>(endpoint: string, body?: unknown, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, body === undefined ? { ...options, method: 'PATCH' } : { ...options, method: 'PATCH', body }),
|
||||
delete: <T>(endpoint: string, options: ApiRequestOptions = {}) =>
|
||||
apiRequest<T>(endpoint, { ...options, method: 'DELETE' }),
|
||||
};
|
||||
@@ -236,7 +247,7 @@ interface LoginResponse {
|
||||
user: {
|
||||
id: string;
|
||||
email: string;
|
||||
role: string;
|
||||
role: 'superuser' | 'manager' | 'developer' | 'top_brass';
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user