import React from 'react'; import { ShoppingCart, ShoppingBag, Trash2, RefreshCw, CreditCard, XCircle } from 'lucide-react'; import type { ModuleItem, Currency, UserProfile, VerificationResult } from '../../types'; interface CartDrawerProps { cart: ModuleItem[]; currency: Currency; setCurrency: (c: Currency) => void; toggleCartItem: (module: ModuleItem) => void; couponCode: string; setCouponCode: (code: string) => void; appliedCoupon: string | null; applyPromoCode: () => void; removePromoCode: () => void; pricingCalc: any; loadingPricing: boolean; loggedInUser: UserProfile | null; onUpdateBillingPhone: () => void; verificationResult: VerificationResult | null; checkoutLoading: boolean; handleCheckout: () => void; } export const CartDrawer: React.FC = ({ cart, currency, setCurrency, toggleCartItem, couponCode, setCouponCode, appliedCoupon, applyPromoCode, removePromoCode, pricingCalc, loadingPricing, loggedInUser, onUpdateBillingPhone, verificationResult, checkoutLoading, handleCheckout, }) => { return (

Cart Summary

{cart.length} {cart.length === 1 ? 'Item' : 'Items'}
{/* Currency selector toggle */}
Billing Currency:
{/* Selected modules list */} {cart.length === 0 ? (

Your checkout cart is empty. Select from curriculum.

) : (
{cart.map((item) => (

{item.name}

{item.category}

{currency === 'INR' ? `₹${item.priceInr}` : currency === 'EUR' ? `€${item.priceEur}` : `$${item.priceUsd}`}
))}
)} {/* Coupon Code Input */} {cart.length > 0 && (
setCouponCode(e.target.value)} placeholder="e.g. AGENT40, EVENT_NEW" className="flex-1 bg-white border border-slate-200 rounded-xl px-3 py-2 text-xs font-semibold text-slate-800 focus:outline-none focus:border-indigo-500 placeholder:text-slate-400 uppercase" />
{appliedCoupon && (pricingCalc?.coupon_error ? (
⚠️ {pricingCalc.coupon_error}
) : (
Coupon Active: {appliedCoupon} ✓{' '} {pricingCalc?.coupon_applied && pricingCalc.coupon_applied !== 'None' ? `(${pricingCalc.coupon_applied.replace(/Code: \w+ - /, '')})` : ''}
))}
)} {/* Checkout Summary Calculations */} {pricingCalc && cart.length > 0 && (
Base Subtotal {currency === 'INR' ? `₹${pricingCalc.base_subtotal}` : currency === 'EUR' ? `€${pricingCalc.base_subtotal}` : `$${pricingCalc.base_subtotal}`}
{pricingCalc.total_discounts > 0 && (
Total Discounts -{currency === 'INR' ? `₹${pricingCalc.total_discounts}` : currency === 'EUR' ? `€${pricingCalc.total_discounts}` : `$${pricingCalc.total_discounts}`}
)} {pricingCalc.convenience_fee > 0 && (
Gateway fee ({pricingCalc.convenience_fee_rate}%) {currency === 'INR' ? `₹${pricingCalc.convenience_fee}` : currency === 'EUR' ? `€${pricingCalc.convenience_fee}` : `$${pricingCalc.convenience_fee}`}
)} {pricingCalc.gst_amount > 0 && (
GST (18%) {currency === 'INR' ? `₹${pricingCalc.gst_amount}` : currency === 'EUR' ? `€${pricingCalc.gst_amount}` : `$${pricingCalc.gst_amount}`}
(Taxable Amount:{' '} {currency === 'INR' ? `₹${pricingCalc.taxable_amount}` : currency === 'EUR' ? `€${pricingCalc.taxable_amount}` : `$${pricingCalc.taxable_amount}`} )
)}
Total Chargeable {currency === 'INR' ? `₹${pricingCalc.grand_total}` : currency === 'EUR' ? `€${pricingCalc.grand_total}` : `$${pricingCalc.grand_total}`}
)} {/* Billing Details Prefill Summary */} {loggedInUser && cart.length > 0 && (
Billing Profile
Email: {loggedInUser.email}
Phone: {loggedInUser.phone_number || ( Required for checkout )}
)} {/* Verification failure result badge */} {verificationResult && verificationResult.status === 'error' && (

Verification Failed

{verificationResult.message}

)} {/* Checkout Trigger */} {cart.length > 0 && (

* Integrated with Razorpay Gateway API (Test Mode).

)}
); };