fix tto order tables
This commit is contained in:
@@ -13,7 +13,6 @@ export default function OrderBlock({
|
||||
analysisOrder,
|
||||
ttoLocation,
|
||||
ttoReservation,
|
||||
medusaOrderStatus,
|
||||
itemsAnalysisPackage,
|
||||
itemsTtoService,
|
||||
itemsOther,
|
||||
@@ -22,7 +21,6 @@ export default function OrderBlock({
|
||||
analysisOrder?: AnalysisOrder;
|
||||
ttoLocation?: { name: string };
|
||||
ttoReservation?: TTOOrder;
|
||||
medusaOrderStatus: string;
|
||||
itemsAnalysisPackage: StoreOrderLineItem[];
|
||||
itemsTtoService: StoreOrderLineItem[];
|
||||
itemsOther: StoreOrderLineItem[];
|
||||
@@ -76,6 +74,7 @@ export default function OrderBlock({
|
||||
bookingCode: ttoReservation?.booking_code,
|
||||
clinicId: ttoReservation?.clinic_id,
|
||||
medusaLineItemId: ttoReservation?.medusa_cart_line_item_id,
|
||||
id: ttoReservation?.id,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { redirect, useRouter } from 'next/navigation';
|
||||
|
||||
import ConfirmationModal from '@/packages/shared/src/components/confirmation-modal';
|
||||
import { StoreOrderLineItem } from '@medusajs/types';
|
||||
import { formatDate } from 'date-fns';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { pathsConfig } from '@kit/shared/config';
|
||||
import { Button } from '@kit/ui/button';
|
||||
@@ -41,6 +42,9 @@ export default function OrderItemsTable({
|
||||
type?: OrderItemType;
|
||||
isPackage?: boolean;
|
||||
}) {
|
||||
const {
|
||||
i18n: { t },
|
||||
} = useTranslation();
|
||||
const router = useRouter();
|
||||
const [isConfirmOpen, setIsConfirmOpen] = useState(false);
|
||||
const isCancelOrderAllowed =
|
||||
@@ -61,7 +65,7 @@ export default function OrderItemsTable({
|
||||
await logAnalysisResultsNavigateAction(order.medusaOrderId);
|
||||
router.push(`${pathsConfig.app.analysisResults}/${order.id}`);
|
||||
} else {
|
||||
router.push(`${pathsConfig.app.myOrders}/${order.medusaOrderId}`);
|
||||
router.push(`${pathsConfig.app.myOrders}/${order.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -74,27 +78,31 @@ export default function OrderItemsTable({
|
||||
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
|
||||
)
|
||||
.map((orderItem) => (
|
||||
<div key={`${orderItem.id}-mobile`}>
|
||||
<React.Fragment key={`${orderItem.id}-mobile`}>
|
||||
<MobileTableRow
|
||||
titleKey={title}
|
||||
title={t(title)}
|
||||
value={orderItem.product_title || ''}
|
||||
/>
|
||||
<MobileTableRow
|
||||
titleKey="orders:table.createdAt"
|
||||
title={t('orders:table.createdAt')}
|
||||
value={formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
|
||||
/>
|
||||
{order.location && (
|
||||
<MobileTableRow
|
||||
titleKey="orders:table.location"
|
||||
title={t('orders:table.location')}
|
||||
value={order.location}
|
||||
/>
|
||||
)}
|
||||
<MobileTableRow
|
||||
titleKey="orders:table.status"
|
||||
title={t('orders:table.status')}
|
||||
value={
|
||||
isPackage
|
||||
? `orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`
|
||||
: `orders:status.${type}.${order?.status ?? 'CONFIRMED'}`
|
||||
? t(
|
||||
`orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`,
|
||||
)
|
||||
: t(
|
||||
`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`,
|
||||
)
|
||||
}
|
||||
/>
|
||||
<TableRow>
|
||||
@@ -114,7 +122,7 @@ export default function OrderItemsTable({
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
@@ -172,23 +180,24 @@ export default function OrderItemsTable({
|
||||
)}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="px-6 text-right">
|
||||
<Button size="sm" onClick={openDetailedView}>
|
||||
<Trans i18nKey="analysis-results:view" />
|
||||
</Button>
|
||||
{isCancelOrderAllowed && (
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-warning/90 hover:bg-warning mt-2 w-full"
|
||||
onClick={() => setIsConfirmOpen(true)}
|
||||
>
|
||||
<Trans i18nKey="analysis-results:cancel" />
|
||||
<TableCell className="px-6 text-right">
|
||||
<Button size="sm" onClick={openDetailedView}>
|
||||
<Trans i18nKey="analysis-results:view" />
|
||||
</Button>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
{isCancelOrderAllowed && (
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-warning/90 hover:bg-warning mt-2 w-full"
|
||||
onClick={() => setIsConfirmOpen(true)}
|
||||
>
|
||||
<Trans i18nKey="analysis-results:cancel" />
|
||||
</Button>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{isCancelOrderAllowed && (
|
||||
<ConfirmationModal
|
||||
isOpen={isConfirmOpen}
|
||||
|
||||
Reference in New Issue
Block a user