error order update

This commit is contained in:
Samandar Turgunboyev
2025-12-23 16:16:14 +05:00
parent c2a4064951
commit af7b9fd590
6 changed files with 56 additions and 19 deletions

View File

@@ -25,6 +25,7 @@ import {
ZoomControl,
} from '@pbe/react-yandex-maps';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { AxiosError } from 'axios';
import {
CheckCircle2,
Clock,
@@ -84,11 +85,14 @@ const OrderPage = () => {
setCart(cart_id);
queryClinet.refetchQueries({ queryKey: ['cart_items'] });
},
onError: () => {
toast.error('Xatolik yuz berdi', {
richColors: true,
position: 'top-center',
});
onError: (error: AxiosError) => {
(
error.response?.data as { items: { non_field_errors: string[] }[] }
).items
?.flatMap((i) => i.non_field_errors || [])
.forEach((msg: string) =>
toast.error(msg, { richColors: true, position: 'top-center' }),
);
},
});
@@ -299,7 +303,7 @@ const OrderPage = () => {
<Input
{...field}
className="w-full border h-12 border-gray-300 rounded-lg px-4 py-3 focus:outline-none focus:border-blue-500"
placeholder={t('Ism Familiyangiz')}
placeholder={t('Familiyangiz')}
/>
</FormControl>
<FormMessage />