26 lines
699 B
TypeScript
26 lines
699 B
TypeScript
import { createFileRoute, Navigate } from '@tanstack/react-router'
|
|
import { AppContainer } from 'web-components'
|
|
import { useStaffAuth } from '../components/context/staff-auth-context'
|
|
|
|
export const Route = createFileRoute('/')({
|
|
component: Index,
|
|
})
|
|
|
|
function Index() {
|
|
const { isLoggedIn, isLoading } = useStaffAuth()
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<AppContainer>
|
|
<div className="flex flex-1 items-center justify-center">
|
|
<div className="h-8 w-8 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500" />
|
|
</div>
|
|
</AppContainer>
|
|
)
|
|
}
|
|
|
|
if (isLoggedIn) {
|
|
return <Navigate to="/dashboard" />
|
|
}
|
|
return <Navigate to="/login" />
|
|
}
|