Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

567 B
Raw Blame
import type { TeamHolding } from "@editor/billing/types";

/** Replaces this deployment's last report with its live roster, without counting it twice. */
export function fleetUsersInUse(
  team: TeamHolding,
  deviceId?: string | null,
  localUsers?: number | null,
): number {
  if (!team.breakdown) return team.usersInUse;
  return team.breakdown.deployments.reduce(
    (total, deployment) =>
      total +
      (deployment.deviceId === deviceId && localUsers != null
        ? localUsers
        : (deployment.users ?? 0)),
    team.breakdown.cloudUsers,
  );
}