import React, { useState } from 'react'; import { PublicService } from '../../hooks/useBooking'; import { CreditCard, ShieldCheck, Lock } from 'lucide-react'; interface PaymentSectionProps { service: PublicService; onPaymentComplete: () => void; } export const PaymentSection: React.FC = ({ service, onPaymentComplete }) => { const [processing, setProcessing] = useState(false); const [cardNumber, setCardNumber] = useState(''); const [expiry, setExpiry] = useState(''); const [cvc, setCvc] = useState(''); // Convert cents to dollars const price = service.price_cents / 100; const deposit = (service.deposit_amount_cents || 0) / 100; // Auto-format card number const handleCardInput = (e: React.ChangeEvent) => { let val = e.target.value.replace(/\D/g, ''); val = val.substring(0, 16); val = val.replace(/(\d{4})/g, '$1 ').trim(); setCardNumber(val); }; const handlePayment = (e: React.FormEvent) => { e.preventDefault(); setProcessing(true); // Simulate Stripe Payment Intent & Processing setTimeout(() => { setProcessing(false); onPaymentComplete(); }, 2000); }; return (
{/* Payment Details Column */}

Card Details

{/* Mock Card Icons */}
setExpiry(e.target.value)} placeholder="MM / YY" className="block w-full px-3 py-3 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-indigo-500 focus:border-indigo-500 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 font-mono" />
setCvc(e.target.value)} placeholder="123" className="block w-full px-3 py-3 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-indigo-500 focus:border-indigo-500 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 font-mono" />

Your payment is secure. We use Stripe to process your payment. {deposit > 0 ? <>A deposit of ${deposit.toFixed(2)} will be charged now. : <>Full payment will be collected at your appointment.}

{/* Summary Column */}

Payment Summary

Service Total ${price.toFixed(2)}
Tax (Estimated) $0.00
Total ${price.toFixed(2)}
{deposit > 0 ? (
Due Now (Deposit) ${deposit.toFixed(2)}
Due at appointment ${(price - deposit).toFixed(2)}
) : (
Due at appointment ${price.toFixed(2)}
)}
); };