chore: redirect to login/dashboard on root path
This commit is contained in:
parent
514c61ea36
commit
a6be0b60af
|
|
@ -16,6 +16,7 @@ import { Route as rootRoute } from './routes/__root'
|
||||||
import { Route as VerifyingLayoutImport } from './routes/_verifyingLayout'
|
import { Route as VerifyingLayoutImport } from './routes/_verifyingLayout'
|
||||||
import { Route as DashboardLayoutImport } from './routes/_dashboardLayout'
|
import { Route as DashboardLayoutImport } from './routes/_dashboardLayout'
|
||||||
import { Route as AssessmentLayoutImport } from './routes/_assessmentLayout'
|
import { Route as AssessmentLayoutImport } from './routes/_assessmentLayout'
|
||||||
|
import { Route as LoginIndexImport } from './routes/login/index'
|
||||||
import { Route as VerifyingLayoutVerifyingIndexImport } from './routes/_verifyingLayout/verifying/index'
|
import { Route as VerifyingLayoutVerifyingIndexImport } from './routes/_verifyingLayout/verifying/index'
|
||||||
import { Route as DashboardLayoutUsersIndexImport } from './routes/_dashboardLayout/users/index'
|
import { Route as DashboardLayoutUsersIndexImport } from './routes/_dashboardLayout/users/index'
|
||||||
import { Route as DashboardLayoutTimetableIndexImport } from './routes/_dashboardLayout/timetable/index'
|
import { Route as DashboardLayoutTimetableIndexImport } from './routes/_dashboardLayout/timetable/index'
|
||||||
|
|
@ -32,7 +33,6 @@ import { Route as AssessmentLayoutAssessmentIndexImport } from './routes/_assess
|
||||||
const IndexLazyImport = createFileRoute('/')()
|
const IndexLazyImport = createFileRoute('/')()
|
||||||
const RegisterIndexLazyImport = createFileRoute('/register/')()
|
const RegisterIndexLazyImport = createFileRoute('/register/')()
|
||||||
const LogoutIndexLazyImport = createFileRoute('/logout/')()
|
const LogoutIndexLazyImport = createFileRoute('/logout/')()
|
||||||
const LoginIndexLazyImport = createFileRoute('/login/')()
|
|
||||||
const ForgotPasswordIndexLazyImport = createFileRoute('/forgot-password/')()
|
const ForgotPasswordIndexLazyImport = createFileRoute('/forgot-password/')()
|
||||||
const ForgotPasswordVerifyLazyImport = createFileRoute(
|
const ForgotPasswordVerifyLazyImport = createFileRoute(
|
||||||
'/forgot-password/verify',
|
'/forgot-password/verify',
|
||||||
|
|
@ -72,11 +72,6 @@ const LogoutIndexLazyRoute = LogoutIndexLazyImport.update({
|
||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
} as any).lazy(() => import('./routes/logout/index.lazy').then((d) => d.Route))
|
} as any).lazy(() => import('./routes/logout/index.lazy').then((d) => d.Route))
|
||||||
|
|
||||||
const LoginIndexLazyRoute = LoginIndexLazyImport.update({
|
|
||||||
path: '/login/',
|
|
||||||
getParentRoute: () => rootRoute,
|
|
||||||
} as any).lazy(() => import('./routes/login/index.lazy').then((d) => d.Route))
|
|
||||||
|
|
||||||
const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
|
const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
|
||||||
path: '/forgot-password/',
|
path: '/forgot-password/',
|
||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
|
|
@ -84,6 +79,11 @@ const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
|
||||||
import('./routes/forgot-password/index.lazy').then((d) => d.Route),
|
import('./routes/forgot-password/index.lazy').then((d) => d.Route),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const LoginIndexRoute = LoginIndexImport.update({
|
||||||
|
path: '/login/',
|
||||||
|
getParentRoute: () => rootRoute,
|
||||||
|
} as any)
|
||||||
|
|
||||||
const ForgotPasswordVerifyLazyRoute = ForgotPasswordVerifyLazyImport.update({
|
const ForgotPasswordVerifyLazyRoute = ForgotPasswordVerifyLazyImport.update({
|
||||||
path: '/forgot-password/verify',
|
path: '/forgot-password/verify',
|
||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
|
|
@ -222,6 +222,13 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof ForgotPasswordVerifyLazyImport
|
preLoaderRoute: typeof ForgotPasswordVerifyLazyImport
|
||||||
parentRoute: typeof rootRoute
|
parentRoute: typeof rootRoute
|
||||||
}
|
}
|
||||||
|
'/login/': {
|
||||||
|
id: '/login/'
|
||||||
|
path: '/login'
|
||||||
|
fullPath: '/login'
|
||||||
|
preLoaderRoute: typeof LoginIndexImport
|
||||||
|
parentRoute: typeof rootRoute
|
||||||
|
}
|
||||||
'/forgot-password/': {
|
'/forgot-password/': {
|
||||||
id: '/forgot-password/'
|
id: '/forgot-password/'
|
||||||
path: '/forgot-password'
|
path: '/forgot-password'
|
||||||
|
|
@ -229,13 +236,6 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof ForgotPasswordIndexLazyImport
|
preLoaderRoute: typeof ForgotPasswordIndexLazyImport
|
||||||
parentRoute: typeof rootRoute
|
parentRoute: typeof rootRoute
|
||||||
}
|
}
|
||||||
'/login/': {
|
|
||||||
id: '/login/'
|
|
||||||
path: '/login'
|
|
||||||
fullPath: '/login'
|
|
||||||
preLoaderRoute: typeof LoginIndexLazyImport
|
|
||||||
parentRoute: typeof rootRoute
|
|
||||||
}
|
|
||||||
'/logout/': {
|
'/logout/': {
|
||||||
id: '/logout/'
|
id: '/logout/'
|
||||||
path: '/logout'
|
path: '/logout'
|
||||||
|
|
@ -344,8 +344,8 @@ export const routeTree = rootRoute.addChildren({
|
||||||
VerifyingLayoutVerifyingIndexRoute,
|
VerifyingLayoutVerifyingIndexRoute,
|
||||||
}),
|
}),
|
||||||
ForgotPasswordVerifyLazyRoute,
|
ForgotPasswordVerifyLazyRoute,
|
||||||
|
LoginIndexRoute,
|
||||||
ForgotPasswordIndexLazyRoute,
|
ForgotPasswordIndexLazyRoute,
|
||||||
LoginIndexLazyRoute,
|
|
||||||
LogoutIndexLazyRoute,
|
LogoutIndexLazyRoute,
|
||||||
RegisterIndexLazyRoute,
|
RegisterIndexLazyRoute,
|
||||||
})
|
})
|
||||||
|
|
@ -363,8 +363,8 @@ export const routeTree = rootRoute.addChildren({
|
||||||
"/_dashboardLayout",
|
"/_dashboardLayout",
|
||||||
"/_verifyingLayout",
|
"/_verifyingLayout",
|
||||||
"/forgot-password/verify",
|
"/forgot-password/verify",
|
||||||
"/forgot-password/",
|
|
||||||
"/login/",
|
"/login/",
|
||||||
|
"/forgot-password/",
|
||||||
"/logout/",
|
"/logout/",
|
||||||
"/register/"
|
"/register/"
|
||||||
]
|
]
|
||||||
|
|
@ -400,12 +400,12 @@ export const routeTree = rootRoute.addChildren({
|
||||||
"/forgot-password/verify": {
|
"/forgot-password/verify": {
|
||||||
"filePath": "forgot-password/verify.lazy.tsx"
|
"filePath": "forgot-password/verify.lazy.tsx"
|
||||||
},
|
},
|
||||||
|
"/login/": {
|
||||||
|
"filePath": "login/index.tsx"
|
||||||
|
},
|
||||||
"/forgot-password/": {
|
"/forgot-password/": {
|
||||||
"filePath": "forgot-password/index.lazy.tsx"
|
"filePath": "forgot-password/index.lazy.tsx"
|
||||||
},
|
},
|
||||||
"/login/": {
|
|
||||||
"filePath": "login/index.lazy.tsx"
|
|
||||||
},
|
|
||||||
"/logout/": {
|
"/logout/": {
|
||||||
"filePath": "logout/index.lazy.tsx"
|
"filePath": "logout/index.lazy.tsx"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,17 @@
|
||||||
import { createLazyFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createLazyFileRoute, Navigate } from "@tanstack/react-router";
|
||||||
import { useEffect } from "react";
|
|
||||||
|
|
||||||
export const Route = createLazyFileRoute("/")({
|
export const Route = createLazyFileRoute("/")({
|
||||||
component: HomePage,
|
component: HomePage,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const navigate = useNavigate();
|
const userRole = JSON.parse(localStorage.getItem("userRole") || "{}");
|
||||||
const userRole = JSON.parse(localStorage.getItem('userRole') || '{}');
|
|
||||||
|
|
||||||
useEffect(() => {
|
return userRole === "super-admin" ? (
|
||||||
if (userRole === "super-admin") {
|
<Navigate to="/users" replace />
|
||||||
navigate({
|
) : userRole === "user" ? (
|
||||||
to: "/users",
|
<Navigate to="/assessmentRequest" replace />
|
||||||
replace: true,
|
) : (
|
||||||
});
|
<Navigate to="/login" replace />
|
||||||
} else if (userRole === "user") {
|
);
|
||||||
navigate({
|
|
||||||
to: "/assessmentRequest",
|
|
||||||
replace: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [navigate]);
|
|
||||||
|
|
||||||
return <div>index.lazy</div>;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { createLazyFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { Input } from '@/shadcn/components/ui/input.tsx';
|
import { Input } from '@/shadcn/components/ui/input.tsx';
|
||||||
import { Button } from '@/shadcn/components/ui/button.tsx';
|
import { Button } from '@/shadcn/components/ui/button.tsx';
|
||||||
|
|
@ -21,7 +21,7 @@ import useAuth from "@/hooks/useAuth";
|
||||||
import { TbArrowNarrowRight } from "react-icons/tb";
|
import { TbArrowNarrowRight } from "react-icons/tb";
|
||||||
import amatilogo from "@/assets/logos/amati-logo.png";
|
import amatilogo from "@/assets/logos/amati-logo.png";
|
||||||
|
|
||||||
export const Route = createLazyFileRoute("/login/")({
|
export const Route = createFileRoute("/login/")({
|
||||||
component: LoginPage,
|
component: LoginPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -36,6 +36,7 @@ const formSchema = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
|
console.log("hii");
|
||||||
const [errorMessage, setErrorMessage] = useState("");
|
const [errorMessage, setErrorMessage] = useState("");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user