From af7b9fd590ef941c87e227120d447ce72970a66e Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Tue, 23 Dec 2025 16:16:14 +0500 Subject: [PATCH] error order update --- src/features/cart/ui/OrderPage.tsx | 16 +++++--- .../categories/ui/category-carousel.tsx | 2 + src/widgets/categories/ui/product-card.tsx | 1 + src/widgets/navbar/ui/ChangeLang.tsx | 4 +- src/widgets/navbar/ui/index.tsx | 38 ++++++++++++++++--- src/widgets/welcome/ui/index.tsx | 14 ++++--- 6 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/features/cart/ui/OrderPage.tsx b/src/features/cart/ui/OrderPage.tsx index 0eb740d..e37905f 100644 --- a/src/features/cart/ui/OrderPage.tsx +++ b/src/features/cart/ui/OrderPage.tsx @@ -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 = () => { diff --git a/src/widgets/categories/ui/category-carousel.tsx b/src/widgets/categories/ui/category-carousel.tsx index 05529a6..a84994e 100644 --- a/src/widgets/categories/ui/category-carousel.tsx +++ b/src/widgets/categories/ui/category-carousel.tsx @@ -125,6 +125,7 @@ export function CategoryCarousel({ category }: { category: CategoryResult }) { : 'bg-green-600/50 cursor-not-allowed', )} disabled={!canScrollNext} + aria-label="next images" size="icon" > @@ -137,6 +138,7 @@ export function CategoryCarousel({ category }: { category: CategoryResult }) { ? 'bg-green-600 hover:bg-green-600/70' : 'bg-green-600/50 cursor-not-allowed', )} + aria-label="prev images" disabled={!canScrollPrev} size="icon" > diff --git a/src/widgets/categories/ui/product-card.tsx b/src/widgets/categories/ui/product-card.tsx index 42d13dc..4f0acd2 100644 --- a/src/widgets/categories/ui/product-card.tsx +++ b/src/widgets/categories/ui/product-card.tsx @@ -191,6 +191,7 @@ export function ProductCard({ e.stopPropagation(); favouriteMutation.mutate(product.id); }} + aria-label="liked" className="absolute top-2 right-2 z-10 bg-white hover:bg-gray-200 cursor-pointer rounded-full p-1.5 sm:p-2 shadow hover:scale-110" > ) : ( ru )} diff --git a/src/widgets/navbar/ui/index.tsx b/src/widgets/navbar/ui/index.tsx index 544d057..2a1a213 100644 --- a/src/widgets/navbar/ui/index.tsx +++ b/src/widgets/navbar/ui/index.tsx @@ -144,32 +144,56 @@ const Navbar = () => { {/* Ijtimoiy tarmoqlar */}
  • - +
  • - +
  • - +
  • - +
  • - +
  • - +

    {formatPhone('+998901234567')}

    @@ -404,6 +428,7 @@ const Navbar = () => { variant={'ghost'} className="h-10 max-lg:hidden cursor-pointer border border-slate-200" onClick={() => router.push('/favourite')} + aria-label="my favouurite product" > @@ -427,6 +452,7 @@ const Navbar = () => { router.push('/auth'); } }} + aria-label="my account" className="h-10 max-lg:hidden cursor-pointer border border-slate-200" > diff --git a/src/widgets/welcome/ui/index.tsx b/src/widgets/welcome/ui/index.tsx index 0c6844f..5d68845 100644 --- a/src/widgets/welcome/ui/index.tsx +++ b/src/widgets/welcome/ui/index.tsx @@ -71,7 +71,7 @@ const Welcome = () => { {isLoading && ( - + )} {isError && ( @@ -88,11 +88,11 @@ const Welcome = () => { className="relative overflow-hidden rounded-2xl" > {banner.id} @@ -108,6 +109,7 @@ const Welcome = () => { className="absolute max-lg:w-6 max-lg:h-6 top-1/2 -translate-y-1/2 left-5 cursor-pointer" variant={'secondary'} size={'icon'} + aria-label="prev images" > @@ -146,6 +148,7 @@ const Welcome = () => { className="absolute max-lg:w-8 max-lg:h-8 top-1/2 -translate-y-1/2 -right-2 cursor-pointer" variant={'secondary'} size={'icon'} + aria-label="next images" > @@ -154,6 +157,7 @@ const Welcome = () => { className="absolute max-lg:w-8 max-lg:h-8 top-1/2 -translate-y-1/2 -left-2 cursor-pointer" variant={'secondary'} size={'icon'} + aria-label="prev images" >