Spaces:
Paused
Paused
Download dashboard/src/components/AppRouter.jsx from paras9909/opticparse-python: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/paras9909/opticparse-python/resolve/main/dashboard/src/components/AppRouter.jsx
- Command line
-
hf download hf://spaces/paras9909/opticparse-python/dashboard/src/components/AppRouter.jsx
-
curl -L -o AppRouter.jsx https://huggingface.co/spaces/paras9909/opticparse-python/resolve/main/dashboard/src/components/AppRouter.jsx
1.27 kB
| import React, { useState, useEffect, useRef } from 'react'; | |
| import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts'; | |
| import { initLocalEngine, routeInference } from '../utils/inferenceRouter'; | |
| import HCaptcha from '@hcaptcha/react-hcaptcha'; | |
| import { supabase, useAuth, GATEWAY_URL, LEMON_CHECKOUT_URL } from '../context'; | |
| import AuthPage from './AuthPage'; | |
| import Dashboard from './Dashboard'; | |
| import UpdatePassword from './UpdatePassword'; | |
| export default function AppRouter() { | |
| const { user } = useAuth(); | |
| const [isRecovery, setIsRecovery] = useState(false); | |
| useEffect(() => { | |
| // Check if URL has access token and type=recovery | |
| if (window.location.hash.includes('type=recovery')) { | |
| setIsRecovery(true); | |
| } | |
| // Also listen to auth state changes for the recovery event | |
| const { data: { subscription } } = supabase.auth.onAuthStateChange((event, session) => { | |
| if (event === 'PASSWORD_RECOVERY') { | |
| setIsRecovery(true); | |
| } | |
| }); | |
| return () => subscription.unsubscribe(); | |
| }, []); | |
| if (isRecovery) { | |
| return <UpdatePassword onComplete={() => { | |
| setIsRecovery(false); | |
| window.location.hash = ''; // Clear hash | |
| }} />; | |
| } | |
| return user ? <Dashboard /> : <AuthPage /> | |
| } | |