diff --git a/src/features/category/ui/AllProduct.tsx b/src/features/category/ui/AllProduct.tsx index ff20cc0..3da3e6e 100644 --- a/src/features/category/ui/AllProduct.tsx +++ b/src/features/category/ui/AllProduct.tsx @@ -51,9 +51,7 @@ const AllProducts = () => { const params = new URLSearchParams(searchParams.toString()); params.set('page', newPage.toString()); - router.push(`${pathname}?${params.toString()}`, { - scroll: true, - }); + router.push(`${pathname}?${params.toString()}`); }; return ( diff --git a/src/features/product/ui/Product.tsx b/src/features/product/ui/Product.tsx index 01c9224..13555e7 100644 --- a/src/features/product/ui/Product.tsx +++ b/src/features/product/ui/Product.tsx @@ -42,8 +42,6 @@ const ProductDetail = () => { enabled: !!cart_id, }); - /* ---------------- DERIVED DATA ---------------- */ - const price = Number(data?.prices?.[0]?.price || 0); const maxBalance = data?.balance ?? 0; const measurement = data?.meansurement?.name?.toLowerCase() || ''; @@ -162,7 +160,13 @@ const ProductDetail = () => { /* ---------------- HANDLERS ---------------- */ const handleAddToCart = () => { - if (!data || !cart_id) return; + if (!data || !cart_id) { + toast.error(t('Tizimga kirilmagan'), { + richColors: true, + position: 'top-center', + }); + return; + } const normalizedQty = clampQuantity(numericQty); @@ -208,6 +212,10 @@ const ProductDetail = () => { }); }; + const subtotal = data?.prices?.length + ? Math.min(...data.prices.map((p) => Number(p.price))) + : 0; + /* ---------------- LOADING ---------------- */ if (isLoading) { return ( @@ -242,7 +250,7 @@ const ProductDetail = () => {
{formatPrice(
- Math.max(...product.prices.map((p) => Number(p.price))),
+ Math.min(...product.prices.map((p) => Number(p.price))),
true,
)}
diff --git a/src/widgets/navbar/ui/SearchResult.tsx b/src/widgets/navbar/ui/SearchResult.tsx
index 00380d8..bec9f2a 100644
--- a/src/widgets/navbar/ui/SearchResult.tsx
+++ b/src/widgets/navbar/ui/SearchResult.tsx
@@ -132,6 +132,7 @@ export const SearchResult = ({ query }: SearchResultProps) => {
{formatPrice(
Math.min(...product.prices.map((p) => Number(p.price))),
+ true,
)}