removed stok quantity, added hide/show function to brand field

This commit is contained in:
Jelaletdin12
2026-02-01 21:50:41 +05:00
parent a143c2e18b
commit fcb016589b
3 changed files with 19 additions and 25 deletions

View File

@@ -100,7 +100,7 @@ const Footer = () => {
</div>
</div>
<div className={styles.bottom}>
<p> © 2019-2025 mm.com.tm {t("footer.copyright")}</p>
<p> © 2019-2026 mm.com.tm {t("footer.copyright")}</p>
</div>
</footer>
<FooterBar />

View File

@@ -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];

View File

@@ -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 = ({
</span>
<span className={styles.metaValue}>{product.id}</span>
</div>
<div className={styles.metaItem}>
<span className={styles.metaLabel}>{t("product.barCode")}</span>
<span className={styles.metaValue}>{product.barcode}</span>
</div>
<div className={styles.metaItem}>
<span className={styles.metaLabel}>Brand</span>
<span className={styles.metaValue}>{product.brand.name}</span>
</div>
<div className={styles.metaItem}>
<span className={styles.metaLabel}>Stokta</span>
<span className={styles.metaValue}>{product.stock}</span>
</div>
{product.barcode && (
<div className={styles.metaItem}>
<span className={styles.metaLabel}>{t("product.barCode")}</span>
<span className={styles.metaValue}>{product.barcode}</span>
</div>
)}
{product.brand?.name && (
<div className={styles.metaItem}>
<span className={styles.metaLabel}>{t("order.brand")}</span>
<span className={styles.metaValue}>{product.brand.name}</span>
</div>
)}
</div>
<div className={styles.productActions}>
<div className={styles.priceContainer}>