diff --git a/app/home/(user)/_components/dashboard.tsx b/app/home/(user)/_components/dashboard.tsx
index 7d3146b..f223b1c 100644
--- a/app/home/(user)/_components/dashboard.tsx
+++ b/app/home/(user)/_components/dashboard.tsx
@@ -40,73 +40,80 @@ const cards = ({
age?: number;
height?: number | null;
weight?: number | null;
-}) => [
- {
- title: 'dashboard:gender',
- description: gender ?? 'dashboard:male',
- icon: ,
- iconBg: 'bg-success',
- },
- {
- title: 'dashboard:age',
- description: age ? `${age}` : '-',
- icon: ,
- iconBg: 'bg-success',
- },
- {
- title: 'dashboard:height',
- description: height ? `${height}cm` : '-',
- icon: ,
- iconBg: 'bg-success',
- },
- {
- title: 'dashboard:weight',
- description: weight ? `${weight}kg` : '-',
- icon: ,
- iconBg: 'bg-warning',
- },
- {
- title: 'dashboard:bmi',
- description: '27.5',
- icon: ,
- iconBg: 'bg-warning',
- },
- {
- title: 'dashboard:bloodPressure',
- description: '160/98',
- icon: ,
- iconBg: 'bg-warning',
- },
- {
- title: 'dashboard:cholesterol',
- description: '5',
- icon: ,
- iconBg: 'bg-destructive',
- },
- {
- title: 'dashboard:ldlCholesterol',
- description: '3,6',
- icon: ,
- iconBg: 'bg-warning',
- },
- {
- title: 'Score 2',
- description: 'Normis',
- icon: ,
- iconBg: 'bg-success',
- },
- {
- title: 'dashboard:smoking',
- description: 'dashboard:respondToQuestion',
- descriptionColor: 'text-primary',
- icon: (
-
- ),
- cardVariant: 'gradient-success' as CardProps['variant'],
- },
-];
+}) => {
+ const heightInMeters = height ? height / 100 : null;
+ const bmi =
+ heightInMeters && weight
+ ? (weight / (heightInMeters * heightInMeters)).toFixed(1)
+ : null;
+ return [
+ {
+ title: 'dashboard:gender',
+ description: gender ?? 'dashboard:male',
+ icon: ,
+ iconBg: 'bg-success',
+ },
+ {
+ title: 'dashboard:age',
+ description: age ? `${age}` : '-',
+ icon: ,
+ iconBg: 'bg-success',
+ },
+ {
+ title: 'dashboard:height',
+ description: height ? `${height}cm` : '-',
+ icon: ,
+ iconBg: 'bg-success',
+ },
+ {
+ title: 'dashboard:weight',
+ description: weight ? `${weight}kg` : '-',
+ icon: ,
+ iconBg: 'bg-success',
+ },
+ {
+ title: 'dashboard:bmi',
+ description: bmi,
+ icon: ,
+ iconBg: 'bg-success',
+ },
+ {
+ title: 'dashboard:bloodPressure',
+ description: '-',
+ icon: ,
+ iconBg: 'bg-warning',
+ },
+ {
+ title: 'dashboard:cholesterol',
+ description: '-',
+ icon: ,
+ iconBg: 'bg-destructive',
+ },
+ {
+ title: 'dashboard:ldlCholesterol',
+ description: '-',
+ icon: ,
+ iconBg: 'bg-warning',
+ },
+ // {
+ // title: 'Score 2',
+ // description: 'Normis',
+ // icon: ,
+ // iconBg: 'bg-success',
+ // },
+ // {
+ // title: 'dashboard:smoking',
+ // description: 'dashboard:respondToQuestion',
+ // descriptionColor: 'text-primary',
+ // icon: (
+ //
+ // ),
+ // cardVariant: 'gradient-success' as CardProps['variant'],
+ // },
+ ];
+};
const dummyRecommendations = [
{
@@ -162,8 +169,8 @@ export default function Dashboard({ account }: { account: AccountWithParams }) {
{cards({
gender: params?.gender,
age: params?.age,
- height: account.account_params?.height,
- weight: account.account_params?.weight,
+ height: account.account_params?.[0]?.height,
+ weight: account.account_params?.[0]?.weight,
}).map(
({
title,
diff --git a/packages/features/accounts/src/server/api.ts b/packages/features/accounts/src/server/api.ts
index 3c080a5..7bebe76 100644
--- a/packages/features/accounts/src/server/api.ts
+++ b/packages/features/accounts/src/server/api.ts
@@ -6,10 +6,12 @@ import { UserAnalysis } from '../types/accounts';
export type AccountWithParams =
Database['medreport']['Tables']['accounts']['Row'] & {
- account_params: Pick<
- Database['medreport']['Tables']['account_params']['Row'],
- 'weight' | 'height'
- > | null;
+ account_params:
+ | Pick<
+ Database['medreport']['Tables']['account_params']['Row'],
+ 'weight' | 'height'
+ >[]
+ | null;
};
/**
@@ -222,6 +224,24 @@ class AccountsApi {
),
}));
}
+
+ async hasAccountTeamMembership(accountId?: string) {
+ if (!accountId) {
+ return false;
+ }
+
+ const { count, error } = await this.client
+ .schema('medreport')
+ .from('accounts_memberships')
+ .select('account_id', { count: 'exact', head: true })
+ .eq('account_id', accountId);
+
+ if (error) {
+ throw error;
+ }
+
+ return (count ?? 0) > 0;
+ }
}
export function createAccountsApi(client: SupabaseClient) {