fix(historial): registrar todos los cambios de Zona de marca
Instrumenta kit, fuentes y estilo creativo; el listado filtra por rango e incluye hoy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,9 +22,11 @@ export async function GET(req: NextRequest) {
|
||||
const role = userRole(user);
|
||||
const isAgency = isAgencyRole(role);
|
||||
const sp = req.nextUrl.searchParams;
|
||||
const limit = Number(sp.get('limit') || 50);
|
||||
const limit = Number(sp.get('limit') || 100);
|
||||
const offset = Number(sp.get('offset') || 0);
|
||||
const entityType = sp.get('entity_type') || sp.get('entityType') || null;
|
||||
const since = sp.get('since') || null;
|
||||
const until = sp.get('until') || null;
|
||||
|
||||
let tenantId =
|
||||
sp.get('tenant_id') || sp.get('tenantId') || null;
|
||||
@@ -46,9 +48,11 @@ export async function GET(req: NextRequest) {
|
||||
// Si portfolio wide, tenantId queda null → historial global
|
||||
}
|
||||
|
||||
const { rows, error } = await listChangeHistory({
|
||||
const { rows, error, total } = await listChangeHistory({
|
||||
tenantId,
|
||||
entityType,
|
||||
since,
|
||||
until,
|
||||
limit,
|
||||
offset,
|
||||
});
|
||||
@@ -74,7 +78,10 @@ export async function GET(req: NextRequest) {
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
rows,
|
||||
total: total ?? rows.length,
|
||||
tenant_id: tenantId,
|
||||
portfolio_wide: isAgency && !tenantId,
|
||||
since,
|
||||
until,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user