-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWizard.tsx
34 lines (32 loc) · 988 Bytes
/
Wizard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { useState } from "react";
import { WizardProps } from "./Wizard.types";
import { WizardHeader } from "./components";
import { WizardButtons } from "./components/WizardButtons";
import { ContentWrapper } from "./Wizard.styles";
export const Wizard: React.FC<WizardProps> = ({ steps, onSubmit }) => {
const [step, setStep] = useState(0);
const {
content,
canProceedFurther,
canProceedBack = true,
isLoading,
} = steps[step];
const headerSteps: string[] = steps.map(({ label }) => {
return label;
});
return (
<section>
<WizardHeader steps={headerSteps} currentStep={step} />
<ContentWrapper>{content}</ContentWrapper>
<WizardButtons
setStep={setStep}
currentStep={step}
isFirstStep={step === 0}
isLastStep={step === steps.length - 1}
canProceedFurther={canProceedFurther && !isLoading}
canProceedBack={canProceedBack}
onSubmit={onSubmit}
/>
</section>
);
};