From fcb016589b4d83eba15ed480eab9eedaf0a8eddf Mon Sep 17 00:00:00 2001 From: Jelaletdin12 Date: Sun, 1 Feb 2026 21:50:41 +0500 Subject: [PATCH] removed stok quantity, added hide/show function to brand field --- src/components/Footer/index.jsx | 2 +- src/pages/Cart/index.jsx | 5 ----- src/pages/ProductDetail/index.jsx | 37 +++++++++++++++---------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/components/Footer/index.jsx b/src/components/Footer/index.jsx index f989421..fa8a8cd 100644 --- a/src/components/Footer/index.jsx +++ b/src/components/Footer/index.jsx @@ -100,7 +100,7 @@ const Footer = () => {
-

© 2019-2025 mm.com.tm {t("footer.copyright")}

+

© 2019-2026 mm.com.tm {t("footer.copyright")}

diff --git a/src/pages/Cart/index.jsx b/src/pages/Cart/index.jsx index cad86e9..5f0464a 100644 --- a/src/pages/Cart/index.jsx +++ b/src/pages/Cart/index.jsx @@ -198,7 +198,6 @@ const CartPage = () => { const item = cartItems.find((item) => item.product.id === productId); if (!item) return; - // ✅ Stock kontrolü if (localQuantities[productId] >= item.product.stock) { return; } @@ -222,7 +221,6 @@ const CartPage = () => { const currentQuantity = localQuantities[productId] || 0; - // ✅ 1'den azsa modal göster if (currentQuantity <= 1) { showDeleteConfirm(productId); return; @@ -267,7 +265,6 @@ const CartPage = () => { if (checkoutStores[storeId] && checkoutRefs.current[storeId]) { const success = await checkoutRefs.current[storeId](); if (success) { - // ✅ RTK Query otomatik güncelleyecek, refetch'e gerek yok setCheckoutStores(prev => ({ ...prev, [storeId]: false })); } } else { @@ -295,9 +292,7 @@ const CartPage = () => { if (itemToDelete) { try { await removeFromCart({ productId: itemToDelete }).unwrap(); - // ✅ RTK Query otomatik cache'i güncelleyecek - // ✅ Local state'i de temizle setLocalQuantities((prev) => { const newState = { ...prev }; delete newState[itemToDelete]; diff --git a/src/pages/ProductDetail/index.jsx b/src/pages/ProductDetail/index.jsx index 729408a..bf4f455 100644 --- a/src/pages/ProductDetail/index.jsx +++ b/src/pages/ProductDetail/index.jsx @@ -58,7 +58,7 @@ const ProductPage = ({ const { data: favoriteProducts = [], refetch } = useGetFavoritesQuery(); const [isLoading, setIsLoading] = useState(false); const [localIsFavorite, setLocalIsFavorite] = useState( - favoriteProducts.some((fav) => fav.product?.id === product?.id) + favoriteProducts.some((fav) => fav.product?.id === product?.id), ); const { data: cartData } = useGetCartQuery(undefined, { selectFromResult: (result) => ({ @@ -78,7 +78,7 @@ const ProductPage = ({ return allCartItems.find( (item) => - item.product?.id === product?.id || item.product_id === product?.id + item.product?.id === product?.id || item.product_id === product?.id, ); }; @@ -98,7 +98,7 @@ const ProductPage = ({ useEffect(() => { if (Array.isArray(favoriteProducts)) { const isFav = favoriteProducts.some( - (fav) => fav.product?.id === product?.id + (fav) => fav.product?.id === product?.id, ); setLocalIsFavorite(isFav); } @@ -141,16 +141,15 @@ const ProductPage = ({ return; } - // Badge sayısını anında güncelle setLocalQuantity((prev) => prev + 1); - setPendingQuantity((prev) => prev + 1); // Hemen güncelle + setPendingQuantity((prev) => prev + 1); try { await addToCart({ productId: product.id, quantity: 1 }).unwrap(); } catch (error) { console.error("Failed to add to cart:", error); - setLocalQuantity((prev) => prev - 1); // Başarısız olursa geri al - setPendingQuantity((prev) => prev - 1); // Başarısız olursa geri al + setLocalQuantity((prev) => prev - 1); + setPendingQuantity((prev) => prev - 1); } }; @@ -300,18 +299,18 @@ const ProductPage = ({ {product.id} -
- {t("product.barCode")} - {product.barcode} -
-
- Brand - {product.brand.name} -
-
- Stokta - {product.stock} -
+ {product.barcode && ( +
+ {t("product.barCode")} + {product.barcode} +
+ )} + {product.brand?.name && ( +
+ {t("order.brand")} + {product.brand.name} +
+ )}