Files
rikkei_simple_care/management/src/main.tsx
2026-06-30 10:39:29 +07:00

42 lines
942 B
TypeScript

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { AuthProvider, useAuth } from './auth/AuthContext'
import { LoginPage } from './components/LoginPage'
import { ChangePasswordPage } from './components/AccountsTab'
function AppGate() {
const { token, staff, loading } = useAuth();
if (loading) {
return (
<div className="auth-shell">
<div className="login-card card">Đang tải...</div>
</div>
);
}
if (!token) {
return (
<div className="auth-shell">
<LoginPage />
</div>
);
}
if (staff?.mustChangePassword) {
return (
<div className="auth-shell">
<ChangePasswordPage forced />
</div>
);
}
return <App />;
}
createRoot(document.getElementById('root')!).render(
<StrictMode>
<AuthProvider>
<AppGate />
</AuthProvider>
</StrictMode>,
)