42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
const RootLayout = ({ children }) => (
|
|
<html lang="en">
|
|
<body>
|
|
<AuthProvider>
|
|
{children}
|
|
</AuthProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
|
|
// Main App component to simulate routing
|
|
export default function App() {
|
|
const [route, setRoute] = useState('/login'); // Default route
|
|
|
|
// Simulate navigation for the demo
|
|
useEffect(() => {
|
|
const handleHashChange = () => {
|
|
setRoute(window.location.hash.replace('#', '') || '/');
|
|
};
|
|
window.addEventListener('hashchange', handleHashChange);
|
|
handleHashChange(); // Initial check
|
|
return () => window.removeEventListener('hashchange', handleHashChange);
|
|
}, []);
|
|
|
|
const renderPage = () => {
|
|
switch (route) {
|
|
case '/login':
|
|
return <LoginPage />;
|
|
case '/admin':
|
|
return <MainLayout><AdminPage /></MainLayout>;
|
|
case '/':
|
|
default:
|
|
return <MainLayout><VotingPage /></MainLayout>;
|
|
}
|
|
};
|
|
|
|
return (
|
|
<RootLayout>
|
|
{renderPage()}
|
|
</RootLayout>
|
|
);
|
|
} |