Add image upload to property form via FilesController
All checks were successful
Build frontend / build (push) Successful in 52s

- Added uploadPicture() API function for POST /Files/UploadPicture
- Images uploaded immediately on selection, paths stored
- PropertyInformation.images sent with server-side paths
- Remove image also removes from uploaded paths
This commit is contained in:
Claw AI
2026-03-30 00:57:52 +00:00
parent 1a96e457ca
commit 4299968764
2 changed files with 43 additions and 13 deletions

View File

@ -196,6 +196,32 @@ export async function getCurrencies() {
return apiFetch('/Currency/GetAll');
}
// ─── Files ───
export async function uploadPicture(file) {
console.log('[API] Uploading picture:', file.name);
const formData = new FormData();
formData.append('file', file);
const token = AuthService.getToken();
const res = await fetch(`${API_BASE}/Files/UploadPicture`, {
method: 'POST',
headers: {
...(token && { Authorization: `Bearer ${token}` }),
},
body: formData,
});
const text = await res.text();
console.log('[API] Upload response:', res.status, text?.substring(0, 100));
if (!res.ok) throw new Error(`Upload failed: ${res.status} ${text}`);
// Response is the relative path string (possibly in envelope)
try {
const json = JSON.parse(text);
return json?.data || json;
} catch {
return text;
}
}
// ─── Auth: Registration ───
/**