diff --git a/workers/silverback-ai-studio/.gitignore b/workers/silverback-ai-studio/.gitignore new file mode 100644 index 0000000..cdc33a5 --- /dev/null +++ b/workers/silverback-ai-studio/.gitignore @@ -0,0 +1,2 @@ +package-lock.json +dist/ diff --git a/workers/silverback-ai-studio/src/App.tsx b/workers/silverback-ai-studio/src/App.tsx index 76017d2..60ec1f7 100644 --- a/workers/silverback-ai-studio/src/App.tsx +++ b/workers/silverback-ai-studio/src/App.tsx @@ -400,6 +400,250 @@ function ErrorBoundary({ children }: { children: React.ReactNode }) { return <>{children}; } +// --- Contractors Revenue Page --- +const CONTRACTOR_DATA = [ + { id:'C001', company:'Pacific Coast Freight LLC', city:'Stockton', type:'Fleet HD-OBD', vehicles:12, lastTest:'2026-03-28', revenue:1800, ytd:12, status:'active' }, + { id:'C002', company:'Central Valley Trucking Co.', city:'Modesto', type:'Opacity + HD-OBD', vehicles:8, lastTest:'2026-04-02', revenue:2120, ytd:8, status:'active' }, + { id:'C003', company:'Delta Transport Inc.', city:'Stockton', type:'Fleet HD-OBD', vehicles:15, lastTest:'2026-03-15', revenue:2250, ytd:15, status:'active' }, + { id:'C004', company:'San Joaquin Logistics', city:'Tracy', type:'HD-OBD Only', vehicles:6, lastTest:'2026-04-05', revenue:450, ytd:6, status:'active' }, + { id:'C005', company:'Valley Farm Transport', city:'Lodi', type:'Opacity Test', vehicles:4, lastTest:'2026-02-20', revenue:796, ytd:4, status:'active' }, + { id:'C006', company:'Stockton Steel & Iron', city:'Stockton', type:'Fleet HD-OBD', vehicles:9, lastTest:'2026-03-22', revenue:1350, ytd:9, status:'active' }, + { id:'C007', company:'Big Rig Ready Inc.', city:'Manteca', type:'HD-OBD Only', vehicles:7, lastTest:'2026-04-01', revenue:525, ytd:7, status:'active' }, + { id:'C008', company:'Sunrise Haulers', city:'Stockton', type:'Opacity + HD-OBD', vehicles:5, lastTest:'2026-03-10', revenue:1500, ytd:5, status:'active' }, + { id:'C009', company:'Interstate Cargo Partners', city:'Lathrop', type:'Fleet HD-OBD', vehicles:11, lastTest:'2026-04-08', revenue:1650, ytd:11, status:'active' }, + { id:'C010', company:'Golden State Refrigerated', city:'Stockton', type:'HD-OBD Only', vehicles:3, lastTest:'2026-03-05', revenue:225, ytd:3, status:'pending' }, + { id:'C011', company:'Manteca Moving & Storage', city:'Manteca', type:'HD-OBD Only', vehicles:2, lastTest:'2026-01-18', revenue:150, ytd:2, status:'active' }, + { id:'C012', company:'Turlock Ag Transport', city:'Turlock', type:'Opacity Test', vehicles:6, lastTest:'2026-02-14', revenue:1194, ytd:6, status:'active' }, + { id:'C013', company:'Crossroads Cement Co.', city:'Stockton', type:'Fleet HD-OBD', vehicles:10, lastTest:'2026-03-29', revenue:1490, ytd:10, status:'active' }, + { id:'C014', company:'West Valley Waste Solutions', city:'Modesto', type:'Opacity + HD-OBD', vehicles:7, lastTest:'2026-04-03', revenue:1960, ytd:7, status:'active' }, + { id:'C015', company:'Port of Stockton Contractors', city:'Stockton', type:'Fleet HD-OBD', vehicles:20, lastTest:'2026-04-07', revenue:2980, ytd:20, status:'active' }, + { id:'C016', company:'NorCal Box Trucking', city:'Sacramento', type:'HD-OBD Only', vehicles:5, lastTest:'2026-03-17', revenue:375, ytd:5, status:'active' }, + { id:'C017', company:'Sierra Pacific Timber Haul', city:'Angels Camp', type:'Opacity Test', vehicles:3, lastTest:'2026-02-28', revenue:597, ytd:3, status:'active' }, + { id:'C018', company:'Lodi Nursery & Landscape', city:'Lodi', type:'HD-OBD Only', vehicles:2, lastTest:'2025-12-10', revenue:150, ytd:2, status:'inactive' }, + { id:'C019', company:'Tracy Distribution Center', city:'Tracy', type:'Fleet HD-OBD', vehicles:14, lastTest:'2026-04-04', revenue:2086, ytd:14, status:'active' }, + { id:'C020', company:'Valley Propane & Gas', city:'Stockton', type:'HD-OBD Only', vehicles:4, lastTest:'2026-03-20', revenue:300, ytd:4, status:'active' }, + { id:'C021', company:'SJV Excavating LLC', city:'Fresno', type:'Opacity + HD-OBD', vehicles:6, lastTest:'2026-03-12', revenue:1680, ytd:6, status:'active' }, + { id:'C022', company:'Riverbend Concrete Pumping', city:'Stockton', type:'Fleet HD-OBD', vehicles:8, lastTest:'2026-03-25', revenue:1192, ytd:8, status:'active' }, + { id:'C023', company:'Bay Area Flatbed Express', city:'Oakland', type:'HD-OBD Only', vehicles:3, lastTest:'2026-01-30', revenue:225, ytd:3, status:'pending' }, + { id:'C024', company:'Diablo Asphalt Services', city:'Antioch', type:'Opacity Test', vehicles:5, lastTest:'2026-02-22', revenue:995, ytd:5, status:'active' }, + { id:'C025', company:'Stanislaus Tank Liners', city:'Modesto', type:'HD-OBD Only', vehicles:2, lastTest:'2026-03-08', revenue:150, ytd:2, status:'active' }, + { id:'C026', company:'Central Valley RV Fleet', city:'Stockton', type:'RV Testing', vehicles:4, lastTest:'2026-02-05', revenue:1200, ytd:4, status:'active' }, + { id:'C027', company:'Coastal Crane Rentals', city:'Lathrop', type:'Fleet HD-OBD', vehicles:7, lastTest:'2026-04-06', revenue:1043, ytd:7, status:'active' }, + { id:'C028', company:'Gold Rush Gravel & Sand', city:'Ione', type:'Opacity Test', vehicles:3, lastTest:'2026-03-03', revenue:597, ytd:3, status:'active' }, + { id:'C029', company:'Modesto Ice & Cold Chain', city:'Modesto', type:'HD-OBD Only', vehicles:5, lastTest:'2026-03-14', revenue:375, ytd:5, status:'active' }, + { id:'C030', company:'Apex Auto Transport', city:'Stockton', type:'Fleet HD-OBD', vehicles:9, lastTest:'2026-04-09', revenue:1341, ytd:9, status:'active' }, + { id:'C031', company:'Heritage Lumber Transport', city:'Sonora', type:'Opacity Test', vehicles:4, lastTest:'2026-01-22', revenue:796, ytd:4, status:'pending' }, + { id:'C032', company:'Crossroads Food Distribution', city:'Stockton', type:'Fleet HD-OBD', vehicles:11, lastTest:'2026-03-31', revenue:1639, ytd:11, status:'active' }, + { id:'C033', company:'Mission Ready Mechanical', city:'Tracy', type:'HD-OBD Only', vehicles:3, lastTest:'2026-02-18', revenue:225, ytd:3, status:'active' }, + { id:'C034', company:'Valley Visions Recycling', city:'Stockton', type:'Opacity + HD-OBD', vehicles:5, lastTest:'2026-03-19', revenue:1400, ytd:5, status:'active' }, + { id:'C035', company:'Pacific Rim Containers', city:'Stockton', type:'Fleet HD-OBD', vehicles:16, lastTest:'2026-04-10', revenue:2384, ytd:16, status:'active' }, + { id:'C036', company:'North Valley Fire Protection', city:'Chico', type:'HD-OBD Only', vehicles:2, lastTest:'2025-11-14', revenue:150, ytd:2, status:'inactive' }, + { id:'C037', company:'San Joaquin Crane Service', city:'Stockton', type:'Fleet HD-OBD', vehicles:6, lastTest:'2026-03-26', revenue:894, ytd:6, status:'active' }, + { id:'C038', company:'Delta Ag Spraying LLC', city:'Lodi', type:'HD-OBD Only', vehicles:4, lastTest:'2026-02-10', revenue:300, ytd:4, status:'active' }, + { id:'C039', company:'I-5 Corridor Express', city:'Stockton', type:'Fleet HD-OBD', vehicles:13, lastTest:'2026-04-02', revenue:1937, ytd:13, status:'active' }, + { id:'C040', company:'Sunrise Septic & Drain', city:'Manteca', type:'Opacity Test', vehicles:3, lastTest:'2026-03-07', revenue:597, ytd:3, status:'active' }, + { id:'C041', company:'Big Valley Beverage Dist.', city:'Fresno', type:'Fleet HD-OBD', vehicles:8, lastTest:'2026-03-21', revenue:1192, ytd:8, status:'active' }, + { id:'C042', company:'Turlock Towing & Recovery', city:'Turlock', type:'HD-OBD Only', vehicles:5, lastTest:'2026-01-28', revenue:375, ytd:5, status:'pending' }, + { id:'C043', company:'Sutter Crane & Rigging', city:'Sacramento', type:'Fleet HD-OBD', vehicles:7, lastTest:'2026-04-01', revenue:1043, ytd:7, status:'active' }, + { id:'C044', company:'West Side Produce Inc.', city:'Fresno', type:'Opacity + HD-OBD', vehicles:9, lastTest:'2026-03-16', revenue:2520, ytd:9, status:'active' }, + { id:'C045', company:'Capitol City Flatbed', city:'Sacramento', type:'HD-OBD Only', vehicles:4, lastTest:'2026-02-25', revenue:300, ytd:4, status:'active' }, + { id:'C046', company:'Mountain Pass Logging', city:'Sonora', type:'Opacity Test', vehicles:5, lastTest:'2025-12-20', revenue:995, ytd:5, status:'inactive' }, + { id:'C047', company:'Eastside Iron & Metal', city:'Stockton', type:'Fleet HD-OBD', vehicles:6, lastTest:'2026-04-07', revenue:894, ytd:6, status:'active' }, + { id:'C048', company:'Valley Air Freight', city:'Fresno', type:'HD-OBD Only', vehicles:3, lastTest:'2026-03-11', revenue:225, ytd:3, status:'active' }, + { id:'C049', company:'Horizon Tank Transport', city:'Stockton', type:'Fleet HD-OBD', vehicles:10, lastTest:'2026-04-08', revenue:1490, ytd:10, status:'active' }, + { id:'C050', company:'Sierra Nevada Brewing Dist.', city:'Chico', type:'HD-OBD Only', vehicles:6, lastTest:'2026-03-04', revenue:450, ytd:6, status:'active' }, + { id:'C051', company:'Central Valley Hay & Feed', city:'Tulare', type:'Opacity Test', vehicles:4, lastTest:'2026-02-08', revenue:796, ytd:4, status:'active' }, + { id:'C052', company:'Gold Hills Aggregate', city:'Stockton', type:'Fleet HD-OBD', vehicles:12, lastTest:'2026-04-03', revenue:1788, ytd:12, status:'active' }, + { id:'C053', company:'Triton Marine Transport', city:'Stockton', type:'HD-OBD Only', vehicles:2, lastTest:'2026-01-15', revenue:150, ytd:2, status:'pending' }, + { id:'C054', company:'Sunrise Demolition LLC', city:'Modesto', type:'Opacity + HD-OBD', vehicles:7, lastTest:'2026-03-27', revenue:1960, ytd:7, status:'active' }, + { id:'C055', company:'NorCal Mobile Crane', city:'Sacramento', type:'Fleet HD-OBD', vehicles:5, lastTest:'2026-04-04', revenue:745, ytd:5, status:'active' }, + { id:'C056', company:'Valley Vines Vineyard Svc.', city:'Lodi', type:'HD-OBD Only', vehicles:3, lastTest:'2026-02-17', revenue:225, ytd:3, status:'active' }, + { id:'C057', company:'Stockton Ready Mix Concrete', city:'Stockton', type:'Fleet HD-OBD', vehicles:18, lastTest:'2026-04-09', revenue:2682, ytd:18, status:'active' }, + { id:'C058', company:'Amador County Timber', city:'Jackson', type:'Opacity Test', vehicles:3, lastTest:'2025-10-30', revenue:597, ytd:3, status:'inactive' }, +]; + +type ContractorStatus = 'active' | 'pending' | 'inactive'; + +interface Contractor { + id: string; + company: string; + city: string; + type: string; + vehicles: number; + lastTest: string; + revenue: number; + ytd: number; + status: ContractorStatus; +} + +function ContractorsPage({ onBack }: { onBack: () => void }) { + const [filter, setFilter] = useState<'all' | ContractorStatus | 'fleet'>('all'); + const [search, setSearch] = useState(''); + + const filtered = CONTRACTOR_DATA.filter((c: Contractor) => { + if (search) { + const q = search.toLowerCase(); + if (!c.company.toLowerCase().includes(q) && !c.city.toLowerCase().includes(q)) return false; + } + if (filter === 'all') return true; + if (filter === 'fleet') return c.vehicles >= 5; + return c.status === filter; + }); + + const totalRevenue = CONTRACTOR_DATA.reduce((s, c) => s + c.revenue, 0); + const totalTests = CONTRACTOR_DATA.reduce((s, c) => s + c.ytd, 0); + const totalVehicles = CONTRACTOR_DATA.reduce((s, c) => s + c.vehicles, 0); + const activeCount = CONTRACTOR_DATA.filter(c => c.status === 'active').length; + + const statusColors: Record = { + active: 'text-emerald-400 bg-emerald-400/10 border-emerald-400/30', + pending: 'text-amber-400 bg-amber-400/10 border-amber-400/30', + inactive: 'text-zinc-500 bg-zinc-500/10 border-zinc-500/30', + }; + + const exportCSV = () => { + const header = 'ID,Company,City,Service Type,Vehicles,Last Test,Revenue,YTD Tests,Status\n'; + const rows = CONTRACTOR_DATA.map(c => + `"${c.id}","${c.company}","${c.city}","${c.type}",${c.vehicles},"${c.lastTest}",${c.revenue},${c.ytd},"${c.status}"` + ).join('\n'); + const blob = new Blob([header + rows], { type: 'text/csv' }); + const a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = 'NorCalCARB_Contractors_YTD.csv'; + a.click(); + }; + + return ( +
+ {/* Top bar */} +
+
+
+ +
+
+ Contractor Accounts + Revenue Tracker +
+
+
+ + TESTER ID: IF530523 + + +
+
+
+ +
+ {/* KPI cards */} +
+ {[ + { label: 'Total Revenue YTD', value: '$' + totalRevenue.toLocaleString(), sub: `${CONTRACTOR_DATA.length} accounts`, accent: 'text-emerald-400' }, + { label: 'Tests Completed', value: totalTests.toString(), sub: 'YTD 2025–2026', accent: 'text-brand-orange' }, + { label: 'Active Accounts', value: activeCount.toString(), sub: `of ${CONTRACTOR_DATA.length} total`, accent: 'text-sky-400' }, + { label: 'Avg Rev / Account', value: '$' + Math.round(totalRevenue / CONTRACTOR_DATA.length).toLocaleString(), sub: 'all accounts', accent: 'text-violet-400' }, + { label: 'Fleet Vehicles', value: totalVehicles.toString(), sub: 'units served', accent: 'text-zinc-300' }, + ].map(k => ( +
+
{k.label}
+
{k.value}
+
{k.sub}
+
+ ))} +
+ + {/* Filter bar */} +
+ Filter: + {(['all', 'active', 'pending', 'inactive', 'fleet'] as const).map(f => ( + + ))} + setSearch(e.target.value)} + className="ml-auto bg-white/5 border border-white/10 text-zinc-200 placeholder-zinc-600 text-sm px-4 py-1.5 rounded-xl outline-none focus:border-brand-orange/50 font-mono w-52" + /> +
+ + {/* Table */} +
+
+ + + + {['#', 'Company', 'Service Type', 'Vehicles', 'Last Test', 'Revenue', 'YTD Tests', 'Status'].map(h => ( + + ))} + + + + {filtered.map((c, i) => ( + + + + + + + + + + + ))} + +
{h}
{c.id} +
{c.company}
+
{c.city}, CA
+
+ {c.type} + {c.vehicles}{c.lastTest.replace(/-/g, '/')}${c.revenue.toLocaleString()}{c.ytd} + + {c.status} + +
+
+ {/* Totals row */} +
+ {[ + { label: 'Showing', value: `${filtered.length} accounts` }, + { label: 'Vehicles', value: filtered.reduce((s, c) => s + c.vehicles, 0).toString() }, + { label: 'Revenue', value: '$' + filtered.reduce((s, c) => s + c.revenue, 0).toLocaleString(), green: true }, + { label: 'Tests', value: filtered.reduce((s, c) => s + c.ytd, 0).toString() }, + ].map(t => ( +
+
{t.label}
+
{t.value}
+
+ ))} +
+
+
+
+ ); +} + export default function App() { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); @@ -427,6 +671,18 @@ export default function App() { const [view, setView] = useState<'dashboard' | 'presentation'>('dashboard'); const [currentSlide, setCurrentSlide] = useState(0); const [notifications, setNotifications] = useState([]); + const [page, setPage] = useState<'main' | 'contractors'>(() => + window.location.pathname === '/contractors' ? 'contractors' : 'main' + ); + + // Sync page state with browser back/forward navigation + useEffect(() => { + const handlePopState = () => { + setPage(window.location.pathname === '/contractors' ? 'contractors' : 'main'); + }; + window.addEventListener('popstate', handlePopState); + return () => window.removeEventListener('popstate', handlePopState); + }, []); // --- WebSocket Connection --- useEffect(() => { @@ -740,6 +996,17 @@ export default function App() { ); } + if (page === 'contractors') { + return ( + { + window.history.pushState({ page: 'main' }, '', '/'); + setPage('main'); + }} + /> + ); + } + if (loading) { return (
@@ -792,6 +1059,16 @@ export default function App() { Dashboard +