feat(dashboard): painel Rafael — meta, comissão, inativos, pedidos recentes (C7)
GET /dashboard/rep retorna meta mensal, comissão (fixa + FLEX), clientes inativos >30 dias e pedidos dos últimos 7 dias. RepTarget model com migration. RafaelPainel conectado à API real via useRepDashboard(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
apps/web/src/lib/queries/dashboard.ts
Normal file
14
apps/web/src/lib/queries/dashboard.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { RepDashboardSchema, type RepDashboard } from '@sar/api-interface';
|
||||
import { apiFetch } from '../api-client';
|
||||
|
||||
export function useRepDashboard() {
|
||||
return useQuery<RepDashboard>({
|
||||
queryKey: ['dashboard', 'rep'],
|
||||
queryFn: async () => {
|
||||
const raw = await apiFetch('/dashboard/rep');
|
||||
return RepDashboardSchema.parse(raw);
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // 5 min
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user