Skip to content

Commit 81d3969

Browse files
Merge pull request #1719 from OpenSignLabs/updates-14856876951
v2.20.1
2 parents 6653b7a + 5819103 commit 81d3969

File tree

3 files changed

+62
-30
lines changed

3 files changed

+62
-30
lines changed

apps/OpenSign/src/components/pdf/Placeholder.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import BorderResize from "./BorderResize";
33
import PlaceholderBorder from "./PlaceholderBorder";
44
import { Rnd } from "react-rnd";
55
import {
6+
changeDateToMomentFormat,
67
defaultWidthHeight,
78
fontColorArr,
89
fontsizeArr,
@@ -52,32 +53,6 @@ const selectFormat = (data) => {
5253
}
5354
};
5455

55-
const changeDateToMomentFormat = (format) => {
56-
switch (format) {
57-
case "MM/dd/yyyy":
58-
return "L";
59-
case "dd-MM-yyyy":
60-
return "DD-MM-YYYY";
61-
case "dd/MM/yyyy":
62-
return "DD/MM/YYYY";
63-
case "MMMM dd, yyyy":
64-
return "LL";
65-
case "dd MMM, yyyy":
66-
return "DD MMM, YYYY";
67-
case "yyyy-MM-dd":
68-
return "YYYY-MM-DD";
69-
case "MM-dd-yyyy":
70-
return "MM-DD-YYYY";
71-
case "MM.dd.yyyy":
72-
return "MM.DD.YYYY";
73-
case "MMM dd, yyyy":
74-
return "MMM DD, YYYY";
75-
case "dd MMMM, yyyy":
76-
return "DD MMMM, YYYY";
77-
default:
78-
return "L";
79-
}
80-
};
8156
//function to get default format
8257
const getDefaultFormat = (dateFormat) => dateFormat || "MM/dd/yyyy";
8358

apps/OpenSign/src/constant/Utils.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,32 @@ export const selectFormat = (data) => {
272272
}
273273
};
274274

275+
export const changeDateToMomentFormat = (format) => {
276+
switch (format) {
277+
case "MM/dd/yyyy":
278+
return "L";
279+
case "dd-MM-yyyy":
280+
return "DD-MM-YYYY";
281+
case "dd/MM/yyyy":
282+
return "DD/MM/YYYY";
283+
case "MMMM dd, yyyy":
284+
return "LL";
285+
case "dd MMM, yyyy":
286+
return "DD MMM, YYYY";
287+
case "yyyy-MM-dd":
288+
return "YYYY-MM-DD";
289+
case "MM-dd-yyyy":
290+
return "MM-DD-YYYY";
291+
case "MM.dd.yyyy":
292+
return "MM.DD.YYYY";
293+
case "MMM dd, yyyy":
294+
return "MMM DD, YYYY";
295+
case "dd MMMM, yyyy":
296+
return "DD MMMM, YYYY";
297+
default:
298+
return "L";
299+
}
300+
};
275301
export const addWidgetOptions = (type, signer) => {
276302
const defaultOpt = { name: type, status: "required" };
277303
switch (type) {
@@ -3000,3 +3026,33 @@ export function formatDateTime(date, dateFormat, timeZone, is12Hour) {
30003026
)
30013027
: formatTimeInTimezone(date, timeZone);
30023028
}
3029+
3030+
export const updateDateWidgetsRes = (placeHolders, signerId) => {
3031+
return placeHolders?.map((item) => {
3032+
if (item?.signerObjId === signerId) {
3033+
return {
3034+
...item,
3035+
placeHolder: item.placeHolder.map((ph) => ({
3036+
...ph,
3037+
pos: ph.pos.map((widget) => {
3038+
// only for date widgets *and* missing response
3039+
if (widget.type === "date" && !widget.options.response) {
3040+
return {
3041+
...widget,
3042+
options: {
3043+
...widget.options,
3044+
response: getDate(
3045+
changeDateToMomentFormat(widget.options.validation.format)
3046+
)
3047+
}
3048+
};
3049+
}
3050+
return widget;
3051+
})
3052+
}))
3053+
};
3054+
} else {
3055+
return item;
3056+
}
3057+
});
3058+
};

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import {
4141
addWidgetOptions,
4242
textWidget,
4343
compressedFileSize,
44-
mailTemplate
44+
mailTemplate,
45+
updateDateWidgetsRes
4546
} from "../constant/Utils";
4647
import Header from "../components/pdf/PdfHeader";
4748
import RenderPdf from "../components/pdf/RenderPdf";
@@ -403,7 +404,6 @@ function PdfRequestFiles() {
403404
//condition to check already signed document by someone
404405
if (audittrailData && audittrailData.length > 0) {
405406
setIsDocId(true);
406-
407407
for (const item of placeholdersOrSigners) {
408408
const checkEmail = item?.email;
409409
//if email exist then compare user signed by using email else signers objectId
@@ -429,13 +429,14 @@ function PdfRequestFiles() {
429429
}
430430
setSignedSigners(signers);
431431
setUnSignedSigners(unSignedSigner);
432-
setSignerPos(documentData[0].Placeholders);
433432
} else {
434433
//else condition is show there are no details in audit trail then direct push all signers details
435434
//in unsignedsigners array
436435
setUnSignedSigners(placeholdersOrSigners);
437-
setSignerPos(documentData[0].Placeholders);
438436
}
437+
setSignerPos(
438+
updateDateWidgetsRes(documentData[0].Placeholders, currUserId)
439+
);
439440
setPdfDetails(documentData);
440441
//checking if condition current user already sign or owner does not exist as a signer or document has been declined by someone or document has been expired
441442
//then stop to display tour message

0 commit comments

Comments
 (0)