feat: data export — CSV export for tasks, users, activities
- Backend: GET /api/export/{tasks,users,activities}?month=YYYY-MM
- Frontend: Export panel on Reports page (CEO/CTO/Manager only)
- API: apiExportCsv helper for browser download
This commit is contained in:
15
src/api.ts
15
src/api.ts
@@ -48,6 +48,21 @@ export async function apiDeleteUser(id: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function apiExportCsv(type: 'tasks' | 'users' | 'activities', month?: string) {
|
||||
const params = month ? `?month=${month}` : '';
|
||||
const res = await fetch(`${API_BASE}/export/${type}${params}`);
|
||||
if (!res.ok) throw new Error('Export failed');
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = month ? `${type}_${month}.csv` : `${type}_all.csv`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
// Tasks
|
||||
export async function apiFetchTasks() {
|
||||
return request('/tasks');
|
||||
|
||||
Reference in New Issue
Block a user