From ccdf50dbe0874082bab9e2dc1c54d7f4753c429e Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Fri, 29 Dec 2023 16:50:10 +0530 Subject: [PATCH] add validation for delete contact --- apps/OpenSign/src/App.js | 2 +- apps/OpenSign/src/layout/HomeLayout.js | 14 ++- .../src/primitives/GetReportDisplay.js | 101 ++++++++++++------ .../{layout => primitives}/ValidateRoute.js | 15 ++- 4 files changed, 94 insertions(+), 38 deletions(-) rename apps/OpenSign/src/{layout => primitives}/ValidateRoute.js (65%) diff --git a/apps/OpenSign/src/App.js b/apps/OpenSign/src/App.js index d1555f8bf..cbfc5141a 100644 --- a/apps/OpenSign/src/App.js +++ b/apps/OpenSign/src/App.js @@ -15,7 +15,7 @@ import ForgetPassword from "./routes/ForgetPassword"; import ChangePassword from "./routes/ChangePassword"; import ReportMicroapp from "./components/ReportMicroapp"; import LoadMf from "./routes/LoadMf"; -import ValidateRoute from "./layout/ValidateRoute"; +import ValidateRoute from "./primitives/ValidateRoute"; function App() { const [isloading, setIsLoading] = useState(true); diff --git a/apps/OpenSign/src/layout/HomeLayout.js b/apps/OpenSign/src/layout/HomeLayout.js index 07531f020..4d62aa564 100644 --- a/apps/OpenSign/src/layout/HomeLayout.js +++ b/apps/OpenSign/src/layout/HomeLayout.js @@ -178,8 +178,16 @@ const HomeLayout = ({ children }) => { }; const handleLoginBtn = () => { - Parse.User.logOut(); - navigate("/", { replace: true }); + try { + Parse.User.logOut(); + localStorage.removeItem("accesstoken"); + navigate("/", { replace: true }); + } catch (err) { + console.log("err ", err); + } finally { + localStorage.removeItem("accesstoken"); + navigate("/", { replace: true }); + } }; return (
@@ -213,7 +221,7 @@ const HomeLayout = ({ children }) => { ) : (
-

Your session has expired.

+

Your session has expired.

))} + {isDeleteModal[item.objectId] && ( + +
+
+ Are you sure you want to delete this contact? +
+
+
+ + +
+
+
+ )} ) : ( @@ -421,10 +456,14 @@ const ReportTable = ({
No Data Available
)} - +
diff --git a/apps/OpenSign/src/layout/ValidateRoute.js b/apps/OpenSign/src/primitives/ValidateRoute.js similarity index 65% rename from apps/OpenSign/src/layout/ValidateRoute.js rename to apps/OpenSign/src/primitives/ValidateRoute.js index e1b1b8825..62202dfe6 100644 --- a/apps/OpenSign/src/layout/ValidateRoute.js +++ b/apps/OpenSign/src/primitives/ValidateRoute.js @@ -11,14 +11,23 @@ const ValidateRoute = ({ children }) => { sessionToken: localStorage.getItem("accesstoken") }); if (!user) { - Parse.User.logOut(); + handlelogout(); } } catch (error) { - // Session token is invalid or there was an error - Parse.User.logOut(); + handlelogout(); } })(); }, []); + const handlelogout = async () => { + try { + Parse.User.logOut(); + localStorage.removeItem("accesstoken"); + } catch (err) { + console.log("err ", err); + } finally { + localStorage.removeItem("accesstoken"); + } + }; return
{children}
; };