diff --git a/app/home/(user)/(dashboard)/order-analysis/page.tsx b/app/home/(user)/(dashboard)/order-analysis/page.tsx index 942f78e..6358f18 100644 --- a/app/home/(user)/(dashboard)/order-analysis/page.tsx +++ b/app/home/(user)/(dashboard)/order-analysis/page.tsx @@ -5,6 +5,8 @@ import { Trans } from '@kit/ui/trans'; import { HomeLayoutPageHeader } from '../../_components/home-page-header'; import { loadAnalyses } from '../../_lib/server/load-analyses'; import OrderAnalysesCards from '../../_components/order-analyses-cards'; +import { createPageViewLog, PAGE_VIEW_ACTION } from '~/lib/services/audit/pageView.service'; +import { loadCurrentUserAccount } from '../../_lib/server/load-user-account'; export const generateMetadata = async () => { const { t } = await createI18nServerInstance(); @@ -15,8 +17,18 @@ export const generateMetadata = async () => { }; async function OrderAnalysisPage() { + const account = await loadCurrentUserAccount(); + if (!account) { + throw new Error('Account not found'); + } + const { analyses, countryCode } = await loadAnalyses(); + await createPageViewLog({ + accountId: account.id, + action: PAGE_VIEW_ACTION.VIEW_ORDER_ANALYSIS, + }); + return ( <> { const i18n = await createI18nServerInstance(); @@ -26,6 +27,7 @@ async function UserHomePage() { return ( <> + diff --git a/app/home/(user)/_components/dashboard-cards.tsx b/app/home/(user)/_components/dashboard-cards.tsx new file mode 100644 index 0000000..a24e465 --- /dev/null +++ b/app/home/(user)/_components/dashboard-cards.tsx @@ -0,0 +1,45 @@ +import { Trans } from '@kit/ui/trans'; +import { + Card, + CardHeader, + CardDescription, + CardFooter, +} from '@kit/ui/card'; + +import Link from 'next/link'; +import { Button } from '@kit/ui/button'; +import { ChevronRight, HeartPulse } from 'lucide-react'; + +export default function DashboardCards() { + return ( +
+ + +
+ +
+
+ + + +
+
+ +
+ +
+ + + +
+
+
+ ); +} diff --git a/app/home/(user)/_components/order-analyses-cards.tsx b/app/home/(user)/_components/order-analyses-cards.tsx index 9a9d8d8..f7575bc 100644 --- a/app/home/(user)/_components/order-analyses-cards.tsx +++ b/app/home/(user)/_components/order-analyses-cards.tsx @@ -7,11 +7,14 @@ import { Card, CardHeader, CardFooter, + CardDescription, } from '@kit/ui/card'; import { StoreProduct, StoreProductVariant } from '@medusajs/types'; import { useState } from 'react'; import { handleAddToCart } from '~/lib/services/medusaCart.service'; import { useRouter } from 'next/navigation'; +import { InfoTooltip } from '~/components/ui/info-tooltip'; +import { Trans } from '@kit/ui/trans'; export default function OrderAnalysesCards({ analyses, @@ -21,7 +24,7 @@ export default function OrderAnalysesCards({ countryCode: string; }) { const router = useRouter(); - + const [isAddingToCart, setIsAddingToCart] = useState(false); const handleSelect = async (selectedVariant: StoreProductVariant) => { if (!selectedVariant?.id || isAddingToCart) return null @@ -44,37 +47,62 @@ export default function OrderAnalysesCards({
{analyses.map(({ title, - variants - }) => ( - - -
- -
-
- -
- -
-
- {title} -
-
-
- ))} + +
+ {isAvailable && ( +
+ +
+ )} + + +
+ {title} + {description && ( + <> + {' '} + + + )} +
+ {isAvailable && subtitle && ( + + {subtitle} + + )} + {!isAvailable && ( + + + + )} +
+ + ); + })} ); } diff --git a/lib/services/audit/pageView.service.ts b/lib/services/audit/pageView.service.ts index ea5aaca..28fc458 100644 --- a/lib/services/audit/pageView.service.ts +++ b/lib/services/audit/pageView.service.ts @@ -3,6 +3,7 @@ import { getSupabaseServerClient } from '@kit/supabase/server-client'; export enum PAGE_VIEW_ACTION { VIEW_ANALYSIS_RESULTS = 'VIEW_ANALYSIS_RESULTS', REGISTRATION_SUCCESS = 'REGISTRATION_SUCCESS', + VIEW_ORDER_ANALYSIS = 'VIEW_ORDER_ANALYSIS', } export const createPageViewLog = async ({ diff --git a/public/locales/en/dashboard.json b/public/locales/en/dashboard.json index 3893ce4..8563680 100644 --- a/public/locales/en/dashboard.json +++ b/public/locales/en/dashboard.json @@ -12,5 +12,11 @@ "cholesterol": "Cholesterol", "ldlCholesterol": "LDL Cholesterol", "smoking": "Smoking", - "recommendedForYou": "Recommended for you" + "recommendedForYou": "Recommended for you", + "heroCard": { + "orderAnalysis": { + "title": "Order analysis", + "description": "Select an analysis to get started" + } + } } \ No newline at end of file diff --git a/public/locales/en/order-analysis.json b/public/locales/en/order-analysis.json index 3cc4ea9..6ab9af8 100644 --- a/public/locales/en/order-analysis.json +++ b/public/locales/en/order-analysis.json @@ -1,4 +1,5 @@ { "title": "Select analysis", - "description": "Select the analysis that suits your needs" + "description": "Select the analysis that suits your needs", + "analysisNotAvailable": "Analysis is not available currently" } \ No newline at end of file diff --git a/public/locales/et/dashboard.json b/public/locales/et/dashboard.json index 69df7e4..810c148 100644 --- a/public/locales/et/dashboard.json +++ b/public/locales/et/dashboard.json @@ -12,5 +12,11 @@ "cholesterol": "Kolesterool", "ldlCholesterol": "LDL kolesterool", "smoking": "Suitsetamine", - "recommendedForYou": "Soovitused sulle" + "recommendedForYou": "Soovitused sulle", + "heroCard": { + "orderAnalysis": { + "title": "Telli analüüs", + "description": "Telli endale sobiv analüüs" + } + } } \ No newline at end of file diff --git a/public/locales/et/order-analysis.json b/public/locales/et/order-analysis.json index f04be5e..42f790e 100644 --- a/public/locales/et/order-analysis.json +++ b/public/locales/et/order-analysis.json @@ -1,4 +1,5 @@ { "title": "Vali analüüs", - "description": "Vali enda vajadustele sobiv analüüs" + "description": "Vali enda vajadustele sobiv analüüs", + "analysisNotAvailable": "Analüüsi tellimine ei ole hetkel saadaval" } \ No newline at end of file