Refactor team account statistics and health details
- Simplified the TeamAccountStatistics component by removing unused code and integrating translation for health details. - Updated the load-team-account-health-details to calculate average BMI based on member parameters. - Adjusted the billing page to correctly reference the number of team members. - Enhanced the main account page to pass member parameters to the Dashboard component. - Modified the admin account page to destructure member data from the API response. - Updated the TeamAccountsApi to return member parameters alongside member data. - Added new translations for health details in Estonian locale.
This commit is contained in:
@@ -2,9 +2,11 @@ import React from 'react';
|
||||
|
||||
import { Clock, TrendingUp, User } from 'lucide-react';
|
||||
|
||||
import { TeamAccountStatisticsProps } from '../../_components/team-account-statistics';
|
||||
|
||||
interface AccountHealthDetailsField {
|
||||
title: string;
|
||||
value: string;
|
||||
value: string | number;
|
||||
Icon: React.ComponentType<{
|
||||
size?: number;
|
||||
color?: string;
|
||||
@@ -19,51 +21,59 @@ export enum NormStatus {
|
||||
NORMAL = 'NORMAL',
|
||||
}
|
||||
|
||||
export const getAccountHealthDetailsFields =
|
||||
(): AccountHealthDetailsField[] => {
|
||||
const test = '';
|
||||
return [
|
||||
{
|
||||
title: 'Naised',
|
||||
value: '50% (16)',
|
||||
Icon: User,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'Mehed',
|
||||
value: '50% (16)',
|
||||
Icon: User,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'Keskmine vanus',
|
||||
value: '56',
|
||||
Icon: Clock,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'KMI',
|
||||
value: '271',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.WARNING,
|
||||
},
|
||||
{
|
||||
title: 'Üldkolesterool',
|
||||
value: '6.1',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.WARNING,
|
||||
},
|
||||
{
|
||||
title: 'Vitamiin D',
|
||||
value: '76',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'Suitsetajad',
|
||||
value: '22%',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.CRITICAL,
|
||||
},
|
||||
];
|
||||
};
|
||||
export const getAccountHealthDetailsFields = (
|
||||
memberParams: TeamAccountStatisticsProps['memberParams'],
|
||||
): AccountHealthDetailsField[] => {
|
||||
const averageBMI = (
|
||||
memberParams.reduce((sum, { height, weight }) => {
|
||||
const hMeters = height! / 100;
|
||||
const bmi = weight! / (hMeters * hMeters);
|
||||
return sum + bmi;
|
||||
}, 0) / memberParams.length
|
||||
).toFixed(0);
|
||||
|
||||
return [
|
||||
{
|
||||
title: 'teams:healthDetails.women',
|
||||
value: `50% (${memberParams.length})`,
|
||||
Icon: User,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.men',
|
||||
value: `50% (${memberParams.length})`,
|
||||
Icon: User,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.avgAge',
|
||||
value: '56',
|
||||
Icon: Clock,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.bmi',
|
||||
value: averageBMI,
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.WARNING,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.cholesterol',
|
||||
value: '6.1',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.WARNING,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.vitaminD',
|
||||
value: '76',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.NORMAL,
|
||||
},
|
||||
{
|
||||
title: 'teams:healthDetails.smokers',
|
||||
value: '22%',
|
||||
Icon: TrendingUp,
|
||||
normStatus: NormStatus.CRITICAL,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user