mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 14:37:13 +01:00
do not bail out if start and end are unordered
This commit is contained in:
committed by
Thomas Ruoff
parent
6dca729e18
commit
fcd6e40b0d
@@ -23,6 +23,22 @@ export default function MyCalendar() {
|
||||
const prevBooked = inSelection && getNextSmaller(daysBooked, start)
|
||||
const nextBooked = inSelection && getNextBigger(daysBooked, start)
|
||||
|
||||
function isSelected(date: Date) {
|
||||
if (!startDate) {
|
||||
return false
|
||||
}
|
||||
|
||||
// if end is before start, it is not within
|
||||
if (endDate && !isAfter(endDate, startDate)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isWithinInterval(date, {
|
||||
start: startDate,
|
||||
end: endDate || startDate,
|
||||
})
|
||||
}
|
||||
|
||||
function tileClassName({ date, view }) {
|
||||
const isMonthView = view === 'month'
|
||||
const isDaysBookedLoaded = !!daysBooked
|
||||
@@ -37,12 +53,7 @@ export default function MyCalendar() {
|
||||
'react-calendar__tile--selected-start': isSameDay(date, startDate),
|
||||
'react-calendar__tile--selected-end': isSameDay(date, endDate),
|
||||
'react-calendar__tile--selected':
|
||||
(startDate &&
|
||||
isWithinInterval(date, {
|
||||
start: startDate,
|
||||
end: endDate || startDate,
|
||||
})) ||
|
||||
isSameDay(date, startDate),
|
||||
isSelected(date) || isSameDay(date, startDate),
|
||||
'react-calendar__tile--unselectable':
|
||||
inSelection &&
|
||||
((prevBooked && date < new Date(prevBooked)) ||
|
||||
|
||||
Reference in New Issue
Block a user