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 && ( - - handleSelect(variant.id)} - > - {variantAddingToCart === variant.id ? : } - - - )} + + handleSelect(variant.id)} + > + {variantAddingToCart === variant.id ? : } + + - - - {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