mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
@@ -3,6 +3,7 @@ import BorderResize from "./BorderResize";
|
||||
import PlaceholderBorder from "./PlaceholderBorder";
|
||||
import { Rnd } from "react-rnd";
|
||||
import {
|
||||
changeDateToMomentFormat,
|
||||
defaultWidthHeight,
|
||||
fontColorArr,
|
||||
fontsizeArr,
|
||||
@@ -52,32 +53,6 @@ const selectFormat = (data) => {
|
||||
}
|
||||
};
|
||||
|
||||
const changeDateToMomentFormat = (format) => {
|
||||
switch (format) {
|
||||
case "MM/dd/yyyy":
|
||||
return "L";
|
||||
case "dd-MM-yyyy":
|
||||
return "DD-MM-YYYY";
|
||||
case "dd/MM/yyyy":
|
||||
return "DD/MM/YYYY";
|
||||
case "MMMM dd, yyyy":
|
||||
return "LL";
|
||||
case "dd MMM, yyyy":
|
||||
return "DD MMM, YYYY";
|
||||
case "yyyy-MM-dd":
|
||||
return "YYYY-MM-DD";
|
||||
case "MM-dd-yyyy":
|
||||
return "MM-DD-YYYY";
|
||||
case "MM.dd.yyyy":
|
||||
return "MM.DD.YYYY";
|
||||
case "MMM dd, yyyy":
|
||||
return "MMM DD, YYYY";
|
||||
case "dd MMMM, yyyy":
|
||||
return "DD MMMM, YYYY";
|
||||
default:
|
||||
return "L";
|
||||
}
|
||||
};
|
||||
//function to get default format
|
||||
const getDefaultFormat = (dateFormat) => dateFormat || "MM/dd/yyyy";
|
||||
|
||||
|
||||
@@ -272,6 +272,32 @@ export const selectFormat = (data) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const changeDateToMomentFormat = (format) => {
|
||||
switch (format) {
|
||||
case "MM/dd/yyyy":
|
||||
return "L";
|
||||
case "dd-MM-yyyy":
|
||||
return "DD-MM-YYYY";
|
||||
case "dd/MM/yyyy":
|
||||
return "DD/MM/YYYY";
|
||||
case "MMMM dd, yyyy":
|
||||
return "LL";
|
||||
case "dd MMM, yyyy":
|
||||
return "DD MMM, YYYY";
|
||||
case "yyyy-MM-dd":
|
||||
return "YYYY-MM-DD";
|
||||
case "MM-dd-yyyy":
|
||||
return "MM-DD-YYYY";
|
||||
case "MM.dd.yyyy":
|
||||
return "MM.DD.YYYY";
|
||||
case "MMM dd, yyyy":
|
||||
return "MMM DD, YYYY";
|
||||
case "dd MMMM, yyyy":
|
||||
return "DD MMMM, YYYY";
|
||||
default:
|
||||
return "L";
|
||||
}
|
||||
};
|
||||
export const addWidgetOptions = (type, signer) => {
|
||||
const defaultOpt = { name: type, status: "required" };
|
||||
switch (type) {
|
||||
@@ -3000,3 +3026,33 @@ export function formatDateTime(date, dateFormat, timeZone, is12Hour) {
|
||||
)
|
||||
: formatTimeInTimezone(date, timeZone);
|
||||
}
|
||||
|
||||
export const updateDateWidgetsRes = (placeHolders, signerId) => {
|
||||
return placeHolders?.map((item) => {
|
||||
if (item?.signerObjId === signerId) {
|
||||
return {
|
||||
...item,
|
||||
placeHolder: item.placeHolder.map((ph) => ({
|
||||
...ph,
|
||||
pos: ph.pos.map((widget) => {
|
||||
// only for date widgets *and* missing response
|
||||
if (widget.type === "date" && !widget.options.response) {
|
||||
return {
|
||||
...widget,
|
||||
options: {
|
||||
...widget.options,
|
||||
response: getDate(
|
||||
changeDateToMomentFormat(widget.options.validation.format)
|
||||
)
|
||||
}
|
||||
};
|
||||
}
|
||||
return widget;
|
||||
})
|
||||
}))
|
||||
};
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -41,7 +41,8 @@ import {
|
||||
addWidgetOptions,
|
||||
textWidget,
|
||||
compressedFileSize,
|
||||
mailTemplate
|
||||
mailTemplate,
|
||||
updateDateWidgetsRes
|
||||
} from "../constant/Utils";
|
||||
import Header from "../components/pdf/PdfHeader";
|
||||
import RenderPdf from "../components/pdf/RenderPdf";
|
||||
@@ -403,7 +404,6 @@ function PdfRequestFiles() {
|
||||
//condition to check already signed document by someone
|
||||
if (audittrailData && audittrailData.length > 0) {
|
||||
setIsDocId(true);
|
||||
|
||||
for (const item of placeholdersOrSigners) {
|
||||
const checkEmail = item?.email;
|
||||
//if email exist then compare user signed by using email else signers objectId
|
||||
@@ -429,13 +429,14 @@ function PdfRequestFiles() {
|
||||
}
|
||||
setSignedSigners(signers);
|
||||
setUnSignedSigners(unSignedSigner);
|
||||
setSignerPos(documentData[0].Placeholders);
|
||||
} else {
|
||||
//else condition is show there are no details in audit trail then direct push all signers details
|
||||
//in unsignedsigners array
|
||||
setUnSignedSigners(placeholdersOrSigners);
|
||||
setSignerPos(documentData[0].Placeholders);
|
||||
}
|
||||
setSignerPos(
|
||||
updateDateWidgetsRes(documentData[0].Placeholders, currUserId)
|
||||
);
|
||||
setPdfDetails(documentData);
|
||||
//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
|
||||
//then stop to display tour message
|
||||
|
||||
Reference in New Issue
Block a user