move most isikukood.js usage to utils

This commit is contained in:
2025-09-08 23:42:50 +03:00
parent ccdfd5872b
commit 0081e8948b
5 changed files with 75 additions and 51 deletions

View File

@@ -16,7 +16,6 @@ import {
} from 'lucide-react';
import { pathsConfig } from '@kit/shared/config';
import { getPersonParameters } from '@kit/shared/utils';
import { Button } from '@kit/ui/button';
import {
Card,
@@ -30,7 +29,7 @@ import { cn } from '@kit/ui/utils';
import { isNil } from 'lodash';
import { BmiCategory } from '~/lib/types/bmi';
import {
import PersonalCode, {
bmiFromMetric,
getBmiBackgroundColor,
getBmiStatus,
@@ -145,21 +144,19 @@ export default function Dashboard({
'id'
>[];
}) {
const params = getPersonParameters(account.personal_code!);
const bmiStatus = getBmiStatus(bmiThresholds, {
age: params?.age || 0,
height: account.accountParams?.height || 0,
weight: account.accountParams?.weight || 0,
});
const height = account.accountParams?.height || 0;
const weight = account.accountParams?.weight || 0;
const { age = 0, gender } = PersonalCode.parsePersonalCode(account.personal_code!);
const bmiStatus = getBmiStatus(bmiThresholds, { age, height, weight });
return (
<>
<div className="xs:grid-cols-2 grid auto-rows-fr gap-3 sm:grid-cols-4 lg:grid-cols-5">
{cards({
gender: params?.gender,
age: params?.age,
height: account.accountParams?.height,
weight: account.accountParams?.weight,
gender,
age,
height,
weight,
bmiStatus,
smoking: account.accountParams?.isSmoker,
}).map(