mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
make form just simple
This commit is contained in:
@@ -9,11 +9,13 @@ import moment from 'moment'
|
||||
import 'react-dates/initialize'
|
||||
import { DateRangePicker, SingleDatePicker } from 'react-dates'
|
||||
|
||||
import { dateFormat } from '../lib/dateHelper'
|
||||
|
||||
const fetcher = (path) => fetch(path).then((r) => r.json())
|
||||
|
||||
export default function DateSelect() {
|
||||
const [focusedInput, setFocusedInput] = useState(null)
|
||||
const { state, dispatch } = useContext(WizardContext)
|
||||
const { state, onChange, onChangeEvent } = useContext(WizardContext)
|
||||
const { data: daysBooked, error: fetchBookedOnError } = useSWR(
|
||||
'/api/daysbooked',
|
||||
fetcher
|
||||
@@ -49,13 +51,10 @@ export default function DateSelect() {
|
||||
checked={multipleDays === false}
|
||||
onChange={() => {
|
||||
setFocusedInput(null)
|
||||
dispatch({
|
||||
type: ACTIONS.SET_FORM_DATA,
|
||||
payload: {
|
||||
multipleDays: false,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
},
|
||||
onChange({
|
||||
multipleDays: false,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
@@ -68,13 +67,10 @@ export default function DateSelect() {
|
||||
checked={multipleDays === true}
|
||||
onChange={() => {
|
||||
setFocusedInput(null)
|
||||
dispatch({
|
||||
type: ACTIONS.SET_FORM_DATA,
|
||||
payload: {
|
||||
multipleDays: true,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
},
|
||||
onChange({
|
||||
multipleDays: true,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
@@ -91,11 +87,8 @@ export default function DateSelect() {
|
||||
placeholder="Datum"
|
||||
numberOfMonths={1}
|
||||
onDateChange={(date) =>
|
||||
dispatch({
|
||||
type: ACTIONS.SET_FORM_DATA,
|
||||
payload: {
|
||||
startDate: date && date.toISOString(),
|
||||
},
|
||||
onChange({
|
||||
startDate: date && dateFormat(date),
|
||||
})
|
||||
}
|
||||
focused={typeof focusedInput === 'boolean' && focusedInput}
|
||||
@@ -115,12 +108,9 @@ export default function DateSelect() {
|
||||
endDate={endDate && moment(endDate)}
|
||||
endDateId="endDate"
|
||||
onDatesChange={({ startDate, endDate }) => {
|
||||
dispatch({
|
||||
type: ACTIONS.SET_FORM_DATA,
|
||||
payload: {
|
||||
startDate: startDate && startDate.toISOString(),
|
||||
endDate: endDate && endDate.toISOString(),
|
||||
},
|
||||
onChange({
|
||||
startDate: startDate && dateFormat(startDate),
|
||||
endDate: endDate && dateFormat(endDate),
|
||||
})
|
||||
}}
|
||||
focusedInput={focusedInput}
|
||||
|
||||
Reference in New Issue
Block a user