bug fix
This commit is contained in:
@@ -99,13 +99,21 @@ const OrderPage = () => {
|
|||||||
mutationFn: (body: OrderCreateBody) => cart_api.createOrder(body),
|
mutationFn: (body: OrderCreateBody) => cart_api.createOrder(body),
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
const message = JSON.parse(res.data.response);
|
const message = JSON.parse(res.data.response);
|
||||||
if (message.successes.length > 0) {
|
|
||||||
|
if (message.successes && message.successes.length > 0) {
|
||||||
|
// Buyurtma muvaffaqiyatli
|
||||||
setOrderSuccess(true);
|
setOrderSuccess(true);
|
||||||
setCart(cart_id);
|
setCart(cart_id);
|
||||||
|
|
||||||
queryClinet.refetchQueries({ queryKey: ['cart_items'] });
|
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 {
|
} else {
|
||||||
toast.error(t('Xatolik yuz berdi: Mahsulot omborxonada yetarli emas'), {
|
// Boshqa noaniq holat
|
||||||
|
toast.error(t('Xatolik yuz berdi'), {
|
||||||
richColors: true,
|
richColors: true,
|
||||||
position: 'top-center',
|
position: 'top-center',
|
||||||
});
|
});
|
||||||
@@ -280,13 +288,15 @@ const OrderPage = () => {
|
|||||||
warehouse_code: process.env.NEXT_PUBLIC_WARHOUSES_CODE!,
|
warehouse_code: process.env.NEXT_PUBLIC_WARHOUSES_CODE!,
|
||||||
}));
|
}));
|
||||||
if (user) {
|
if (user) {
|
||||||
|
const dealTime = formatDate.format(deliveryDate, 'DD.MM.YYYY');
|
||||||
|
|
||||||
mutate({
|
mutate({
|
||||||
order: [
|
order: [
|
||||||
{
|
{
|
||||||
filial_code: process.env.NEXT_PUBLIC_FILIAL_CODE!,
|
filial_code: process.env.NEXT_PUBLIC_FILIAL_CODE!,
|
||||||
delivery_date: formatDate.format(deliveryDate, 'DD.MM.YYYY'),
|
delivery_date: formatDate.format(deliveryDate, 'DD.MM.YYYY'),
|
||||||
room_code: process.env.NEXT_PUBLIC_ROOM_CODE!,
|
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!,
|
robot_code: process.env.NEXT_PUBLIC_ROBOT_CODE!,
|
||||||
status: 'B#N',
|
status: 'B#N',
|
||||||
sales_manager_code: process.env.NEXT_PUBLIC_SALES_MANAGER_CODE!,
|
sales_manager_code: process.env.NEXT_PUBLIC_SALES_MANAGER_CODE!,
|
||||||
|
|||||||
Reference in New Issue
Block a user