feat(MED-123): analysis to order can be not-available

This commit is contained in:
Karli
2025-08-18 14:11:19 +03:00
parent 9b50b0f92a
commit abf455117d
3 changed files with 56 additions and 41 deletions

View File

@@ -14,6 +14,7 @@ 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,
@@ -49,47 +50,59 @@ export default function OrderAnalysesCards({
variants,
description,
subtitle,
}) => (
<Card
key={title}
variant="gradient-success"
className="flex flex-col justify-between"
>
<CardHeader className="flex-row">
<div
className={'flex size-8 items-center-safe justify-center-safe rounded-full text-white bg-primary\/10 mb-6'}
>
<HeartPulse className="size-4 fill-green-500" />
</div>
<div className='ml-auto flex size-8 items-center-safe justify-center-safe rounded-full text-white bg-warning'>
<Button
size="icon"
variant="outline"
className="px-2 text-black"
onClick={() => handleSelect(variants![0]!)}
status,
metadata,
}) => {
const isAvailable = status === 'published' && !!metadata?.analysisIdOriginal;
return (
<Card
key={title}
variant={isAvailable ? "gradient-success" : "gradient-warning"}
className="flex flex-col justify-between"
>
<CardHeader className="flex-row">
<div
className={'flex size-8 items-center-safe justify-center-safe rounded-full text-white bg-primary\/10 mb-6'}
>
{isAddingToCart ? <Loader2 className="size-4 stroke-2 animate-spin" /> : <ShoppingCart className="size-4 stroke-2" />}
</Button>
</div>
</CardHeader>
<CardFooter className="flex flex-col items-start gap-2">
<h5>
{title}
{description && (
<>
{' '}
<InfoTooltip content={`${description}`} />
</>
<HeartPulse className="size-4 fill-green-500" />
</div>
{isAvailable && (
<div className='ml-auto flex size-8 items-center-safe justify-center-safe rounded-full text-white bg-warning'>
<Button
size="icon"
variant="outline"
className="px-2 text-black"
onClick={() => handleSelect(variants![0]!)}
>
{isAddingToCart ? <Loader2 className="size-4 stroke-2 animate-spin" /> : <ShoppingCart className="size-4 stroke-2" />}
</Button>
</div>
)}
</h5>
{subtitle && (
<CardDescription>
{subtitle}
</CardDescription>
)}
</CardFooter>
</Card>
))}
</CardHeader>
<CardFooter className="flex flex-col items-start gap-2">
<h5>
{title}
{description && (
<>
{' '}
<InfoTooltip content={`${description}`} />
</>
)}
</h5>
{isAvailable && subtitle && (
<CardDescription>
{subtitle}
</CardDescription>
)}
{!isAvailable && (
<CardDescription>
<Trans i18nKey={'order-analysis:analysisNotAvailable'} />
</CardDescription>
)}
</CardFooter>
</Card>
);
})}
</div>
);
}

View File

@@ -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"
}

View File

@@ -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"
}