Feat/dimentorin landing page (#49)

* feat(dimentorin): slicing landing page menu mentoring

* feat(dimentorin): slicing landing page detail mentor

* feat(dimentorin): slicing modal booking mentor

* feat(dimentorin): slicing landing - resources page

* feat(dimentorin): slicing landing - articles page

* feat(dimentorin): slicing landing - detail articles page
This commit is contained in:
Muhamad Rijal
2025-07-28 23:26:22 +07:00
committed by GitHub
parent 228f92e9ed
commit f3a19fa460
44 changed files with 1952 additions and 23 deletions
+14 -1
View File
@@ -16,7 +16,8 @@ const mappingPublicRoutes = [
'/auth/new-password',
'/auth/register-mentor',
'/auth/register-mentor/pending',
'/auth/register-mentor/success'
'/auth/register-mentor/success',
'/resources',
];
const mappingRoutePermissions = [
@@ -74,6 +75,11 @@ const mappingRoutePermissions = [
},
];
const mappingPublicPrefixRoutes = [
'/mentoring',
'/articles',
]
//TODO : Fix this later
// const redirectToFirstAccessibleRoute = (userPermissions: string[]) => {
// const fallback = mappingRoutePermissions.find((route) =>
@@ -90,6 +96,13 @@ export const middleware = async ({ request }: LoaderFunctionArgs) => {
const token = session_token?.token?.access_token;
const userPermissions =
session?.role?.permissions?.map?.((perm) => perm?.name) ?? [];
// Allow to access the landing page without authentication
// So, if the route prefix is in the mappingPublicPrefixRoutes, we return null
// to indicate that we don't need to authenticate the user
if (mappingPublicPrefixRoutes.some((prefix) => pathname.startsWith(prefix))) {
return null;
}
if (mappingPublicRoutes.includes(pathname)) {
if (token) return redirect('/dashboard');