/* acme-app.jsx — Main app with routing, state, animations, and tweaks */ const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "model": "acme-credit-v3.2", "showMetadata": true, "animateScoring": true }/*EDITMODE-END*/; const AcmeApp = () => { const [t, setTweak] = useTweaks(TWEAK_DEFAULTS); const [view, setView] = React.useState('dashboard'); // 'dashboard' | 'applications' const [selectedIdx, setSelectedIdx] = React.useState(0); const [phase, setPhase] = React.useState('done'); const [factorsVisible, setFactorsVisible] = React.useState(true); const [decisionVisible, setDecisionVisible] = React.useState(true); const phaseRef = React.useRef('done'); const app = APPLICANTS[selectedIdx]; const model = MODELS[t.model] || MODELS['acme-credit-v3.2']; const handleNavClick = (tab) => { if (tab === 'Dashboard') setView('dashboard'); else if (tab === 'Applications') setView('applications'); }; const handleOpenApplication = (idx) => { setSelectedIdx(idx); setView('applications'); // Reset animation state for fresh entry setFactorsVisible(true); setDecisionVisible(true); setPhase('done'); phaseRef.current = 'done'; if (t.animateScoring) { setFactorsVisible(false); setDecisionVisible(false); setPhase('loading'); phaseRef.current = 'loading'; setTimeout(() => { if (phaseRef.current === 'loading') { setPhase('animating'); phaseRef.current = 'animating'; setTimeout(() => { setFactorsVisible(true); setTimeout(() => { setDecisionVisible(true); setPhase('done'); phaseRef.current = 'done'; }, 600); }, 800); } }, 1200); } }; const handleSidebarSelect = (idx) => { if (idx === selectedIdx) return; handleOpenApplication(idx); }; const isLoading = phase === 'loading'; const isAnimating = phase === 'loading'; const activeTab = view === 'dashboard' ? 'Dashboard' : 'Applications'; return (
{view === 'dashboard' ? ( ) : (
{/* ─── Left Panel ─── */}
{/* Header */}
{app.initials}
{app.name}
{app.id}·{app.product}·Submitted {app.submitted}
{/* ─── Right Panel ─── */}
{/* Score */}
Credit Assessment
{isLoading ? ( ) : (
)}
{/* Factors */} {!isLoading && (
Contributing Factors
{app.factors.map((f, i) => ( ))}
)} {/* Conditions */} {!isLoading && app.conditions.length > 0 && (
Conditions for Approval
{app.conditions.map((c, i) => (
{i + 1}.{c}
))}
)} {/* Actions */} {!isLoading && (
{app.decisionType !== 'declined' && ( )}
)}
{/* Footer */} {t.showMetadata && (
Model: {t.model} ({model.label}) · Inference: {app.inference} · Confidence: {app.confidence}
{model.engine}
)}
)} ({ value: k, label: MODELS[k].label }))} onChange={(v) => setTweak('model', v)} /> setTweak('animateScoring', v)} /> setTweak('showMetadata', v)} />
); }; /* Small status badge for the applicant header */ const StatusBadge = ({ type }) => { const map = { 'approved-conditions': { bg: '#FEF3C7', color: '#B45309', dot: '#F59E0B', label: 'Under Review' }, 'review': { bg: '#DBEAFE', color: '#1D4ED8', dot: '#3B82F6', label: 'Pending Review' }, 'approved': { bg: '#D1FAE5', color: '#065F46', dot: '#10B981', label: 'Approved' }, 'declined': { bg: '#FEE2E2', color: '#991B1B', dot: '#EF4444', label: 'Declined' }, }; const s = map[type] || map['review']; return (
{s.label}
); }; window.AcmeApp = AcmeApp;