Spaces:
Sleeping
Sleeping
Naufal Arhab
chore: full codebase audit fixes, L2/whale/calibration upgrades, and rebuild frontend dist
48f60d7 Download frontend/src/App.tsx from agus1111/Perps-Terminal: direct link, hf CLI and curl.
- Browser
- Download file 4.65 kB
-
https://huggingface.co/spaces/agus1111/Perps-Terminal/resolve/main/frontend/src/App.tsx
- Command line
-
hf download hf://spaces/agus1111/Perps-Terminal/frontend/src/App.tsx
-
curl -L -o App.tsx https://huggingface.co/spaces/agus1111/Perps-Terminal/resolve/main/frontend/src/App.tsx
4.65 kB
| import { useState, useCallback, lazy, Suspense } from 'react'; | |
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | |
| import { Dashboard } from './pages/Dashboard'; | |
| import { AITerminal } from './pages/AITerminal'; | |
| import { TradeJournal } from './pages/TradeJournal'; | |
| import { LiveChartTerminal } from './pages/LiveChartTerminal'; | |
| import { Header, AppTab } from './components/layout/Header'; | |
| import { MobileBottomNav } from './components/layout/MobileBottomNav'; | |
| import { ToastProvider } from './components/ui/Toast'; | |
| import { useWebSocket } from './hooks/useWebSocket'; | |
| import { usePairs } from './hooks/usePairs'; | |
| import { useAISettings } from './hooks/useAISettings'; | |
| // Lazy-load settings modal | |
| const GlobalAISettingsModal = lazy(() => | |
| import('./components/ui/GlobalAISettingsModal').then((m) => ({ default: m.GlobalAISettingsModal })) | |
| ); | |
| const queryClient = new QueryClient({ | |
| defaultOptions: { | |
| queries: { | |
| refetchOnWindowFocus: false, | |
| retry: 2, | |
| }, | |
| }, | |
| }); | |
| function MainApp() { | |
| const [activeTab, setActiveTab] = useState<AppTab>('signals'); | |
| const [chartSelectedSymbol, setChartSelectedSymbol] = useState<string>('BTCUSDT'); | |
| const [aiSelectedSymbol, setAiSelectedSymbol] = useState<string>('BTCUSDT'); | |
| const [isMobileDrawerOpen, setIsMobileDrawerOpen] = useState(false); | |
| const [isAISettingsOpen, setIsAISettingsOpen] = useState(false); | |
| const { status: wsStatus, lastUpdated } = useWebSocket(); | |
| const { data: pairs = [] } = usePairs(); | |
| const { isConfigured: isAIConfigured } = useAISettings(); | |
| const activePairCount = pairs.filter((p) => p.is_active).length; | |
| const handleNavigateToChart = useCallback((symbol: string) => { | |
| setChartSelectedSymbol(symbol); | |
| setActiveTab('chart'); | |
| }, []); | |
| const handleNavigateToAI = useCallback((symbol: string) => { | |
| setAiSelectedSymbol(symbol); | |
| setActiveTab('ai'); | |
| }, []); | |
| const handleOpenPairsDrawer = useCallback(() => { | |
| setActiveTab((prev) => (prev !== 'signals' ? 'signals' : prev)); | |
| setIsMobileDrawerOpen(true); | |
| }, []); | |
| return ( | |
| <div className="flex flex-col h-screen bg-bg-primary overflow-hidden relative"> | |
| <Header | |
| wsStatus={wsStatus} | |
| lastUpdated={lastUpdated} | |
| activePairCount={activePairCount} | |
| activeTab={activeTab} | |
| onTabChange={setActiveTab} | |
| onOpenMobileDrawer={() => setIsMobileDrawerOpen(true)} | |
| onOpenAISettings={() => setIsAISettingsOpen(true)} | |
| /> | |
| {/* View 1: Live Sinyal (Dashboard) */} | |
| <div className={activeTab === 'signals' ? 'flex flex-1 overflow-hidden' : 'hidden'}> | |
| <Dashboard | |
| onNavigateToAI={handleNavigateToAI} | |
| onNavigateToChart={handleNavigateToChart} | |
| isMobileDrawerOpen={isMobileDrawerOpen} | |
| setIsMobileDrawerOpen={setIsMobileDrawerOpen} | |
| /> | |
| </div> | |
| {/* View 2: Live Chart & Order Flow Terminal */} | |
| <div className={activeTab === 'chart' ? 'flex flex-1 overflow-hidden' : 'hidden'}> | |
| <LiveChartTerminal | |
| initialSymbol={chartSelectedSymbol} | |
| onSelectSymbol={setChartSelectedSymbol} | |
| onNavigateToAI={handleNavigateToAI} | |
| isActiveTab={activeTab === 'chart'} | |
| /> | |
| </div> | |
| {/* View 3: Tanya AI (AITerminal) */} | |
| <div className={activeTab === 'ai' ? 'flex flex-1 overflow-hidden' : 'hidden'}> | |
| <AITerminal | |
| initialSymbol={aiSelectedSymbol} | |
| onSelectSymbol={setAiSelectedSymbol} | |
| /> | |
| </div> | |
| {/* View 4: Jurnal Trade & Damian Continuous Learning */} | |
| <div className={activeTab === 'journal' ? 'flex flex-1 overflow-hidden' : 'hidden'}> | |
| <TradeJournal | |
| onNavigateToAI={handleNavigateToAI} | |
| isActiveTab={activeTab === 'journal'} | |
| /> | |
| </div> | |
| {/* Mobile Bottom Navigation Bar (Thumb-friendly & Fast) */} | |
| <MobileBottomNav | |
| activeTab={activeTab} | |
| onTabChange={setActiveTab} | |
| onOpenMobileDrawer={handleOpenPairsDrawer} | |
| onOpenAISettings={() => setIsAISettingsOpen(true)} | |
| activePairCount={activePairCount} | |
| isAIConfigured={isAIConfigured} | |
| /> | |
| {/* Centralized Global AI Settings Modal */} | |
| {isAISettingsOpen && ( | |
| <Suspense fallback={null}> | |
| <GlobalAISettingsModal | |
| isOpen={isAISettingsOpen} | |
| onClose={() => setIsAISettingsOpen(false)} | |
| /> | |
| </Suspense> | |
| )} | |
| </div> | |
| ); | |
| } | |
| export default function App() { | |
| return ( | |
| <QueryClientProvider client={queryClient}> | |
| <ToastProvider> | |
| <MainApp /> | |
| </ToastProvider> | |
| </QueryClientProvider> | |
| ); | |
| } | |