feat(MED-50): use account_params in dashboard

This commit is contained in:
2025-07-24 08:38:12 +03:00
parent 66760adc06
commit 349e3e3143
5 changed files with 57 additions and 18 deletions

View File

@@ -37,7 +37,7 @@ async function UserHomePage() {
}
/>
<PageBody>
<Dashboard />
<Dashboard account={account} />
</PageBody>
</>
);

View File

@@ -15,6 +15,7 @@ import {
TrendingUp,
User,
} from 'lucide-react';
import Isikukood from 'isikukood';
import { Button } from '@kit/ui/button';
import {
@@ -27,29 +28,40 @@ import {
} from '@kit/ui/card';
import { Trans } from '@kit/ui/trans';
import { cn } from '@kit/ui/utils';
import type { AccountWithParams } from '@/packages/features/accounts/src/server/api';
const dummyCards = [
const cards = ({
gender,
age,
height,
weight,
}: {
gender?: string;
age?: number;
height?: number | null;
weight?: number | null;
}) => [
{
title: 'dashboard:gender',
description: 'dashboard:male',
description: gender ?? 'dashboard:male',
icon: <User />,
iconBg: 'bg-success',
},
{
title: 'dashboard:age',
description: '43',
description: age ? `${age}` : '-',
icon: <Clock9 />,
iconBg: 'bg-success',
},
{
title: 'dashboard:height',
description: '183',
description: height ? `${height}cm` : '-',
icon: <RulerHorizontalIcon className="size-4" />,
iconBg: 'bg-success',
},
{
title: 'dashboard:weight',
description: '92kg',
description: weight ? `${weight}kg` : '-',
icon: <Scale />,
iconBg: 'bg-warning',
},
@@ -128,11 +140,31 @@ const dummyRecommendations = [
},
];
export default function Dashboard() {
const getPersonParameters = (personalCode: string) => {
try {
const person = new Isikukood(personalCode);
return {
gender: person.getGender(),
age: person.getAge(),
};
} catch (error) {
console.error(error);
return null;
}
};
export default function Dashboard({ account }: { account: AccountWithParams }) {
const params = getPersonParameters(account.personal_code!);
return (
<>
<div className="grid auto-rows-fr grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-5">
{dummyCards.map(
{cards({
gender: params?.gender,
age: params?.age,
height: account.account_params?.height,
weight: account.account_params?.weight,
}).map(
({
title,
description,