From cb11244d79a95fad8b66ffb905e0adf2674c0c0e Mon Sep 17 00:00:00 2001 From: Karli Date: Wed, 10 Sep 2025 06:32:41 +0300 Subject: [PATCH] improve order analyses cards --- .../_components/order-analyses-cards.tsx | 78 +++++++++---------- app/home/(user)/_lib/server/load-analyses.ts | 10 +-- public/locales/en/order-analysis.json | 1 - public/locales/et/order-analysis.json | 1 - public/locales/ru/order-analysis.json | 1 - 5 files changed, 42 insertions(+), 49 deletions(-) diff --git a/app/home/(user)/_components/order-analyses-cards.tsx b/app/home/(user)/_components/order-analyses-cards.tsx index 5cb4d31..2e1064d 100644 --- a/app/home/(user)/_components/order-analyses-cards.tsx +++ b/app/home/(user)/_components/order-analyses-cards.tsx @@ -21,7 +21,6 @@ import { formatCurrency } from '@/packages/shared/src/utils'; export type OrderAnalysisCard = Pick< StoreProduct, 'title' | 'description' | 'subtitle' > & { - isAvailable: boolean; variant: { id: string }; price: number | null; }; @@ -64,7 +63,6 @@ export default function OrderAnalysesCards({ variant, description, subtitle, - isAvailable, price, }) => { const formattedPrice = typeof price === 'number' @@ -77,7 +75,7 @@ export default function OrderAnalysesCards({ return ( @@ -86,46 +84,44 @@ export default function OrderAnalysesCards({ > - {isAvailable && ( -
- -
- )} +
+ +
- -
- {title} - {description && ( - <> - {' '} - - {formattedPrice} - {description} - - } - /> - + +
+
+ {title} + {description && ( + <> + {' '} + + {formattedPrice} + {description} +
+ } + /> + + )} +
+ {subtitle && ( + + {subtitle} + )} - - {isAvailable && subtitle && ( - - {subtitle} - - )} - {!isAvailable && ( - - - - )} + +
+ {formattedPrice} +
); diff --git a/app/home/(user)/_lib/server/load-analyses.ts b/app/home/(user)/_lib/server/load-analyses.ts index 1cc954c..cd16e61 100644 --- a/app/home/(user)/_lib/server/load-analyses.ts +++ b/app/home/(user)/_lib/server/load-analyses.ts @@ -41,7 +41,7 @@ async function analysesLoader() { const categoryProducts = category ? await listProducts({ countryCode, - queryParams: { limit: 100, category_id: category.id }, + queryParams: { limit: 100, category_id: category.id, order: 'title' }, }) : null; @@ -51,8 +51,10 @@ async function analysesLoader() { return { analyses: - categoryProducts?.response.products.map( - ({ title, description, subtitle, variants, status, metadata }) => { + categoryProducts?.response.products + .filter(({ status, metadata }) => status === 'published' && !!metadata?.analysisIdOriginal) + .map( + ({ title, description, subtitle, variants }) => { const variant = variants![0]!; return { title, @@ -61,8 +63,6 @@ async function analysesLoader() { variant: { id: variant.id, }, - isAvailable: - status === 'published' && !!metadata?.analysisIdOriginal, price: variant.calculated_price?.calculated_amount ?? null, }; }, diff --git a/public/locales/en/order-analysis.json b/public/locales/en/order-analysis.json index 2031316..11d1145 100644 --- a/public/locales/en/order-analysis.json +++ b/public/locales/en/order-analysis.json @@ -1,7 +1,6 @@ { "title": "Select analysis", "description": "All analysis results will appear within 1-3 days after the blood test.", - "analysisNotAvailable": "Analysis is not available currently", "analysisAddedToCart": "Analysis added to cart", "analysisAddToCartError": "Adding analysis to cart failed" } \ No newline at end of file diff --git a/public/locales/et/order-analysis.json b/public/locales/et/order-analysis.json index 9c7b750..8ff008d 100644 --- a/public/locales/et/order-analysis.json +++ b/public/locales/et/order-analysis.json @@ -1,7 +1,6 @@ { "title": "Vali analüüs", "description": "Kõikide analüüside tulemused ilmuvad 1–3 tööpäeva jooksul peale vere andmist.", - "analysisNotAvailable": "Analüüsi tellimine ei ole hetkel saadaval", "analysisAddedToCart": "Analüüs lisatud ostukorvi", "analysisAddToCartError": "Analüüsi lisamine ostukorvi ebaõnnestus" } \ No newline at end of file diff --git a/public/locales/ru/order-analysis.json b/public/locales/ru/order-analysis.json index ea36b5c..c837255 100644 --- a/public/locales/ru/order-analysis.json +++ b/public/locales/ru/order-analysis.json @@ -1,7 +1,6 @@ { "title": "Выберите анализ", "description": "Результаты всех анализов будут доступны в течение 1–3 рабочих дней после сдачи крови.", - "analysisNotAvailable": "Заказ анализа в данный момент недоступен", "analysisAddedToCart": "Анализ добавлен в корзину", "analysisAddToCartError": "Не удалось добавить анализ в корзину" } \ No newline at end of file