diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index 08e121c3e..87312ae99 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -61,23 +61,53 @@ const changeDateToMomentFormat = (format) => { } }; -const getDefaultdate = (selectedDate) => - selectedDate ? new Date(selectedDate) : new Date(); +// const getDefaultdate = (selectedDate) => { +// return selectedDate ? new Date(selectedDate) : new Date(); +// }; +const getDefaultdate = (selectedDate, format = "dd-MM-yyyy") => { + let date; + if (format && format === "dd-MM-yyyy") { + const newdate = selectedDate + ? selectedDate + : moment(new Date()).format(changeDateToMomentFormat(format)); + const [day, month, year] = newdate.split("-"); + date = new Date(`${year}-${month}-${day}`); + } else { + date = new Date(selectedDate); + } + const value = date; + return value; +}; const getDefaultFormat = (dateFormat) => dateFormat || "MM/dd/yyyy"; function Placeholder(props) { const [isDraggingEnabled, setDraggingEnabled] = useState(true); const [isShowDateFormat, setIsShowDateFormat] = useState(false); + // const [selectDate, setSelectDate] = useState({ + // date: moment( + // getDefaultdate(props?.pos?.options?.response).getTime() + // ).format(changeDateToMomentFormat(props.pos?.options?.validation?.format)), + // format: getDefaultFormat(props.pos?.options?.validation?.format) + // }); const [selectDate, setSelectDate] = useState({ date: moment( - getDefaultdate(props?.pos?.options?.response).getTime() + getDefaultdate( + props?.pos?.options?.response, + props.pos?.options?.validation?.format + ).getTime() ).format(changeDateToMomentFormat(props.pos?.options?.validation?.format)), format: getDefaultFormat(props.pos?.options?.validation?.format) }); const [dateFormat, setDateFormat] = useState([]); const [saveDateFormat, setSaveDateFormat] = useState(""); + // const [startDate, setStartDate] = useState( + // getDefaultdate(props?.pos?.options?.response) + // ); const [startDate, setStartDate] = useState( - getDefaultdate(props?.pos?.options?.response) + getDefaultdate( + props?.pos?.options?.response, + props.pos?.options?.validation?.format + ) ); const dateFormatArr = [ "L", @@ -91,8 +121,6 @@ function Placeholder(props) { "DD MMMM, YYYY" ]; - // console.log('props.pos',props.pos?.options?.validation?.format) - //useEffect for to set date and date format for all flow (signyour-self, request-sign,placeholder,template) //checking if already have data and set else set new date // useEffect(() => { @@ -125,28 +153,23 @@ function Placeholder(props) { //function change format array list with selected date and format const changeDateFormat = () => { - // console.log("selected date", selectDate); const updateDate = []; dateFormatArr.map((data) => { let date; - if (selectDate.format === "dd-MM-yyyy") { + if (selectDate && selectDate.format === "dd-MM-yyyy") { const [day, month, year] = selectDate.date.split("-"); date = new Date(`${year}-${month}-${day}`); } else { date = new Date(selectDate?.date); } const milliseconds = date.getTime(); - // console.log('data',data) const newDate = moment(milliseconds).format(data); - // console.log('new date',newDate) const dateObj = { date: newDate, format: selectFormat(data) }; - // console.log('dateobj',dateObj) updateDate.push(dateObj); }); - // console.log('updated format',updateDate) setDateFormat(updateDate); }; diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index 7aa433107..d21906c8c 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -133,27 +133,28 @@ function PlaceholderType(props) { if (type && type === "date") { if (props?.selectDate) { let updateDate; - if (props?.selectDate.format === "dd-MM-yyyy") { - // console.log('saveDateformat',props.saveDateFormat) - const [day, month, year] = props.saveDateFormat.split("-"); - updateDate = new Date(`${year}-${month}-${day}`); - } else { - if (props?.saveDateFormat) { - updateDate = new Date(props.saveDateFormat); - } - } + // if (props?.selectDate.format === "dd-MM-yyyy") { + // // console.log('saveDateformat',props.saveDateFormat) + // const [day, month, year] = props.saveDateFormat.split("-"); + // updateDate = new Date(`${year}-${month}-${day}`); + // console.log('update',updateDate) + // } else { + // if (props?.saveDateFormat) { + // updateDate = new Date(props.saveDateFormat); + // } + // } // const updateDate = new Date(props.saveDateFormat); - props.setStartDate(updateDate); - const dateObj = { - date: props.saveDateFormat, - format: props.selectDate - ? props.selectDate?.format - : props.pos?.options?.validation?.format - ? props.pos?.options?.validation?.format - : "MM/dd/yyyy" - }; - console.log("savedateformat selectdate", dateObj); - props.setSelectDate(dateObj); + // props.setStartDate(updateDate); + // const dateObj = { + // date: props.saveDateFormat, + // format: props.selectDate + // ? props.selectDate?.format + // : props.pos?.options?.validation?.format + // ? props.pos?.options?.validation?.format + // : "MM/dd/yyyy" + // }; + + // props.setSelectDate(dateObj); onChangeInput( props.saveDateFormat, props.pos.key, diff --git a/apps/OpenSign/src/components/pdf/WidgetComponent.js b/apps/OpenSign/src/components/pdf/WidgetComponent.js index 943e9f30e..1b9a0094b 100644 --- a/apps/OpenSign/src/components/pdf/WidgetComponent.js +++ b/apps/OpenSign/src/components/pdf/WidgetComponent.js @@ -204,17 +204,17 @@ function WidgetComponent({ dragSignature, dragStamp, initials, + name, + jobTitle, + company, + date, label, text, checkbox, dropdown, radio, image, - date, - name, - email, - company, - jobTitle + email ]; const getWidgetArray = widgets; const newUpdateSigner = getWidgetArray.map((obj, ind) => { diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js index 088424b19..936d1d9de 100644 --- a/apps/OpenSign/src/constant/Utils.js +++ b/apps/OpenSign/src/constant/Utils.js @@ -161,6 +161,26 @@ export const widgets = [ icon: "fa-solid fa-signature", iconSize: "15px" }, + { + type: "name", + icon: "fa-solid fa-user", + iconSize: "21px" + }, + { + type: "job title", + icon: "fa-solid fa-address-card", + iconSize: "17px" + }, + { + type: "company", + icon: "fa-solid fa-building", + iconSize: "25px" + }, + { + type: "date", + icon: "fa-solid fa-calendar-days", + iconSize: "20px" + }, { type: "label", icon: "fa-solid fa-text-width", @@ -191,40 +211,19 @@ export const widgets = [ icon: "fa-solid fa-image", iconSize: "20px" }, - { - type: "date", - icon: "fa-solid fa-calendar-days", - iconSize: "20px" - }, - { - type: "name", - icon: "fa-solid fa-user", - iconSize: "21px" - }, { type: "email", icon: "fa-solid fa-envelope", iconSize: "20px" - }, - { - type: "company", - icon: "fa-solid fa-building", - iconSize: "25px" - }, - { - type: "job title", - icon: "fa-solid fa-address-card", - iconSize: "17px" } ]; -const getDate = () => { +export const getDate = () => { const date = new Date(); const milliseconds = date.getTime(); const newDate = moment(milliseconds).format("MM/DD/YYYY"); return newDate; }; - export const addWidgetOptions = (type) => { const defaultOpt = { name: "", diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.js index 4b7501c56..0b56688a6 100644 --- a/apps/OpenSign/src/pages/SignyourselfPdf.js +++ b/apps/OpenSign/src/pages/SignyourselfPdf.js @@ -25,7 +25,8 @@ import { onSaveSign, contractUsers, contactBook, - randomId + randomId, + getDate } from "../constant/Utils"; import { useParams } from "react-router-dom"; import Tour from "reactour"; @@ -308,13 +309,6 @@ function SignYourSelf() { setIsLoading(loadObj); } }; - - const getDate = () => { - const date = new Date(); - const milliseconds = date.getTime(); - const newDate = moment(milliseconds).format("MM/DD/YYYY"); - return newDate; - }; const getWidgetValue = (type) => { switch (type) { case "name": @@ -333,6 +327,7 @@ function SignYourSelf() { return ""; } }; + const addWidgetOptions = (type) => { switch (type) { case "signature": @@ -596,7 +591,6 @@ function SignYourSelf() { await signPdfFun(pdfBytes, documentId); } } - //function for get digital signature const signPdfFun = async (base64Url, documentId) => { let singleSign = {