|
1 | 1 | import React from "react";
|
2 | 2 | import { Steps, Step } from "./lib";
|
3 |
| - |
4 |
| -const Step1 = (props) => { |
5 |
| - return ( |
6 |
| - <div className="step"> |
7 |
| - First Name:{" "} |
8 |
| - <input |
9 |
| - name="firstname" |
10 |
| - data-testid="firstname" |
11 |
| - value={props.getState("firstname")} |
12 |
| - onChange={props.handleChange} |
13 |
| - /> |
14 |
| - Last Name:{" "} |
15 |
| - <input |
16 |
| - name="lastname" |
17 |
| - data-testid="lastname" |
18 |
| - value={props.getState("lastname")} |
19 |
| - onChange={props.handleChange} |
20 |
| - /> |
21 |
| - Over 18?{" "} |
22 |
| - <input |
23 |
| - type="checkbox" |
24 |
| - name="over18" |
25 |
| - data-testid="checkbox" |
26 |
| - checked={props.getState("over18")} |
27 |
| - onChange={props.handleChange} |
28 |
| - /> |
29 |
| - <span> |
30 |
| - <button |
31 |
| - data-testid="green" |
32 |
| - onClick={() => props.setState("color", "green")} |
33 |
| - > |
34 |
| - Green |
35 |
| - </button> |
36 |
| - <button |
37 |
| - data-testid="blue" |
38 |
| - onClick={() => props.setState("color", "blue")} |
39 |
| - > |
40 |
| - Blue |
41 |
| - </button> |
42 |
| - </span> |
43 |
| - { |
44 |
| - <button disabled={props.step.isFirst()} onClick={props.prev}> |
45 |
| - Previous |
46 |
| - </button> |
47 |
| - } |
48 |
| - {props.step.hasNext() && <button onClick={props.next}>Next</button>} |
49 |
| - <button data-testid="jump3" onClick={() => props.jump(3)}> |
50 |
| - Jump to 3. Step |
51 |
| - </button> |
52 |
| - <button data-testid="jump5" onClick={() => props.jump(5)}> |
53 |
| - Jump to 5. Step |
54 |
| - </button> |
55 |
| - </div> |
56 |
| - ); |
57 |
| -}; |
58 |
| - |
59 |
| -const Step2 = (props) => { |
60 |
| - return ( |
61 |
| - <div className="step"> |
62 |
| - Email:{" "} |
63 |
| - <input |
64 |
| - name="email" |
65 |
| - data-testid="email" |
66 |
| - value={props.getState("email")} |
67 |
| - onChange={props.handleChange} |
68 |
| - /> |
69 |
| - Password:{" "} |
70 |
| - <input |
71 |
| - name="password" |
72 |
| - data-testid="password" |
73 |
| - value={props.getState("password")} |
74 |
| - onChange={props.handleChange} |
75 |
| - /> |
76 |
| - {props.step.hasPrev() && <button onClick={props.prev}>Previous</button>} |
77 |
| - {props.step.hasNext() && <button onClick={props.next}>Next</button>} |
78 |
| - </div> |
79 |
| - ); |
80 |
| -}; |
81 |
| - |
82 |
| -const Step3 = (props) => { |
83 |
| - return ( |
84 |
| - <div className="step"> |
85 |
| - Address:{" "} |
86 |
| - <input |
87 |
| - name="address" |
88 |
| - data-testid="address" |
89 |
| - value={props.getState("address")} |
90 |
| - onChange={props.handleChange} |
91 |
| - /> |
92 |
| - Phone:{" "} |
93 |
| - <input |
94 |
| - name="phone" |
95 |
| - data-testid="phone" |
96 |
| - value={props.getState("phone")} |
97 |
| - onChange={props.handleChange} |
98 |
| - /> |
99 |
| - {props.step.hasPrev() && <button onClick={props.prev}>Previous</button>} |
100 |
| - {props.step.hasNext() && <button onClick={props.next}>Next</button>} |
101 |
| - </div> |
102 |
| - ); |
103 |
| -}; |
104 |
| - |
105 |
| -const Step4 = (props) => { |
106 |
| - return ( |
107 |
| - <div className="step"> |
108 |
| - <p> |
109 |
| - <strong>Name:</strong> |
110 |
| - <span data-testid="final_name"> |
111 |
| - {props.getState("firstname")} {props.getState("lastname")} |
112 |
| - </span> |
113 |
| - </p> |
114 |
| - <p> |
115 |
| - <strong>Email:</strong> |
116 |
| - <span data-testid="final_email">{props.getState("email")}</span> |
117 |
| - </p> |
118 |
| - <p> |
119 |
| - <strong>Password:</strong> |
120 |
| - <span data-testid="final_pass">{props.getState("password")}</span> |
121 |
| - </p> |
122 |
| - <p> |
123 |
| - <strong>Address:</strong> |
124 |
| - <span data-testid="final_address">{props.getState("address")}</span> |
125 |
| - </p> |
126 |
| - <p> |
127 |
| - <strong>Phone:</strong> |
128 |
| - <span data-testid="final_phone">{props.getState("phone")}</span> |
129 |
| - </p> |
130 |
| - <p> |
131 |
| - <strong>Color Choice:</strong> |
132 |
| - <span data-testid="final_color">{props.getState("color")}</span> |
133 |
| - </p> |
134 |
| - {props.step.hasPrev() && <button onClick={props.prev}>Previous</button>} |
135 |
| - { |
136 |
| - <button |
137 |
| - data-testid="last-next" |
138 |
| - onClick={props.next} |
139 |
| - disabled={props.step.isLast()} |
140 |
| - > |
141 |
| - Next |
142 |
| - </button> |
143 |
| - } |
144 |
| - <div> |
145 |
| - {props.allSteps().map(({ order, title }) => ( |
146 |
| - <p key={order}> |
147 |
| - <span data-testid={`order ${order}`}>{order}</span>{" "} |
148 |
| - <span data-testid={`title ${order}`}>{title}</span> |
149 |
| - </p> |
150 |
| - ))} |
151 |
| - </div> |
152 |
| - </div> |
153 |
| - ); |
154 |
| -}; |
| 3 | +import Step1 from "./stepComponents/Step1"; |
| 4 | +import Step2 from "./stepComponents/Step2"; |
| 5 | +import Step3 from "./stepComponents/Step3"; |
| 6 | +import Step4 from "./stepComponents/Step4"; |
155 | 7 |
|
156 | 8 | const App = () => {
|
157 | 9 | return (
|
|
0 commit comments