mirror of
https://github.com/allankoechke/mantisbase-admin.git
synced 2026-11-30 10:19:37 +00:00
Improve table view layout, dark theme, data protection, schema config, and documentation links. Add theme system, data protection, and professional polish. #VERCEL_SKIP Co-authored-by: Allan K. Koech <44490960+allankoechke@users.noreply.github.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { LoginForm } from "@/components/login-form"
|
|
import { AdminDashboard } from "@/components/admin-dashboard"
|
|
import { Toaster } from "@/components/ui/toaster"
|
|
import { ThemeProvider } from "@/components/theme-provider"
|
|
|
|
export default function Page() {
|
|
const [token, setToken] = React.useState<string | null>(null)
|
|
const [mounted, setMounted] = React.useState(false)
|
|
|
|
React.useEffect(() => {
|
|
setMounted(true)
|
|
const savedToken = localStorage.getItem("admin_token")
|
|
if (savedToken) {
|
|
setToken(savedToken)
|
|
}
|
|
}, [])
|
|
|
|
const handleLogin = (newToken: string) => {
|
|
setToken(newToken)
|
|
}
|
|
|
|
const handleLogout = () => {
|
|
setToken(null)
|
|
}
|
|
|
|
if (!mounted) {
|
|
return (
|
|
<div className="flex min-h-screen w-full items-center justify-center">
|
|
<div className="text-center">
|
|
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"></div>
|
|
<p className="text-muted-foreground">Loading...</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
|
{!token ? <LoginForm onLogin={handleLogin} /> : <AdminDashboard token={token} onLogout={handleLogout} />}
|
|
<Toaster />
|
|
</ThemeProvider>
|
|
)
|
|
}
|