Merge branch 'develop' into MED-177

This commit is contained in:
Danel Kungla
2025-10-21 17:27:54 +03:00
131 changed files with 2202 additions and 921 deletions

View File

@@ -51,7 +51,7 @@ export default function OrderBlock({
</Link>
</div>
)}
<div className="flex flex-col gap-4">
<div className="flex flex-col sm:gap-4">
{analysisOrder && (
<OrderItemsTable
items={itemsAnalysisPackage}
@@ -61,6 +61,7 @@ export default function OrderBlock({
id: analysisOrder.id,
status: analysisOrder.status,
}}
isPackage
/>
)}
{itemsTtoService && (
@@ -82,6 +83,8 @@ export default function OrderBlock({
items={itemsOther}
title="orders:table.otherOrders"
order={{
medusaOrderId: analysisOrder?.medusa_order_id,
id: analysisOrder?.id,
status: analysisOrder?.status,
}}
/>

View File

@@ -23,6 +23,7 @@ import { Trans } from '@kit/ui/trans';
import type { Order } from '~/lib/types/order';
import { cancelTtoBooking } from '../../_lib/server/actions';
import MobileTableRow from '../cart/mobile-table-row';
import { logAnalysisResultsNavigateAction } from './actions';
export type OrderItemType = 'analysisOrder' | 'ttoService';
@@ -32,11 +33,13 @@ export default function OrderItemsTable({
title,
order,
type = 'analysisOrder',
isPackage = false,
}: {
items: StoreOrderLineItem[];
title: string;
order: Order;
type?: OrderItemType;
isPackage?: boolean;
}) {
const router = useRouter();
const [isConfirmOpen, setIsConfirmOpen] = useState(false);
@@ -63,52 +66,111 @@ export default function OrderItemsTable({
};
return (
<Table className="border-separate rounded-lg border">
<TableHeader className="text-ui-fg-subtle txt-medium-plus">
<TableRow>
<TableHead className="px-6">
<Trans i18nKey={title} />
</TableHead>
<TableHead className="px-6">
<Trans i18nKey="orders:table.createdAt" />
</TableHead>
{order.location && (
<TableHead className="px-6">
<Trans i18nKey="orders:table.location" />
</TableHead>
)}
<TableHead className="px-6">
<Trans i18nKey="orders:table.status" />
</TableHead>
{isAnalysisOrder && <TableHead className="px-6"></TableHead>}
</TableRow>
</TableHeader>
<TableBody>
{items
.sort((a, b) =>
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
)
.map((orderItem) => (
<TableRow className="w-full" key={orderItem.id}>
<TableCell className="w-[100%] px-6 text-left">
<p className="txt-medium-plus text-ui-fg-base">
{orderItem.product_title}
</p>
</TableCell>
<TableCell className="px-6 whitespace-nowrap">
{formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
</TableCell>
{order.location && (
<TableCell className="min-w-[180px] px-6">
{order.location}
</TableCell>
)}
<TableCell className="min-w-[180px] px-6">
<Trans
i18nKey={`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`}
<>
<Table className="border-separate rounded-lg border p-2 sm:hidden">
<TableBody>
{items
.sort((a, b) =>
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
)
.map((orderItem) => (
<div key={`${orderItem.id}-mobile`}>
<MobileTableRow
titleKey={title}
value={orderItem.product_title || ''}
/>
</TableCell>
<MobileTableRow
titleKey="orders:table.createdAt"
value={formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
/>
{order.location && (
<MobileTableRow
titleKey="orders:table.location"
value={order.location}
/>
)}
<MobileTableRow
titleKey="orders:table.status"
value={
isPackage
? `orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`
: `orders:status.${type}.${order?.status ?? 'CONFIRMED'}`
}
/>
<TableRow>
<TableCell />
<TableCell className="flex w-full items-center justify-end p-0 pt-2">
<Button size="sm" onClick={openDetailedView}>
<Trans i18nKey="analysis-results:view" />
</Button>
{isTtoservice && order.bookingCode && (
<Button
size="sm"
className="bg-warning/90 hover:bg-warning"
onClick={() => setIsConfirmOpen(true)}
>
<Trans i18nKey="analysis-results:cancel" />
</Button>
)}
</TableCell>
</TableRow>
</div>
))}
</TableBody>
</Table>
<Table className="hidden border-separate rounded-lg border sm:block">
<TableHeader className="text-ui-fg-subtle txt-medium-plus">
<TableRow>
<TableHead className="px-6">
<Trans i18nKey={title} />
</TableHead>
<TableHead className="px-6">
<Trans i18nKey="orders:table.createdAt" />
</TableHead>
{order.location && (
<TableHead className="px-6">
<Trans i18nKey="orders:table.location" />
</TableHead>
)}
<TableHead className="px-6">
<Trans i18nKey="orders:table.status" />
</TableHead>
{isAnalysisOrder && <TableHead className="px-6"></TableHead>}
</TableRow>
</TableHeader>
<TableBody>
{items
.sort((a, b) =>
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
)
.map((orderItem) => (
<TableRow className="w-full" key={orderItem.id}>
<TableCell className="w-[100%] px-6 text-left">
<p className="txt-medium-plus text-ui-fg-base">
{orderItem.product_title}
</p>
</TableCell>
<TableCell className="px-6 whitespace-nowrap">
{formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
</TableCell>
{order.location && (
<TableCell className="min-w-[180px] px-6">
{order.location}
</TableCell>
)}
<TableCell className="min-w-[180px] px-6">
{isPackage ? (
<Trans
i18nKey={`orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`}
/>
) : (
<Trans
i18nKey={`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`}
/>
)}
</TableCell>
<TableCell className="px-6 text-right">
<Button size="sm" onClick={openDetailedView}>
@@ -144,6 +206,6 @@ export default function OrderItemsTable({
descriptionKey="orders:confirmBookingCancel.description"
/>
)}
</Table>
</>
);
}