react-modern-calendar-datepicker icon indicating copy to clipboard operation
react-modern-calendar-datepicker copied to clipboard

Disable a day or a set of days for whole calendar

Open sshahzaiib opened this issue 4 years ago • 6 comments

Is there a way to disable a day or multiple days for the whole calendar? I'm working on showing slots for specific day and there are some days that are not available for booking So I was wondering if we can disable a day like Monday for whole calendar.

sshahzaiib avatar Nov 13 '20 07:11 sshahzaiib

the Behaiver U want as Define the dates that can be selected. The function receives (currentDate, selectedDate) and should return a true or false whether the currentDate is valid or not

isValidDate?: (currentDate: any, selectedDate: any) => boolean; u can add it to your Date calnder and add to the calnder Cpmponent isValidDate={validDate} this should return false for specfic day and true for the other const validDate = current => current.day() !== 0 while week start at sun from 0 so here sunday is not a valid date and it's disabled

i hope it helps

Adamkaram avatar Dec 13 '20 12:12 Adamkaram

I'm using Calendar component and there a prop for disabledDays which accepts an array of individual dates to be disabled

https://github.com/Kiarash-Z/react-modern-calendar-datepicker/blob/0cd7478b2fda3f755f0128a2ba1244346ed9eba0/src/Calendar.js#L162

I can't find this isValidDate prop with this Calendar component.

sshahzaiib avatar Dec 14 '20 08:12 sshahzaiib

I'm using Calendar component and there a prop for disabledDays which accepts an array of individual dates to be disabled

https://github.com/Kiarash-Z/react-modern-calendar-datepicker/blob/0cd7478b2fda3f755f0128a2ba1244346ed9eba0/src/Calendar.js#L162

I can't find this isValidDate prop with this Calendar component.

i told u mate u can add logic like it in ur package it self wihout damage ur package

you can make a helper fuction to do it for u , any way i requested that featuer the day before i hope they add it

Adamkaram avatar Dec 14 '20 08:12 Adamkaram

This would be a great feature. Writing custom functionality for this doesn't make sense, and you'd have to calculate it from now until the end of time.

mildrenben avatar Dec 29 '20 19:12 mildrenben

I have created a pull requests that contains a feature to disable specific week days and to forcely enable specific calendar days.

For example: disable every monday and friday and then enable a specific date (like monday, even though mondays are disabled via that disabledWeekDays feature.

#224

sentisso avatar Jan 15 '21 18:01 sentisso

any updates on this ?

endurance21 avatar May 18 '21 12:05 endurance21