Files
plantillas-proyectos/frontend/src/lib/api/dashboard/index.ts
acazares 3865a53c5c feat(dashboard): add dashboard module for business metrics and statistics
- Implemented DTOs for KPIs, activity items, chart data points, and dashboard statistics.
- Created API routes for fetching dashboard statistics, operations overview, and inventory metrics.
- Developed a service layer to handle the logic for generating dashboard statistics, including invoice metrics, client/provider metrics, and recent activity.
- Added frontend API client methods for fetching dashboard data.
- Created TypeScript types for dashboard data structures.
- Developed Svelte components for displaying recent activity, KPI cards, trend charts, and donut charts.
2026-01-12 18:09:06 -06:00

43 lines
1.2 KiB
TypeScript

/**
* Cliente API para el dashboard
*/
import { api } from '$lib/api';
import type { DashboardStats, OperationsOverview, InventoryMetrics } from './types';
export async function getDashboardStats(companyId: number): Promise<DashboardStats> {
const response = await api.get<DashboardStats>(
`/v1/core/dashboard/stats?company_id=${companyId}`
);
if (response.error || !response.data) {
throw new Error(response.error || 'Failed to fetch dashboard stats');
}
return response.data;
}
export async function getOperationsOverview(companyId: number): Promise<OperationsOverview> {
const response = await api.get<OperationsOverview>(
`/v1/core/dashboard/operations-overview?company_id=${companyId}`
);
if (response.error || !response.data) {
throw new Error(response.error || 'Failed to fetch operations overview');
}
return response.data;
}
export async function getInventoryMetrics(companyId: number): Promise<InventoryMetrics> {
const response = await api.get<InventoryMetrics>(
`/v1/core/dashboard/inventory-metrics?company_id=${companyId}`
);
if (response.error || !response.data) {
throw new Error(response.error || 'Failed to fetch inventory metrics');
}
return response.data;
}