feat: real file upload to /opt/hotelsync/uploads + serve via /uploads/ on API
This commit is contained in:
@@ -344,6 +344,23 @@ export const api = {
|
||||
req<void>('DELETE', `/api/hotels/${slug}/rental-bookings/${id}`),
|
||||
},
|
||||
|
||||
// ── File Upload ───────────────────────────────────────────────────────────
|
||||
upload: {
|
||||
photo: async (file: File): Promise<string> => {
|
||||
const token = localStorage.getItem('access_token')
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
const res = await fetch(`${BASE}/api/upload`, {
|
||||
method: 'POST',
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
||||
body: fd,
|
||||
})
|
||||
if (!res.ok) throw new Error(`Upload failed: ${res.statusText}`)
|
||||
const data = await res.json() as { url: string }
|
||||
return data.url
|
||||
},
|
||||
},
|
||||
|
||||
// ── Categories ────────────────────────────────────────────────────────────
|
||||
categories: {
|
||||
list: (slug: string) =>
|
||||
|
||||
Reference in New Issue
Block a user