diff --git a/frontend/application/components/CartDrawer.tsx b/frontend/application/components/CartDrawer.tsx index 727d816..e9f9767 100644 --- a/frontend/application/components/CartDrawer.tsx +++ b/frontend/application/components/CartDrawer.tsx @@ -9,6 +9,7 @@ import { productService } from "../lib/services/productService"; import SafeImage from "./SafeImage"; import { useUserStore } from "../lib/store/userStore"; import { useSettingsStore } from "../lib/store/settingsStore"; +import { useCatalogMode } from "../lib/useCatalogMode"; import AuthModal from "./AuthModal"; import DeleteConfirmModal from "./DeleteConfirmModal"; import { toast } from "sonner"; @@ -21,6 +22,7 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate }) { const { items, updateQuantity, removeItem, isSubscribed, toggleSubscription, getTotal, getSubtotal, getDiscount, coupon, applyCoupon, addItem } = useCartStore(); const { isLoggedIn } = useUserStore(); + const { showPrices } = useCatalogMode(); const isRefillEnabled = useSettingsStore((state) => state.getText('REFILL_SUBSCRIPTION_ENABLED', 'false') === 'true'); const refillPercent = useSettingsStore((state) => state.getText('REFILL_REWARD_PERCENT', '5')); const [isAuthModalOpen, setIsAuthModalOpen] = useState(false); @@ -168,10 +170,12 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate -
- {toPersian((item.product.priceValue * item.quantity).toLocaleString())} - تومان -
+ {showPrices && ( +
+ {toPersian((item.product.priceValue * item.quantity).toLocaleString())} + تومان +
+ )} {/* Delete Confirmation Overlay */} @@ -248,48 +252,50 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate {/* Footer */} {items.length > 0 && (
- {/* Discount Code */} -
-
- - کد تخفیف اختصاصی -
-
- setCouponCode(e.target.value)} - className={`w-full bg-white border ${couponStatus === 'error' ? 'border-red-300' : 'border-medical-gray-200'} rounded-2xl py-3 px-4 pr-10 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-canina-blue/20 transition-all`} - /> - -
- {coupon && ( -
-
-
- کد {coupon.code} ({(coupon.discount < 1 ? coupon.discount * 100 : coupon.discount)} {coupon.discount < 1 ? '٪' : 'تومان'}) اعمال شد -
+ {/* Discount Code (Only when prices are active) */} + {showPrices && ( +
+
+ + کد تخفیف اختصاصی +
+
+ setCouponCode(e.target.value)} + className={`w-full bg-white border ${couponStatus === 'error' ? 'border-red-300' : 'border-medical-gray-200'} rounded-2xl py-3 px-4 pr-10 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-canina-blue/20 transition-all`} + />
- )} -
+ {coupon && ( +
+
+
+ کد {coupon.code} ({(coupon.discount < 1 ? coupon.discount * 100 : coupon.discount)} {coupon.discount < 1 ? '٪' : 'تومان'}) اعمال شد +
+ +
+ )} +
+ )} {/* Subscription Toggle */} - {isRefillEnabled && ( + {showPrices && isRefillEnabled && (
{ if (!isLoggedIn && !isSubscribed) { @@ -336,25 +342,34 @@ export default function CartDrawer({ isOpen, onClose, onCheckout, onShopNavigate setIsAuthModalOpen(false)} /> -
-
- مجموع اقلام - {toPersian(getSubtotal().toLocaleString())} تومان -
- {getDiscount() > 0 && ( -
- مجموع تخفیف‌ها - -{toPersian(getDiscount().toLocaleString())} تومان + {showPrices ? ( +
+
+ مجموع اقلام + {toPersian(getSubtotal().toLocaleString())} تومان
- )} -
- مجموع قابل پرداخت -
-

{toPersian(getTotal().toLocaleString())}

-

تومان

+ {getDiscount() > 0 && ( +
+ مجموع تخفیف‌ها + -{toPersian(getDiscount().toLocaleString())} تومان +
+ )} +
+ مجموع قابل پرداخت +
+

{toPersian(getTotal().toLocaleString())}

+

تومان

+
-
+ ) : ( +
+ تعداد کل اقلام انتخابی + + {toPersian(items.reduce((acc, curr) => acc + curr.quantity, 0))} قلم کالا + +
+ )}
-
4304 nodes · 7945 edges · 313 communities
+
4304 nodes · 7950 edges · 312 communities