mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
address breaking changes
This commit is contained in:
committed by
Thomas Ruoff
parent
8222e04880
commit
ef7f80fd92
@@ -3,19 +3,20 @@ import { BookContext } from '../../context/book'
|
||||
import InputWrapper from '../inputWrapper'
|
||||
import Input from '../input'
|
||||
import Calendar from '../calendar'
|
||||
import { dateFormatBackend } from '../../helpers/date'
|
||||
|
||||
export default function DateSelect() {
|
||||
const { onChangeEvent, onChange, state } = useContext(BookContext)
|
||||
const { startDate, endDate } = state.formData
|
||||
|
||||
const today = new Date().toISOString().substring(0, 10)
|
||||
const today = dateFormatBackend(new Date())
|
||||
|
||||
return (
|
||||
<>
|
||||
<InputWrapper label="Datum" required>
|
||||
<Calendar
|
||||
start={startDate}
|
||||
end={endDate}
|
||||
start={dateFormatBackend(startDate)}
|
||||
end={dateFormatBackend(endDate)}
|
||||
onChange={onChange}
|
||||
className="my-6 max-w-lg"
|
||||
/>
|
||||
@@ -27,7 +28,7 @@ export default function DateSelect() {
|
||||
type="date"
|
||||
className=""
|
||||
name="startDate"
|
||||
value={startDate || ''}
|
||||
value={dateFormatBackend(startDate) || ''}
|
||||
onChange={onChangeEvent}
|
||||
min={today}
|
||||
required
|
||||
@@ -40,10 +41,10 @@ export default function DateSelect() {
|
||||
type="date"
|
||||
className=""
|
||||
name="endDate"
|
||||
value={endDate || ''}
|
||||
value={dateFormatBackend(endDate) || ''}
|
||||
placeholder="Von"
|
||||
onChange={onChangeEvent}
|
||||
min={startDate || today}
|
||||
min={dateFormatBackend(startDate) || today}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -122,15 +122,15 @@ export default function MyCalendar({
|
||||
|
||||
// when startDate missing or both are already set
|
||||
if (!startDate || (!!startDate && !!endDate)) {
|
||||
onChange({ startDate: dateFormatBackend(date), endDate: null })
|
||||
onChange({ startDate: date, endDate: null })
|
||||
return
|
||||
}
|
||||
|
||||
// when startDate set, but end missing
|
||||
if (isAfter(date, startDate)) {
|
||||
onChange({ endDate: dateFormatBackend(date) })
|
||||
onChange({ endDate: date })
|
||||
} else {
|
||||
onChange({ startDate: dateFormatBackend(date), endDate: start })
|
||||
onChange({ startDate: date, endDate: date })
|
||||
}
|
||||
}}
|
||||
tileClassName={tileClassName}
|
||||
|
||||
Reference in New Issue
Block a user