import React, { useState } from 'react'; import { TagData } from '../types'; import { Play, Pause, Trash2, Download, Fingerprint, ScanBarcode, CircuitBoard } from 'lucide-react'; interface Props { tags: TagData[]; isScanning: boolean; onToggleScan: () => void; onClear: () => void; onFetchTids: () => void; } export const InventoryPanel: React.FC = ({ tags, isScanning, onToggleScan, onClear, onFetchTids }) => { const [viewMode, setViewMode] = useState<'epc' | 'tid'>('epc'); const exportCsv = () => { const csvContent = "data:text/csv;charset=utf-8," + "EPC,TID,Count,Timestamp\n" + tags.map(t => `${t.epc},${t.tid || ''},${t.count},${new Date(t.timestamp).toISOString()}`).join("\n"); const encodedUri = encodeURI(csvContent); const link = document.createElement("a"); link.setAttribute("href", encodedUri); link.setAttribute("download", "rfid_inventory.csv"); document.body.appendChild(link); link.click(); }; return (
{/* Main Inventory Table Card */}
{/* Header / Controls */}

EPC C1G2 Inventory

{tags.length} Unique Tags Found
{/* View Mode Switcher */}
{viewMode === 'tid' && ( )}
{/* Table Area */}
{viewMode === 'tid' && } {tags.length === 0 ? ( ) : ( tags.map((tag, index) => ( {/* Main ID Column */} {/* EPC Reference Column (Only in TID view) */} {viewMode === 'tid' && ( )} {/* Length Column */} )) )}
# {viewMode === 'epc' ? 'EPC ID' : 'TID (Tag Identifier)'} EPC ReferenceLength (Bits) Count
No tags scanned yet. Press "Start Scan" to begin.
{index + 1} {viewMode === 'epc' ? ( tag.epc ) : ( tag.tid ? ( {tag.tid} ) : ( Not Read (Click "Read TIDs") ) )} {tag.epc} {viewMode === 'epc' ? tag.epc.replace(/\s/g, '').length * 4 : (tag.tid ? tag.tid.replace(/\s/g, '').length * 4 : '-') } {tag.count}
); };