Skip to content

Commit

Permalink
fix: default data of name,email,copmany,job title issue in request si…
Browse files Browse the repository at this point in the history
…gn flow
  • Loading branch information
raktima-opensignlabs committed Mar 7, 2024
1 parent 1357c76 commit 6e5a237
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 311 deletions.
11 changes: 2 additions & 9 deletions microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { HTML5Backend } from "react-dnd-html5-backend";
import { useParams } from "react-router-dom";
import SignPad from "./component/signPad";
import RenderAllPdfPage from "./component/renderAllPdfPage";
import { useNavigate } from "react-router-dom";
import Tour from "reactour";
import {
contractDocument,
Expand All @@ -20,8 +19,7 @@ import {
onImageSelect,
onSaveSign,
onSaveImage,
addDefaultSignatureImg,
getHostUrl
addDefaultSignatureImg
} from "../utils/Utils";
import Loader from "./component/loader";
import HandleError from "./component/HandleError";
Expand All @@ -34,7 +32,6 @@ import DefaultSignature from "./component/defaultSignature";
import ModalUi from "../premitives/ModalUi";

function PdfRequestFiles() {
const navigate = useNavigate();
const { docId } = useParams();
const [pdfDetails, setPdfDetails] = useState([]);
const [signedSigners, setSignedSigners] = useState([]);
Expand Down Expand Up @@ -377,8 +374,7 @@ function PdfRequestFiles() {
(data) => data.signerObjId === signerObjectId
);
if (checkUser && checkUser.length > 0) {
let unSignUrlData,
checkboxExist,
let checkboxExist,
requiredRadio,
showAlert = false,
widgetKey,
Expand Down Expand Up @@ -464,9 +460,6 @@ function PdfRequestFiles() {
position.type !== "checkbox"
);
if (requiredWidgets && requiredWidgets?.length > 0) {
unSignUrlData = checkUser[0].placeHolder[i].pos.filter(
(pos) => !pos?.SignUrl && !pos.options.response
);
let checkSigned;
for (let i = 0; i < requiredWidgets?.length; i++) {
checkSigned = requiredWidgets[i]?.options?.response;
Expand Down
2 changes: 0 additions & 2 deletions microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ function SignYourSelf() {

const x = offset.x - containerRect.left;
const y = offset.y - containerRect.top;
const ybottom = containerRect.bottom - offset.y;

dropObj = {
xPosition: signBtnPosition[0] ? x - signBtnPosition[0].xPos : x,
yPosition: signBtnPosition[0] ? y - signBtnPosition[0].yPos : y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ function DropdownWidgetOption(props) {
const statusArr = ["required", "optional"];
const [defaultCheckbox, setDefaultCheckbox] = useState([]);


const resetState = () => {
setDropdownOptionList(["option-1", "option-2"]);
setDropdownName(props.type);
setIsReadOnly(false);
setIsReadOnly(false);
setMinCount(0);
setMaxCount(0);
setDefaultCheckbox([]);
setDefaultValue("")
setDefaultValue("");
};

useEffect(() => {
if (
props.currWidgetsDetails?.options?.name &&
Expand All @@ -42,47 +41,65 @@ function DropdownWidgetOption(props) {
setIsReadOnly(props.currWidgetsDetails?.options?.isReadOnly);
setStatus(props.currWidgetsDetails?.options?.status || "required");
setDefaultValue(props.currWidgetsDetails?.options?.defaultValue || "");
setDefaultCheckbox(props.currWidgetsDetails?.options?.defaultValue|| []);
setDefaultCheckbox(props.currWidgetsDetails?.options?.defaultValue || []);
} else {
setStatus("required");
resetState();
resetState();
}
}, [props.currWidgetsDetails]);
const handleInputChange = (index, value) => {

const handleInputChange = (index, value) => {
setDropdownOptionList((prevInputs) => {
const newInputs = [...prevInputs];
newInputs[index] = value;
return newInputs;
});
};

//function add add checkbox option and add width of checkbox
//function add add checkbox option and add width of checkbox
const handleAddInput = () => {
const deleteOption = false;
const addOption = true
setDropdownOptionList((prevInputs) => [...prevInputs, ""]);
props.handleSaveWidgetsOptions(null, null, null, null, null, addOption, deleteOption);
const addOption = true;
setDropdownOptionList((prevInputs) => [...prevInputs, ""]);
props.handleSaveWidgetsOptions(
null,
null,
null,
null,
null,
addOption,
deleteOption
);
};

//function add add checkbox option and delete width of checkbox
//function add add checkbox option and delete width of checkbox
const handleDeleteInput = (ind) => {
const deleteOption = true;
const addOption = false
const addOption = false;
const getUpdatedOptions = dropdownOptionList.filter(
(data, index) => index !== ind
);
setDropdownOptionList(getUpdatedOptions);
props.handleSaveWidgetsOptions(null, null, null, null, null, addOption, deleteOption);
props.handleSaveWidgetsOptions(
null,
null,
null,
null,
null,
addOption,
deleteOption
);
};



const handleSaveOption = () => {
const defaultData =
defaultCheckbox && defaultCheckbox.length > 0
? defaultCheckbox
: defaultValue;

let defaultData;
if (props.type === "checkbox") {
defaultData =
defaultCheckbox && defaultCheckbox.length > 0 ? defaultCheckbox : [];
} else {
defaultData = defaultValue ? defaultValue : "";
}

props.handleSaveWidgetsOptions(
dropdownName,
dropdownOptionList,
Expand All @@ -94,15 +111,15 @@ function DropdownWidgetOption(props) {
status,
defaultData
);
// props.setShowDropdown(false);
// props.setShowDropdown(false);
setDropdownOptionList(["option-1", "option-2"]);
setDropdownName(props.type);
// props.setCurrWidgetsDetails({});
// props.setCurrWidgetsDetails({});
setIsReadOnly(false);
setMinCount(0);
setMaxCount(0);
setDefaultCheckbox([]);
setDefaultValue("")
setDefaultValue("");
};

const handleSetMinMax = (e) => {
Expand All @@ -121,9 +138,8 @@ function DropdownWidgetOption(props) {
} else {
return false;
}

};

return (
//props.showDropdown
<ModalUi
Expand All @@ -133,28 +149,27 @@ function DropdownWidgetOption(props) {
closeOff={true}
>
<div style={{ height: "100%", padding: 20 }}>


<form
onSubmit={(e) => {
e.preventDefault();
handleSaveOption();
}}
>
<div className="dropdownContainer">
{["checkbox","radio"].includes(props.type) && !props.isSignYourself && (
<div>
<input
type="checkbox"
checked={isReadOnly}
onChange={(e) => {
setIsReadOnly(e.target.checked);
}}
/>
{["checkbox", "radio"].includes(props.type) &&
!props.isSignYourself && (
<div>
<input
type="checkbox"
checked={isReadOnly}
onChange={(e) => {
setIsReadOnly(e.target.checked);
}}
/>

<label style={{ marginLeft: "10px" }}>Is read only</label>
</div>
)}
<label style={{ marginLeft: "10px" }}>Is read only</label>
</div>
)}
<label style={{ fontSize: "13px", fontWeight: "600" }}>
Name<span style={{ color: "red", fontSize: 13 }}> *</span>
</label>
Expand All @@ -165,8 +180,7 @@ function DropdownWidgetOption(props) {
onChange={(e) => setDropdownName(e.target.value)}
className="drodown-input"
/>



{props.type === "checkbox" && !props.isSignYourself && (
<>
<label style={{ fontSize: "13px", fontWeight: "600" }}>
Expand Down Expand Up @@ -219,34 +233,39 @@ function DropdownWidgetOption(props) {
alignItems: "center"
}}
>
{props.type === "checkbox" && !props.isSignYourself && (
<input type="checkbox"
checked={handleDefaultCheck(index)}
onChange={(e) => {

if (e.target.checked) {
const getDefaultCheck =
defaultCheckbox?.includes(index);
if (!getDefaultCheck) {
setDefaultCheckbox((prev) => [...prev, index]);
}
} else {
const removeOption = defaultCheckbox.filter(
(data) => data !== index
);
setDefaultCheckbox(removeOption);
}
}}
style={{width:"23px",height:"19px",marginRight:"5px"}} />
)}
{props.type === "checkbox" && !props.isSignYourself && (
<input
type="checkbox"
checked={handleDefaultCheck(index)}
onChange={(e) => {
if (e.target.checked) {
const getDefaultCheck =
defaultCheckbox?.includes(index);
if (!getDefaultCheck) {
setDefaultCheckbox((prev) => [...prev, index]);
}
} else {
const removeOption = defaultCheckbox.filter(
(data) => data !== index
);
setDefaultCheckbox(removeOption);
}
}}
style={{
width: "23px",
height: "19px",
marginRight: "5px"
}}
/>
)}
<input
required
className="drodown-input"
type="text"
value={option}
onChange={(e) => handleInputChange(index, e.target.value)}
/>

<i
className="fa-solid fa-rectangle-xmark"
onClick={() => handleDeleteInput(index)}
Expand All @@ -270,36 +289,42 @@ function DropdownWidgetOption(props) {
className="fa-solid fa-square-plus"
></i>
</div>
{["dropdown","radio"].includes(props.type) && (
{["dropdown", "radio"].includes(props.type) && (
<>
<label style={{ fontSize: "13px", fontWeight: "600", marginTop: "5px" }}>Default value</label>
<label
style={{
fontSize: "13px",
fontWeight: "600",
marginTop: "5px"
}}
>
Default value
</label>
<select
onChange={(e) => setDefaultValue(e.target.value)}
onChange={(e) => setDefaultValue(e.target.value)}
className="drodown-input"
name="defaultvalue"
value={defaultValue}
placeholder="select default value"
>
<option value="" disabled hidden style={{ fontSize: "13px" }}>
Select...
</option>
{dropdownOptionList.map((data, ind) => {
return (
<option
style={{ fontSize: "13px" }}
key={ind}
value={data}
>
{data}
</option>
);
})}
</select>


name="defaultvalue"
value={defaultValue}
placeholder="select default value"
>
<option value="" disabled hidden style={{ fontSize: "13px" }}>
Select...
</option>
{dropdownOptionList.map((data, ind) => {
return (
<option
style={{ fontSize: "13px" }}
key={ind}
value={data}
>
{data}
</option>
);
})}
</select>
</>
)}
{props.type !== "checkbox" && props.type !== 'radio' && (
{props.type !== "checkbox" && props.type !== "radio" && (
<>
<div
style={{
Expand Down Expand Up @@ -348,7 +373,6 @@ function DropdownWidgetOption(props) {
}}
></div>
<button
// onClick={() => handleSaveOption()}
disabled={dropdownOptionList.length === 0 && true}
style={{
background: themeColor(),
Expand All @@ -364,8 +388,8 @@ function DropdownWidgetOption(props) {
type="submit"
className="finishBtn cancelBtn"
onClick={() => {
props.handleClose && props.handleClose()
resetState()
props.handleClose && props.handleClose();
resetState();
}}
>
Cancel
Expand Down
Loading

0 comments on commit 6e5a237

Please sign in to comment.