some ai generated code from claude that does not work

This commit is contained in:
2026-04-08 02:03:43 -04:00
parent 3c9910a723
commit 90d7eab7d0
19 changed files with 1206 additions and 53 deletions

View File

@@ -9,6 +9,29 @@ export interface UploadError {
error: string;
}
export interface AvatarUploadResult {
success: true;
avatarUrl: string;
}
export async function uploadAvatar(
file: File,
csrfToken: string
): Promise<AvatarUploadResult | UploadError> {
const formData = new FormData();
formData.append("file", file);
const res = await fetch("/upload/avatar", {
method: "POST",
headers: { "X-CSRF-Token": csrfToken },
body: formData,
});
const json = await res.json();
if (!res.ok || !json.success) {
return { error: json.error ?? "Upload failed" };
}
return json as AvatarUploadResult;
}
export async function uploadFile(
file: File,
csrfToken: string