Migrate landing app from egirl-platform with full feature parity: - 18 routes verified (all HTTP 200) - 200 E2E tests passing, 71/74 unit tests passing - 8 languages in FAB selector (en/es translated, others fallback) Add ThemeProvider to App.tsx for styled-components theme context. Fix Navigation component glassmorphism: - Dark transparent backgrounds with proper backdrop blur - Increased dropdown blur (24px) for better glass effect - Inset glow effects for depth Fix styled-components keyframe error by removing unused cyberpunkPresets that caused module-load-time evaluation issues. Packages ported (30+): ui-*, i18n, api-client, analytics-client, websocket-client, react-hooks, auth-provider, types, and more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
173 lines
4.2 KiB
TypeScript
173 lines
4.2 KiB
TypeScript
/**
|
|
* PaymentMethodSelector Usage Examples
|
|
*
|
|
* This file demonstrates how to use the PaymentMethodSelector component
|
|
* in different scenarios.
|
|
*/
|
|
|
|
import { useState } from 'react'
|
|
import { PaymentMethodSelector } from './PaymentMethodSelector'
|
|
|
|
/**
|
|
* Example 1: Basic usage with both card and crypto options
|
|
*/
|
|
export function BasicPaymentMethodSelector() {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>()
|
|
|
|
return (
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => {
|
|
console.log(`Add new ${type} payment method`)
|
|
// Open modal to add payment method
|
|
}}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Example 2: Card-only selector
|
|
*/
|
|
export function CardOnlySelector() {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>()
|
|
|
|
return (
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => {
|
|
console.log(`Add new ${type} payment method`)
|
|
}}
|
|
allowedTypes={['card']}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Example 3: Crypto-only selector
|
|
*/
|
|
export function CryptoOnlySelector() {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>()
|
|
|
|
return (
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => {
|
|
console.log(`Add new ${type} payment method`)
|
|
}}
|
|
allowedTypes={['crypto']}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Example 4: Disabled state
|
|
*/
|
|
export function DisabledSelector() {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>('pm-123')
|
|
|
|
return (
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => {
|
|
console.log(`Add new ${type} payment method`)
|
|
}}
|
|
disabled={true}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Example 5: Integration with subscription purchase flow
|
|
*/
|
|
export function SubscriptionPaymentFlow() {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>()
|
|
const [showAddModal, setShowAddModal] = useState<'card' | 'crypto' | null>(null)
|
|
|
|
const handlePurchase = async () => {
|
|
if (!selectedMethodId) {
|
|
alert('Please select a payment method')
|
|
return
|
|
}
|
|
|
|
// Process subscription purchase with selected payment method
|
|
console.log('Processing subscription with method:', selectedMethodId)
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h2>Subscribe to Premium</h2>
|
|
<p>Select a payment method to continue</p>
|
|
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => setShowAddModal(type)}
|
|
/>
|
|
|
|
<button
|
|
onClick={handlePurchase}
|
|
disabled={!selectedMethodId}
|
|
style={{ marginTop: '16px' }}
|
|
>
|
|
Complete Purchase
|
|
</button>
|
|
|
|
{showAddModal && (
|
|
<div>Add {showAddModal} modal would open here</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Example 6: Integration with booking deposit payment
|
|
*/
|
|
export function BookingDepositPayment({ bookingId }: { bookingId: string }) {
|
|
const [selectedMethodId, setSelectedMethodId] = useState<string>()
|
|
const [isProcessing, setIsProcessing] = useState(false)
|
|
|
|
const handlePayDeposit = async () => {
|
|
if (!selectedMethodId) return
|
|
|
|
setIsProcessing(true)
|
|
try {
|
|
// Process booking deposit payment
|
|
console.log('Processing deposit for booking:', bookingId, 'with method:', selectedMethodId)
|
|
// await api.createPaymentIntent({ ... })
|
|
} finally {
|
|
setIsProcessing(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h3>Pay Booking Deposit</h3>
|
|
|
|
<PaymentMethodSelector
|
|
userId="user-123"
|
|
selectedMethodId={selectedMethodId}
|
|
onSelect={setSelectedMethodId}
|
|
onAddNew={(type) => {
|
|
console.log(`Redirect to add ${type} payment method`)
|
|
}}
|
|
disabled={isProcessing}
|
|
/>
|
|
|
|
<button
|
|
onClick={handlePayDeposit}
|
|
disabled={!selectedMethodId || isProcessing}
|
|
>
|
|
{isProcessing ? 'Processing...' : 'Pay Deposit'}
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|