diff --git a/services/api.ts b/services/api.ts index c77c5da..d726af3 100644 --- a/services/api.ts +++ b/services/api.ts @@ -2,7 +2,7 @@ import { Condo, Family, Payment, AppSettings, User, AuthResponse, Ticket, TicketComment, ExtraordinaryExpense, Notice, - AlertDefinition, NoticeRead, CondoExpense + AlertDefinition, NoticeRead, CondoExpense, Document } from '../types'; const API_URL = '/api'; @@ -365,5 +365,25 @@ export const CondoService = { }, getCondoExpenseAttachment: async (expenseId: string, attId: string): Promise => { return request(`/condo-expenses/${expenseId}/attachments/${attId}`); + }, + + // --- DOCUMENTS --- + getDocuments: async (): Promise => { + const activeId = CondoService.getActiveCondoId(); + return request(`/documents?condoId=${activeId}`); + }, + uploadDocument: async (doc: any): Promise => { + const activeId = CondoService.getActiveCondoId(); + const settings = await CondoService.getSettings(); // Get current storage config + return request('/documents', { + method: 'POST', + body: JSON.stringify({ ...doc, condoId: activeId, storageConfig: settings.storageConfig }) + }); + }, + deleteDocument: async (id: string): Promise => { + return request(`/documents/${id}`, { method: 'DELETE' }); + }, + getDocumentDownload: async (id: string): Promise<{fileName: string, fileType: string, data: string}> => { + return request(`/documents/${id}/download`); } };