From eebaea3788ee417f8ca96c844bd399334344b877 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 21 Jun 2024 17:32:38 -0300 Subject: [PATCH] fix refresh on App --- src/frontend/src/App.tsx | 43 +-------------- src/frontend/src/alerts/displayArea/index.tsx | 53 +++++++++++++++++++ .../messagesPage/hooks/use-updateMessage.tsx | 12 ++--- 3 files changed, 61 insertions(+), 47 deletions(-) create mode 100644 src/frontend/src/alerts/displayArea/index.tsx diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 720ffb6b2..a30f50426 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -25,21 +25,13 @@ import useFlowsManagerStore from "./stores/flowsManagerStore"; import { useFolderStore } from "./stores/foldersStore"; import { useGlobalVariablesStore } from "./stores/globalVariablesStore/globalVariables"; import { useStoreStore } from "./stores/storeStore"; +import AlertDisplayArea from "./alerts/displayArea"; export default function App() { useTrackLastVisitedPath(); - const removeFromTempNotificationList = useAlertStore( - (state) => state.removeFromTempNotificationList, - ); - const tempNotificationList = useAlertStore( - (state) => state.tempNotificationList, - ); const [fetchError, setFetchError] = useState(false); const isLoading = useFlowsManagerStore((state) => state.isLoading); - const removeAlert = (id: string) => { - removeFromTempNotificationList(id); - }; const { isAuthenticated, login, setUserData, setAutoLogin, getUser } = useContext(AuthContext); @@ -208,38 +200,7 @@ export default function App() {
-
- {tempNotificationList.map((alert) => ( -
- {alert.type === "error" ? ( - - ) : alert.type === "notice" ? ( - - ) : ( - alert.type === "success" && ( - - ) - )} -
- ))} -
+
); diff --git a/src/frontend/src/alerts/displayArea/index.tsx b/src/frontend/src/alerts/displayArea/index.tsx new file mode 100644 index 000000000..9f39ee6dd --- /dev/null +++ b/src/frontend/src/alerts/displayArea/index.tsx @@ -0,0 +1,53 @@ +import useAlertStore from "../../stores/alertStore"; +import ErrorAlert from "../error"; +import NoticeAlert from "../notice"; +import SuccessAlert from "../success"; + +export default function AlertDisplayArea(){ + + const removeFromTempNotificationList = useAlertStore( + (state) => state.removeFromTempNotificationList, + ); + const tempNotificationList = useAlertStore( + (state) => state.tempNotificationList, + ); + const removeAlert = (id: string) => { + removeFromTempNotificationList(id); + }; + + + return ( +
+ {tempNotificationList.map((alert) => ( +
+ {alert.type === "error" ? ( + + ) : alert.type === "notice" ? ( + + ) : ( + alert.type === "success" && ( + + ) + )} +
+ ))} +
+ ) +} \ No newline at end of file diff --git a/src/frontend/src/pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage.tsx b/src/frontend/src/pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage.tsx index f199ac489..1396acf4b 100644 --- a/src/frontend/src/pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage.tsx @@ -12,14 +12,14 @@ const useUpdateMessage = (setSuccessData, setErrorData) => { updateMessage(data); // Set success message - setSuccessData({ - title: "Messages updated successfully.", - }); + // setSuccessData({ + // title: "Messages updated successfully.", + // }); } catch (error) { // Set error message - setErrorData({ - title: "Error updating messages.", - }); + // setErrorData({ + // title: "Error updating messages.", + // }); return Promise.reject(error); } };