Files
bogazici-admin/src/routes/_authenticated/route.tsx
2026-03-27 22:12:23 +03:00

19 lines
575 B
TypeScript

import { createFileRoute, redirect } from '@tanstack/react-router'
import { AuthenticatedLayout } from '@/components/layout/authenticated-layout'
import { useAuthStore } from '@/stores/auth-store'
export const Route = createFileRoute('/_authenticated')({
beforeLoad: ({ location }) => {
const { accessToken } = useAuthStore.getState().auth
if (!accessToken) {
throw redirect({
to: '/sign-in',
search: {
redirect: location.href === '/' ? undefined : location.href,
},
})
}
},
component: AuthenticatedLayout,
})