Phase 2 Complete by Claude Code

This commit is contained in:
2026-02-17 00:10:37 +02:00
parent 5e2d4b6b1b
commit 2b48426fe5
17 changed files with 1671 additions and 14 deletions

View File

@@ -57,6 +57,39 @@ class ApiClient {
delete(endpoint) {
return this.request(endpoint, { method: "DELETE" });
}
async upload(endpoint, file) {
const url = `${API_BASE}${endpoint}`;
const token = this.getToken();
const formData = new FormData();
formData.append("file", file);
const headers = {};
if (token) {
headers["Authorization"] = `Bearer ${token}`;
}
const response = await fetch(url, {
method: "POST",
headers,
body: formData,
});
if (response.status === 401) {
localStorage.removeItem("access_token");
localStorage.removeItem("user");
window.location.href = "/login";
throw new Error("Session expired");
}
if (!response.ok) {
const error = await response.json().catch(() => ({}));
throw new Error(error.detail || `Upload failed: ${response.status}`);
}
return response.json();
}
}
const api = new ApiClient();