import React from 'react'; import { View, Text, StyleSheet, FlatList } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { Icon } from '../../../components/Icon'; import Animated, { FadeInUp } from 'react-native-reanimated'; import { ScreenShell } from '../../../components'; import { useTheme, fontFamily } from '../../../theme'; import { useAppSelector } from '../../../app/hooks'; import { selectCustomerById } from '../store/agentSelectors'; import type { AgentCustomersStackParamList } from '../navigation/agentNavigationTypes'; import { formatAgentCurrency, formatDateTime } from '../utils/agentFormatters'; import { AgentEmptyState } from '../components/AgentEmptyState'; type Props = NativeStackScreenProps; export default function CustomerInstallmentHistoryScreen({ route, navigation }: Props) { const { customerId } = route.params; const theme = useTheme(); const customer = useAppSelector(selectCustomerById(customerId)); if (!customer) { return ( ); } // Generate mock history based on totalCollected for demo purposes const history = Array.from({ length: 10 }).map((_, i) => { const isPaid = i < (customer.totalCollected / 500); const date = new Date(); date.setDate(date.getDate() - (i * 30)); return { id: `hist-${i}`, amount: 500, date: date.toISOString(), status: isPaid ? 'paid' : 'pending', receiptNo: isPaid ? `RCP-${date.getFullYear()}${String(date.getMonth()+1).padStart(2,'0')}${String(date.getDate()).padStart(2,'0')}-${1000+i}` : null, }; }); const renderItem = ({ item, index }: { item: any, index: number }) => ( {formatDateTime(item.date)} {item.receiptNo ? ( {item.receiptNo} ) : ( Pending Installment )} {formatAgentCurrency(item.amount)} {item.status.toUpperCase()} ); return ( {customer.name} {customer.accounts[0]?.type} A/C: {customer.accounts[0]?.accountNumber} item.id} renderItem={renderItem} contentContainerStyle={styles.listContent} showsVerticalScrollIndicator={false} /> ); } const styles = StyleSheet.create({ header: { padding: 16, paddingTop: 8, borderBottomWidth: 1, }, customerName: { fontSize: 18, fontFamily: fontFamily.bold, marginBottom: 4, }, accNumber: { fontSize: 14, fontFamily: fontFamily.mono, }, listContent: { padding: 16, }, card: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 16, borderRadius: 16, borderWidth: 1, marginBottom: 12, }, leftSide: { flexDirection: 'row', alignItems: 'center', gap: 12, }, iconFrame: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', }, date: { fontSize: 14, fontFamily: fontFamily.semibold, marginBottom: 2, }, receipt: { fontSize: 11, }, rightSide: { alignItems: 'flex-end', }, amount: { fontSize: 15, fontFamily: fontFamily.bold, marginBottom: 2, }, status: { fontSize: 10, fontFamily: fontFamily.bold, }, });