-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
71 lines (61 loc) · 2.33 KB
/
Copy pathApp.tsx
File metadata and controls
71 lines (61 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { useState } from 'react';
import { Sidebar } from './components/Sidebar';
import { Dashboard } from './pages/Dashboard';
import { LoanList } from './pages/LoanList';
import { LoanDetail } from './pages/LoanDetail';
import { LoanOrigination } from './pages/LoanOrigination';
import { RiskReports } from './pages/RiskReports';
import { Alerts } from './pages/Alerts';
import { MarketIntelligence } from './pages/MarketIntelligence';
import { Login } from './pages/Login';
import { AIContextProvider } from './contexts/AIContext';
import { AIChatWidget } from './components/AIChatWidget';
import { AuthProvider, useAuth } from './contexts/AuthContext';
const AuthenticatedApp: React.FC = () => {
const { isAuthenticated } = useAuth();
const [currentPage, setCurrentPage] = useState('dashboard');
const [selectedLoanId, setSelectedLoanId] = useState<string | null>(null);
if (!isAuthenticated) {
return <Login />;
}
const handleNavigate = (page: string) => {
setCurrentPage(page);
setSelectedLoanId(null);
};
const handleViewLoan = (id: string) => {
setSelectedLoanId(id);
setCurrentPage('details');
};
const handleCreateLoan = () => {
setCurrentPage('origination');
}
return (
<AIContextProvider>
<div className="flex min-h-screen bg-slate-50">
<Sidebar activePage={currentPage} onNavigate={handleNavigate} />
<main className="flex-1 ml-64 relative">
{currentPage === 'dashboard' && <Dashboard />}
{currentPage === 'loans' && <LoanList onView={handleViewLoan} onCreate={handleCreateLoan} />}
{currentPage === 'details' && selectedLoanId && (
<LoanDetail loanId={selectedLoanId} onBack={() => handleNavigate('loans')} />
)}
{currentPage === 'origination' && (
<LoanOrigination onBack={() => handleNavigate('loans')} onComplete={() => handleNavigate('loans')} />
)}
{currentPage === 'reports' && <RiskReports />}
{currentPage === 'alerts' && <Alerts />}
{currentPage === 'market' && <MarketIntelligence />}
<AIChatWidget />
</main>
</div>
</AIContextProvider>
);
}
const App: React.FC = () => {
return (
<AuthProvider>
<AuthenticatedApp />
</AuthProvider>
);
};
export default App;