change wizard a bit

This commit is contained in:
Thomas Ruoff
2020-07-16 23:22:30 +02:00
parent cbfb421c02
commit 07af619a60

View File

@@ -22,7 +22,26 @@ function WizardInternal() {
const isLastStep = currentStep === STEPS.length - 1
return (
<Form>
<Form
onSubmit={(event) => {
event.preventDefault()
const fd = new FormData(event.currentTarget)
for (const [key, value] of fd.entries()) {
console.log(key, value)
}
console.log(state)
return
if (!isLastStep) {
dispatch({ type: ACTIONS.NEXT_STEP })
return
}
dispatch({ type: ACTIONS.SUBMIT })
}}
>
{STEPS.map(({ id, component: Component }, index) => (
<>{currentStep === index && <Component />}</>
))}
@@ -34,14 +53,8 @@ function WizardInternal() {
Zurück
</Button>
)}
{!isLastStep && (
<Button onClick={() => dispatch({ type: ACTIONS.NEXT_STEP })}>
Weiter
</Button>
)}
{isLastStep && (
<Button onClick={() => console.log('SEND OFF', state)}>Absenden</Button>
)}
{!isLastStep && <Button type="submit">Weiter</Button>}
{isLastStep && <Button>Absenden</Button>}
</Form>
)
}