feat(team-accounts): enhance team account statistics and health details components with new data and improved calculations

This commit is contained in:
Danel Kungla
2025-08-25 12:24:27 +03:00
parent ee86bb8829
commit 56ffd7591e
12 changed files with 336 additions and 150 deletions

View File

@@ -2,6 +2,7 @@
import { use } from 'react';
import { createAccountsApi } from '@/packages/features/accounts/src/server/api';
import { CompanyGuard } from '@/packages/features/team-accounts/src/components';
import { createTeamAccountsApi } from '@/packages/features/team-accounts/src/server/api';
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
@@ -11,6 +12,10 @@ import { Trans } from '@kit/ui/trans';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
import { withI18n } from '~/lib/i18n/with-i18n';
import {
PAGE_VIEW_ACTION,
createPageViewLog,
} from '~/lib/services/audit/pageView.service';
import { Dashboard } from './_components/dashboard';
import { TeamAccountLayoutPageHeader } from './_components/team-account-layout-page-header';
@@ -31,25 +36,32 @@ export const generateMetadata = async () => {
function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
const account = use(params).account;
const client = getSupabaseServerClient();
const api = createTeamAccountsApi(client);
const teamAccount = use(api.getTeamAccount(account));
const { memberParams } = use(api.getMembers(account));
const teamAccountsApi = createTeamAccountsApi(client);
const accountsApi = createAccountsApi(client);
const teamAccount = use(teamAccountsApi.getTeamAccount(account));
const { memberParams, members } = use(teamAccountsApi.getMembers(account));
const bmiThresholds = use(accountsApi.fetchBmiThresholds());
const companyParams = use(
teamAccountsApi.getTeamAccountParams(teamAccount.id),
);
use(
createPageViewLog({
accountId: teamAccount.id,
action: PAGE_VIEW_ACTION.VIEW_TEAM_ACCOUNT_DASHBOARD,
}),
);
return (
<>
<TeamAccountLayoutPageHeader
title={
<Trans
i18nKey={'teams:home.headerTitle'}
values={{ companyName: account }}
/>
}
<PageBody>
<Dashboard
teamAccount={teamAccount}
memberParams={memberParams}
bmiThresholds={bmiThresholds}
members={members}
companyParams={companyParams}
/>
<PageBody>
<Dashboard teamAccount={teamAccount} memberParams={memberParams} />
</PageBody>
</>
</PageBody>
);
}