This commit is contained in:
Samandar Turgunboyev
2026-02-12 17:19:19 +05:00
parent ed4601b8e8
commit b1fb8fb0c4

View File

@@ -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!,