refactor: remove unnecessary component

This commit is contained in:
prafull-opensignlabs
2024-03-06 11:08:42 +05:30
parent fcad04461f
commit afbfd9ed43
18 changed files with 115 additions and 294 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
# Frontend config ************************************************************************************************************************************************************************************************
# Set CI to false while running the app locally
CI=false
# Set it to the URL form where the app home page will be accessed
PUBLIC_URL=https://app.opensignlabs.com/
# Set it to true if you want to generate the Sourcemap for debugging
-2
View File
@@ -2,8 +2,6 @@
# When used as it is, this env config will connect to our hosted UAT backend
# Note that any data in staging will get cleared from time to time and you may have to sign up again and again
# Set CI to false while running the app locally
CI=false
# Set it to the URL form where the app home page will be accessed
PUBLIC_URL=http://localhost:3000
# Set it to true if you want to generate the Sourcemap for debugging
-2
View File
@@ -2,8 +2,6 @@
# When used as it is, this env config will connect to our hosted UAT backend
# Note that any data in staging will get cleared from time to time and you may have to sign up again and again
# Set CI to false while running the app locally
CI=false
# Set it to the URL form where the app home page will be accessed
PUBLIC_URL=http://localhost:3000
# Set it to true if you want to generate the Sourcemap for debugging
@@ -1,49 +0,0 @@
import React, { Component } from "react";
export class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError() {
return {
hasError: true
};
}
componentDidCatch(error, info) {
console.log(error);
console.log(info);
}
render() {
if (this.state.hasError) {
return (
<div className="p-2">
<div
style={{
height: "100vh",
display: "flex",
flexFlow: "column"
}}
>
<h1
style={{
fontSize: "2em",
fontFamily: "sans-serif",
textShadow: "0 0 20px black"
}}
>
Something went wrong.
</h1>
</div>
</div>
);
}
return this.props.children;
}
}
export default ErrorBoundary;
@@ -1,8 +1,5 @@
import React, { Suspense, lazy } from "react";
import ErrorBoundary from "../ErrorBoundary";
const DashboardCard = lazy(() => import("./DashboardCard"));
const DashboardReport = lazy(() => import("./DashboardReport"));
const GetDashboard = (props) => {
@@ -76,25 +73,23 @@ const GetDashboard = (props) => {
}
};
return (
<ErrorBoundary>
<div>
{props.dashboard.map((val, key) => (
<div key={"a" + key} className="row">
{val.columns.map((col, i) =>
col.widget.data && col.widget.data.tourSection ? (
<div key={i} className={props.classnameArray[key][i]}>
{renderSwitchWithTour(col)}
</div>
) : (
<div key={i} className={props.classnameArray[key][i]}>
{renderSwitch(col)}
</div>
)
)}
</div>
))}
</div>
</ErrorBoundary>
<div>
{props.dashboard.map((val, key) => (
<div key={"a" + key} className="row">
{val.columns.map((col, i) =>
col.widget.data && col.widget.data.tourSection ? (
<div key={i} className={props.classnameArray[key][i]}>
{renderSwitchWithTour(col)}
</div>
) : (
<div key={i} className={props.classnameArray[key][i]}>
{renderSwitch(col)}
</div>
)
)}
</div>
))}
</div>
);
};
@@ -327,7 +327,7 @@ function Placeholder(props) {
className="dropdown-item itemColor"
style={{ fontSize: "12px" }}
>
{data?.date ? data?.date : "nodata"}
{data?.date ? data?.date : "No data"}
</span>
);
})}
@@ -6,8 +6,8 @@ import {
handleImageResize,
handleSignYourselfImageResize
} from "../../constant/Utils";
import EmailToast from "../../primitives/EmailToast";
import Placeholder from "./Placeholder";
import Alert from "../../primitives/Alert";
function RenderPdf({
pageNumber,
@@ -324,6 +324,7 @@ function RenderPdf({
return (
<>
{successEmail && <Alert type={"success"}>Email sent successfully!</Alert>}
{isMobile && scale ? (
<div
style={{
@@ -333,7 +334,6 @@ function RenderPdf({
ref={drop}
id="container"
>
<EmailToast isShow={successEmail} />
{pdfLoadFail.status &&
(pdfRequest
? signerPos.map((data, key) => {
@@ -514,7 +514,6 @@ function RenderPdf({
ref={drop}
id="container"
>
<EmailToast isShow={successEmail} />
{pdfLoadFail.status &&
(pdfRequest
? signerPos.map((data, key) => {
+1 -1
View File
@@ -18,7 +18,7 @@ const Alert = ({ children, type }) => {
<>
{children && (
<div
className={`z-40 fixed top-20 left-1/2 transform -translate-x-1/2 border-[1px] text-sm ${textcolor} rounded py-[.75rem] px-[1.25rem] `}
className={`z-40 fixed top-20 left-1/2 transform -translate-x-1/2 border-[1px] text-sm ${textcolor} rounded py-[.75rem] px-[1.25rem] z-50`}
>
{children}
</div>
@@ -1,21 +0,0 @@
import React from "react";
import "../styles/signature.css";
function EmailToast({ isShow }) {
return (
<>
{isShow && (
<div style={{ display: "flex", justifyContent: "center" }}>
<div
className="alert alert-success successBox"
style={{ zIndex: "1051" }}
>
Email sent successfully!
</div>
</div>
)}
</>
);
}
export default EmailToast;
-18
View File
@@ -1,18 +0,0 @@
import React from "react";
function Nodata() {
return (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "50vh"
}}
>
<span style={{ fontWeight: "bold" }}>No Data Found!</span>
</div>
);
}
export default Nodata;
+45 -37
View File
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from "react";
import Parse from "parse";
import "../styles/toast.css";
import "../styles/loader.css";
import { connect } from "react-redux";
import { fetchAppInfo, showTenantName } from "../redux/actions";
@@ -13,6 +12,7 @@ import login_img from "../assets/images/login_img.svg";
import { useWindowSize } from "../hook/useWindowSize";
import ModalUi from "../primitives/ModalUi";
import { modalCancelBtnColor, modalSubmitBtnColor } from "../constant/const";
import Alert from "../primitives/Alert";
function Login(props) {
const navigate = useNavigate();
@@ -20,8 +20,8 @@ function Login(props) {
const { width } = useWindowSize();
const [state, setState] = useState({
email: "",
toastColor: "#5cb85c",
toastDescription: "",
alertType: "success",
alertMsg: "",
password: "",
passwordVisible: false,
mobile: "",
@@ -354,13 +354,16 @@ function Login(props) {
setState({
...state,
loading: false,
toastColor: "#d9534f",
toastDescription: `${error.message}`
alertType: "danger",
alertMsg: `${error.message}`
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
...state,
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
console.log(error);
}
@@ -370,13 +373,16 @@ function Login(props) {
setState({
...state,
loading: false,
toastColor: "#d9534f",
toastDescription: "Login failed: Invalid username or password."
alertType: "danger",
alertMsg: "Invalid username or password!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
...state,
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
console.error("Error while logging in user", error);
});
@@ -647,13 +653,16 @@ function Login(props) {
setState({
...state,
loading: false,
toastColor: "#d9534f",
toastDescription: `${error.message}`
alertType: "danger",
alertMsg: `${error.message}`
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
...state,
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
console.log(error);
}
@@ -717,13 +726,17 @@ function Login(props) {
setState({
...state,
loading: false,
toastColor: "#d9534f",
toastDescription: `Does not have permissions to access this application.`
alertType: "danger",
alertMsg:
"Does not have permissions to access this application!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
...state,
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
}
// _currentRole = userRoles[0];
@@ -802,14 +815,16 @@ function Login(props) {
setState({
...state,
loading: false,
toastColor: "#d9534f",
toastDescription:
"You don`t have access to this application."
alertType: "danger",
alertMsg: "You don`t have access to this application!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
...state,
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
localStorage.setItem("accesstoken", null);
console.error("Error while fetching Follow", error);
@@ -1124,14 +1139,7 @@ function Login(props) {
)}
</div>
</div>
<div
id="snackbar"
role="alert"
style={{ backgroundColor: state.toastColor }}
>
{state.toastDescription}
</div>
<Alert type={state.alertType}>{state.alertMsg}</Alert>
</div>
<ModalUi isOpen={isModal} title="Additional Info" showClose={false}>
<form className="px-4 py-3">
+1 -5
View File
@@ -23,7 +23,6 @@ import {
} from "../constant/Utils";
import Loader from "../components/pdf/Loader";
import HandleError from "../primitives/HandleError";
import Nodata from "../primitives/Nodata";
import Header from "../components/pdf/Header";
import RenderPdf from "../components/pdf/RenderPdf";
import PdfDeclineModal from "../primitives/PdfDeclineModal";
@@ -58,7 +57,6 @@ function PdfRequestFiles() {
const [pdfNewWidth, setPdfNewWidth] = useState();
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
const [signerPos, setSignerPos] = useState([]);
const [noData, setNoData] = useState(false);
const [signerObjectId, setSignerObjectId] = useState();
const [isUiLoading, setIsUiLoading] = useState(false);
const [isDecline, setIsDecline] = useState({ isDeclined: false });
@@ -295,7 +293,7 @@ function PdfRequestFiles() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -977,8 +975,6 @@ function PdfRequestFiles() {
<Loader isLoading={isLoading} />
) : handleError ? (
<HandleError handleError={handleError} />
) : noData ? (
<Nodata />
) : (
<div>
{isUiLoading && (
+2 -8
View File
@@ -14,7 +14,6 @@ import loader from "../assets/images/loader2.gif";
import { useLocation, useParams } from "react-router-dom";
import Loader from "../components/pdf/Loader";
import HandleError from "../primitives/HandleError";
import Nodata from "../primitives/Nodata";
import SignerListPlace from "../components/pdf/SignerListPlace";
import Header from "../components/pdf/Header";
import {
@@ -65,7 +64,6 @@ function PlaceHolderSign() {
const [checkTourStatus, setCheckTourStatus] = useState(false);
const [tourStatus, setTourStatus] = useState([]);
const [signerUserId, setSignerUserId] = useState();
const [noData, setNoData] = useState(false);
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
const [contractName, setContractName] = useState("");
const [containerWH, setContainerWH] = useState();
@@ -274,8 +272,7 @@ function PlaceHolderSign() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -305,8 +302,7 @@ function PlaceHolderSign() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (res.length === 0) {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -1315,8 +1311,6 @@ function PlaceHolderSign() {
<Loader isLoading={isLoading} />
) : handleError ? (
<HandleError handleError={handleError} />
) : noData ? (
<Nodata />
) : (
<div className="signatureContainer" ref={divRef}>
{isUiLoading && (
+41 -35
View File
@@ -7,6 +7,7 @@ import { fetchAppInfo, showTenantName } from "../redux/actions";
import { useNavigate, NavLink } from "react-router-dom";
import login_img from "../assets/images/login_img.svg";
import { useWindowSize } from "../hook/useWindowSize";
import Alert from "../primitives/Alert";
const Signup = (props) => {
const { width } = useWindowSize();
@@ -21,8 +22,8 @@ const Signup = (props) => {
const [jobTitle, setJobTitle] = useState("");
const [state, setState] = useState({
loading: false,
toastColor: "#5cb85c",
toastDescription: ""
alertType: "success",
alertMsg: ""
});
const [showPassword, setShowPassword] = useState(false);
const [lengthValid, setLengthValid] = useState(false);
@@ -358,19 +359,18 @@ const Signup = (props) => {
}
},
(error) => {
/* alert(
"You dont have access to this application."
); */
setState({
loading: false,
toastColor: "#d9534f",
toastDescription:
"You dont have access to this application."
alertType: "danger",
alertMsg:
"You dont have access to this application!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
localStorage.setItem("accesstoken", null);
console.error("Error while fetching Follow", error);
@@ -381,25 +381,29 @@ const Signup = (props) => {
} else {
setState({
loading: false,
toastColor: "#d9534f",
toastDescription: "User Role Not Found."
alertType: "danger",
alertMsg: "User Role Not Found!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
}
} else {
setState({
loading: false,
toastColor: "#d9534f",
toastDescription: "User Role Not Found."
alertType: "danger",
alertMsg: "User Role Not Found!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
}
})
@@ -407,13 +411,16 @@ const Signup = (props) => {
console.log("err", err);
setState({
loading: false,
toastColor: "#d9534f",
toastDescription: `Does not have permissions to access this application.`
alertType: "danger",
alertMsg:
"Does not have permissions to access this application!"
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
});
}
@@ -421,13 +428,15 @@ const Signup = (props) => {
// alert(`${error.message}`);
setState({
loading: false,
toastColor: "#d9534f",
toastDescription: `${error.message}`
alertType: "danger",
alertMsg: `${error.message}`
});
const x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
setState({
loading: false,
alertType: "danger",
alertMsg: ""
});
}, 2000);
console.log(error);
}
@@ -644,10 +653,7 @@ const Signup = (props) => {
)}
</div>
</div>
<div id="snackbar" style={{ backgroundColor: state.toastColor }}>
{state.toastDescription}
</div>
<Alert type={state.alertType}>{state.alertMsg}</Alert>
</div>
) : (
<div
+2 -6
View File
@@ -30,7 +30,6 @@ import { useParams } from "react-router-dom";
import Tour from "reactour";
import Signedby from "../components/pdf/Signedby";
import HandleError from "../primitives/HandleError";
import Nodata from "../primitives/Nodata";
import Header from "../components/pdf/Header";
import RenderPdf from "../components/pdf/RenderPdf";
import PlaceholderCopy from "../components/pdf/PlaceholderCopy";
@@ -81,7 +80,6 @@ function SignYourSelf() {
const [checkTourStatus, setCheckTourStatus] = useState(false);
const [signerUserId, setSignerUserId] = useState();
const [tourStatus, setTourStatus] = useState([]);
const [noData, setNoData] = useState(false);
const [contractName, setContractName] = useState("");
const [containerWH, setContainerWH] = useState({});
const [isPageCopy, setIsPageCopy] = useState(false);
@@ -215,7 +213,7 @@ function SignYourSelf() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -298,7 +296,7 @@ function SignYourSelf() {
}
}
} else {
setNoData(true);
setHandleError("No Data Found!");
}
const loadObj = {
isLoad: false
@@ -967,8 +965,6 @@ function SignYourSelf() {
<Loader isLoading={isLoading} />
) : handleError ? (
<HandleError handleError={handleError} />
) : noData ? (
<Nodata />
) : (
<div>
{isUiLoading && (
@@ -11,7 +11,6 @@ import WidgetComponent from "../components/pdf/WidgetComponent";
import Tour from "reactour";
import Loader from "../components/pdf/Loader";
import HandleError from "../primitives/HandleError";
import Nodata from "../primitives/Nodata";
import SignerListPlace from "../components/pdf/SignerListPlace";
import Header from "../components/pdf/Header";
import WidgetNameModal from "../components/pdf/WidgetNameModal";
@@ -62,7 +61,6 @@ const TemplatePlaceholder = () => {
const [checkTourStatus, setCheckTourStatus] = useState(false);
const [tourStatus, setTourStatus] = useState([]);
const [signerUserId, setSignerUserId] = useState();
const [noData, setNoData] = useState(false);
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
const [contractName, setContractName] = useState("");
const [containerWH, setContainerWH] = useState();
@@ -261,8 +259,7 @@ const TemplatePlaceholder = () => {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -301,8 +298,7 @@ const TemplatePlaceholder = () => {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (res.length === 0) {
setNoData(true);
setHandleError("No Data Found!");
const loadObj = {
isLoad: false
};
@@ -1168,8 +1164,6 @@ const TemplatePlaceholder = () => {
<Loader isLoading={isLoading} />
) : handleError ? (
<HandleError handleError={handleError} />
) : noData ? (
<Nodata />
) : (
<div className="signatureContainer" ref={divRef}>
{/* this component used for UI interaction and show their functionality */}
-10
View File
@@ -169,16 +169,6 @@
box-shadow: 0 2px 4px rgba(154, 36, 36, 0.1), 0 2px 4px rgba(0, 0, 0, 0.18);
}
.emailToast {
position: absolute;
z-index: 10;
background: #aeedae;
padding: 0 3px 3px 3px;
margin: 2px;
border-radius: 2px;
}
.signatureBtn {
border: 1.5px solid #47a3ad;
-64
View File
@@ -1,64 +0,0 @@
#snackbar {
visibility: hidden;
min-width: 250px;
margin-left: -125px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
z-index: 99999;
left: 50%;
top: 30px;
font-size: 14px;
}
#snackbar.show {
visibility: visible;
-webkit-animation: fadein 0.5s;
}
@-webkit-keyframes fadein {
from {
top: 0;
opacity: 0;
}
to {
top: 30px;
opacity: 1;
}
}
@keyframes fadein {
from {
top: 0;
opacity: 0;
}
to {
top: 30px;
opacity: 1;
}
}
@-webkit-keyframes fadeout {
from {
top: 30px;
opacity: 1;
}
to {
top: 0;
opacity: 0;
}
}
@keyframes fadeout {
from {
top: 30px;
opacity: 1;
}
to {
top: 0;
opacity: 0;
}
}