Skip to content

🔥 The free & Open Source DocuSign alternative

fix profile dropdown issue and navigation issue in login

prafullnavkar-nxg3349811c590b
diff --git a/apps/OpenSign/src/components/Header.js b/apps/OpenSign/src/components/Header.js
index 84a7e97e8..f15af8a65 100644
--- a/apps/OpenSign/src/components/Header.js
+++ b/apps/OpenSign/src/components/Header.js
@@ -82,7 +82,10 @@ const Header = ({ showSidebar }) => {
/>
</div>
</div>
- <div className="flex justify-between items-center gap-x-3">
+ <div
+ id="profile-menu"
+ className="flex justify-between items-center gap-x-3"
+ >
<div>
<FullScreenButton />
</div>
@@ -103,7 +106,7 @@ const Header = ({ showSidebar }) => {
{username && username}
</div>
)}
- <div className="relative" id="profile-menu">
+ <div className="relative">
<div className="cursor-pointer">
<i onClick={toggleDropdown} className="fa-solid fa-angle-down"></i>
</div>
diff --git a/apps/OpenSign/src/routes/Login.js b/apps/OpenSign/src/routes/Login.js
index 8eea2dba7..ed9b0baeb 100644
--- a/apps/OpenSign/src/routes/Login.js
+++ b/apps/OpenSign/src/routes/Login.js
@@ -1,4 +1,4 @@
-import React, { Component, useState } from "react";
+import React, { useEffect, useState } from "react";
import Parse from "parse";
import "../styles/toast.css";
import "../styles/loader.css";
@@ -8,11 +8,12 @@ import axios from "axios";
import Title from "../components/Title";
import GoogleSignInBtn from "../components/LoginGoogle";
import LoginFacebook from "../components/LoginFacebook";
-import { NavLink, Navigate } from "react-router-dom";
+import { NavLink, useNavigate } from "react-router-dom";
import login_img from "../assets/images/login_img.svg";
-class Login extends Component {
- state = {
+function Login(props) {
+ const navigate = useNavigate();
+ const [state, setState] = useState({
email: "",
toastColor: "#5cb85c",
toastDescription: "",
@@ -28,32 +29,54 @@ class Login extends Component {
loading: false,
thirdpartyLoader: false,
orgModal: false,
- roleModal: false,
ReqOtp: ""
- };
+ });
+
+ const image = props?.appInfo?.applogo || undefined;
- handleChange = (event) => {
+ useEffect(() => {
+ if (localStorage.getItem("accesstoken")) {
+ setState({ ...state, loading: true });
+ GetLoginData();
+ }
+ props.fetchAppInfo(
+ localStorage.getItem("domain"),
+ localStorage.getItem("BaseUrl12"),
+ localStorage.getItem("AppID12")
+ );
+ // eslint-disable-next-line
+ }, []);
+ useEffect(() => {
+ resize();
+ window.addEventListener("resize", resize());
+ return () => {
+ window.removeEventListener("resize", resize());
+ };
+ // eslint-disable-next-line
+ }, []);
+ const handleChange = (event) => {
const { name, value } = event.target;
- this.setState({ [name]: value });
+ setState({ ...state, [name]: value });
};
- resize = () => {
+ const resize = () => {
let currentHideNav = window.innerWidth <= 760;
- if (currentHideNav !== this.state.hideNav) {
- this.setState({ hideNav: currentHideNav });
+ if (currentHideNav !== state.hideNav) {
+ setState({ ...state, hideNav: currentHideNav });
}
};
- handleSubmit = async (event) => {
+ const handleSubmit = async (event) => {
+ localStorage.removeItem("accesstoken");
event.preventDefault();
- const { email, password } = this.state;
+ const { email, password } = state;
if (email && password) {
try {
- this.setState({ loading: true });
+ setState({ ...state, loading: true });
let baseUrl = localStorage.getItem("baseUrl");
let parseAppId = localStorage.getItem("parseAppId");
- localStorage.setItem("appLogo", this.props.appInfo.applogo);
- localStorage.setItem("appName", this.props.appInfo.appname);
+ localStorage.setItem("appLogo", props.appInfo.applogo);
+ localStorage.setItem("appName", props.appInfo.appname);
Parse.serverURL = localStorage.getItem("baseUrl");
Parse.initialize(localStorage.getItem("parseAppId"));
// Pass the username and password to logIn function
@@ -75,8 +98,8 @@ class Login extends Component {
// Check extended class user role and tenentId
try {
let userRoles = [];
- if (this.props.appInfo.settings) {
- let userSettings = this.props.appInfo.settings;
+ if (props.appInfo.settings) {
+ let userSettings = props.appInfo.settings;
//Get Current user roles
let url = `${baseUrl}functions/UserGroups`;
@@ -160,7 +183,7 @@ class Login extends Component {
}
});
if (tenentInfo.length) {
- this.props.showTenantName(
+ props.showTenantName(
tenentInfo[0].tenentName || ""
);
localStorage.setItem(
@@ -170,11 +193,6 @@ class Login extends Component {
}
localStorage.setItem("showpopup", true);
- localStorage.setItem(
- "IncludedApps",
- JSON.stringify(tenentInfo)
- );
-
localStorage.setItem(
"PageLanding",
element.pageId
@@ -187,8 +205,8 @@ class Login extends Component {
"pageType",
element.pageType
);
- this.setState({ loading: false });
- window.location = "/";
+ setState({ ...state, loading: false });
+ navigate("/");
} else {
extendedInfo.forEach((x) => {
if (x.TenantId) {
@@ -205,7 +223,7 @@ class Login extends Component {
}
});
if (tenentInfo.length) {
- this.props.showTenantName(
+ props.showTenantName(
tenentInfo[0].tenentName || ""
);
localStorage.setItem(
@@ -225,7 +243,7 @@ class Login extends Component {
"pageType",
element.pageType
);
- this.setState({ loading: false });
+ setState({ ...state, loading: false });
if (
process.env
.REACT_APP_ENABLE_SUBSCRIPTION
@@ -248,16 +266,19 @@ class Login extends Component {
localStorage.removeItem(
"userDetails"
);
-
- window.location = `/${element.pageType}/${element.pageId}`;
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
} else {
- window.location = `/${element.pageType}/${element.pageId}`;
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
}
}
} else {
@@ -273,7 +294,7 @@ class Login extends Component {
"pageType",
element.pageType
);
- this.setState({ loading: false });
+ setState({ ...state, loading: false });
if (
process.env.REACT_APP_ENABLE_SUBSCRIPTION
) {
@@ -289,10 +310,12 @@ class Login extends Component {
);
const billingDate = "";
if (billingDate) {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
} else {
- window.location = `/${element.pageType}/${element.pageId}`;
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
}
}
},
@@ -300,27 +323,22 @@ class Login extends Component {
/* alert(
"You dont have access to this application."
); */
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription:
- "You dont have access to this application."
- },
- () => {
- var x =
- document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace(
- "show",
- ""
- );
- }, 5000);
- localStorage.setItem("accesstoken", null);
- }
- );
-
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription:
+ "You dont have access to this application."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace(
+ "show",
+ ""
+ );
+ }, 2000);
+ localStorage.setItem("accesstoken", null);
console.error(
"Error while fetching Follow",
error
@@ -330,103 +348,87 @@ class Login extends Component {
}
});
} else {
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: "User Role Not Found."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
- }
- } else {
- this.setState(
- {
+ setState({
+ ...state,
loading: false,
toastColor: "#d9534f",
toastDescription: "User Role Not Found."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
- }
- })
- .catch((err) => {
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: `Does not have permissions to access this application.`
- },
- () => {
- var x = document.getElementById("snackbar");
+ });
+ const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
- }, 5000);
+ }, 2000);
}
- );
+ } else {
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: "User Role Not Found."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
+ }
+ })
+ .catch((err) => {
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: `Does not have permissions to access this application.`
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
});
}
} catch (error) {
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: `${error.message}`
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
-
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: `${error.message}`
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
console.log(error);
}
}
})
.catch((error) => {
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: "Login failed: Invalid username or password."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: "Login failed: Invalid username or password."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
console.error("Error while logging in user", error);
});
} catch (error) {
console.log(error.message);
- this.setState({ loading: false });
+ setState({ ...state, loading: false });
}
}
};
- setThirdpartyLoader = (value) => {
- this.setState({ thirdpartyLoader: value });
+ const setThirdpartyLoader = (value) => {
+ setState({ ...state, thirdpartyLoader: value });
};
- thirdpartyLoginfn = async (sessionToken, billingDate) => {
+ const thirdpartyLoginfn = async (sessionToken, billingDate) => {
const baseUrl = localStorage.getItem("BaseUrl12");
const parseAppId = localStorage.getItem("AppID12");
const res = await axios.get(baseUrl + "users/me", {
@@ -454,8 +456,8 @@ class Login extends Component {
// Check extended class user role and tenentId
try {
let userRoles = [];
- if (this.props.appInfo.settings) {
- let userSettings = this.props.appInfo.settings;
+ if (props.appInfo.settings) {
+ let userSettings = props.appInfo.settings;
//Get Current user roles
let url = `${baseUrl}functions/UserGroups`;
@@ -535,7 +537,7 @@ class Login extends Component {
}
});
if (tenentInfo.length) {
- this.props.showTenantName(
+ props.showTenantName(
tenentInfo[0].tenentName || ""
);
localStorage.setItem(
@@ -545,11 +547,6 @@ class Login extends Component {
}
localStorage.setItem("showpopup", true);
- localStorage.setItem(
- "IncludedApps",
- JSON.stringify(tenentInfo)
- );
-
localStorage.setItem(
"PageLanding",
element.pageId
@@ -562,9 +559,9 @@ class Login extends Component {
"pageType",
element.pageType
);
- this.setThirdpartyLoader(false);
- this.setState({ loading: false });
- window.location = "/";
+ setThirdpartyLoader(false);
+ setState({ ...state, loading: false });
+ navigate(`/`);
} else {
extendedInfo.forEach((x) => {
if (x.TenantId) {
@@ -580,7 +577,7 @@ class Login extends Component {
}
});
if (tenentInfo.length) {
- this.props.showTenantName(
+ props.showTenantName(
tenentInfo[0].tenentName || ""
);
localStorage.setItem(
@@ -600,17 +597,19 @@ class Login extends Component {
"pageType",
element.pageType
);
- this.setThirdpartyLoader(false);
- this.setState({ loading: false });
+ setThirdpartyLoader(false);
+ setState({ ...state, loading: false });
if (billingDate) {
if (billingDate > new Date()) {
localStorage.removeItem("userDetails");
- window.location = `/${element.pageType}/${element.pageId}`;
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
}
} else {
@@ -620,18 +619,19 @@ class Login extends Component {
element.menuId
);
localStorage.setItem("pageType", element.pageType);
- this.setState({ loading: false });
- this.setThirdpartyLoader(false);
+ setState({ ...state, loading: false });
+ setThirdpartyLoader(false);
if (billingDate) {
if (billingDate > new Date()) {
localStorage.removeItem("userDetails");
-
- window.location = `/${element.pageType}/${element.pageId}`;
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
} else {
- window.location = `/subscription`;
+ navigate(`/subscription`);
}
}
},
@@ -639,645 +639,460 @@ class Login extends Component {
/* alert(
"You dont have access to this application."
); */
- this.setThirdpartyLoader(false);
+ setThirdpartyLoader(false);
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription:
- "You dont have access to this application."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- localStorage.setItem("accesstoken", null);
- }
- );
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription:
+ "You dont have access to this application."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
+ localStorage.setItem("accesstoken", null);
console.error("Error while fetching Follow", error);
}
);
}
});
} else {
- this.setThirdpartyLoader(false);
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: "User Role Not Found."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
- }
- } else {
- this.setThirdpartyLoader(false);
- this.setState(
- {
+ setThirdpartyLoader(false);
+ setState({
+ ...state,
loading: false,
toastColor: "#d9534f",
toastDescription: "User Role Not Found."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
- }
- })
- .catch((err) => {
- this.setThirdpartyLoader(false);
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: `Does not have permissions to access this application.`
- },
- () => {
- var x = document.getElementById("snackbar");
+ });
+
+ const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
- }, 5000);
+ }, 2000);
}
- );
+ } else {
+ setThirdpartyLoader(false);
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: "User Role Not Found."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
+ }
+ })
+ .catch((err) => {
+ setThirdpartyLoader(false);
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: `Does not have permissions to access this application.`
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
});
}
} catch (error) {
- this.setThirdpartyLoader(false);
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription: `${error.message}`
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- }
- );
-
+ setThirdpartyLoader(false);
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription: `${error.message}`
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
console.log(error);
}
}
};
- GetLoginData = async () => {
+ const GetLoginData = async () => {
try {
Parse.serverURL = localStorage.getItem("baseUrl");
Parse.initialize(localStorage.getItem("parseAppId"));
- await Parse.User.become(localStorage.getItem("accesstoken")).then(
- async (user) => {
- let _usss = user.toJSON();
- localStorage.setItem("UserInformation", JSON.stringify(_usss));
- localStorage.setItem("username", _usss.name);
- localStorage.setItem("accesstoken", _usss.sessionToken);
- localStorage.setItem("scriptId", true);
- if (_usss.ProfilePic) {
- localStorage.setItem("profileImg", _usss.ProfilePic);
- } else {
- localStorage.setItem("profileImg", "");
- }
- try {
- let userRoles = [];
-
- if (localStorage.getItem("userSettings")) {
- let userSettings = localStorage.getItem("userSettings");
+ const user = await Parse.User.become(localStorage.getItem("accesstoken"));
+ let _usss = user.toJSON();
+ localStorage.setItem("UserInformation", JSON.stringify(_usss));
+ localStorage.setItem("username", _usss.name);
+ localStorage.setItem("accesstoken", _usss.sessionToken);
+ localStorage.setItem("scriptId", true);
+ if (_usss.ProfilePic) {
+ localStorage.setItem("profileImg", _usss.ProfilePic);
+ } else {
+ localStorage.setItem("profileImg", "");
+ }
+ let userRoles = [];
- //Get Current user roles
- let url = `${localStorage.getItem(
- "baseUrl"
- )}functions/UserGroups`;
- const headers1 = {
- "Content-Type": "application/json",
- "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
- sessionToken: _usss.sessionToken
- };
+ if (localStorage.getItem("userSettings")) {
+ let userSettings = localStorage.getItem("userSettings");
- let body = {
- appname: localStorage.getItem("_appName")
- };
+ //Get Current user roles
+ let url = `${localStorage.getItem("baseUrl")}functions/UserGroups`;
+ const headers1 = {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
+ sessionToken: _usss.sessionToken
+ };
- await axios
- .post(url, JSON.stringify(body), { headers: headers1 })
- .then((roles) => {
- if (roles) {
- userRoles = roles.data.result;
- let _currentRole = "";
- if (userRoles.length > 1) {
- if (
- userRoles[0] ===
- `${localStorage.getItem("_appName")}_appeditor`
- ) {
- _currentRole = userRoles[1];
- } else {
- _currentRole = userRoles[0];
- }
- } else {
- _currentRole = userRoles[0];
- }
- let SettingsUser = JSON.parse(userSettings);
- SettingsUser.forEach(async (element) => {
- if (element.role === _currentRole) {
- let _role = _currentRole.replace(
- `${localStorage.getItem("_appName")}_`,
- ""
- );
- localStorage.setItem("_user_role", _role);
+ let body = {
+ appname: localStorage.getItem("_appName")
+ };
- // Get TenentID from Extendend Class
- localStorage.setItem(
- "extended_class",
- element.extended_class
- );
+ await axios
+ .post(url, JSON.stringify(body), { headers: headers1 })
+ .then((roles) => {
+ if (roles) {
+ userRoles = roles.data.result;
+ let _currentRole = "";
+ if (userRoles.length > 1) {
+ if (
+ userRoles[0] ===
+ `${localStorage.getItem("_appName")}_appeditor`
+ ) {
+ _currentRole = userRoles[1];
+ } else {
+ _currentRole = userRoles[0];
+ }
+ } else {
+ _currentRole = userRoles[0];
+ }
+ let SettingsUser = JSON.parse(userSettings);
+ SettingsUser.forEach(async (element) => {
+ if (element.role === _currentRole) {
+ let _role = _currentRole.replace(
+ `${localStorage.getItem("_appName")}_`,
+ ""
+ );
+ localStorage.setItem("_user_role", _role);
- const extendedClass = Parse.Object.extend(
- element.extended_class
- );
- let query = new Parse.Query(extendedClass);
- query.equalTo("UserId", Parse.User.current());
- query.include("TenantId");
- await query.find().then(
- (results) => {
- let tenentInfo = [];
- if (results) {
- let extendedInfo_stringify =
- JSON.stringify(results);
- let extendedInfo = JSON.parse(
- extendedInfo_stringify
- );
- if (extendedInfo.length > 1) {
- extendedInfo.forEach((x) => {
- if (x.TenantId) {
- let obj = {
- tenentId: x.TenantId.objectId,
- tenentName: x.TenantId.TenantName || ""
- };
- tenentInfo.push(obj);
- }
- });
+ // Get TenentID from Extendend Class
+ localStorage.setItem(
+ "extended_class",
+ element.extended_class
+ );
- localStorage.setItem("showpopup", true);
- localStorage.setItem(
- "IncludedApps",
- JSON.stringify(tenentInfo)
- );
+ const extendedClass = Parse.Object.extend(
+ element.extended_class
+ );
+ let query = new Parse.Query(extendedClass);
+ query.equalTo("UserId", Parse.User.current());
+ query.include("TenantId");
+ await query.find().then(
+ (results) => {
+ let tenentInfo = [];
+ if (results) {
+ let extendedInfo_stringify = JSON.stringify(results);
+ let extendedInfo = JSON.parse(extendedInfo_stringify);
+ if (extendedInfo.length > 1) {
+ extendedInfo.forEach((x) => {
+ if (x.TenantId) {
+ let obj = {
+ tenentId: x.TenantId.objectId,
+ tenentName: x.TenantId.TenantName || ""
+ };
+ tenentInfo.push(obj);
+ }
+ });
- localStorage.setItem(
- "PageLanding",
- element.pageId
- );
- localStorage.setItem(
- "defaultmenuid",
- element.menuId
- );
- localStorage.setItem(
- "pageType",
- element.pageType
- );
- window.location = `/`;
- } else {
- extendedInfo.forEach((x) => {
- if (x.TenantId) {
- let obj = {
- tenentId: x.TenantId.objectId,
- tenentName: x.TenantId.TenantName || ""
- };
- localStorage.setItem(
- "TenetId",
- x.TenantId.objectId
- );
- tenentInfo.push(obj);
- }
- });
- localStorage.setItem(
- "PageLanding",
- element.pageId
- );
- localStorage.setItem(
- "defaultmenuid",
- element.menuId
- );
- localStorage.setItem(
- "pageType",
- element.pageType
- );
- window.location = `/${element.pageType}/${element.pageId}`;
- }
- } else {
- localStorage.setItem(
- "PageLanding",
- element.pageId
- );
- localStorage.setItem(
- "defaultmenuid",
- element.menuId
- );
+ localStorage.setItem("showpopup", true);
+ localStorage.setItem("PageLanding", element.pageId);
+ localStorage.setItem("defaultmenuid", element.menuId);
+ localStorage.setItem("pageType", element.pageType);
+ navigate("/");
+ } else {
+ extendedInfo.forEach((x) => {
+ if (x.TenantId) {
+ let obj = {
+ tenentId: x.TenantId.objectId,
+ tenentName: x.TenantId.TenantName || ""
+ };
localStorage.setItem(
- "pageType",
- element.pageType
+ "TenetId",
+ x.TenantId.objectId
);
- window.location = `/${element.pageType}/${element.pageId}`;
+ tenentInfo.push(obj);
}
- },
- (error) => {
- this.setState(
- {
- loading: false,
- toastColor: "#d9534f",
- toastDescription:
- "You don`t have access to this application."
- },
- () => {
- var x = document.getElementById("snackbar");
- x.className = "show";
- setTimeout(function () {
- x.className = x.className.replace("show", "");
- }, 5000);
- localStorage.setItem("accesstoken", null);
- localStorage.removeItem("SwitcherApp");
- }
- );
-
- console.error("Error while fetching Follow", error);
- }
- );
+ });
+ localStorage.setItem("PageLanding", element.pageId);
+ localStorage.setItem("defaultmenuid", element.menuId);
+ localStorage.setItem("pageType", element.pageType);
+ navigate(`/${element.pageType}/${element.pageId}`);
+ }
+ } else {
+ localStorage.setItem("PageLanding", element.pageId);
+ localStorage.setItem("defaultmenuid", element.menuId);
+ localStorage.setItem("pageType", element.pageType);
+ navigate(`/${element.pageType}/${element.pageId}`);
}
- });
- } else {
- console.log("User Role Not Found.");
- localStorage.removeItem("SwitcherApp");
- }
- })
- .catch((err) => {
- this.setState({ roleModal: true });
- localStorage.removeItem("SwitcherApp");
- });
+ },
+ (error) => {
+ setState({
+ ...state,
+ loading: false,
+ toastColor: "#d9534f",
+ toastDescription:
+ "You don`t have access to this application."
+ });
+ const x = document.getElementById("snackbar");
+ x.className = "show";
+ setTimeout(function () {
+ x.className = x.className.replace("show", "");
+ }, 2000);
+ localStorage.setItem("accesstoken", null);
+ console.error("Error while fetching Follow", error);
+ }
+ );
+ }
+ });
+ } else {
+ console.log("User Role Not Found.");
}
- } catch (error) {
- localStorage.removeItem("SwitcherApp");
- }
- }
- );
+ })
+ .catch((err) => {
+ setState({ ...state, loading: false });
+ console.log("err", err);
+ });
+ }
} catch (error) {
+ setState({ ...state, loading: false });
console.log("err", error);
}
};
- sendAddRoleRequest = (e) => {
- try {
- e.preventDefault();
- let _user = JSON.parse(localStorage.getItem("UserInformation"));
- Parse.serverURL = localStorage.getItem("baseUrl");
- Parse.initialize(localStorage.getItem("parseAppId"));
- const role_req = Parse.Object.extend("partners_Request");
- const myNewObject = new role_req();
- myNewObject.set("AppName", localStorage.getItem("_appName"));
- myNewObject.set("Status", "Pending");
- myNewObject.set("UserId", {
- __type: "Pointer",
- className: "_User",
- objectId: _user.objectId
- });
- myNewObject.set("TenetId", {
- __type: "Pointer",
- className: "partners_Tenant",
- objectId: localStorage.getItem("TenetId")
- });
- /* myNewObject.set("AppId", {
- __type: "Pointer",
- className: "elearning_BuildConfig",
- objectId: localStorage.getItem("TenetId")
- }); */
- myNewObject
- .save()
- .then((result) => {
- if (result) {
- alert("Request sended successfully.");
- this.setState({ roleModal: false });
- }
- })
- .catch((err) => {
- alert(err.message);
- this.setState({ roleModal: false });
- });
- } catch (error) {
- alert(error.message);
- this.setState({ roleModal: false });
- }
+ const togglePasswordVisibility = () => {
+ setState({ ...state, passwordVisible: !state.passwordVisible });
};
- componentDidMount() {
- window.addEventListener("resize", this.resize.bind(this));
- if (
- localStorage.getItem("accesstoken") &&
- localStorage.getItem("SwitcherApp")
- ) {
- this.GetLoginData();
- }
- this.props.fetchAppInfo(
- localStorage.getItem("domain"),
- localStorage.getItem("BaseUrl12"),
- localStorage.getItem("AppID12")
- );
- this.resize();
- }
-
- render() {
- if (
- localStorage.getItem("accesstoken") &&
- localStorage.getItem("pageType")
- ) {
- let _redirect = `/${localStorage.getItem(
- "pageType"
- )}/${localStorage.getItem("PageLanding")}`;
- return <Navigate to={_redirect} />;
- }
-
- const { email, password, passwordVisible } = this.state;
- let image = this.props.appInfo.applogo;
- let settings = this.props.appInfo.settings || undefined;
- const togglePasswordVisibility = () => {
- this.setState((prevState) => ({
- passwordVisible: !prevState.passwordVisible
- }));
- };
- return (
- <div className="bg-white">
- {settings &&
- settings.map((x) => {
- return x.pageType === "microapp" ? (
- <iframe
- key={x.pageId}
- id="def_iframe"
- src={x.pageId}
- height="0px"
- width="0px"
- title="micro"
- />
- ) : null;
- })}
-
- <Title title={"Login Page"} />
-
- {this.props.isloginVisible && this.props.isloginVisible ? (
- <div>
- <div className="md:m-10 lg:m-16 md:p-4 lg:p-10 p-5 bg-[#ffffff] md:border-[1px] md:border-gray-400 ">
- <div className="w-[250px] h-[66px] inline-block">
- {this.state.hideNav ? (
- <img src={image} width="100%" alt="" />
- ) : (
- <img src={image} width="100%" alt="" />
- )}
- </div>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-x-2">
- <div className="">
- <div>
- <form onSubmit={this.handleSubmit}>
- <h2 className="text-[30px] mt-6">Welcome Back !</h2>
- <span className="text-[12px] text-[#878787]">
- Login to your account
- </span>
- <div className="shadow-md rounded my-4">
- <div className="px-6 py-4">
- <label className="block text-xs">Username</label>
+ return (
+ <div className="bg-white">
+ <Title title={"Login Page"} />
+ {state.loading && (
+ <div
+ style={{
+ position: "fixed",
+ width: "100vw",
+ height: "100vh",
+ backgroundColor: "rgba(0,0,0,0.2)",
+ top: 0,
+ left: 0,
+ zIndex: 2
+ }}
+ >
+ <div
+ style={{
+ position: "fixed",
+ fontSize: "50px",
+ color: "#3ac9d6",
+ top: "50%",
+ left: "45%"
+ }}
+ className="loader-37"
+ ></div>
+ </div>
+ )}
+ {props.isloginVisible && props.isloginVisible ? (
+ <div>
+ <div className="md:m-10 lg:m-16 md:p-4 lg:p-10 p-5 bg-[#ffffff] md:border-[1px] md:border-gray-400 ">
+ <div className="w-[250px] h-[66px] inline-block">
+ {state.hideNav ? (
+ <img src={image} width="100%" alt="" />
+ ) : (
+ <img src={image} width="100%" alt="" />
+ )}
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-x-2">
+ <div className="">
+ <div>
+ <form onSubmit={handleSubmit}>
+ <h2 className="text-[30px] mt-6">Welcome Back !</h2>
+ <span className="text-[12px] text-[#878787]">
+ Login to your account
+ </span>
+ <div className="shadow-md rounded my-4">
+ <div className="px-6 py-4">
+ <label className="block text-xs">Username</label>
+ <input
+ type="text"
+ className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
+ name="email"
+ value={state.email}
+ onChange={handleChange}
+ required
+ />
+ <hr className="my-2 border-none" />
+ <label className="block text-xs">Password</label>
+ <div className="relative">
<input
- type="text"
+ type={state.passwordVisible ? "text" : "password"}
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
- name="email"
- value={email}
- onChange={this.handleChange}
+ name="password"
+ value={state.password}
+ onChange={handleChange}
required
/>
- <hr className="my-2 border-none" />
- <label className="block text-xs">Password</label>
- <div className="relative">
- <input
- type={passwordVisible ? "text" : "password"}
- className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
- name="password"
- value={password}
- onChange={this.handleChange}
- required
- />
- <span
- className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
- passwordVisible
- ? "text-[#007bff]"
- : "text-black"
- }`}
- onClick={togglePasswordVisibility}
- >
- {passwordVisible ? (
- <i className="fa fa-eye-slash" /> // Close eye icon
- ) : (
- <i className="fa fa-eye" /> // Open eye icon
- )}
- </span>
- </div>
- </div>
- </div>
- <div className="flex flex-row justify-between items-center text-xs px-4 py-2">
- <div>
- <label className="form-check-label">
- <input
- type="checkbox"
- className="form-check-input"
- value=""
- />
- <span className="text-center pl-1">
- Remember Password
- </span>
- </label>
- </div>
- <div>
- <span className="text-[13px]">
- <NavLink to={`/forgetpassword`}>
- Forgot Password ?
- </NavLink>
+ <span
+ className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
+ state.passwordVisible
+ ? "text-[#007bff]"
+ : "text-black"
+ }`}
+ onClick={togglePasswordVisibility}
+ >
+ {state.passwordVisible ? (
+ <i className="fa fa-eye-slash" /> // Close eye icon
+ ) : (
+ <i className="fa fa-eye" /> // Open eye icon
+ )}
</span>
</div>
</div>
- <div className="flex flex-col md:flex-row justify-between items-stretch gap-8 text-center text-xs font-bold mt-2">
- <button
- type="submit"
- className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow uppercase"
- disabled={this.state.loading}
- >
- {this.state.loading ? "Loading..." : "Login"}
- </button>
- <NavLink
- className="rounded-sm cursor-pointer bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] w-full py-3 shadow uppercase"
- to="/signup"
- style={
- this.state.hideNav ? { textAlign: "center" } : {}
- }
- >
- Create Account
- </NavLink>
+ </div>
+ <div className="flex flex-row justify-between items-center text-xs px-4 py-2">
+ <div>
+ <label className="form-check-label">
+ <input
+ type="checkbox"
+ className="form-check-input"
+ value=""
+ />
+ <span className="text-center pl-1">
+ Remember Password
+ </span>
+ </label>
</div>
- </form>
- <br />
- {(this.props.appInfo.fbAppId ||
- this.props.appInfo.googleClietId) && (
- <div
- style={{
- display: "flex",
- alignItems: "center",
- justifyContent: "center"
- }}
- className="text-sm"
- >
- <hr
- className={"border-[1px] border-gray-300 w-full"}
- style={{ color: "grey" }}
- />
- <span style={{ color: "grey" }} className="px-2 ">
- OR
+ <div>
+ <span className="text-[13px]">
+ <NavLink to={`/forgetpassword`}>
+ Forgot Password ?
+ </NavLink>
</span>
- <hr
- className={"border-[1px] border-gray-300 w-full"}
- style={{ color: "grey" }}
- />
</div>
- )}
- <br />
- <div
- style={{
- textAlign: "center",
- display: "flex",
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- {this.props.appInfo.fbAppId &&
- this.props.appInfo.fbAppId !== "" ? (
- <LoginFacebook
- FBCred={this.props.appInfo.fbAppId}
- thirdpartyLoginfn={this.thirdpartyLoginfn}
- thirdpartyLoader={this.state.thirdpartyLoader}
- setThirdpartyLoader={this.setThirdpartyLoader}
- />
- ) : null}
</div>
- <div style={{ margin: "10px 0" }}></div>
+ <div className="flex flex-col md:flex-row justify-between items-stretch gap-8 text-center text-xs font-bold mt-2">
+ <button
+ type="submit"
+ className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow uppercase"
+ disabled={state.loading}
+ >
+ {state.loading ? "Loading..." : "Login"}
+ </button>
+ <NavLink
+ className="rounded-sm cursor-pointer bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] w-full py-3 shadow uppercase"
+ to="/signup"
+ style={state.hideNav ? { textAlign: "center" } : {}}
+ >
+ Create Account
+ </NavLink>
+ </div>
+ </form>
+ <br />
+ {(props.appInfo.fbAppId || props.appInfo.googleClietId) && (
<div
style={{
- textAlign: "center",
display: "flex",
alignItems: "center",
justifyContent: "center"
}}
+ className="text-sm"
>
- {this.props.appInfo.googleClietId &&
- this.props.appInfo.googleClietId !== "" ? (
- <GoogleSignInBtn
- GoogleCred={this.props.appInfo.googleClietId}
- thirdpartyLoginfn={this.thirdpartyLoginfn}
- thirdpartyLoader={this.state.thirdpartyLoader}
- setThirdpartyLoader={this.setThirdpartyLoader}
- />
- ) : null}
+ <hr
+ className={"border-[1px] border-gray-300 w-full"}
+ style={{ color: "grey" }}
+ />
+ <span style={{ color: "grey" }} className="px-2 ">
+ OR
+ </span>
+ <hr
+ className={"border-[1px] border-gray-300 w-full"}
+ style={{ color: "grey" }}
+ />
</div>
+ )}
+ <br />
+ <div
+ style={{
+ textAlign: "center",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center"
+ }}
+ >
+ {props.appInfo.fbAppId && props.appInfo.fbAppId !== "" ? (
+ <LoginFacebook
+ FBCred={props.appInfo.fbAppId}
+ thirdpartyLoginfn={thirdpartyLoginfn}
+ thirdpartyLoader={state.thirdpartyLoader}
+ setThirdpartyLoader={setThirdpartyLoader}
+ />
+ ) : null}
</div>
- </div>
- {!this.state.hideNav && (
- <div className="self-center">
- <div className="mx-auto md:w-[300px] lg:w-[500px]">
- <img src={login_img} alt="bisec" width="100%" />
- </div>
+ <div style={{ margin: "10px 0" }}></div>
+ <div
+ style={{
+ textAlign: "center",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center"
+ }}
+ >
+ {props.appInfo.googleClietId &&
+ props.appInfo.googleClietId !== "" ? (
+ <GoogleSignInBtn
+ GoogleCred={props.appInfo.googleClietId}
+ thirdpartyLoginfn={thirdpartyLoginfn}
+ thirdpartyLoader={state.thirdpartyLoader}
+ setThirdpartyLoader={setThirdpartyLoader}
+ />
+ ) : null}
</div>
- )}
+ </div>
</div>
- </div>
- {this.state.roleModal && (
- <div className="fixed top-0 left-0 w-full h-full flex items-center justify-center bg-black bg-opacity-50 z-50">
- {/* <!-- Modal Container --> */}
- <div className="bg-white p-4 rounded-lg shadow-lg max-w-xs md:min-w-[500px] md:max-w-md">
- {/* <!-- Modal Header --> */}
- <div className="flex justify-between w-full items-center border-b-2 mb-2">
- <h2 className="text-md md:text-xl font-semibold">
- Request for Access Application
- </h2>
- <button
- className="text-black focus:outline-none"
- id="closeModal"
- onClick={(e) => {
- e.preventDefault();
- this.setState({ roleModal: false });
- }}
- >
- <svg
- xmlns="http://www.w3.org/2000/svg"
- className="h-6 w-6"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- d="M6 18L18 6M6 6l12 12"
- />
- </svg>
- </button>
- </div>
- {/* <!-- Modal Body --> */}
- <div className="p-4">
- <p>{`Are you sure to send request for access ${localStorage.getItem(
- "appTitle"
- )} application.`}</p>
- <button
- type="button"
- onClick={this.sendAddRoleRequest}
- className="px-6 py-2 bg-[#2abfcc] text-white rounded shadow"
- >
- Send Request
- </button>
+ {!state.hideNav && (
+ <div className="self-center">
+ <div className="mx-auto md:w-[300px] lg:w-[500px]">
+ <img src={login_img} alt="bisec" width="100%" />
</div>
</div>
- </div>
- )}
-
- <div
- id="snackbar"
- style={{ backgroundColor: this.state.toastColor }}
- >
- {this.state.toastDescription}
+ )}
</div>
</div>
- ) : (
- <div
- style={{
- position: "fixed",
- fontSize: "50px",
- color: "#3ac9d6",
- top: "50%",
- left: "45%"
- }}
- className="loader-37"
- ></div>
- )}
- </div>
- );
- }
+
+ <div id="snackbar" style={{ backgroundColor: state.toastColor }}>
+ {state.toastDescription}
+ </div>
+ </div>
+ ) : (
+ <div
+ style={{
+ position: "fixed",
+ fontSize: "50px",
+ color: "#3ac9d6",
+ top: "50%",
+ left: "45%"
+ }}
+ className="loader-37"
+ ></div>
+ )}
+ </div>
+ );
+ // }
}
const mapStateToProps = (state) => {