import { InvoiceItem } from '@/types/types';
import { ArrowRight, FileText, MapPin } from 'lucide-react-native';
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';

interface InvoiceCardProps {
    item: InvoiceItem;
    onPress: (id: number) => void;
}

function InvoiceCard({ item, onPress }: InvoiceCardProps) {
    return (
        <TouchableOpacity
            onPress={() => onPress(item.id)}
            className="bg-white p-5 rounded-3xl shadow-sm border border-gray-100 flex-row justify-between items-center active:bg-gray-50"
        >
            <View className="flex-row items-center gap-4 flex-1">
                <View className="p-4 rounded-2xl bg-blue-50">
                    <FileText size={24} color="#1071C2" />
                </View>
                <View className="flex-1">
                    <View className="mb-0.5">
                        <Text className="text-gray-500 text-xs font-bold uppercase mt-1">N° {item.documentNumber} del {item.date}</Text>
                    </View>
                    <Text className="font-bold text-gray-800 text-lg mb-1" numberOfLines={1}>{item.supplier}</Text>
                    <View className="flex-row items-center justify-between mt-1 gap-2">
                        <View className="flex-row items-center gap-1 flex-1">
                            <MapPin size={12} color="#8F9BB3" />
                            <Text className="text-[#8F9BB3] text-xs font-medium flex-1" numberOfLines={1}>{item.placeName}</Text>
                        </View>
                        <Text className="font-bold text-[#1071C2] text-base leading-tight">{item.totalAmount}</Text>
                    </View>
                </View>
            </View>
            <View className="ml-3">
                <ArrowRight size={20} color="#D1D5DB" />
            </View>
        </TouchableOpacity>
    );
}

export default React.memo(InvoiceCard);
