Update api.ts
This commit is contained in:
@@ -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<any> => {
|
||||
return request(`/condo-expenses/${expenseId}/attachments/${attId}`);
|
||||
},
|
||||
|
||||
// --- DOCUMENTS ---
|
||||
getDocuments: async (): Promise<Document[]> => {
|
||||
const activeId = CondoService.getActiveCondoId();
|
||||
return request<Document[]>(`/documents?condoId=${activeId}`);
|
||||
},
|
||||
uploadDocument: async (doc: any): Promise<void> => {
|
||||
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<void> => {
|
||||
return request(`/documents/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
getDocumentDownload: async (id: string): Promise<{fileName: string, fileType: string, data: string}> => {
|
||||
return request(`/documents/${id}/download`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user