diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx index d4c4c6162bc3d..15741b7c29992 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx @@ -376,9 +376,7 @@ const useActivityItems = (order: AdminOrder): Activity[] => { : edit.status === "canceled" ? edit.canceled_at : edit.created_at, - children: isConfirmed ? ( - - ) : null, + children: isConfirmed ? : null, }) } @@ -839,18 +837,12 @@ const ExchangeBody = ({ ) } -const OrderEditBody = ({ - edit, - itemsMap, -}: { - edit: AdminOrderChange - itemsMap: Map -}) => { +const OrderEditBody = ({ edit }: { edit: AdminOrderChange }) => { const { t } = useTranslation() const [itemsAdded, itemsRemoved] = useMemo( - () => countItemsChange(edit.actions, itemsMap), - [edit, itemsMap] + () => countItemsChange(edit.actions), + [edit] ) return ( @@ -873,10 +865,7 @@ const OrderEditBody = ({ /** * Returns count of added and removed item quantity */ -function countItemsChange( - actions: AdminOrderChange["actions"], - itemsMap: Map -) { +function countItemsChange(actions: AdminOrderChange["actions"]) { let added = 0 let removed = 0 @@ -885,20 +874,12 @@ function countItemsChange( added += action.details!.quantity as number } if (action.action === "ITEM_UPDATE") { - const newQuantity = action.details!.quantity as number - const originalQuantity: number | undefined = itemsMap.get( - action.details!.reference_id as string - )?.quantity - - if (typeof originalQuantity === "number") { - const diff = Math.abs(newQuantity - originalQuantity) - - if (newQuantity > originalQuantity) { - added += diff - } - if (newQuantity < originalQuantity) { - removed += diff - } + const quantityDiff = action.details!.quantity_diff as number + + if (quantityDiff > 0) { + added += quantityDiff + } else { + removed += Math.abs(quantityDiff) } } })