feat(contribuyentes): mostrar nombre del supervisor en card
This commit is contained in:
@@ -42,7 +42,24 @@ export async function list(req: Request, res: Response, next: NextFunction) {
|
|||||||
try {
|
try {
|
||||||
const visibleIds = await getEntidadesVisibles(req.tenantPool!, req.user!.userId, req.user!.role);
|
const visibleIds = await getEntidadesVisibles(req.tenantPool!, req.user!.userId, req.user!.role);
|
||||||
const rows = await contribuyenteService.listContribuyentes(req.tenantPool!, visibleIds, req.user!.tenantId);
|
const rows = await contribuyenteService.listContribuyentes(req.tenantPool!, visibleIds, req.user!.tenantId);
|
||||||
return res.json({ data: rows });
|
|
||||||
|
// Batch lookup de nombres de supervisores
|
||||||
|
const supervisorIds = [...new Set(rows.map(r => r.supervisorUserId).filter(Boolean))] as string[];
|
||||||
|
const supervisorNames: Record<string, string> = {};
|
||||||
|
if (supervisorIds.length > 0) {
|
||||||
|
const users = await prisma.user.findMany({
|
||||||
|
where: { id: { in: supervisorIds } },
|
||||||
|
select: { id: true, nombre: true },
|
||||||
|
});
|
||||||
|
for (const u of users) supervisorNames[u.id] = u.nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
data: rows.map(r => ({
|
||||||
|
...r,
|
||||||
|
supervisorNombre: r.supervisorUserId ? (supervisorNames[r.supervisorUserId] ?? null) : null,
|
||||||
|
})),
|
||||||
|
});
|
||||||
} catch (err) { return next(err); }
|
} catch (err) { return next(err); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ export default function ContribuyentesPage() {
|
|||||||
<p className="font-semibold">{c.nombre}</p>
|
<p className="font-semibold">{c.nombre}</p>
|
||||||
<p className="text-sm text-muted-foreground font-mono">{c.rfc}</p>
|
<p className="text-sm text-muted-foreground font-mono">{c.rfc}</p>
|
||||||
{c.regimenFiscal && <p className="text-xs text-muted-foreground mt-1">Régimen: {c.regimenFiscal}</p>}
|
{c.regimenFiscal && <p className="text-xs text-muted-foreground mt-1">Régimen: {c.regimenFiscal}</p>}
|
||||||
|
{c.supervisorNombre && <p className="text-xs text-muted-foreground mt-1">Supervisor: {c.supervisorNombre}</p>}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{(user?.role === 'owner' || user?.role === 'cfo') && (
|
{(user?.role === 'owner' || user?.role === 'cfo') && (
|
||||||
|
|||||||
Reference in New Issue
Block a user