feat: implement organization insights dashboard with detailed metrics and collaboration data in sysadmin-cli
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Request, Response } from "express";
|
||||
import { paginateCompanies, setCompanyBanned, updateCompany } from "../services/companies.service";
|
||||
import { getOrganizationInsights, paginateCompanies, setCompanyBanned, updateCompany } from "../services/companies.service";
|
||||
|
||||
export const paginate = async (req: Request, res: Response) => {
|
||||
try {
|
||||
@@ -33,3 +33,14 @@ export const setBanned = async (req: Request, res: Response) => {
|
||||
res.status(500).json({ error: err });
|
||||
}
|
||||
};
|
||||
|
||||
export const insights = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const result = await getOrganizationInsights(req.body);
|
||||
res.json(result);
|
||||
} catch (e: any) {
|
||||
console.log(e);
|
||||
const err = e.response ? e.response.data : e.message;
|
||||
res.status(500).json({ error: err });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,3 +35,72 @@ export type SetCompanyBannedParams = {
|
||||
id: string;
|
||||
banned: boolean;
|
||||
};
|
||||
|
||||
export type OrganizationInsightsParams = {
|
||||
companyId: string;
|
||||
};
|
||||
|
||||
export type OrganizationInsightsResult = {
|
||||
organization: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
categoryId: number;
|
||||
banned: boolean;
|
||||
published?: string;
|
||||
onboardingStep?: number;
|
||||
onboardingCompleted?: boolean;
|
||||
};
|
||||
owner: {
|
||||
id: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
verificated?: boolean;
|
||||
phoneCountryCode?: string;
|
||||
phoneAreaCode?: string;
|
||||
phoneNumber?: string;
|
||||
} | null;
|
||||
collaborators: {
|
||||
id: string;
|
||||
userId?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
fullName?: string;
|
||||
email?: string;
|
||||
roles?: string[];
|
||||
removed?: boolean;
|
||||
active: boolean;
|
||||
avatar?: string;
|
||||
}[];
|
||||
subscription: {
|
||||
id: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
isActive: boolean;
|
||||
autoRenew: boolean;
|
||||
mpStatus?: string;
|
||||
pendingPaymentType?: "extension" | "upgrade";
|
||||
plan: {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
price: number;
|
||||
limitOrganizations: number;
|
||||
limitEmployees: number;
|
||||
limitServices: number;
|
||||
limitAppointments: number;
|
||||
limitClients: number;
|
||||
} | null;
|
||||
} | null;
|
||||
stats: {
|
||||
employeesCount: number;
|
||||
activeEmployeesCount: number;
|
||||
servicesCount: number;
|
||||
activeServicesCount: number;
|
||||
clientsCount: number;
|
||||
activeClientsCount: number;
|
||||
reservationsLast30Days: number;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Router } from "express";
|
||||
import { paginate, setBanned, update } from "../controllers/companies.controller";
|
||||
import { insights, paginate, setBanned, update } from "../controllers/companies.controller";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post("/paginate", paginate);
|
||||
router.post("/update", update);
|
||||
router.post("/set-banned", setBanned);
|
||||
router.post("/insights", insights);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -5,6 +5,8 @@ import { getApiHost } from "../helpers/GetApiHost";
|
||||
import {
|
||||
PaginateCompaniesParams,
|
||||
PaginateCompaniesResults,
|
||||
OrganizationInsightsParams,
|
||||
OrganizationInsightsResult,
|
||||
SetCompanyBannedParams,
|
||||
UpdateCompanyParams,
|
||||
} from "../models/Companies.Model";
|
||||
@@ -35,3 +37,12 @@ export const setCompanyBanned = async (params: SetCompanyBannedParams): Promise<
|
||||
});
|
||||
return result.data;
|
||||
};
|
||||
|
||||
export const getOrganizationInsights = async (params: OrganizationInsightsParams): Promise<OrganizationInsightsResult> => {
|
||||
const nonce = await getSysAdminNonce();
|
||||
const result = await axios.post(`${getApiHost()}/sysadmin/companies/insights`, {
|
||||
...params,
|
||||
payload: getPayload(nonce),
|
||||
});
|
||||
return result.data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user