feat(MED-97): display accounts count, usage total
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { formatCurrency } from '@/packages/shared/src/utils';
|
import { formatCurrency } from '@/packages/shared/src/utils';
|
||||||
import { PiggyBankIcon } from 'lucide-react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { Card, CardTitle } from '@kit/ui/card';
|
import { Card, CardTitle } from '@kit/ui/card';
|
||||||
import { cn } from '@kit/ui/lib/utils';
|
import { cn } from '@kit/ui/lib/utils';
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import { TeamAccountBenefitExpensesOverview } from '../_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benefit-statistics';
|
import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benefit-statistics';
|
||||||
|
|
||||||
const StatisticsCard = ({ children }: { children: React.ReactNode }) => {
|
const StatisticsCard = ({ children }: { children: React.ReactNode }) => {
|
||||||
@@ -38,8 +38,10 @@ const StatisticsValue = ({ children }: { children: React.ReactNode }) => {
|
|||||||
|
|
||||||
const TeamAccountBenefitStatistics = ({
|
const TeamAccountBenefitStatistics = ({
|
||||||
accountBenefitStatistics,
|
accountBenefitStatistics,
|
||||||
|
expensesOverview,
|
||||||
}: {
|
}: {
|
||||||
accountBenefitStatistics: AccountBenefitStatistics;
|
accountBenefitStatistics: AccountBenefitStatistics;
|
||||||
|
expensesOverview: TeamAccountBenefitExpensesOverview;
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
i18n: { language },
|
i18n: { language },
|
||||||
@@ -47,25 +49,16 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col gap-2 sm:flex-row">
|
<div className="flex h-full w-full flex-col gap-2 sm:flex-row">
|
||||||
<Card className="relative flex flex-row">
|
<div className="grid flex-2 grid-cols-2 gap-2 sm:grid-cols-3 sm:grid-rows-2">
|
||||||
<div className="p-6">
|
<StatisticsCard>
|
||||||
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-orange-100">
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
<PiggyBankIcon className="h-[32px] w-[32px] stroke-orange-400 stroke-2" />
|
<Trans i18nKey="teams:benefitStatistics.budget.membersCount" />
|
||||||
</div>
|
|
||||||
<StatisticsCardTitle className="mt-4 text-xl font-bold">
|
|
||||||
<Trans i18nKey="teams:benefitStatistics.budget.volume" />
|
|
||||||
</StatisticsCardTitle>
|
</StatisticsCardTitle>
|
||||||
<StatisticsValue>
|
<StatisticsValue>
|
||||||
{formatCurrency({
|
{accountBenefitStatistics.companyAccountsCount}
|
||||||
value: accountBenefitStatistics.periodTotal,
|
|
||||||
locale: language,
|
|
||||||
currencyCode: 'EUR',
|
|
||||||
})}
|
|
||||||
</StatisticsValue>
|
</StatisticsValue>
|
||||||
</div>
|
</StatisticsCard>
|
||||||
</Card>
|
|
||||||
|
|
||||||
<div className="grid flex-2 grid-cols-2 gap-2 sm:grid-cols-3 sm:grid-rows-2">
|
|
||||||
<StatisticsCard>
|
<StatisticsCard>
|
||||||
<StatisticsCardTitle className="text-lg font-bold">
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
<Trans i18nKey="teams:benefitStatistics.data.totalSum" />
|
<Trans i18nKey="teams:benefitStatistics.data.totalSum" />
|
||||||
@@ -79,11 +72,30 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
</StatisticsValue>
|
</StatisticsValue>
|
||||||
</StatisticsCard>
|
</StatisticsCard>
|
||||||
|
|
||||||
|
<StatisticsCard>
|
||||||
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
|
<Trans i18nKey="teams:benefitStatistics.data.currentMonthUsageTotal" />
|
||||||
|
</StatisticsCardTitle>
|
||||||
|
<StatisticsValue>
|
||||||
|
{formatCurrency({
|
||||||
|
value: expensesOverview.currentMonthUsageTotal,
|
||||||
|
locale: language,
|
||||||
|
currencyCode: 'EUR',
|
||||||
|
})}
|
||||||
|
</StatisticsValue>
|
||||||
|
</StatisticsCard>
|
||||||
|
|
||||||
<StatisticsCard>
|
<StatisticsCard>
|
||||||
<StatisticsCardTitle>
|
<StatisticsCardTitle>
|
||||||
<Trans i18nKey="teams:benefitStatistics.data.analysis" />
|
<Trans i18nKey="teams:benefitStatistics.data.analysis" />
|
||||||
</StatisticsCardTitle>
|
</StatisticsCardTitle>
|
||||||
<StatisticsValue>{accountBenefitStatistics.orders.analysesSum} €</StatisticsValue>
|
<StatisticsValue>
|
||||||
|
{formatCurrency({
|
||||||
|
value: accountBenefitStatistics.orders.analysesSum,
|
||||||
|
locale: language,
|
||||||
|
currencyCode: 'EUR',
|
||||||
|
})}
|
||||||
|
</StatisticsValue>
|
||||||
<StatisticsDescription>
|
<StatisticsDescription>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="teams:benefitStatistics.data.reservations"
|
i18nKey="teams:benefitStatistics.data.reservations"
|
||||||
@@ -106,7 +118,9 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
<StatisticsDescription>
|
<StatisticsDescription>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="teams:benefitStatistics.data.analysisPackagesCount"
|
i18nKey="teams:benefitStatistics.data.analysisPackagesCount"
|
||||||
values={{ value: accountBenefitStatistics.orders.analysisPackagesCount }}
|
values={{
|
||||||
|
value: accountBenefitStatistics.orders.analysisPackagesCount,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StatisticsDescription>
|
</StatisticsDescription>
|
||||||
</StatisticsCard>
|
</StatisticsCard>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benef
|
|||||||
import TeamAccountBenefitStatistics from './team-account-benefit-statistics';
|
import TeamAccountBenefitStatistics from './team-account-benefit-statistics';
|
||||||
import TeamAccountHealthDetails from './team-account-health-details';
|
import TeamAccountHealthDetails from './team-account-health-details';
|
||||||
import type { Account, AccountParams, BmiThresholds } from '@/packages/features/accounts/src/types/accounts';
|
import type { Account, AccountParams, BmiThresholds } from '@/packages/features/accounts/src/types/accounts';
|
||||||
|
import { TeamAccountBenefitExpensesOverview } from '../_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
|
|
||||||
export interface TeamAccountStatisticsProps {
|
export interface TeamAccountStatisticsProps {
|
||||||
teamAccount: Account;
|
teamAccount: Account;
|
||||||
@@ -27,6 +28,7 @@ export interface TeamAccountStatisticsProps {
|
|||||||
bmiThresholds: Omit<BmiThresholds, 'id'>[];
|
bmiThresholds: Omit<BmiThresholds, 'id'>[];
|
||||||
members: Database['medreport']['Functions']['get_account_members']['Returns'];
|
members: Database['medreport']['Functions']['get_account_members']['Returns'];
|
||||||
accountBenefitStatistics: AccountBenefitStatistics;
|
accountBenefitStatistics: AccountBenefitStatistics;
|
||||||
|
expensesOverview: TeamAccountBenefitExpensesOverview;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TeamAccountStatistics({
|
export default function TeamAccountStatistics({
|
||||||
@@ -35,6 +37,7 @@ export default function TeamAccountStatistics({
|
|||||||
bmiThresholds,
|
bmiThresholds,
|
||||||
members,
|
members,
|
||||||
accountBenefitStatistics,
|
accountBenefitStatistics,
|
||||||
|
expensesOverview,
|
||||||
}: TeamAccountStatisticsProps) {
|
}: TeamAccountStatisticsProps) {
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const [date, setDate] = useState<DateRange | undefined>({
|
const [date, setDate] = useState<DateRange | undefined>({
|
||||||
@@ -50,7 +53,7 @@ export default function TeamAccountStatistics({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mt-4 flex items-center justify-between">
|
<div className="mt-4 flex flex-col gap-4 sm:gap-0 sm:flex-row items-center justify-between">
|
||||||
<h4 className="font-bold">
|
<h4 className="font-bold">
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey={'teams:home.headerTitle'}
|
i18nKey={'teams:home.headerTitle'}
|
||||||
@@ -75,7 +78,7 @@ export default function TeamAccountStatistics({
|
|||||||
'animate-in fade-in flex flex-col space-y-4 pb-36 duration-500'
|
'animate-in fade-in flex flex-col space-y-4 pb-36 duration-500'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TeamAccountBenefitStatistics accountBenefitStatistics={accountBenefitStatistics} />
|
<TeamAccountBenefitStatistics accountBenefitStatistics={accountBenefitStatistics} expensesOverview={expensesOverview} />
|
||||||
|
|
||||||
<h5 className="mt-4 mb-2">
|
<h5 className="mt-4 mb-2">
|
||||||
<Trans i18nKey="teams:home.healthDetails" />
|
<Trans i18nKey="teams:home.healthDetails" />
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const loadCompanyPersonalAccountsBalanceEntries = async ({
|
|||||||
const { count, data: accountMemberships } = await supabase
|
const { count, data: accountMemberships } = await supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('accounts_memberships')
|
.from('accounts_memberships')
|
||||||
.select('user_id')
|
.select('user_id', { count: 'exact' })
|
||||||
.eq('account_id', accountId)
|
.eq('account_id', accountId)
|
||||||
.throwOnError();
|
.throwOnError();
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
|
|
||||||
import { Dashboard } from './_components/dashboard';
|
import { Dashboard } from './_components/dashboard';
|
||||||
import { loadAccountBenefitStatistics } from './_lib/server/load-team-account-benefit-statistics';
|
import { loadAccountBenefitStatistics } from './_lib/server/load-team-account-benefit-statistics';
|
||||||
|
import { loadTeamAccountBenefitExpensesOverview } from './_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
|
|
||||||
interface TeamAccountHomePageProps {
|
interface TeamAccountHomePageProps {
|
||||||
params: Promise<{ account: string }>;
|
params: Promise<{ account: string }>;
|
||||||
@@ -41,6 +42,10 @@ function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
|
|||||||
const { memberParams, members } = use(teamAccountsApi.getMembers(account));
|
const { memberParams, members } = use(teamAccountsApi.getMembers(account));
|
||||||
const bmiThresholds = use(userAnalysesApi.fetchBmiThresholds());
|
const bmiThresholds = use(userAnalysesApi.fetchBmiThresholds());
|
||||||
const accountBenefitStatistics = use(loadAccountBenefitStatistics(teamAccount.id));
|
const accountBenefitStatistics = use(loadAccountBenefitStatistics(teamAccount.id));
|
||||||
|
const expensesOverview = use(loadTeamAccountBenefitExpensesOverview({
|
||||||
|
companyId: teamAccount.id,
|
||||||
|
employeeCount: members.length,
|
||||||
|
}));
|
||||||
|
|
||||||
use(
|
use(
|
||||||
createPageViewLog({
|
createPageViewLog({
|
||||||
@@ -57,6 +62,7 @@ function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
|
|||||||
bmiThresholds={bmiThresholds}
|
bmiThresholds={bmiThresholds}
|
||||||
members={members}
|
members={members}
|
||||||
accountBenefitStatistics={accountBenefitStatistics}
|
accountBenefitStatistics={accountBenefitStatistics}
|
||||||
|
expensesOverview={expensesOverview}
|
||||||
/>
|
/>
|
||||||
</PageBody>
|
</PageBody>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Company Health Account Balance",
|
"title": "Company Health Account Balance",
|
||||||
"balance": "Budget Balance {{balance}}",
|
"balance": "Budget Balance {{balance}}",
|
||||||
"volume": "Budget Volume"
|
"volume": "Budget Volume",
|
||||||
|
"membersCount": "Members Count"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} services",
|
"reservations": "{{value}} services",
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"analysisPackages": "Health Analysis Packages",
|
"analysisPackages": "Health Analysis Packages",
|
||||||
"analysisPackagesCount": "{{value}} service usage",
|
"analysisPackagesCount": "{{value}} service usage",
|
||||||
"totalSum": "Total Sum",
|
"totalSum": "Total Sum",
|
||||||
"eclinic": "E-Clinic"
|
"eclinic": "E-Clinic",
|
||||||
|
"currentMonthUsageTotal": "Current Month Usage"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
@@ -28,17 +28,19 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Ettevõtte Tervisekassa seis",
|
"title": "Ettevõtte Tervisekassa seis",
|
||||||
"balance": "Eelarve jääk {{balance}}",
|
"balance": "Eelarve jääk {{balance}}",
|
||||||
"volume": "Eelarve maht"
|
"volume": "Eelarve maht",
|
||||||
|
"membersCount": "Töötajate arv"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} teenust",
|
"reservations": "{{value}} tellimus(t)",
|
||||||
"analysis": "Analüüsid",
|
"analysis": "Analüüsid",
|
||||||
"doctorsAndSpecialists": "Eriarstid ja spetsialistid",
|
"doctorsAndSpecialists": "Eriarstid ja spetsialistid",
|
||||||
"researches": "Uuringud",
|
"researches": "Uuringud",
|
||||||
"analysisPackages": "Terviseuuringute paketid",
|
"analysisPackages": "Terviseuuringute paketid",
|
||||||
"analysisPackagesCount": "{{value}} teenuse kasutust",
|
"analysisPackagesCount": "{{value}} tellimus(t)",
|
||||||
"totalSum": "Tellitud teenuste summa",
|
"totalSum": "Tellitud teenuste summa",
|
||||||
"eclinic": "Digikliinik"
|
"eclinic": "Digikliinik",
|
||||||
|
"currentMonthUsageTotal": "Kasutatud eelarve"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Баланс Tervisekassa компании",
|
"title": "Баланс Tervisekassa компании",
|
||||||
"balance": "Остаток бюджета {{balance}}",
|
"balance": "Остаток бюджета {{balance}}",
|
||||||
"volume": "Объем бюджета"
|
"volume": "Объем бюджета",
|
||||||
|
"membersCount": "Количество сотрудников"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} услуги",
|
"reservations": "{{value}} услуги",
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"analysisPackages": "Пакеты медицинских исследований",
|
"analysisPackages": "Пакеты медицинских исследований",
|
||||||
"analysisPackagesCount": "{{value}} использование услуг",
|
"analysisPackagesCount": "{{value}} использование услуг",
|
||||||
"totalSum": "Сумма услуг",
|
"totalSum": "Сумма услуг",
|
||||||
"eclinic": "Дигиклиника"
|
"eclinic": "Дигиклиника",
|
||||||
|
"currentMonthUsageTotal": "Текущее использование бюджета"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
Reference in New Issue
Block a user