import React, { useCallback, useState } from 'react'; import { ActivityIndicator, FlatList, StyleSheet, Text, View } from 'react-native'; import { useFocusEffect } from '@react-navigation/native'; import { ps } from '@/api/client'; import { useTheme } from '@/theme/ThemeContext'; import type { CreditCardDetail } from 'parksmarter-client'; export function PaymentMethodsScreen() { const { colors } = useTheme(); const [cards, setCards] = useState([]); const [loading, setLoading] = useState(true); useFocusEffect( useCallback(() => { setLoading(true); ps.getUserDetail() .then((u) => setCards(u.CreditCardDetails ?? [])) .catch(() => setCards([])) .finally(() => setLoading(false)); }, []), ); if (loading) { return ( ); } return ( String(c.CCID ?? i)} ListHeaderComponent={ View only — add/edit coming later. } ListEmptyComponent={ No saved cards. } renderItem={({ item }) => ( {item.CCAlias || 'Card'} {String(item.CCDefault) === 'true' ? ( Default ) : null} •••• •••• •••• {item.CCLastFour ?? '••••'} Exp {item.CCExpDate ?? '--/--'} {item.CCZip ? ` · ZIP ${item.CCZip}` : ''} )} /> ); } const styles = StyleSheet.create({ center: { flex: 1, alignItems: 'center', justifyContent: 'center' }, note: { fontSize: 13, marginBottom: 12 }, card: { borderRadius: 12, padding: 16, marginBottom: 12 }, rowBetween: { flexDirection: 'row', justifyContent: 'space-between' }, brand: { fontSize: 16, fontWeight: '700' }, badge: { fontSize: 12, fontWeight: '700' }, num: { fontSize: 18, letterSpacing: 2, marginTop: 10, fontVariant: ['tabular-nums'] }, meta: { fontSize: 13, marginTop: 6 }, });