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:
2026-05-28 00:29:31 +00:00
parent 356c8e3c2c
commit 6028bf1ba9
12 changed files with 432 additions and 105 deletions

View File

@@ -988,6 +988,35 @@ async function main() {
}
console.log(`${repDiscountLimits.length} alçadas configuradas.`);
// Metas mensais (C7)
const now = new Date();
const repTargets = [
{
repId: DEV_REP_ID,
year: now.getFullYear(),
month: now.getMonth() + 1,
targetAmount: 60000,
commissionRate: 3,
flexRate: 1,
},
{
repId: DEV_REP2_ID,
year: now.getFullYear(),
month: now.getMonth() + 1,
targetAmount: 40000,
commissionRate: 3,
flexRate: 1,
},
];
for (const t of repTargets) {
await prisma.repTarget.upsert({
where: { repId_year_month: { repId: t.repId, year: t.year, month: t.month } },
create: t,
update: { targetAmount: t.targetAmount },
});
}
console.log(`${repTargets.length} metas mensais configuradas.`);
// Upsert clients (sem lastOrderAt/openOrdersCount — calculados depois)
for (const data of clientDefs) {
await prisma.client.upsert({