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:
Danel Kungla
2025-08-18 16:50:26 +03:00
parent 937f3e4a71
commit 2b79a9e401
9 changed files with 189 additions and 861 deletions

View File

@@ -164,7 +164,7 @@ async function TeamAccountPage(props: {
account: Account & { memberships: Membership[] };
}) {
const api = createTeamAccountsApi(getSupabaseServerClient());
const members = await api.getMembers(props.account.slug ?? '');
const { members } = await api.getMembers(props.account.slug ?? '');
return (
<>

View File

@@ -308,7 +308,32 @@ export class TeamAccountsApi {
throw members.error;
}
return members.data;
const memberIds = members.data?.map((member) => member.id) ?? [];
const memberParams = await this.client
.schema('medreport')
.from('account_params')
.select('weight, height')
.in('account_id', memberIds);
if (memberParams.error) {
throw memberParams.error;
}
return { members: members.data, memberParams: memberParams.data };
}
async getMemberParams(ids: string[]) {
const memberParams = await this.client
.schema('medreport')
.from('account_params')
.select('weight, height')
.in('account_id', ids);
if (memberParams.error) {
throw memberParams.error;
}
return memberParams.data;
}
}