Files
medreport_mrb2b/app/home/[account]/page.tsx
Helena 8c6ce29c23 MED-147: add doctor actions logging (#59)
* MED-147: add doctor actions logging

* enum casing
2025-08-27 08:11:13 +03:00

67 lines
1.9 KiB
TypeScript

'use server';
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';
import { PageBody } from '@kit/ui/page';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
import { withI18n } from '~/lib/i18n/with-i18n';
import {
PageViewAction,
createPageViewLog,
} from '~/lib/services/audit/pageView.service';
import { Dashboard } from './_components/dashboard';
interface TeamAccountHomePageProps {
params: Promise<{ account: string }>;
}
export const generateMetadata = async () => {
const i18n = await createI18nServerInstance();
const title = i18n.t('teams:home.pageTitle');
return {
title,
};
};
function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
const account = use(params).account;
const client = getSupabaseServerClient();
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: PageViewAction.VIEW_TEAM_ACCOUNT_DASHBOARD,
}),
);
return (
<PageBody>
<Dashboard
teamAccount={teamAccount}
memberParams={memberParams}
bmiThresholds={bmiThresholds}
members={members}
companyParams={companyParams}
/>
</PageBody>
);
}
export default withI18n(CompanyGuard(TeamAccountHomePage));