refactor: custom post loading and add AppAuthenticatedPage (#3632)

* Added post loading hook to appInitPage

* Removed custom post loading

* Changed custom post loading to cusotm post auth

* Adds AppAuthenticatedPage

* Uses AppAuthenticatedPage inside protected route
This commit is contained in:
Lucas Oliveira 2024-08-30 14:53:11 -03:00 • committed by GitHub
commit 3bef9aa633
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 112 additions and 77 deletions

View file

@ -0,0 +1,16 @@
import { UseRequestProcessor } from "@/controllers/API/services/request-processor";
import { useQueryFunctionType } from "@/types/api";
export const useCustomPostAuth: useQueryFunctionType<undefined, null> = (
options,
) => {
const { query } = UseRequestProcessor();
const getPostAuthFn = async () => {
return null;
};
const queryResult = query(["usePostAuth"], getPostAuthFn, options);
return queryResult;
};

View file

@ -0,0 +1,8 @@
import { useCustomPostAuth } from "@/customization/hooks/use-custom-post-auth";
import { Outlet } from "react-router-dom";
export function AppAuthenticatedPage() {
useCustomPostAuth();
return <Outlet />;
}

View file

@ -14,6 +14,7 @@ import ContextWrapper from "./contexts";
import { CustomNavigate } from "./customization/components/custom-navigate"; import { CustomNavigate } from "./customization/components/custom-navigate";
import { BASENAME } from "./customization/config-constants"; import { BASENAME } from "./customization/config-constants";
import { ENABLE_CUSTOM_PARAM } from "./customization/feature-flags"; import { ENABLE_CUSTOM_PARAM } from "./customization/feature-flags";
import { AppAuthenticatedPage } from "./pages/AppAuthenticatedPage";
import { AppInitPage } from "./pages/AppInitPage"; import { AppInitPage } from "./pages/AppInitPage";
import { AppWrapperPage } from "./pages/AppWrapperPage"; import { AppWrapperPage } from "./pages/AppWrapperPage";
import { DashboardWrapperPage } from "./pages/DashboardWrapperPage"; import { DashboardWrapperPage } from "./pages/DashboardWrapperPage";
@ -57,22 +58,31 @@ const router = createBrowserRouter(
</ProtectedRoute> </ProtectedRoute>
} }
> >
<Route path="" element={<AppAuthenticatedPage />}>
<Route path="" element={<DashboardWrapperPage />}> <Route path="" element={<DashboardWrapperPage />}>
<Route path="" element={<HomePage />}> <Route path="" element={<HomePage />}>
<Route index element={<CustomNavigate replace to={"all"} />} /> <Route
index
element={<CustomNavigate replace to={"all"} />}
/>
<Route <Route
path="flows/" path="flows/"
element={<MyCollectionComponent key="flows" type="flow" />} element={<MyCollectionComponent key="flows" type="flow" />}
> >
<Route <Route
path="folder/:folderId" path="folder/:folderId"
element={<MyCollectionComponent key="flows" type="flow" />} element={
<MyCollectionComponent key="flows" type="flow" />
}
/> />
</Route> </Route>
<Route <Route
path="components/" path="components/"
element={ element={
<MyCollectionComponent key="components" type="component" /> <MyCollectionComponent
key="components"
type="component"
/>
} }
> >
<Route <Route
@ -155,6 +165,7 @@ const router = createBrowserRouter(
<Route path="" element={<PlaygroundPage />} /> <Route path="" element={<PlaygroundPage />} />
</Route> </Route>
</Route> </Route>
</Route>
<Route <Route
path="login" path="login"
element={ element={