I am using a date picker easepick and I’m trying to pass the dates through to javascript file and disable the dates that I am passing through. The problem is even if I try to set more than one date in a variable it only disables the first date.
This is an example from easepick however this is with hard coded dates inside easepick
const bookedDates = [
'2024-09-02',
['2024-09-06', '2024-09-11'],
'2024-09-18',
'2024-09-19',
'2024-09-20',
'2024-09-25',
'2024-09-28',
].map(d => {
if (d instanceof Array) {
const start = new DateTime(d[0], 'YYYY-MM-DD');
const end = new DateTime(d[1], 'YYYY-MM-DD');
return [start, end];
}
This is what I’ve tried
if (datesUna == undefined) {
date1 = '2024-09-19';
date2 = '2024-09-21';
datesUna = date1.concat(",",date2);
console.log(datesUna);
} else {
datesUna = datesUna.replaceAll('"', '');
console.log(datesUna);
}
This is the concatinated string : 2024-09-19,2024-09-21
This is the console log for a string that I pass through from the backend :
‘2024-09-07′,’2024-10-13′,’2024-10-14′,’2024-10-15′,’2024-10-16′,’2024-10-17′,’2024-10-18′,’2024-10-19′,’2024-10-20′,’2024-11-08′,’2024-11-09′,’2024-11-22′,’2024-11-23′,’2024-11-24′,’2024-11-25′,’2024-11-26′,’2024-12-04′,’2024-12-05′,’2024-12-06′,’2024-12-07′,’2024-12-23′,’2024-12-24′,’2024-12-25′,’2024-12-26′,’2025-04-23′,’2025-04-24′,’2025-04-25′,’2025-04-26′,’2025-05-22′,’2025-05-23′,’2025-05-24′,’2025-05-25′,’2025-05-26′,’2025-07-01′,’2025-07-02′,’2025-07-03′,’2025-07-04′,’2025-07-05′,’2025-07-06′,’2025-07-07′,’2025-07-08′,’2025-07-09′,’2025-07-10′,’2025-07-25′,’2025-07-26′,’2025-07-27′,’2025-07-28′,’2025-07-29′,’2025-07-30′,’2025-07-31′,’2025-08-01′,’2025-08-02′,’2025-08-03′,’2025-08-04′,’2025-08-05′,’2025-08-06′,’2025-08-07’
const bookedDates = [datesUna].map(d => {
if (d instanceof Array) {
const start = new DateTime(d[0], 'YYYY-MM-DD');
const end = new DateTime(d[1], 'YYYY-MM-DD');
return [start, end];
}
return new DateTime(d, 'YYYY-MM-DD');
});
Even if I concat two dates only the date1 will be disabled and date2 won’t be.