import React, { useState } from 'react'; /* Fix: react-router-dom exports may be flaky in this environment, using standard v6 imports */ import { useParams, useNavigate } from 'react-router-dom'; import { ListTree, ArrowLeft, Edit3, Save, X, MoreVertical, Search, Hash, FileText, Tag } from 'lucide-react'; import { LineItem, LineItemUpdateRequest } from '../types/index'; const MOCK_LINE_ITEMS: LineItem[] = [ { id: 'LI-001', amount: 12000.50, currency: 'USD', description: 'Monthly Compute - Node A', ledger_account_id: 'LED-991', itemizable_id: 'TXN-8821', itemizable_type: 'payment_orders', createdAt: '2024-03-25' }, { id: 'LI-002', amount: 2500.00, currency: 'USD', description: 'Storage Surcharge - Region East', ledger_account_id: 'LED-992', itemizable_id: 'TXN-8821', itemizable_type: 'payment_orders', createdAt: '2024-03-25' }, { id: 'LI-003', amount: 30499.50, currency: 'USD', description: 'Quantum Networking Handshake', ledger_account_id: 'LED-991', itemizable_id: 'TXN-8821', itemizable_type: 'payment_orders', createdAt: '2024-03-25' }, ]; const LineItems: React.FC = () => { const { type, id } = useParams<{ type: string; id: string }>(); const navigate = useNavigate(); const [items, setItems] = useState(MOCK_LINE_ITEMS); const [editingId, setEditingId] = useState(null); const [editForm, setEditForm] = useState({}); const handleEdit = (item: LineItem) => { setEditingId(item.id); setEditForm({ description: item.description }); }; const handleSave = (id: string) => { setItems(prev => prev.map(item => item.id === id ? { ...item, ...editForm } : item)); setEditingId(null); }; return (

Line Ledger

{type?.replace('_', ' ')} ID: {id}

Granular Breakdown

{items.map(item => ( ))}
Item Detail Ledger Mapping Created At Amount (USD) Actions
{editingId === item.id ? ( setEditForm({ ...editForm, description: e.target.value })} className="w-full bg-black border border-zinc-800 rounded-lg px-3 py-1 text-xs text-white outline-none focus:border-blue-500/50" autoFocus /> ) : (

{item.description}

)}

ID: {item.id}

{item.ledger_account_id}

{item.createdAt}

${item.amount.toLocaleString(undefined, { minimumFractionDigits: 2 })}

{item.currency}

{editingId === item.id ? ( <> ) : (
)}

Total Aggregate

Calculated from {items.length} granular entries

${items.reduce((sum, i) => sum + i.amount, 0).toLocaleString(undefined, { minimumFractionDigits: 2 })}

Verified Audit Payload

); }; export default LineItems;