mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 07:02:32 +02:00
fix: invalid date issue for indian format
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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: "",
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user