From ea097d39539a307edc2fbdd257bddf593f228392 Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Wed, 18 Feb 2026 10:33:01 +0500 Subject: [PATCH] refresh api logout and login --- src/features/auth/ui/Login.tsx | 3 +-- src/features/cart/ui/CartPage.tsx | 4 ++-- src/features/cart/ui/OrderPage.tsx | 6 +++--- src/features/product/ui/Product.tsx | 2 +- src/features/profile/ui/Profile.tsx | 13 ++----------- src/shared/ui/global-pagination.tsx | 2 +- src/widgets/categories/ui/product-card.tsx | 2 +- src/widgets/navbar/ui/SearchResult.tsx | 4 +++- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/features/auth/ui/Login.tsx b/src/features/auth/ui/Login.tsx index bb6c28c..70fea41 100644 --- a/src/features/auth/ui/Login.tsx +++ b/src/features/auth/ui/Login.tsx @@ -45,8 +45,7 @@ const Login = () => { setRefToken(res.data.refresh); setUser(form.getValues('username')); router.push('/'); - queryClient.refetchQueries({ queryKey: ['product_list'] }); - queryClient.refetchQueries({ queryKey: ['get_me'] }); + queryClient.refetchQueries(); }, onError: () => { toast.error(t('Username yoki parol xato kiritildi'), { diff --git a/src/features/cart/ui/CartPage.tsx b/src/features/cart/ui/CartPage.tsx index 0281f83..35573d5 100644 --- a/src/features/cart/ui/CartPage.tsx +++ b/src/features/cart/ui/CartPage.tsx @@ -125,7 +125,7 @@ const CartPage = () => { const subtotal = cartItems.reduce((sum, item) => { if (!item.product.prices.length) return sum; - const maxPrice = Math.max( + const maxPrice = Math.min( ...item.product.prices.map((p) => Number(p.price)), ); return sum + maxPrice * (quantities[item.id] || item.quantity); @@ -228,7 +228,7 @@ const CartPage = () => {
{formatPrice( - Math.max( + Math.min( ...item.product.prices.map((p) => Number(p.price)), ), true, diff --git a/src/features/cart/ui/OrderPage.tsx b/src/features/cart/ui/OrderPage.tsx index 823f129..c1e4651 100644 --- a/src/features/cart/ui/OrderPage.tsx +++ b/src/features/cart/ui/OrderPage.tsx @@ -143,7 +143,7 @@ const OrderPage = () => { if (item.product.prices.length === 0) return sum; // narx yo'q bo'lsa qo'shmaymiz // Eng yuqori narxni olish - const maxPrice = Math.max( + const maxPrice = Math.min( ...item.product.prices.map((p) => Number(p.price)), ); @@ -587,7 +587,7 @@ const OrderPage = () => { {item.quantity} x{' '} {formatPrice( item.product.prices.length !== 0 - ? Math.max( + ? Math.min( ...item.product.prices.map((p) => Number(p.price), ), @@ -599,7 +599,7 @@ const OrderPage = () => {

{formatPrice( item.product.prices.length !== 0 - ? Math.max( + ? Math.min( ...item.product.prices.map((p) => Number(p.price), ), diff --git a/src/features/product/ui/Product.tsx b/src/features/product/ui/Product.tsx index 233f756..12eae77 100644 --- a/src/features/product/ui/Product.tsx +++ b/src/features/product/ui/Product.tsx @@ -200,7 +200,7 @@ const ProductDetail = () => { setQuantity((q) => { let next = q - STEP; if (isGram) next = Math.floor(next / STEP) * STEP; - return Math.max(MIN_QTY, next); + return Math.min(MIN_QTY, next); }); }; diff --git a/src/features/profile/ui/Profile.tsx b/src/features/profile/ui/Profile.tsx index 1c8bb53..1dc70a8 100644 --- a/src/features/profile/ui/Profile.tsx +++ b/src/features/profile/ui/Profile.tsx @@ -115,10 +115,7 @@ const Profile = () => {