mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
emm - use string instead of date for start/endDate
This commit is contained in:
@@ -15,8 +15,8 @@ export default function DateSelect() {
|
||||
<>
|
||||
<InputWrapper label="Datum" required>
|
||||
<Calendar
|
||||
start={dateFormatBackend(startDate)}
|
||||
end={dateFormatBackend(endDate)}
|
||||
start={startDate}
|
||||
end={endDate}
|
||||
onChange={onChange}
|
||||
className="my-6 max-w-lg"
|
||||
/>
|
||||
@@ -28,7 +28,7 @@ export default function DateSelect() {
|
||||
type="date"
|
||||
className=""
|
||||
name="startDate"
|
||||
value={dateFormatBackend(startDate) || ''}
|
||||
value={startDate || ''}
|
||||
onChange={onChangeEvent}
|
||||
min={today}
|
||||
required
|
||||
@@ -41,10 +41,10 @@ export default function DateSelect() {
|
||||
type="date"
|
||||
className=""
|
||||
name="endDate"
|
||||
value={dateFormatBackend(endDate) || ''}
|
||||
value={endDate || ''}
|
||||
placeholder="Von"
|
||||
onChange={onChangeEvent}
|
||||
min={dateFormatBackend(startDate) || today}
|
||||
min={startDate || today}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -107,6 +107,8 @@ export default function MyCalendar({
|
||||
return
|
||||
}
|
||||
|
||||
const dateAsBackendFormat = dateFormatBackend(date);
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
||||
@@ -122,15 +124,15 @@ export default function MyCalendar({
|
||||
|
||||
// when startDate missing or both are already set
|
||||
if (!startDate || (!!startDate && !!endDate)) {
|
||||
onChange({ startDate: date, endDate: null })
|
||||
onChange({ startDate: dateAsBackendFormat, endDate: null })
|
||||
return
|
||||
}
|
||||
|
||||
// when startDate set, but end missing
|
||||
if (isAfter(date, startDate)) {
|
||||
onChange({ endDate: date })
|
||||
onChange({ endDate: dateAsBackendFormat })
|
||||
} else {
|
||||
onChange({ startDate: date, endDate: date })
|
||||
onChange({ startDate: dateAsBackendFormat, endDate: dateAsBackendFormat })
|
||||
}
|
||||
}}
|
||||
tileClassName={tileClassName}
|
||||
|
||||
Reference in New Issue
Block a user