Skip to content

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

Fix/notification closes after few seconds (#283)

jagadeeswaran-zipstack9692d88304c0
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index f6c380058..20a139cc1 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,4 +1,4 @@
-import { ConfigProvider, notification, theme } from "antd";
+import { Button, ConfigProvider, notification, theme } from "antd";
import { BrowserRouter } from "react-router-dom";
import { THEME } from "./helpers/GetStaticData.js";
@@ -13,12 +13,19 @@ function App() {
const { sessionDetails } = useSessionStore();
const { alertDetails } = useAlertStore();
+ const btn = (
+ <Button type="link" size="small" onClick={() => notificationAPI.destroy()}>
+ Destroy All
+ </Button>
+ );
+
alertDetails.content &&
notificationAPI.open({
message: alertDetails.title,
description: alertDetails.content,
type: alertDetails.type,
- duration: 0,
+ duration: alertDetails.duration,
+ btn,
});
return (
diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.js
index 2c3fc90a6..2ef717411 100644
--- a/frontend/src/helpers/GetStaticData.js
+++ b/frontend/src/helpers/GetStaticData.js
@@ -390,6 +390,10 @@ const docIndexStatus = {
done: "DONE",
};
+const isNonNegativeNumber = (value) => {
+ return typeof value === "number" && !isNaN(value) && value >= 0;
+};
+
export {
CONNECTOR_TYPE_MAP,
O_AUTH_PROVIDERS,
@@ -424,4 +428,5 @@ export {
titleCase,
getMenuItem,
docIndexStatus,
+ isNonNegativeNumber,
};
diff --git a/frontend/src/hooks/useExceptionHandler.jsx b/frontend/src/hooks/useExceptionHandler.jsx
index b9de44de3..d1268823d 100644
--- a/frontend/src/hooks/useExceptionHandler.jsx
+++ b/frontend/src/hooks/useExceptionHandler.jsx
@@ -7,17 +7,19 @@ const useExceptionHandler = () => {
err,
errMessage = "Something went wrong",
setBackendErrors = undefined,
- title = "Failed"
+ title = "Failed",
+ duration = 0
) => {
if (!err) {
return {
type: "error",
content: errMessage,
title: title,
+ duration: duration,
};
}
- if (err.response && err.response.data) {
+ if (err?.response?.data) {
const { type, errors } = err.response.data;
switch (type) {
case "validation_error":
@@ -31,22 +33,23 @@ const useExceptionHandler = () => {
return {
title: title,
type: "error",
- content:
- errors && errors[0]?.detail ? errors[0].detail : errMessage,
+ content: errors?.[0]?.detail ? errors[0].detail : errMessage,
+ duration: duration,
};
case "client_error":
case "server_error":
return {
title: title,
type: "error",
- content:
- errors && errors[0]?.detail ? errors[0].detail : errMessage,
+ content: errors?.[0]?.detail ? errors[0].detail : errMessage,
+ duration: duration,
};
default:
return {
title: title,
type: "error",
content: errMessage,
+ duration: duration,
};
}
} else {
@@ -54,6 +57,7 @@ const useExceptionHandler = () => {
title: title,
type: "error",
content: errMessage,
+ duration: duration,
};
}
};
diff --git a/frontend/src/store/alert-store.js b/frontend/src/store/alert-store.js
index 0ed6f0bc2..fbb5bc235 100644
--- a/frontend/src/store/alert-store.js
+++ b/frontend/src/store/alert-store.js
@@ -1,20 +1,27 @@
import { create } from "zustand";
+import { isNonNegativeNumber } from "../helpers/GetStaticData";
const STORE_VARIABLES = {
alertDetails: {
type: "",
content: "",
title: "",
+ duration: undefined,
},
};
const useAlertStore = create((setState) => ({
...STORE_VARIABLES,
setAlertDetails: (details) => {
setState(() => {
- const title = details.title;
- const notificationTitle =
- title || (details.type === "error" ? "Failed" : "Success");
- return { alertDetails: { ...details, title: notificationTitle } };
+ const isErrorType = details?.type === "error";
+ details["title"] =
+ details["title"] || (isErrorType ? "Failed" : "Success");
+ details["duration"] = isNonNegativeNumber(details.duration)
+ ? details.duration
+ : isErrorType
+ ? 0
+ : undefined;
+ return { alertDetails: { ...details } };
});
},
}));