Update: nueva version Horux Despachos
This commit is contained in:
44
apps/web/lib/api/admin-clientes.ts
Normal file
44
apps/web/lib/api/admin-clientes.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { apiClient } from './client';
|
||||
|
||||
export interface ClientesStats {
|
||||
suscripcionesPorPlan: Array<{ plan: string; count: number }>;
|
||||
ingresos: { total: number; paymentsCount: number };
|
||||
noRenovaciones: Array<{
|
||||
tenantId: string;
|
||||
tenantNombre: string;
|
||||
rfc: string;
|
||||
plan: string;
|
||||
currentPeriodEnd: string;
|
||||
statusActual: string;
|
||||
}>;
|
||||
usuariosPorCliente: Array<{
|
||||
tenantId: string;
|
||||
tenantNombre: string;
|
||||
rfc: string;
|
||||
activeUsers: number;
|
||||
owners: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface TenantUsuario {
|
||||
userId: string;
|
||||
email: string;
|
||||
nombre: string;
|
||||
rol: string;
|
||||
isOwner: boolean;
|
||||
joinedAt: string;
|
||||
lastLogin: string | null;
|
||||
}
|
||||
|
||||
export async function getClientesStats(from?: string, to?: string): Promise<ClientesStats> {
|
||||
const params = new URLSearchParams();
|
||||
if (from) params.set('from', from);
|
||||
if (to) params.set('to', to);
|
||||
const res = await apiClient.get<ClientesStats>(`/admin/clientes/stats?${params}`);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function getTenantUsuarios(tenantId: string): Promise<TenantUsuario[]> {
|
||||
const res = await apiClient.get<{ data: TenantUsuario[] }>(`/admin/clientes/${tenantId}/usuarios`);
|
||||
return res.data.data;
|
||||
}
|
||||
Reference in New Issue
Block a user