diff --git a/src/features/cart/ui/OrderPage.tsx b/src/features/cart/ui/OrderPage.tsx index d1df956..20e5f0b 100644 --- a/src/features/cart/ui/OrderPage.tsx +++ b/src/features/cart/ui/OrderPage.tsx @@ -259,15 +259,23 @@ const OrderPage = () => { return; } - const order_products = cartItems.map((item) => ({ - inventory_kind: 'G', - product_code: item.product.code, - on_balance: 'Y', - order_quant: item.quantity, - price_type_code: item.product.prices?.[0]?.price_type?.code, - product_price: item.product.prices?.[0]?.price, - warehouse_code: 'wh1', - })); + const order_products = cartItems + .filter( + (item) => + item.product.prices && + item.product.prices.length > 0 && + item.product.prices[0].price_type?.code && + item.product.prices[0].price, + ) + .map((item) => ({ + inventory_kind: 'G', + product_code: item.product.code, + on_balance: 'Y', + order_quant: item.quantity, + price_type_code: item.product.prices![0].price_type.code, + product_price: item.product.prices![0].price, + warehouse_code: 'wh1', + })); mutate({ order: [ @@ -283,6 +291,7 @@ const OrderPage = () => { currency_code: '860', owner_person_code: '1234567', note: value.comment, + order_products: order_products, }, ],