removed stok quantity, added hide/show function to brand field
This commit is contained in:
@@ -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}>
|
||||
|
||||
Reference in New Issue
Block a user