mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
added app context with reducer
This commit is contained in:
@@ -1,23 +1,31 @@
|
||||
export default function RangeSelect({ multipleDays, setMultipleDays }) {
|
||||
return (
|
||||
<div>
|
||||
Ich will das Bussle für
|
||||
<input
|
||||
type="radio"
|
||||
id="single"
|
||||
name="days"
|
||||
value="singleDay"
|
||||
onChange={() => setMultipleDays(false)}
|
||||
/>
|
||||
<label htmlFor="single">einen Tag</label>
|
||||
<input
|
||||
type="radio"
|
||||
id="multiple"
|
||||
name="days"
|
||||
value="multipleDays"
|
||||
onChange={() => setMultipleDays(true)}
|
||||
/>
|
||||
<label htmlFor="multiple">mehrere Tage</label> mieten
|
||||
</div>
|
||||
)
|
||||
import { useContext } from 'react'
|
||||
import { AppContext, ACTIONS } from '../context/appStore'
|
||||
export default function RangeSelect() {
|
||||
const { state, dispatch } = useContext(AppContext)
|
||||
|
||||
return (
|
||||
<div>
|
||||
Ich will das Bussle für
|
||||
<input
|
||||
type="radio"
|
||||
id="single"
|
||||
name="days"
|
||||
checked={state.multipleDays === false}
|
||||
onChange={() =>
|
||||
dispatch({ type: ACTIONS.SET_MULTIPLE_DAYS, payload: false })
|
||||
}
|
||||
/>
|
||||
<label htmlFor="single">einen Tag</label>
|
||||
<input
|
||||
type="radio"
|
||||
id="multiple"
|
||||
name="days"
|
||||
checked={state.multipleDays === true}
|
||||
onChange={() =>
|
||||
dispatch({ type: ACTIONS.SET_MULTIPLE_DAYS, payload: true })
|
||||
}
|
||||
/>
|
||||
<label htmlFor="multiple">mehrere Tage</label> mieten
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user