feat: add teacher-facing frontend

This commit is contained in:
2026-09-25 11:11:31 +08:00
parent eece55d08d
commit d6203cc7ea
4 changed files with 171 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
export async function api(path: string, method = 'GET', body?: unknown): Promise<any> {
const response = await fetch('/api' + path, { method, headers: body === undefined ? {} : { 'Content-Type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body) });
if (!response.ok) {
let detail = response.statusText;
try { const value = await response.json(); detail = typeof value.detail === 'string' ? value.detail : JSON.stringify(value.detail); } catch { /* server returned no JSON */ }
throw new Error(detail);
}
return response.json();
}
export const post = (path: string, body?: unknown) => api(path, 'POST', body);
export const put = (path: string, body: unknown) => api(path, 'PUT', body);