remove multipleDays choice

This commit is contained in:
Thomas Ruoff
2020-08-11 22:51:51 +02:00
parent 99b02e32bf
commit e5bbde90b4
2 changed files with 45 additions and 92 deletions

View File

@@ -55,7 +55,6 @@ export default function DateSelect() {
toRef.current?.getInput().focus() toRef.current?.getInput().focus()
}, [range.from]) }, [range.from])
const { multipleDays } = state.formData
const { from, to } = range const { from, to } = range
const disabledDays = [dayDisabled] const disabledDays = [dayDisabled]
const modifiers = { const modifiers = {
@@ -74,100 +73,55 @@ export default function DateSelect() {
} }
return ( return (
<> <Form.Group>
<Form.Group controlId="dateSelect"> <Form.Label component="legend" style={{ display: 'block' }}>
<Form.Label> Datum <Required />
Willst du einen odere mehrere Tage buchen? <Required /> </Form.Label>
</Form.Label> <Form.Group>
<Form.Check <DayPickerInput
type="radio" ref={fromRef}
id={'multipleDays-single'} component={Form.Control}
label="Einen Tag" value={from}
name="multipleDays" placeholder="Von"
value="single" formatDate={dateFormat}
checked={multipleDays === false} parseDate={parseDate}
onChange={() => { dayPickerProps={{
//setFocusedInput(null) className: 'Selectable',
onChange({ selectedDays: [from, { from, to }],
multipleDays: false, disabledDays,
startDate: null, modifiers,
endDate: null, numberOfMonths: 1,
})
}} }}
onDayChange={(from) => setRange({ ...range, from })}
/> />
<Form.Check <Form.Label className="px-2">bis</Form.Label>
type="radio" <DayPickerInput
id={'multipleDays-multiple'} ref={toRef}
label="Mehrere Tage" component={Form.Control}
name="multipleDays" inputProps={{ disabled: !from }}
value="multiple" value={to}
checked={multipleDays === true} placeholder="Bis"
onChange={() => { formatDate={dateFormat}
//setFocusedInput(null) parseDate={parseDate}
onChange({ dayPickerProps={{
multipleDays: true, className: 'Selectable',
startDate: null, selectedDays: [from, { from, to }],
endDate: null, disabledDays,
}) modifiers,
numberOfMonths: 1,
month: from,
fromMonth: from,
}} }}
onDayChange={(to) => setRange({ ...range, to })}
/> />
<Button
className="ml-2"
variant="outline-secondary"
onClick={() => setRange({})}
>
Zurücksetzen
</Button>
</Form.Group> </Form.Group>
{multipleDays !== null && ( </Form.Group>
<Form.Group>
<Form.Label component="legend" style={{ display: 'block' }}>
Datum <Required />
</Form.Label>
{
<>
<Form.Group>
<DayPickerInput
ref={fromRef}
component={Form.Control}
value={from}
placeholder="Von"
formatDate={dateFormat}
parseDate={parseDate}
dayPickerProps={{
className: 'Selectable',
selectedDays: [from, { from, to }],
disabledDays,
modifiers,
numberOfMonths: 1,
}}
onDayChange={(from) => setRange({ ...range, from })}
/>
<Form.Label className="px-2">bis</Form.Label>
<DayPickerInput
ref={toRef}
component={Form.Control}
inputProps={{ disabled: !range.from }}
value={to}
placeholder="Bis"
formatDate={dateFormat}
parseDate={parseDate}
dayPickerProps={{
className: 'Selectable',
selectedDays: [from, { from, to }],
disabledDays,
modifiers,
numberOfMonths: 1,
month: from,
fromMonth: from,
}}
onDayChange={(to) => setRange({ ...range, to })}
/>
<Button
className="ml-2"
variant="outline-secondary"
onClick={() => setRange({})}
>
Zurücksetzen
</Button>
</Form.Group>
</>
}
</Form.Group>
)}
</>
) )
} }

View File

@@ -63,7 +63,6 @@ const initialState = {
postDataError: null, postDataError: null,
postDataSuccess: null, postDataSuccess: null,
formData: { formData: {
multipleDays: true,
//startDate: '2020-08-10', //startDate: '2020-08-10',
//endDate: '2020-08-17', //endDate: '2020-08-17',
//purpose: 'Sommerlager 2021', //purpose: 'Sommerlager 2021',