import React, { memo, useState, useMemo } from 'react'; import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform, Modal } from 'react-native'; import { Package, IndianRupee, FileText, Download, ArrowLeft, Info, } from 'lucide-react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useAucitonItemDetail } from '../../../Services/ApiCall/Hooks'; import ReactNativeBlobUtil from 'react-native-blob-util'; import { AUCTION_ITEM_DOCUMENT_DOWNLOAD } from '../../../Services/ApiCall/ApiUrls'; import { Loader } from '../../../Component/Index'; import { useTheme } from '../../../Hooks/useTheme'; import AppText from '../../../components/AppText'; interface Props { visible: boolean; onClose: () => void; data?: any; } const Section = ({ title, icon: Icon, children, styles, colors }: any) => ( {title} {children} ); const PriceTile = ({ label, fig, words, full = false, styles }: any) => ( {label} ₹{Number(fig).toLocaleString('en-IN')} {words} ); const AuctionItemDetail: React.FC = ({ visible, onClose, data }) => { const inset = useSafeAreaInsets() const { colors, typography } = useTheme(); const styles = useMemo(() => createStyles(colors, typography), [colors, typography]); const [allBoolean, setAllBoolean] = useState({ fileLoading: false }); const { data: itemData } = useAucitonItemDetail({ auctionItemId: data?.id }); const handleDownload = async (id: number, fileName: string) => { try { setAllBoolean((prev: any) => ({ ...prev, fileLoading: true })); const { dirs } = ReactNativeBlobUtil.fs; const path = `${dirs.DownloadDir}/${fileName}.pdf`; const downloadUrl = `${AUCTION_ITEM_DOCUMENT_DOWNLOAD}?auctionItemId=${id}`; const response = await ReactNativeBlobUtil.config({ fileCache: false, addAndroidDownloads: { useDownloadManager: true, notification: true, path, mime: 'application/pdf', title: `${fileName}.pdf`, description: 'Downloading document', mediaScannable: true, }, }).fetch('GET', downloadUrl, { Accept: 'application/pdf', }); const stat = await ReactNativeBlobUtil.fs.stat(path); } catch (error: any) { console.log('Error:', error?.message || error); } finally { setAllBoolean((prev: any) => ({ ...prev, fileLoading: false })); } }; return ( {/* Navbar */} Item Information Detail View
{data?.productName?.toUpperCase()} {data?.categoryName} Sub Category {data?.subCategoryName} Duration {data?.timeDurationType}
{data?.briefDescription}
{itemData?.length &&
Sr No. Document Name Action {itemData?.map((doc: any, index: any) => ( { handleDownload(doc.assetId, doc.fileName) }} key={doc.assetId}> {index + 1} {doc.fileName} {allBoolean.fileLoading ? ( ) : ( )} ))}
}
); }; const createStyles = (colors: any, typography: any) => StyleSheet.create({ fullModal: { margin: 0, backgroundColor: colors.background }, safeArea: { flex: 1, backgroundColor: colors.background }, header: { flexDirection: 'row', alignItems: 'center', padding: 16, backgroundColor: colors.surface, borderBottomWidth: 1, borderBottomColor: colors.border, }, backBtn: { padding: 8, marginRight: 8 }, headerTitle: { fontSize: 18, color: colors.text }, headerSub: { fontSize: 12, color: colors.textSecondary, textTransform: 'uppercase' }, scrollView: { flex: 1 }, scrollContent: { padding: 16, paddingBottom: 50 }, sectionCard: { backgroundColor: colors.surface, borderRadius: 24, padding: 20, marginBottom: 16, ...Platform.select({ ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.05, shadowRadius: 10 }, android: { elevation: 3 } }) }, sectionHeader: { flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 20, }, iconCircle: { width: 36, height: 36, borderRadius: 12, backgroundColor: colors.primary + '10', alignItems: 'center', justifyContent: 'center', }, sectionTitle: { fontSize: 14, color: colors.text, textTransform: 'uppercase', letterSpacing: 0.5, }, // Product Identity identityHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 15 }, productNameText: { fontSize: 20, color: colors.text, flex: 1 }, categoryBadge: { backgroundColor: colors.border, paddingHorizontal: 12, paddingVertical: 6, borderRadius: 20 }, categoryText: { fontSize: 11, color: colors.textSecondary, textTransform: 'uppercase' }, specGrid: { flexDirection: 'row', gap: 24, marginTop: 5 }, specItem: { flex: 1 }, specValue: { fontSize: 15, color: colors.text, marginTop: 2 }, // Pricing priceTile: { marginBottom: 16 }, label: { fontSize: 11, color: colors.textSecondary, textTransform: 'uppercase', marginBottom: 4 }, priceFig: { fontSize: 22, color: colors.text }, priceWords: { fontSize: 13, color: colors.textSecondary, fontStyle: 'italic', marginTop: 2 }, hDivider: { height: 1, backgroundColor: colors.border, marginBottom: 16 }, row: { flexDirection: 'row', justifyContent: 'space-between' }, // Description descContent: { fontSize: 15, color: colors.textSecondary, lineHeight: 22, fontFamily: typography.fonts.medium }, // Table docTableHead: { flexDirection: 'row', paddingBottom: 10, borderBottomWidth: 1, borderBottomColor: colors.border, marginBottom: 10 }, tableLabel: { fontSize: 11, color: colors.textSecondary, flex: 1 }, docRow: { flexDirection: 'row', alignItems: 'center', backgroundColor: colors.background, padding: 12, borderRadius: 12 }, docIndex: { flex: 1, fontSize: 14, color: colors.textSecondary }, docTitle: { fontSize: 14, color: colors.text }, downloadIconBox: { backgroundColor: colors.surface, padding: 8, borderRadius: 10, borderWidth: 1, borderColor: colors.border }, // Footer footer: { position: 'absolute', bottom: 0, width: '100%', backgroundColor: colors.surface, padding: 20, paddingBottom: Platform.OS === 'ios' ? 34 : 20, borderTopWidth: 1, borderTopColor: colors.border }, primaryBtn: { backgroundColor: colors.primary, height: 56, borderRadius: 18, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 }, primaryBtnText: { color: colors.buttonText, fontSize: 16, fontFamily: typography.fonts.bold } }); export default memo(AuctionItemDetail);