Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-2347 [FIX] Loading overlay during logout (#1366)

jagadeeswaran-zipstack5b2431844e84
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 4f08dac19..83a79f6f1 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,14 +1,15 @@
import { Button, ConfigProvider, notification, theme } from "antd";
import { BrowserRouter } from "react-router-dom";
import { HelmetProvider } from "react-helmet-async";
+import { useEffect } from "react";
import { THEME } from "./helpers/GetStaticData.js";
import { Router } from "./routes/Router.jsx";
import { useAlertStore } from "./store/alert-store.js";
import { useSessionStore } from "./store/session-store.js";
+import { GenericLoader } from "./components/generic-loader/GenericLoader";
import PostHogPageviewTracker from "./PostHogPageviewTracker.js";
import { PageTitle } from "./components/widgets/page-title/PageTitle.jsx";
-import { useEffect } from "react";
import CustomMarkdown from "./components/helpers/custom-markdown/CustomMarkdown.jsx";
import { useSocketLogsStore } from "./store/socket-logs-store.js";
@@ -23,7 +24,7 @@ try {
function App() {
const [notificationAPI, contextHolder] = notification.useNotification();
const { defaultAlgorithm, darkAlgorithm } = theme;
- const { sessionDetails } = useSessionStore();
+ const { sessionDetails, isLogoutLoading } = useSessionStore();
const { alertDetails } = useAlertStore();
const { pushLogMessages } = useSocketLogsStore();
@@ -86,6 +87,11 @@ function App() {
}}
>
<HelmetProvider>
+ {isLogoutLoading && (
+ <div className="fullscreen-loader">
+ <GenericLoader />
+ </div>
+ )}
<BrowserRouter>
<PostHogPageviewTracker />
<PageTitle title={"Unstract"} />
diff --git a/frontend/src/hooks/useLogout.js b/frontend/src/hooks/useLogout.js
index 1395dc905..d5e0a9452 100644
--- a/frontend/src/hooks/useLogout.js
+++ b/frontend/src/hooks/useLogout.js
@@ -1,25 +1,38 @@
+import axios from "axios";
import Cookies from "js-cookie";
import { usePostHog } from "posthog-js/react";
+
import { getSessionData } from "../helpers/GetSessionData";
import { getBaseUrl } from "../helpers/GetStaticData";
import { useSessionStore } from "../store/session-store";
+import { useAlertStore } from "../store/alert-store";
+import { useExceptionHandler } from "./useExceptionHandler";
function useLogout() {
const setSessionDetails = useSessionStore((state) => state.setSessionDetails);
+ const setLogoutLoading = useSessionStore((state) => state.setLogoutLoading);
const posthog = usePostHog();
+ const { setAlertDetails } = useAlertStore();
+ const handleException = useExceptionHandler();
const clearSessionCookies = () => {
Cookies.remove("sessionid");
Cookies.remove("csrftoken");
};
- return () => {
+ return async () => {
+ setLogoutLoading(true);
setSessionDetails(getSessionData(null));
posthog.reset();
clearSessionCookies();
const baseUrl = getBaseUrl();
- const newURL = baseUrl + "/api/v1/logout";
- window.location.href = newURL;
+ try {
+ await axios.get(baseUrl + "/api/v1/logout");
+ } catch (error) {
+ setAlertDetails(handleException(error));
+ }
+ setLogoutLoading(false);
+ window.location.href = baseUrl + "/";
};
}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 3fdbf2ea9..62d01b1eb 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -235,3 +235,13 @@ body {
.mar-0{
margin: 0;
}
+
+.fullscreen-loader {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100vh;
+ background-color: #ffffff;
+ z-index: 2000;
+}
diff --git a/frontend/src/store/session-store.js b/frontend/src/store/session-store.js
index 5f0b96942..b4ff96403 100644
--- a/frontend/src/store/session-store.js
+++ b/frontend/src/store/session-store.js
@@ -2,6 +2,7 @@ import { create } from "zustand";
const STORE_VARIABLES = {
sessionDetails: {},
+ isLogoutLoading: false,
};
const useSessionStore = create((setState, getState) => ({
...STORE_VARIABLES,
@@ -15,6 +16,9 @@ const useSessionStore = create((setState, getState) => ({
return { sessionDetails: { ...getState().sessionDetails, ...details } };
});
},
+ setLogoutLoading: (loading) => {
+ setState(() => ({ isLogoutLoading: loading }));
+ },
}));
export { useSessionStore };