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 const isLastStep = currentStep === STEPS.length - 1
return ( 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) => ( {STEPS.map(({ id, component: Component }, index) => (
<>{currentStep === index && <Component />}</> <>{currentStep === index && <Component />}</>
))} ))}
@@ -34,14 +53,8 @@ function WizardInternal() {
Zurück Zurück
</Button> </Button>
)} )}
{!isLastStep && ( {!isLastStep && <Button type="submit">Weiter</Button>}
<Button onClick={() => dispatch({ type: ACTIONS.NEXT_STEP })}> {isLastStep && <Button>Absenden</Button>}
Weiter
</Button>
)}
{isLastStep && (
<Button onClick={() => console.log('SEND OFF', state)}>Absenden</Button>
)}
</Form> </Form>
) )
} }