Fix main layout
This commit is contained in:
@@ -1,42 +1,16 @@
|
|||||||
const RootLayout = ({ children }) => (
|
import { AuthProvider } from '@/lib/auth';
|
||||||
|
import './globals.css';
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body>
|
<body>
|
||||||
<AuthProvider>
|
<AuthProvider>{children}</AuthProvider>
|
||||||
{children}
|
|
||||||
</AuthProvider>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user