diff --git a/apps/spa/src/components/CartDrawer.tsx b/apps/spa/src/components/CartDrawer.tsx index 6bfe149..f6035ec 100644 --- a/apps/spa/src/components/CartDrawer.tsx +++ b/apps/spa/src/components/CartDrawer.tsx @@ -125,6 +125,10 @@ function CartDrawerFooter({ subtotal, onClose }: { subtotal: number; onClose: () const [isFreeShipping, setIsFreeShipping] = React.useState(false) const [couponValid, setCouponValid] = React.useState(false) const [activePromos, setActivePromos] = React.useState([]) + + const [couponInput, setCouponInput] = React.useState('') + const [couponLoading, setCouponLoading] = React.useState(false) + const [couponError, setCouponError] = React.useState('') React.useEffect(() => { fetch(`${API_BASE}/promotions/active`) @@ -164,6 +168,21 @@ function CartDrawerFooter({ subtotal, onClose }: { subtotal: number; onClose: () setDiscountAmount(0) setIsFreeShipping(false) setCouponValid(false) + setCouponError('') + setCouponInput('') + } + + const handleApplyCoupon = async () => { + if (!couponInput.trim()) return + setCouponLoading(true) + setCouponError('') + + // We must validate with subtotalAfterL2, but since we don't have it defined here yet, + // we'll calculate it inline or rely on the effect. Actually, we can just save it to localStorage and let the effect handle it. + localStorage.setItem('homaroma_active_coupon', couponInput.toUpperCase()) + setSavedCoupon(couponInput.toUpperCase()) + setCouponInput('') + setCouponLoading(false) } // Calculate Level 1 Promo @@ -185,6 +204,26 @@ function CartDrawerFooter({ subtotal, onClose }: { subtotal: number; onClose: () return (
+ + {/* Coupon Input */} + {!savedCoupon && ( +
+ setCouponInput(e.target.value.toUpperCase())} + placeholder={t('cart.couponPlaceholder', 'Discount Code')} + className="flex-1 bg-white border border-spa-stone/20 rounded-lg px-3 py-2 text-sm text-pop-black focus:border-spa-forest outline-none uppercase tracking-widest placeholder:text-spa-stone/50" + /> + +
+ )} {/* Totals */}
diff --git a/apps/spa/src/pages/CheckoutPage.tsx b/apps/spa/src/pages/CheckoutPage.tsx index 53684f6..1e11172 100644 --- a/apps/spa/src/pages/CheckoutPage.tsx +++ b/apps/spa/src/pages/CheckoutPage.tsx @@ -23,6 +23,7 @@ export default function CheckoutPage() { const [isFreeShipping, setIsFreeShipping] = useState(false) const [couponLoading, setCouponLoading] = useState(false) const [couponError, setCouponError] = useState('') + const [isSummaryExpanded, setIsSummaryExpanded] = useState(true) const [activePromos, setActivePromos] = useState([]) const [customerPoints, setCustomerPoints] = useState(0) @@ -293,9 +294,9 @@ export default function CheckoutPage() {

Checkout

-
+
{/* Form Section */} -
+

Shipping Information

@@ -357,12 +358,22 @@ export default function CheckoutPage() {
{/* Summary Section */} -
-
-

Order Summary

+
+
+ - {/* Coupon Section */} -
+
+ {/* Coupon Section */} +
{!appliedCoupon ? (
@@ -495,6 +506,8 @@ export default function CheckoutPage() {
+
{/* End Accordion Content */} +