1+ import React from "react" ;
2+ import { useForm , useStep } from "react-hooks-helper" ;
3+
4+ import StepOne from "./stepOne" ;
5+ import StepTwo from "./stepTwo" ;
6+ import StepThree from "./stepThree" ;
7+ import ReviewNewPatientDetails from "./ReviewNewPatientDetails" ;
8+ import SubmitPatientForm from "./submitPatientForm" ;
9+
10+
11+ const steps = [
12+ { id : "stepOne" } ,
13+ { id : "stepTwo" } ,
14+ { id : "stepThree" } ,
15+ { id : "reviewNewPatientDetails" } ,
16+ { id : "submitPatientForm" }
17+ ] ;
18+
19+ const defaultData = {
20+ firstnamePatient : "" ,
21+ lastnamePatient : "" ,
22+ ncdNumberPatient : "" ,
23+ dfidStudyNumberPatient : "" ,
24+ optionsGender : "" ,
25+ optionTypeDiabetes : "" ,
26+ dobPatient : "" ,
27+ } ;
28+
29+ const MultiStepForm = ( ) => {
30+
31+ const [ formData , setForm ] = useForm ( defaultData ) ;
32+ const { step, navigation } = useStep ( { initialStep : 0 , steps } ) ;
33+ const { id } = step ;
34+
35+ const props = { formData, setForm, navigation} ;
36+
37+ switch ( id ) {
38+ case "stepOne" :
39+ return < StepOne { ...props } /> ;
40+ case "stepTwo" :
41+ return < StepTwo { ...props } /> ;
42+ case "stepThree" :
43+ return < StepThree { ...props } /> ;
44+ case "reviewNewPatientDetails" :
45+ return < ReviewNewPatientDetails { ...props } /> ;
46+ case "submitPatientForm" :
47+ return < SubmitPatientForm { ...props } /> ;
48+ default :
49+ return null ;
50+ }
51+ } ;
52+
53+ export default MultiStepForm ;
0 commit comments