Merge branch 'develop' into MED-194

This commit is contained in:
Danel Kungla
2025-10-06 15:16:48 +03:00
12 changed files with 390 additions and 30 deletions

View File

@@ -29,10 +29,13 @@ async function TeamAccountBillingPage({ params }: TeamAccountBillingPageProps) {
const account = await api.getTeamAccount(accountSlug);
const { members } = await api.getMembers(accountSlug);
const eligibleMembersCount = members.filter(
({ is_eligible_for_benefits }) => !!is_eligible_for_benefits,
).length;
const [expensesOverview, companyParams] = await Promise.all([
loadTeamAccountBenefitExpensesOverview({
companyId: account.id,
employeeCount: members.length,
employeeCount: eligibleMembersCount,
}),
api.getTeamAccountParams(account.id),
]);
@@ -42,7 +45,7 @@ async function TeamAccountBillingPage({ params }: TeamAccountBillingPageProps) {
<HealthBenefitForm
account={account}
companyParams={companyParams}
employeeCount={members.length}
employeeCount={eligibleMembersCount}
expensesOverview={expensesOverview}
/>
</PageBody>

View File

@@ -65,18 +65,17 @@ async function loadAccountMembers(
const members = data ?? [];
return members
.sort((prev, next) => {
if (prev.primary_owner_user_id === prev.user_id) {
return -1;
}
return members.sort((prev, next) => {
if (prev.primary_owner_user_id === prev.user_id) {
return -1;
}
if (prev.role_hierarchy_level < next.role_hierarchy_level) {
return -1;
}
if (prev.role_hierarchy_level < next.role_hierarchy_level) {
return -1;
}
return 1;
});
return 1;
});
}
export async function loadAccountMembersBenefitsUsage(
@@ -100,11 +99,7 @@ export async function loadAccountMembersBenefitsUsage(
return [];
}
return (data ?? []) as unknown as {
personal_account_id: string;
benefit_amount: number;
benefit_unused_amount: number;
}[];
return data ?? [];
}
/**

View File

@@ -52,6 +52,7 @@ async function TeamAccountMembersPage({ params }: TeamAccountMembersPageProps) {
const canManageRoles = account.permissions.includes('roles.manage');
const canManageInvitations = account.permissions.includes('invites.manage');
const canUpdateBenefit = account.permissions.includes('benefit.manage');
const isPrimaryOwner = account.primary_owner_user_id === user.id;
const currentUserRoleHierarchy = account.role_hierarchy_level;
@@ -103,6 +104,7 @@ async function TeamAccountMembersPage({ params }: TeamAccountMembersPageProps) {
members={members}
isPrimaryOwner={isPrimaryOwner}
canManageRoles={canManageRoles}
canUpdateBenefit={canUpdateBenefit}
membersBenefitsUsage={membersBenefitsUsage}
/>
</CardContent>