import React, { useCallback, useEffect } from 'react';
import {
View,
Text,
SafeAreaView,
FlatList,
TouchableOpacity,
} from 'react-native';
// import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { Header } from '@components';
import { useAppTheme } from '@theme';
import { getStyles } from './walletScreen.styles';
import { WalletTransaction } from '@interfaces';
import { useAppDispatch, useAppSelector } from '@store';
import { getAllWalletTransactions } from './thunk';
import { useFocusEffect } from '@react-navigation/native';
import { getWalletBalanceThunk } from '../accountScreen';
// const balance = 17496.05;
// const transactions: WalletTransaction[] = [
// {
// id: '1',
// walletId: '',
// transactionReference: 'TXN-1784543790637-2387',
// direction: 'OUT',
// amount: '1408.95',
// balanceBefore: '18905',
// balanceAfter: '17496.05',
// type: 'PAYMENT',
// referenceId: null,
// description: null,
// idempotencyKey: null,
// createdAt: '2026-07-20T10:36:30.639Z',
// },
// {
// id: '2',
// walletId: '',
// transactionReference: 'TXN-1784199810512-8502',
// direction: 'OUT',
// amount: '1095',
// balanceBefore: '20000',
// balanceAfter: '18905',
// type: 'PAYMENT',
// referenceId: null,
// description: null,
// idempotencyKey: null,
// createdAt: '2026-07-16T11:03:30.515Z',
// },
// ];
const WalletScreen = () => {
const { colors } = useAppTheme();
const styles = getStyles(colors);
const dispatch = useAppDispatch();
const { walletTransactions } = useAppSelector(state => state.wallet);
const { wallet } = useAppSelector(state => state.account);
useFocusEffect(
useCallback(() => {
dispatch(getAllWalletTransactions());
dispatch(getWalletBalanceThunk());
}, []),
);
const renderItem = ({ item }: { item: WalletTransaction }) => {
const isCredit = item.direction === 'IN';
return (
{/* */}
{item.type}
{item.transactionReference}
{new Date(item.createdAt).toLocaleString()}
{isCredit ? '+' : '-'}₹{item.amount}
Bal ₹{item.balanceAfter}
);
};
return (
Available Balance
₹{wallet?.balance.toFixed(2)}
{/* */}
Add Money
Recent Transactions
item.id}
renderItem={renderItem}
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.listContainer}
ListEmptyComponent={
{/* */}
No Transactions Yet
}
/>
);
};
export default WalletScreen;