Skip to content

Commit

Permalink
fix validation issue to finish signature
Browse files Browse the repository at this point in the history
  • Loading branch information
raktima-opensignlabs committed Mar 6, 2024
1 parent a53f919 commit 1357c76
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
4 changes: 0 additions & 4 deletions microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ function PdfRequestFiles() {
for (let j = 0; j < checkUser[0].placeHolder[i].pos.length; j++) {
checkboxExist =
checkUser[0].placeHolder[i].pos[j].type === "checkbox";

// radioExist = checkUser[0].placeHolder[i].pos[i].some(
// (data) => data.type === "radio"
// );
radioExist = checkUser[0].placeHolder[i].pos[j].type === "radio";
if (checkboxExist) {
requiredCheckbox = checkUser[0].placeHolder[i].pos.filter(
Expand Down
32 changes: 23 additions & 9 deletions microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,24 +518,38 @@ function SignYourSelf() {

//function for send placeholder's co-ordinate(x,y) position embed signature url or stamp url
async function embedWidgetsData() {
let checkSigned = 0;
let allXyPos = 0;
let showAlert = false;

for (let i = 0; i < xyPostion.length; i++) {
const posWidgetData = xyPostion[i].pos.filter(
(pos) => pos.options.response
for (let i = 0; i < xyPostion?.length; i++) {
const requiredWidgets = xyPostion[i].pos.filter(
(position) => position.type !== "checkbox"
);

checkSigned = checkSigned + posWidgetData.length;
allXyPos = allXyPos + xyPostion[i].pos.length;
if (requiredWidgets && requiredWidgets?.length > 0) {
let checkSigned;
for (let i = 0; i < requiredWidgets?.length; i++) {
checkSigned = requiredWidgets[i]?.options?.response;
if (!checkSigned) {
const checkSignUrl = requiredWidgets[i]?.pos?.SignUrl;

let checkDefaultSigned = requiredWidgets[i]?.options?.defaultValue;
if (!checkSignUrl) {
if (!checkDefaultSigned) {
if (!showAlert) {
showAlert = true;
}
}
}
}
}
}
}
if (xyPostion.length === 0) {
setIsAlert({
isShow: true,
alertMessage: "Please complete your signature!"
});
return;
} else if (xyPostion.length > 0 && allXyPos !== checkSigned) {
} else if (showAlert) {
setIsAlert({
isShow: true,
alertMessage: "Please complete your signature!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function PlaceholderType(props) {
const inputRef = useRef(null);
const [textValue, setTextValue] = useState();
const [selectedCheckbox, setSelectedCheckbox] = useState([]);

const validateExpression = (regexValidation) => {
let regexObject = regexValidation;
if (props.pos?.options.validation.type === "regex") {
Expand Down Expand Up @@ -159,7 +158,19 @@ function PlaceholderType(props) {
));

useEffect(() => {
if (props.pos?.type) {
if (
["name", "email", "job title", "company"].includes(props.pos?.type) &&
props.isNeedSign &&
props.data?.signerObjId === props?.signerObjId
) {
const defaultData = props.pos?.options?.defaultValue;
if (defaultData) {
setTextValue(defaultData);
}
}
}, [props.pos?.options?.defaultValue]);
useEffect(() => {
if (["name", "email", "job title", "company"].includes(props.pos?.type)) {
const senderUser = localStorage.getItem(`Extand_Class`);
const jsonSender = JSON.parse(senderUser);

Expand Down Expand Up @@ -486,7 +497,7 @@ function PlaceholderType(props) {
style={{ fontSize: calculateFontSize() }}
className="inputPlaceholder"
type="text"
value={textValue ? textValue : props.pos?.options?.defaultValue}
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
handleTextValid(e);
Expand Down Expand Up @@ -520,7 +531,7 @@ function PlaceholderType(props) {
ref={inputRef}
placeholder={"company"}
style={{ fontSize: calculateFontSize() }}
value={textValue ? textValue : props.pos?.options?.defaultValue}
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
handleTextValid(e);
Expand Down Expand Up @@ -554,7 +565,7 @@ function PlaceholderType(props) {
ref={inputRef}
placeholder={"job title"}
style={{ fontSize: calculateFontSize() }}
value={textValue ? textValue : props.pos?.options?.defaultValue}
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
handleTextValid(e);
Expand Down Expand Up @@ -641,7 +652,7 @@ function PlaceholderType(props) {
ref={inputRef}
placeholder={"email"}
style={{ fontSize: calculateFontSize() }}
value={textValue ? textValue : props.pos?.options?.defaultValue}
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
handleTextValid(e);
Expand Down

0 comments on commit 1357c76

Please sign in to comment.