From e7650e3c32b64a5aed02b97edaa1d1f1a0b2e173 Mon Sep 17 00:00:00 2001 From: Karli Date: Wed, 17 Sep 2025 11:16:50 +0300 Subject: [PATCH] feat(MED-161): move type to types file --- .../(dashboard)/cart/montonio-callback/actions.ts | 2 +- app/home/(user)/_components/dashboard.tsx | 2 +- .../(user)/_lib/server/load-analysis-packages.ts | 4 ++-- .../_components/account-preferences-form.tsx | 2 +- .../_components/account-settings-form.tsx | 2 +- packages/features/accounts/src/server/api.ts | 15 +-------------- packages/features/accounts/src/types/accounts.ts | 14 ++++++++++++++ packages/shared/package.json | 3 ++- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts b/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts index 5650f0c..7e7b22e 100644 --- a/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts +++ b/app/home/(user)/(dashboard)/cart/montonio-callback/actions.ts @@ -12,7 +12,7 @@ import { sendOrderToMedipost } from '~/lib/services/medipost/medipostPrivateMess import { getOrderedAnalysisIds } from '~/lib/services/medusaOrder.service'; import { createNotificationsApi } from '@kit/notifications/api'; import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client'; -import type { AccountWithParams } from '@kit/accounts/api'; +import type { AccountWithParams } from '@kit/accounts/types/accounts'; import type { StoreOrder } from '@medusajs/types'; const ANALYSIS_PACKAGES_TYPE_HANDLE = 'analysis-packages'; diff --git a/app/home/(user)/_components/dashboard.tsx b/app/home/(user)/_components/dashboard.tsx index f8b2e79..51faecd 100644 --- a/app/home/(user)/_components/dashboard.tsx +++ b/app/home/(user)/_components/dashboard.tsx @@ -2,7 +2,7 @@ import Link from 'next/link'; -import type { AccountWithParams } from '@/packages/features/accounts/src/server/api'; +import type { AccountWithParams } from '@kit/accounts/types/accounts'; import { Database } from '@/packages/supabase/src/database.types'; import { BlendingModeIcon, RulerHorizontalIcon } from '@radix-ui/react-icons'; import { diff --git a/app/home/(user)/_lib/server/load-analysis-packages.ts b/app/home/(user)/_lib/server/load-analysis-packages.ts index f7fffb9..596a041 100644 --- a/app/home/(user)/_lib/server/load-analysis-packages.ts +++ b/app/home/(user)/_lib/server/load-analysis-packages.ts @@ -5,8 +5,8 @@ import { listRegions } from '@lib/data/regions'; import { getAnalysisElementMedusaProductIds } from '@/utils/medusa-product'; import type { StoreProduct } from '@medusajs/types'; import { loadCurrentUserAccount } from './load-user-account'; -import { AccountWithParams } from '@/packages/features/accounts/src/server/api'; -import { AnalysisPackageWithVariant } from '@kit/shared/components/select-analysis-package'; +import type { AccountWithParams } from '@kit/accounts/types/accounts'; +import type { AnalysisPackageWithVariant } from '@kit/shared/components/select-analysis-package'; import PersonalCode from '~/lib/utils'; async function countryCodesLoader() { diff --git a/app/home/(user)/settings/_components/account-preferences-form.tsx b/app/home/(user)/settings/_components/account-preferences-form.tsx index aa19746..f36adb3 100644 --- a/app/home/(user)/settings/_components/account-preferences-form.tsx +++ b/app/home/(user)/settings/_components/account-preferences-form.tsx @@ -4,7 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod'; import { useForm } from 'react-hook-form'; import { Trans } from 'react-i18next'; -import { AccountWithParams } from '@kit/accounts/api'; +import type { AccountWithParams } from '@kit/accounts/types/accounts'; import { useRevalidatePersonalAccountDataQuery } from '@kit/accounts/hooks/use-personal-account-data'; import { Button } from '@kit/ui/button'; import { Card, CardDescription, CardTitle } from '@kit/ui/card'; diff --git a/app/home/(user)/settings/_components/account-settings-form.tsx b/app/home/(user)/settings/_components/account-settings-form.tsx index 8513798..5aba272 100644 --- a/app/home/(user)/settings/_components/account-settings-form.tsx +++ b/app/home/(user)/settings/_components/account-settings-form.tsx @@ -4,7 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod'; import { useForm } from 'react-hook-form'; import { Trans } from 'react-i18next'; -import { AccountWithParams } from '@kit/accounts/api'; +import type { AccountWithParams } from '@kit/accounts/types/accounts'; import { useRevalidatePersonalAccountDataQuery } from '@kit/accounts/hooks/use-personal-account-data'; import { Button } from '@kit/ui/button'; import { diff --git a/packages/features/accounts/src/server/api.ts b/packages/features/accounts/src/server/api.ts index d29e52b..187da61 100644 --- a/packages/features/accounts/src/server/api.ts +++ b/packages/features/accounts/src/server/api.ts @@ -6,20 +6,7 @@ import PersonalCode from '~/lib/utils'; import type { AnalysisResultDetails, AnalysisResultDetailsMapped, UserAnalysis } from '../types/analysis-results'; import type { AnalysisOrder } from '../types/analysis-orders'; - -export type AccountWithParams = - Database['medreport']['Tables']['accounts']['Row'] & { - accountParams: - | (Pick< - Database['medreport']['Tables']['account_params']['Row'], - 'weight' | 'height' - > & { - isSmoker: - | Database['medreport']['Tables']['account_params']['Row']['is_smoker'] - | null; - }) - | null; - }; +import { AccountWithParams } from '../types/accounts'; /** * Class representing an API for interacting with user accounts. diff --git a/packages/features/accounts/src/types/accounts.ts b/packages/features/accounts/src/types/accounts.ts index 02700b2..7259cfb 100644 --- a/packages/features/accounts/src/types/accounts.ts +++ b/packages/features/accounts/src/types/accounts.ts @@ -7,3 +7,17 @@ export enum ApplicationRoleEnum { Doctor = 'doctor', SuperAdmin = 'super_admin', } + +export type AccountWithParams = + Database['medreport']['Tables']['accounts']['Row'] & { + accountParams: + | (Pick< + Database['medreport']['Tables']['account_params']['Row'], + 'weight' | 'height' + > & { + isSmoker: + | Database['medreport']['Tables']['account_params']['Row']['is_smoker'] + | null; + }) + | null; + }; diff --git a/packages/shared/package.json b/packages/shared/package.json index 27fc7b2..a0fc483 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -16,7 +16,8 @@ "./events": "./src/events/index.tsx", "./components/*": "./src/components/*.tsx", "./registry": "./src/registry/index.ts", - "./config": "./src/config/index.ts" + "./config": "./src/config/index.ts", + "./types/*": "./src/types/*.ts" }, "devDependencies": { "@kit/eslint-config": "workspace:*",