import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'; import Animated, { FadeIn, FadeOut, Layout, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated'; import { ChevronDown, Trash2, Info } from 'lucide-react-native'; import { InsideHeader } from '../../Component/Index'; import colors from '../../Constant/Color'; import { useNavigation } from '@react-navigation/native'; import NavigationString from '../../Constant/NavigationString'; import { useDispatch, useSelector } from 'react-redux'; import { togglePurchaseAuction } from '../../Redux/Slices/selectPurchaseAuction'; const PurchaseList = () => { const Navigation: any = useNavigation() const Dispatch = useDispatch() const [expandedIndex, setExpandedIndex] = useState(null); const SelectedPurchaseList = useSelector((state: any) => state.selectPurchaseAuction); const toggleExpand = (index: number) => { setExpandedIndex(prev => (prev === index ? null : index)); }; return ( {/* Header */} Purchase List {/* Cards */} {SelectedPurchaseList.map((item: any, index: any) => { const expanded = expandedIndex === index; return ( toggleExpand(index)} > Auction No: {item.auctionNumber} Status:{' '} {item.status ? 'Open' : 'Closed'} {/* Expanded Content */} {expanded && ( {renderRow('Auction Mode', item.auctionMode)} {renderRow('Pattern', item.auctionPattern)} {renderRow('Fees', `₹ ${item.auctionFees}`)} {renderRow('Department', item.deptName)} {renderRow('Purchase End', item.purchaseEnd)} { Dispatch(togglePurchaseAuction(item)) }}> Remove )} ); })} {/* Footer */} { Navigation.navigate(NavigationString.PurchaseAuctionList) }}> Proceed to Purchase ); }; export default PurchaseList; const CardHeader = ({ title, expanded }: { title: string; expanded: boolean; }) => { const rotation = useSharedValue(expanded ? 1 : 0); rotation.value = withTiming(expanded ? 1 : 0, { duration: 220 }); const arrowStyle = useAnimatedStyle(() => ({ transform: [{ rotate: `${rotation.value * 180}deg` }], })); return ( {title} ); }; const renderRow = (label: string, value: string) => ( {label} {value} ); const styles = StyleSheet.create({ screen: { flex: 1, backgroundColor: '#F8FAFC', }, container: { padding: 16, paddingBottom: 110, }, header: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 14, }, heading: { fontSize: 22, fontWeight: '800', color: colors.black, }, card: { backgroundColor: '#fff', borderRadius: 18, padding: 16, marginBottom: 14, borderWidth: 1, borderColor: '#E5E7EB', }, cardHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, title: { fontSize: 16, fontWeight: '700', color: '#0F172A', flex: 1, marginRight: 12, }, subTitle: { fontSize: 14, color: '#64748B', marginTop: 6, }, details: { marginTop: 16, paddingTop: 14, borderTopWidth: 1, borderTopColor: '#E5E7EB', }, row: { marginVertical: 6, }, label: { fontSize: 13, color: '#64748B', }, value: { fontSize: 15, fontWeight: '600', color: '#0F172A', }, removeButton: { marginTop: 18, backgroundColor: colors.primary, borderRadius: 14, paddingVertical: 12, flexDirection: 'row', justifyContent: 'center', gap: 8, }, removeText: { color: '#fff', fontWeight: '700', }, proceedButton: { position: 'absolute', bottom: 16, left: 16, right: 16, backgroundColor: colors.primary, paddingVertical: 16, borderRadius: 18, alignItems: 'center', }, proceedText: { color: '#fff', fontSize: 16, fontWeight: '800', }, });