Compare commits

..
Author SHA1 Message Date
nxglabs ec38860ceb Merge pull request #341 from OpenSignLabs/staging 2025-02-22 11:10:58 +00:00
@@ -76,20 +76,7 @@ const changeDateToMomentFormat = (format) => {
};
//function to get default format
const getDefaultFormat = (dateFormat) => dateFormat || "MM/dd/yyyy";
//function to convert formated date to new Date() format
const getDefaultDate = (dateStr, format) => {
//get valid date format for moment to convert formated date to new Date() format
const formats = changeDateToMomentFormat(format);
const parsedDate = moment(dateStr, formats);
let date;
if (parsedDate.isValid()) {
date = new Date(parsedDate.toISOString());
return date;
} else {
date = new Date();
return date;
}
};
function Placeholder(props) {
//'isTouchDevice' is used to detect whether a device has a touchscreen or is mouse-based
const isTouchDevice = navigator.maxTouchPoints > 0;
@@ -104,14 +91,7 @@ function Placeholder(props) {
const [selectDate, setSelectDate] = useState({});
const [dateFormat, setDateFormat] = useState([]);
const [clickonWidget, setClickonWidget] = useState({});
const [startDate, setStartDate] = useState(
props?.pos?.options?.response
? getDefaultDate(
props?.pos?.options?.response,
props.pos?.options?.validation?.format
)
: new Date()
);
const [startDate, setStartDate] = useState(new Date());
const [getCheckboxRenderWidth, setGetCheckboxRenderWidth] = useState({
width: null,
height: null
@@ -459,7 +439,7 @@ function Placeholder(props) {
if (props.pos.type === "date") {
const isDateChange = true;
const dateObj = {
date: startDate,
date: startDate || new Date(),
format: getDefaultFormat(props.pos?.options?.validation?.format)
};
handleSaveDate(dateObj, isDateChange); //function to save date and format in local array