add tto order

This commit is contained in:
Danel Kungla
2025-09-26 15:58:25 +03:00
parent 6c3ae1eda6
commit bfdd1ec62a
6 changed files with 30 additions and 31 deletions

View File

@@ -26,17 +26,7 @@ async function OrderConfirmedPage(props: {
params: Promise<{ orderId: string }>;
}) {
const params = await props.params;
const order = await getAnalysisOrder({
analysisOrderId: Number(params.orderId),
}).catch(() => null);
if (!order) {
redirect(pathsConfig.app.myOrders);
}
const medusaOrder = await retrieveOrder(order.medusa_order_id).catch(
() => null,
);
const medusaOrder = await retrieveOrder(params.orderId).catch(() => null);
if (!medusaOrder) {
redirect(pathsConfig.app.myOrders);
}
@@ -46,7 +36,12 @@ async function OrderConfirmedPage(props: {
<PageHeader title={<Trans i18nKey="cart:order.title" />} />
<Divider />
<div className="small:grid-cols-[1fr_360px] grid grid-cols-1 gap-x-40 gap-y-6 lg:px-4">
<OrderDetails order={order} />
<OrderDetails
order={{
id: medusaOrder.id,
created_at: medusaOrder.created_at,
}}
/>
<Divider />
<OrderItems medusaOrder={medusaOrder} />
<CartTotals medusaOrder={medusaOrder} />

View File

@@ -171,9 +171,11 @@ const TimeSlots = ({
reservationId,
newStartTime: timeSlot.StartTime,
newServiceId: Number(syncedService.id),
timeSlot.UserID,
timeSlot.SyncUserID,
booking.selectedLocationId ? booking.selectedLocationId : null,
newAppointmentUserId: timeSlot.UserID,
newSyncUserId: timeSlot.SyncUserID,
newLocationId: booking.selectedLocationId
? booking.selectedLocationId
: null,
cartId,
});

View File

@@ -4,14 +4,18 @@ import { Trans } from '@kit/ui/trans';
import type { AnalysisOrder } from '~/lib/types/order';
export default function OrderDetails({ order }: { order: AnalysisOrder }) {
export default function OrderDetails({
order,
}: {
order: { id: string; created_at: string | Date };
}) {
return (
<div className="flex flex-col gap-y-2">
<div>
<span className="font-bold">
<Trans i18nKey="cart:orderConfirmed.orderNumber" />:{' '}
</span>
<span>{order.medusa_order_id}</span>
<span>{order.id}</span>
</div>
<div>

View File

@@ -64,7 +64,10 @@ export default function OrderBlock({
items={itemsTtoService}
title="orders:table.ttoService"
type="ttoService"
order={{ status: medusaOrderStatus.toUpperCase() }}
order={{
status: medusaOrderStatus.toUpperCase(),
medusaOrderId,
}}
/>
)}
<OrderItemsTable

View File

@@ -42,10 +42,12 @@ export default function OrderItemsTable({
const isAnalysisOrder = type === 'analysisOrder';
const openAnalysisResults = async () => {
const openDetailedView = async () => {
if (isAnalysisOrder && order?.medusaOrderId && order?.id) {
await logAnalysisResultsNavigateAction(order.medusaOrderId);
router.push(`${pathsConfig.app.analysisResults}/${order.id}`);
} else {
router.push(`${pathsConfig.app.myOrders}/${order.medusaOrderId}`);
}
};
@@ -88,13 +90,11 @@ export default function OrderItemsTable({
/>
</TableCell>
{isAnalysisOrder && (
<TableCell className="px-6 text-right">
<Button size="sm" onClick={openAnalysisResults}>
<Trans i18nKey="analysis-results:view" />
</Button>
</TableCell>
)}
<TableCell className="px-6 text-right">
<Button size="sm" onClick={openDetailedView}>
<Trans i18nKey="analysis-results:view" />
</Button>
</TableCell>
</TableRow>
))}
</TableBody>

View File

@@ -61,11 +61,6 @@ export const listOrders = async (
};
export const createTransferRequest = async (
state: {
success: boolean;
error: string | null;
order: HttpTypes.StoreOrder | null;
},
formData: FormData,
): Promise<{
success: boolean;