import { useState } from 'react'; import { FileText, Download, Filter, Plus, Eye, Clock, CheckCircle2, AlertTriangle, Send, Database } from 'lucide-react'; import { reportConfigs } from '../data/portalData'; import type { ReportingStandard } from '../types/portal'; import { useLiveChain } from '../hooks/useLiveChain'; import { endpoints } from '../config/endpoints'; const standardColors: Record = { IPSAS: '#a855f7', US_GAAP: '#3b82f6', IFRS: '#22c55e', }; const statusIcons: Record = { draft: Clock, generated: AlertTriangle, reviewed: Eye, published: CheckCircle2, }; const statusColors: Record = { draft: '#6b7280', generated: '#eab308', reviewed: '#3b82f6', published: '#22c55e', }; export default function ReportingPage() { const [standardFilter, setStandardFilter] = useState('all'); const [typeFilter, setTypeFilter] = useState('all'); const [activeStandard, setActiveStandard] = useState('IFRS'); const { health, stats, error: liveErr, lastUpdated: liveUpdatedAt } = useLiveChain(); const filtered = reportConfigs.filter(r => { const matchStandard = standardFilter === 'all' || r.standard === standardFilter; const matchType = typeFilter === 'all' || r.type === typeFilter; return matchStandard && matchType; }); const standardDetails: Record = { IPSAS: { full: 'International Public Sector Accounting Standards', description: 'Accrual-based accounting standards for public sector entities, issued by the IPSASB. Ensures transparency and accountability in government financial reporting.', keyStatements: ['Statement of Financial Position', 'Statement of Financial Performance', 'Statement of Changes in Net Assets', 'Cash Flow Statement', 'Budget Comparison Statement'], jurisdiction: 'International (Public Sector)', }, US_GAAP: { full: 'United States Generally Accepted Accounting Principles', description: 'Comprehensive accounting framework issued by FASB, mandatory for US public companies and widely adopted by financial institutions.', keyStatements: ['Balance Sheet', 'Income Statement', 'Statement of Cash Flows', 'Statement of Stockholders\' Equity', 'Notes to Financial Statements'], jurisdiction: 'United States', }, IFRS: { full: 'International Financial Reporting Standards', description: 'Global accounting standards issued by the IASB, adopted by 140+ jurisdictions. Principle-based framework for transparent financial reporting.', keyStatements: ['Statement of Financial Position', 'Statement of Profit or Loss', 'Statement of Comprehensive Income', 'Statement of Cash Flows', 'Statement of Changes in Equity'], jurisdiction: 'International (140+ jurisdictions)', }, }; const detail = standardDetails[activeStandard]; return (

Financial Reporting

IPSAS, US GAAP, and IFRS compliant reporting frameworks

{/* On-Chain Reporting Snapshot — live data from Chain-138 + SolaceScan */}
On-Chain Reporting Snapshot — Chain {endpoints.chain138.chainId} {liveErr ? `RPC degraded · ${liveErr}` : liveUpdatedAt ? `updated ${liveUpdatedAt.toLocaleTimeString()}` : 'polling…'}
Latest Block
{liveErr ? '—' : (health?.blockNumber?.toLocaleString() ?? '…')}
Total Blocks (ledger depth)
{liveErr ? '—' : (stats?.total_blocks?.toLocaleString() ?? '…')}
Total Transactions
{liveErr ? '—' : (stats?.total_transactions?.toLocaleString() ?? '…')}
Total Addresses
{liveErr ? '—' : (stats?.total_addresses?.toLocaleString() ?? '…')}
Network Utilisation
{liveErr ? '—' : (stats ? `${stats.network_utilization_percentage.toFixed(1)}%` : '…')}
Avg Block Time
{liveErr ? '—' : (stats ? `${stats.average_block_time.toFixed(1)}s` : '…')}
Sources: {endpoints.chain138.rpcUrl} {' · '}{endpoints.explorer.apiBaseUrl}/api/v2/stats {' · the IFRS / US GAAP / IPSAS reports below are generated by dbis_core (currently mocked — no public deployment).'}
{/* Standards Overview */}
{(['IPSAS', 'US_GAAP', 'IFRS'] as ReportingStandard[]).map(std => ( ))}

{activeStandard.replace('_', ' ')}

{detail.full}

{detail.jurisdiction}

{detail.description}

Key Financial Statements:
{detail.keyStatements.map(stmt => ( {stmt} ))}
{/* Reports Table */}

Generated Reports

Report Name Standard Type Period Status Generated By Actions
{filtered.map(report => { const StatusIcon = statusIcons[report.status] || Clock; return (
{report.name} {report.standard.replace('_', ' ')} {report.type.replace(/_/g, ' ')} {report.period} {report.status} {report.generatedAt ? report.generatedAt.toLocaleDateString() : '—'} {report.generatedBy || '—'}
); })}
); }