From b1fb8fb0c41ad79801c44f107506dddaa3ac59a9 Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Thu, 12 Feb 2026 17:19:19 +0500 Subject: [PATCH] bug fix --- src/features/cart/ui/OrderPage.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/features/cart/ui/OrderPage.tsx b/src/features/cart/ui/OrderPage.tsx index 96d8f12..c8bd42f 100644 --- a/src/features/cart/ui/OrderPage.tsx +++ b/src/features/cart/ui/OrderPage.tsx @@ -99,13 +99,21 @@ const OrderPage = () => { mutationFn: (body: OrderCreateBody) => cart_api.createOrder(body), onSuccess: (res) => { const message = JSON.parse(res.data.response); - if (message.successes.length > 0) { + + if (message.successes && message.successes.length > 0) { + // Buyurtma muvaffaqiyatli setOrderSuccess(true); setCart(cart_id); - queryClinet.refetchQueries({ queryKey: ['cart_items'] }); + } else if (message.errors && message.errors.length > 0) { + // Xatolik bo'lsa chiqarish + toast.error(t('Xatolik yuz berdi: ') + message.errors[0].message, { + richColors: true, + position: 'top-center', + }); } else { - toast.error(t('Xatolik yuz berdi: Mahsulot omborxonada yetarli emas'), { + // Boshqa noaniq holat + toast.error(t('Xatolik yuz berdi'), { richColors: true, position: 'top-center', }); @@ -280,13 +288,15 @@ const OrderPage = () => { warehouse_code: process.env.NEXT_PUBLIC_WARHOUSES_CODE!, })); if (user) { + const dealTime = formatDate.format(deliveryDate, 'DD.MM.YYYY'); + mutate({ order: [ { filial_code: process.env.NEXT_PUBLIC_FILIAL_CODE!, delivery_date: formatDate.format(deliveryDate, 'DD.MM.YYYY'), room_code: process.env.NEXT_PUBLIC_ROOM_CODE!, - deal_time: formatDate.format(deliveryDate, 'DD.MM.YYYY'), + deal_time: `${dealTime}`, robot_code: process.env.NEXT_PUBLIC_ROBOT_CODE!, status: 'B#N', sales_manager_code: process.env.NEXT_PUBLIC_SALES_MANAGER_CODE!,