質問編集履歴
11
文章訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,9 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
**/src/components/Optional.js: 'return' outside of function.
|
11
|
+
**/src/components/Optional.js: 'return' outside of function.**
|
12
|
-
|
13
|
-
**
|
14
12
|
|
15
13
|
```
|
16
14
|
|
10
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
『'return' outside of function』を改善したい
|
test
CHANGED
@@ -2,7 +2,37 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
相談内容(Optional.js)を確認画面(contents.js/case3)に表示する為の実装を行い、ソースコードを記入して
|
6
|
+
|
7
|
+
npm startをしたら、『'return' outside of function』という書きのエラーが表示されるので、それを改善したい。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
**/src/components/Optional.js: 'return' outside of function.
|
12
|
+
|
13
|
+
**
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
15 | setCurrentState({...currentState, "Optional": data });
|
18
|
+
|
19
|
+
16 | };
|
20
|
+
|
21
|
+
> 17 | return (
|
22
|
+
|
23
|
+
| ^
|
24
|
+
|
25
|
+
18 | <div>
|
26
|
+
|
27
|
+
19 | <Grid container>
|
28
|
+
|
29
|
+
20 | <Grid sm={2} />
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
|
6
36
|
|
7
37
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
8
38
|
|
@@ -10,408 +40,278 @@
|
|
10
40
|
|
11
41
|
**期待する動作**
|
12
42
|
|
13
|
-
|
43
|
+
『'return' outside of function』を改善したい
|
14
44
|
|
15
45
|
|
16
46
|
|
17
47
|
**問題解決のため行なったこと**
|
18
48
|
|
19
|
-
|
20
|
-
|
21
|
-
① Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
22
|
-
|
23
|
-
Questionnaireの実装と同じようにBasic Optional の実装を
|
24
|
-
|
25
|
-
Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
49
|
+
『'return' outside of function』で検索して、記事を読んだが該当する内容ではないため、改善しなかった。
|
30
|
-
|
31
|
-
|
50
|
+
|
32
|
-
|
33
|
-
|
34
|
-
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
35
|
-
**src / components /
|
55
|
+
**src / components / Optional.js**
|
36
|
-
|
37
|
-
|
38
|
-
|
56
|
+
|
39
|
-
```
|
57
|
+
```Optional.js
|
58
|
+
|
59
|
+
|
40
60
|
|
41
61
|
import React from "react";
|
42
62
|
|
43
|
-
import
|
63
|
+
import { Grid } from "@mui/material";
|
44
|
-
|
45
|
-
|
64
|
+
|
46
|
-
|
47
|
-
import FormControlLabel from "@mui/material/FormControlLabel";
|
48
|
-
|
49
|
-
import FormControl from "@mui/material/FormControl";
|
50
|
-
|
51
|
-
import FormLabel from "@mui/material/FormLabel";
|
52
|
-
|
53
|
-
import InputLabel from "@mui/material/InputLabel";
|
54
|
-
|
55
|
-
import
|
65
|
+
import Tooltip from "@mui/material/Tooltip";
|
66
|
+
|
56
|
-
|
67
|
+
import TextField from "@mui/material/TextField";
|
68
|
+
|
57
|
-
|
69
|
+
import { UserInputData } from "./Content";
|
70
|
+
|
71
|
+
|
72
|
+
|
58
|
-
|
73
|
+
function Optional (props) {
|
74
|
+
|
75
|
+
const { getValues } = useForm({
|
76
|
+
|
77
|
+
defaultValues: {
|
78
|
+
|
79
|
+
multilineText: "",
|
80
|
+
|
81
|
+
},
|
82
|
+
|
83
|
+
});
|
84
|
+
|
85
|
+
const { currentState, setCurrentState } = useContext(UserInputData);
|
86
|
+
|
59
|
-
const
|
87
|
+
const data = getValues();
|
88
|
+
|
89
|
+
setCurrentState({...currentState, "Optional": data });
|
90
|
+
|
91
|
+
};
|
60
92
|
|
61
93
|
return (
|
62
94
|
|
63
|
-
<>
|
64
|
-
|
65
|
-
<d
|
66
|
-
|
67
|
-
<
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
<
|
72
|
-
|
73
|
-
<
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<option key={num} value={num + 1}>
|
100
|
-
|
101
|
-
{num + 1990}
|
102
|
-
|
103
|
-
</option>
|
104
|
-
|
105
|
-
))}
|
106
|
-
|
107
|
-
</optgroup>
|
108
|
-
|
109
|
-
</Select>
|
110
|
-
|
111
|
-
</FormControl>
|
112
|
-
|
113
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
114
|
-
|
115
|
-
<InputLabel htmlFor="grouped-native-select">month</InputLabel>
|
116
|
-
|
117
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
118
|
-
|
119
|
-
<option aria-label="None" value="" />
|
120
|
-
|
121
|
-
<optgroup label="month">
|
122
|
-
|
123
|
-
{Array.from(Array(12), (_, num) => (
|
124
|
-
|
125
|
-
<option key={num} value={num + 1}>
|
126
|
-
|
127
|
-
{num + 1}
|
128
|
-
|
129
|
-
</option>
|
130
|
-
|
131
|
-
))}
|
132
|
-
|
133
|
-
</optgroup>
|
134
|
-
|
135
|
-
</Select>
|
136
|
-
|
137
|
-
</FormControl>
|
138
|
-
|
139
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
140
|
-
|
141
|
-
<InputLabel htmlFor="grouped-native-select">day</InputLabel>
|
142
|
-
|
143
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
144
|
-
|
145
|
-
<option aria-label="None" value="" />
|
146
|
-
|
147
|
-
<optgroup label="day">
|
148
|
-
|
149
|
-
{Array.from(Array(12), (_, num) => (
|
150
|
-
|
151
|
-
<option key={num} value={num + 1}>
|
152
|
-
|
153
|
-
{num + 1}
|
154
|
-
|
155
|
-
</option>
|
156
|
-
|
157
|
-
))}
|
158
|
-
|
159
|
-
</optgroup>
|
160
|
-
|
161
|
-
</Select>
|
162
|
-
|
163
|
-
</FormControl>
|
164
|
-
|
165
|
-
</div>
|
166
|
-
|
167
|
-
</>
|
95
|
+
<div>
|
96
|
+
|
97
|
+
<Grid container>
|
98
|
+
|
99
|
+
<Grid sm={2} />
|
100
|
+
|
101
|
+
<Grid lg={8} sm={8} spacing={10}>
|
102
|
+
|
103
|
+
<Tooltip title="ご相談内容を記入することができます" placement="top-start" arrow>
|
104
|
+
|
105
|
+
<TextField
|
106
|
+
|
107
|
+
label="ご相談内容"
|
108
|
+
|
109
|
+
fullWidth
|
110
|
+
|
111
|
+
margin="normal"
|
112
|
+
|
113
|
+
rows={4}
|
114
|
+
|
115
|
+
multiline
|
116
|
+
|
117
|
+
variant="outlined"
|
118
|
+
|
119
|
+
placeholder="その他ご要望等あれば、ご記入ください"
|
120
|
+
|
121
|
+
/>
|
122
|
+
|
123
|
+
</Tooltip>
|
124
|
+
|
125
|
+
</Grid>
|
126
|
+
|
127
|
+
</Grid>
|
128
|
+
|
129
|
+
</div>
|
168
130
|
|
169
131
|
);
|
170
132
|
|
171
133
|
};
|
172
134
|
|
173
|
-
|
174
|
-
|
175
|
-
export default
|
135
|
+
export default Optional;
|
176
|
-
|
136
|
+
|
137
|
+
|
138
|
+
|
177
|
-
```
|
139
|
+
```
|
178
|
-
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
179
|
-
**src / components /
|
145
|
+
**src / components / contents.js**
|
180
|
-
|
146
|
+
|
147
|
+
|
148
|
+
|
181
|
-
```
|
149
|
+
```
|
182
150
|
|
183
151
|
import React from "react";
|
184
152
|
|
185
153
|
import { Grid } from "@mui/material";
|
186
154
|
|
155
|
+
import Stepper from "@mui/material/Stepper";
|
156
|
+
|
187
|
-
import
|
157
|
+
import Step from "@mui/material/Step";
|
188
|
-
|
158
|
+
|
189
|
-
import
|
159
|
+
import StepLabel from "@mui/material/StepLabel";
|
160
|
+
|
190
|
-
|
161
|
+
import Button from "@mui/material/Button";
|
162
|
+
|
191
|
-
|
163
|
+
import Typography from "@mui/material/Typography";
|
164
|
+
|
192
|
-
|
165
|
+
import Basic from "./Basic";
|
166
|
+
|
167
|
+
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
168
|
+
|
169
|
+
import Optional from "./Optional";
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
function getSteps() {
|
174
|
+
|
175
|
+
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
const StepContent = ({ stepIndex, BasicProps, questionnaireProps, OptionalProps }) => {
|
182
|
+
|
183
|
+
switch (stepIndex) {
|
184
|
+
|
185
|
+
case 0:
|
186
|
+
|
187
|
+
return <Basic {...BasicProps} />;
|
188
|
+
|
189
|
+
case 1:
|
190
|
+
|
191
|
+
return <Questionnaire {...questionnaireProps} />;
|
192
|
+
|
193
|
+
case 2:
|
194
|
+
|
195
|
+
return <Optional {...OptionalProps} />;
|
196
|
+
|
197
|
+
case 3:
|
198
|
+
|
199
|
+
return (
|
200
|
+
|
201
|
+
<div style={{ textAlign: "center" }}>
|
202
|
+
|
203
|
+
<Basic {...BasicProps} />
|
204
|
+
|
205
|
+
<Questionnaire {...questionnaireProps} />
|
206
|
+
|
207
|
+
<Optional {...OptionalProps} />
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
);
|
212
|
+
|
213
|
+
default:
|
214
|
+
|
215
|
+
return "Unknown stepIndex";
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
};
|
220
|
+
|
221
|
+
function Content() {
|
222
|
+
|
223
|
+
const [activeStep, setActiveStep] = React.useState(0);
|
224
|
+
|
225
|
+
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
226
|
+
|
227
|
+
const steps = getSteps();
|
228
|
+
|
229
|
+
const handleNext = () => {
|
230
|
+
|
231
|
+
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
232
|
+
|
233
|
+
};
|
234
|
+
|
193
|
-
const
|
235
|
+
const handleBack = () => {
|
236
|
+
|
237
|
+
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
238
|
+
|
239
|
+
};
|
240
|
+
|
241
|
+
const handleReset = () => {
|
242
|
+
|
243
|
+
setActiveStep(0);
|
244
|
+
|
245
|
+
};
|
246
|
+
|
247
|
+
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
194
248
|
|
195
249
|
return (
|
196
250
|
|
251
|
+
<Grid container>
|
252
|
+
|
253
|
+
<Grid sm={2} />
|
254
|
+
|
255
|
+
<Grid lg={8} sm={8} spacing={10}>
|
256
|
+
|
257
|
+
<Stepper activeStep={activeStep} alternativeLabel>
|
258
|
+
|
259
|
+
{steps.map((label) => (
|
260
|
+
|
261
|
+
<Step key={label}>
|
262
|
+
|
263
|
+
<StepLabel>{label}</StepLabel>
|
264
|
+
|
265
|
+
</Step>
|
266
|
+
|
267
|
+
))}
|
268
|
+
|
269
|
+
</Stepper>
|
270
|
+
|
271
|
+
{activeStep === steps.length ? (
|
272
|
+
|
273
|
+
<div style={{ textAlign: "center" }}>
|
274
|
+
|
275
|
+
<Typography>全ステップの表示を完了</Typography>
|
276
|
+
|
277
|
+
<Button onClick={handleReset}>リセット</Button>
|
278
|
+
|
279
|
+
</div>
|
280
|
+
|
281
|
+
) : (
|
282
|
+
|
197
|
-
<div>
|
283
|
+
<div>
|
198
|
-
|
284
|
+
|
199
|
-
<
|
285
|
+
<Typography>
|
286
|
+
|
200
|
-
|
287
|
+
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
288
|
+
|
201
|
-
|
289
|
+
</Typography>
|
202
|
-
|
290
|
+
|
203
|
-
<
|
291
|
+
<Button disabled={activeStep === 0} onClick={handleBack}>
|
204
|
-
|
205
|
-
|
292
|
+
|
206
|
-
|
207
|
-
<TextField
|
208
|
-
|
209
|
-
label="ご相談内容"
|
210
|
-
|
211
|
-
fullWidth
|
212
|
-
|
213
|
-
margin="normal"
|
214
|
-
|
215
|
-
|
293
|
+
戻る
|
216
|
-
|
217
|
-
|
294
|
+
|
218
|
-
|
219
|
-
variant="outlined"
|
220
|
-
|
221
|
-
placeholder="その他ご要望等あれば、ご記入ください"
|
222
|
-
|
223
|
-
/>
|
224
|
-
|
225
|
-
</
|
295
|
+
</Button>
|
296
|
+
|
226
|
-
|
297
|
+
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
298
|
+
|
299
|
+
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
300
|
+
|
301
|
+
</Button>
|
302
|
+
|
227
|
-
</
|
303
|
+
</div>
|
304
|
+
|
305
|
+
)}
|
228
306
|
|
229
307
|
</Grid>
|
230
308
|
|
231
|
-
</d
|
309
|
+
</Grid>
|
232
310
|
|
233
311
|
);
|
234
312
|
|
235
|
-
};
|
236
|
-
|
237
|
-
export default Optional;
|
238
|
-
|
239
|
-
```
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
**src / components / contents.js**
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
```
|
250
|
-
|
251
|
-
import React from "react";
|
252
|
-
|
253
|
-
import { Grid } from "@mui/material";
|
254
|
-
|
255
|
-
import Stepper from "@mui/material/Stepper";
|
256
|
-
|
257
|
-
import Step from "@mui/material/Step";
|
258
|
-
|
259
|
-
import StepLabel from "@mui/material/StepLabel";
|
260
|
-
|
261
|
-
import Button from "@mui/material/Button";
|
262
|
-
|
263
|
-
import Typography from "@mui/material/Typography";
|
264
|
-
|
265
|
-
import Basic from "./Basic";
|
266
|
-
|
267
|
-
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
268
|
-
|
269
|
-
import Optional from "./Optional";
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
function getSteps() {
|
274
|
-
|
275
|
-
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
276
|
-
|
277
313
|
}
|
278
314
|
|
279
|
-
|
280
|
-
|
281
|
-
const StepContent = ({ stepIndex, BasicProps, questionnaireProps, OptionalProps }) => {
|
282
|
-
|
283
|
-
switch (stepIndex) {
|
284
|
-
|
285
|
-
case 0:
|
286
|
-
|
287
|
-
return <Basic {...BasicProps} />;
|
288
|
-
|
289
|
-
case 1:
|
290
|
-
|
291
|
-
return <Questionnaire {...questionnaireProps} />;
|
292
|
-
|
293
|
-
case 2:
|
294
|
-
|
295
|
-
return <Optional {...OptionalProps} />;
|
296
|
-
|
297
|
-
case 3:
|
298
|
-
|
299
|
-
return (
|
300
|
-
|
301
|
-
<div style={{ textAlign: "center" }}>
|
302
|
-
|
303
|
-
<Basic {...BasicProps} />
|
304
|
-
|
305
|
-
<Questionnaire {...questionnaireProps} />
|
306
|
-
|
307
|
-
<Optional {...OptionalProps} />
|
308
|
-
|
309
|
-
</div>
|
310
|
-
|
311
|
-
);
|
312
|
-
|
313
|
-
default:
|
314
|
-
|
315
|
-
return "Unknown stepIndex";
|
316
|
-
|
317
|
-
}
|
318
|
-
|
319
|
-
};
|
320
|
-
|
321
|
-
function Content() {
|
322
|
-
|
323
|
-
const [activeStep, setActiveStep] = React.useState(0);
|
324
|
-
|
325
|
-
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
326
|
-
|
327
|
-
const steps = getSteps();
|
328
|
-
|
329
|
-
const handleNext = () => {
|
330
|
-
|
331
|
-
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
332
|
-
|
333
|
-
};
|
334
|
-
|
335
|
-
const handleBack = () => {
|
336
|
-
|
337
|
-
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
338
|
-
|
339
|
-
};
|
340
|
-
|
341
|
-
const handleReset = () => {
|
342
|
-
|
343
|
-
setActiveStep(0);
|
344
|
-
|
345
|
-
};
|
346
|
-
|
347
|
-
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
348
|
-
|
349
|
-
return (
|
350
|
-
|
351
|
-
<Grid container>
|
352
|
-
|
353
|
-
<Grid sm={2} />
|
354
|
-
|
355
|
-
<Grid lg={8} sm={8} spacing={10}>
|
356
|
-
|
357
|
-
<Stepper activeStep={activeStep} alternativeLabel>
|
358
|
-
|
359
|
-
{steps.map((label) => (
|
360
|
-
|
361
|
-
<Step key={label}>
|
362
|
-
|
363
|
-
<StepLabel>{label}</StepLabel>
|
364
|
-
|
365
|
-
</Step>
|
366
|
-
|
367
|
-
))}
|
368
|
-
|
369
|
-
</Stepper>
|
370
|
-
|
371
|
-
{activeStep === steps.length ? (
|
372
|
-
|
373
|
-
<div style={{ textAlign: "center" }}>
|
374
|
-
|
375
|
-
<Typography>全ステップの表示を完了</Typography>
|
376
|
-
|
377
|
-
<Button onClick={handleReset}>リセット</Button>
|
378
|
-
|
379
|
-
</div>
|
380
|
-
|
381
|
-
) : (
|
382
|
-
|
383
|
-
<div>
|
384
|
-
|
385
|
-
<Typography>
|
386
|
-
|
387
|
-
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
388
|
-
|
389
|
-
</Typography>
|
390
|
-
|
391
|
-
<Button disabled={activeStep === 0} onClick={handleBack}>
|
392
|
-
|
393
|
-
戻る
|
394
|
-
|
395
|
-
</Button>
|
396
|
-
|
397
|
-
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
398
|
-
|
399
|
-
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
400
|
-
|
401
|
-
</Button>
|
402
|
-
|
403
|
-
</div>
|
404
|
-
|
405
|
-
)}
|
406
|
-
|
407
|
-
</Grid>
|
408
|
-
|
409
|
-
</Grid>
|
410
|
-
|
411
|
-
);
|
412
|
-
|
413
|
-
}
|
414
|
-
|
415
315
|
export default Content;
|
416
316
|
|
417
317
|
```
|
9
文章訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**Optional.js
|
5
|
+
**Basic.js Optional.js の質問及び答えた回答をContent.js case3で表示したい。**
|
6
6
|
|
7
7
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
8
8
|
|
@@ -10,17 +10,25 @@
|
|
10
10
|
|
11
11
|
**期待する動作**
|
12
12
|
|
13
|
-
Optional.js
|
13
|
+
Basic.js Optional.js の質問及び答えた回答をContent.js case3で表示したい。
|
14
14
|
|
15
15
|
|
16
16
|
|
17
17
|
**問題解決のため行なったこと**
|
18
18
|
|
19
|
+
|
20
|
+
|
19
|
-
Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
21
|
+
① Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
22
|
+
|
20
|
-
|
23
|
+
Questionnaireの実装と同じようにBasic Optional の実装を
|
24
|
+
|
21
|
-
|
25
|
+
Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
26
|
+
|
27
|
+
|
28
|
+
|
22
|
-
|
29
|
+
②Basic コンポーネントは中で state を扱えていないので、Questionnaire.jsを参考にしたがうまく実装できなかった。
|
30
|
+
|
23
|
-
|
31
|
+
また渡すべき state を React.useState() で作ったり、それを props で渡していないので、表示する以前に回答の保存ができていないということは理解できるが、Questionnaire.jsを参考にしたがうまく実装できなかった。
|
24
32
|
|
25
33
|
|
26
34
|
|
8
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Optional.js で記入した"ご相談内容"をContent.js / case3で表示したい
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**
|
5
|
+
**Optional.js で記入した"ご相談内容"をContent.js case3で表示したい。**
|
6
6
|
|
7
7
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
8
8
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
**期待する動作**
|
12
12
|
|
13
|
-
|
13
|
+
Optional.js で記入した"ご相談内容"をContent.js case3で表示したい。
|
14
14
|
|
15
15
|
|
16
16
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
20
20
|
|
21
|
-
Questionnaireの実装と同じように
|
21
|
+
Questionnaireの実装と同じようにOptional の実装を Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
22
22
|
|
23
23
|
|
24
24
|
|
7
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Basic.js
|
1
|
+
Basic.js の質問及び答えた回答をContent.js / case3で表示したい
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**Basic.js
|
5
|
+
**Basic.js の質問及び答えた回答をContent.js case3で表示したい。**
|
6
6
|
|
7
7
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
8
8
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
**期待する動作**
|
12
12
|
|
13
|
-
Basic.js
|
13
|
+
Basic.js の質問及び答えた回答をContent.js case3で表示したい。
|
14
14
|
|
15
15
|
|
16
16
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
20
20
|
|
21
|
-
Questionnaireの実装と同じようにBasic
|
21
|
+
Questionnaireの実装と同じようにBasic の実装を Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
22
22
|
|
23
23
|
|
24
24
|
|
6
文章訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,31 +22,381 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
|
26
|
+
|
27
|
+
**src / components / Basic.js**
|
28
|
+
|
29
|
+
|
30
|
+
|
25
|
-
|
31
|
+
```Basic.js
|
32
|
+
|
33
|
+
import React from "react";
|
34
|
+
|
35
|
+
import Radio from "@mui/material/Radio";
|
36
|
+
|
37
|
+
import RadioGroup from "@mui/material/RadioGroup";
|
38
|
+
|
39
|
+
import FormControlLabel from "@mui/material/FormControlLabel";
|
40
|
+
|
41
|
+
import FormControl from "@mui/material/FormControl";
|
42
|
+
|
43
|
+
import FormLabel from "@mui/material/FormLabel";
|
44
|
+
|
45
|
+
import InputLabel from "@mui/material/InputLabel";
|
46
|
+
|
47
|
+
import Select from "@mui/material/Select";
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
const Basic = () => {
|
52
|
+
|
53
|
+
return (
|
54
|
+
|
55
|
+
<>
|
56
|
+
|
57
|
+
<div style={{ textAlign: "center" }}>
|
58
|
+
|
59
|
+
<FormControl component="fieldset">
|
60
|
+
|
61
|
+
<FormLabel component="legend">- 性別 -</FormLabel>
|
62
|
+
|
63
|
+
<RadioGroup row aria-label="gender" name="row-radio-buttons-group">
|
64
|
+
|
65
|
+
<FormControlLabel value="male" control={<Radio />} label="男性" />
|
66
|
+
|
67
|
+
<FormControlLabel value="female" control={<Radio />} label="女性" />
|
68
|
+
|
69
|
+
</RadioGroup>
|
70
|
+
|
71
|
+
</FormControl>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div style={{ textAlign: "center" }}>
|
76
|
+
|
77
|
+
<FormLabel component="legend">- 生年月日 -</FormLabel>
|
78
|
+
|
79
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
80
|
+
|
81
|
+
<InputLabel htmlFor="grouped-native-select">year</InputLabel>
|
82
|
+
|
83
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
84
|
+
|
85
|
+
<option aria-label="None" value="" />
|
86
|
+
|
87
|
+
<optgroup label="year">
|
88
|
+
|
89
|
+
{Array.from(Array(2020), (_, num) => (
|
90
|
+
|
91
|
+
<option key={num} value={num + 1}>
|
92
|
+
|
93
|
+
{num + 1990}
|
94
|
+
|
95
|
+
</option>
|
96
|
+
|
97
|
+
))}
|
98
|
+
|
99
|
+
</optgroup>
|
100
|
+
|
101
|
+
</Select>
|
102
|
+
|
103
|
+
</FormControl>
|
104
|
+
|
105
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
106
|
+
|
107
|
+
<InputLabel htmlFor="grouped-native-select">month</InputLabel>
|
108
|
+
|
109
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
110
|
+
|
111
|
+
<option aria-label="None" value="" />
|
112
|
+
|
113
|
+
<optgroup label="month">
|
114
|
+
|
115
|
+
{Array.from(Array(12), (_, num) => (
|
116
|
+
|
117
|
+
<option key={num} value={num + 1}>
|
118
|
+
|
119
|
+
{num + 1}
|
120
|
+
|
121
|
+
</option>
|
122
|
+
|
123
|
+
))}
|
124
|
+
|
125
|
+
</optgroup>
|
126
|
+
|
127
|
+
</Select>
|
128
|
+
|
129
|
+
</FormControl>
|
130
|
+
|
131
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
132
|
+
|
133
|
+
<InputLabel htmlFor="grouped-native-select">day</InputLabel>
|
134
|
+
|
135
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
136
|
+
|
137
|
+
<option aria-label="None" value="" />
|
138
|
+
|
139
|
+
<optgroup label="day">
|
140
|
+
|
141
|
+
{Array.from(Array(12), (_, num) => (
|
142
|
+
|
143
|
+
<option key={num} value={num + 1}>
|
144
|
+
|
145
|
+
{num + 1}
|
146
|
+
|
147
|
+
</option>
|
148
|
+
|
149
|
+
))}
|
150
|
+
|
151
|
+
</optgroup>
|
152
|
+
|
153
|
+
</Select>
|
154
|
+
|
155
|
+
</FormControl>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
</>
|
160
|
+
|
161
|
+
);
|
162
|
+
|
163
|
+
};
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
export default Basic;
|
26
168
|
|
27
169
|
```
|
28
170
|
|
171
|
+
**src / components / Optional.js**
|
172
|
+
|
173
|
+
```Optional.js
|
174
|
+
|
175
|
+
import React from "react";
|
176
|
+
|
29
177
|
import { Grid } from "@mui/material";
|
30
178
|
|
31
|
-
import Header from "./components/Header";
|
32
|
-
|
33
|
-
import
|
179
|
+
import Tooltip from "@mui/material/Tooltip";
|
180
|
+
|
34
|
-
|
181
|
+
import TextField from "@mui/material/TextField";
|
35
|
-
|
36
|
-
|
182
|
+
|
183
|
+
|
184
|
+
|
37
|
-
|
185
|
+
const Optional = () => {
|
38
186
|
|
39
187
|
return (
|
40
188
|
|
189
|
+
<div>
|
190
|
+
|
41
|
-
<Grid container
|
191
|
+
<Grid container>
|
42
|
-
|
192
|
+
|
43
|
-
<
|
193
|
+
<Grid sm={2} />
|
44
|
-
|
194
|
+
|
45
|
-
<d
|
195
|
+
<Grid lg={8} sm={8} spacing={10}>
|
196
|
+
|
46
|
-
|
197
|
+
<Tooltip title="ご相談内容を記入することができます" placement="top-start" arrow>
|
198
|
+
|
199
|
+
<TextField
|
200
|
+
|
201
|
+
label="ご相談内容"
|
202
|
+
|
203
|
+
fullWidth
|
204
|
+
|
205
|
+
margin="normal"
|
206
|
+
|
207
|
+
rows={4}
|
208
|
+
|
209
|
+
multiline
|
210
|
+
|
211
|
+
variant="outlined"
|
212
|
+
|
213
|
+
placeholder="その他ご要望等あれば、ご記入ください"
|
214
|
+
|
215
|
+
/>
|
216
|
+
|
217
|
+
</Tooltip>
|
218
|
+
|
47
|
-
<
|
219
|
+
</Grid>
|
220
|
+
|
48
|
-
|
221
|
+
</Grid>
|
222
|
+
|
49
|
-
|
223
|
+
</div>
|
224
|
+
|
225
|
+
);
|
226
|
+
|
227
|
+
};
|
228
|
+
|
229
|
+
export default Optional;
|
230
|
+
|
231
|
+
```
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
**src / components / contents.js**
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
import React from "react";
|
244
|
+
|
245
|
+
import { Grid } from "@mui/material";
|
246
|
+
|
247
|
+
import Stepper from "@mui/material/Stepper";
|
248
|
+
|
249
|
+
import Step from "@mui/material/Step";
|
250
|
+
|
251
|
+
import StepLabel from "@mui/material/StepLabel";
|
252
|
+
|
253
|
+
import Button from "@mui/material/Button";
|
254
|
+
|
255
|
+
import Typography from "@mui/material/Typography";
|
256
|
+
|
257
|
+
import Basic from "./Basic";
|
258
|
+
|
259
|
+
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
260
|
+
|
261
|
+
import Optional from "./Optional";
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
function getSteps() {
|
266
|
+
|
267
|
+
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
const StepContent = ({ stepIndex, BasicProps, questionnaireProps, OptionalProps }) => {
|
274
|
+
|
275
|
+
switch (stepIndex) {
|
276
|
+
|
277
|
+
case 0:
|
278
|
+
|
279
|
+
return <Basic {...BasicProps} />;
|
280
|
+
|
281
|
+
case 1:
|
282
|
+
|
283
|
+
return <Questionnaire {...questionnaireProps} />;
|
284
|
+
|
285
|
+
case 2:
|
286
|
+
|
287
|
+
return <Optional {...OptionalProps} />;
|
288
|
+
|
289
|
+
case 3:
|
290
|
+
|
291
|
+
return (
|
292
|
+
|
293
|
+
<div style={{ textAlign: "center" }}>
|
294
|
+
|
295
|
+
<Basic {...BasicProps} />
|
296
|
+
|
297
|
+
<Questionnaire {...questionnaireProps} />
|
298
|
+
|
299
|
+
<Optional {...OptionalProps} />
|
300
|
+
|
301
|
+
</div>
|
302
|
+
|
303
|
+
);
|
304
|
+
|
305
|
+
default:
|
306
|
+
|
307
|
+
return "Unknown stepIndex";
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
};
|
312
|
+
|
313
|
+
function Content() {
|
314
|
+
|
315
|
+
const [activeStep, setActiveStep] = React.useState(0);
|
316
|
+
|
317
|
+
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
318
|
+
|
319
|
+
const steps = getSteps();
|
320
|
+
|
321
|
+
const handleNext = () => {
|
322
|
+
|
323
|
+
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
324
|
+
|
325
|
+
};
|
326
|
+
|
327
|
+
const handleBack = () => {
|
328
|
+
|
329
|
+
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
330
|
+
|
331
|
+
};
|
332
|
+
|
333
|
+
const handleReset = () => {
|
334
|
+
|
335
|
+
setActiveStep(0);
|
336
|
+
|
337
|
+
};
|
338
|
+
|
339
|
+
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
340
|
+
|
341
|
+
return (
|
342
|
+
|
343
|
+
<Grid container>
|
344
|
+
|
345
|
+
<Grid sm={2} />
|
346
|
+
|
347
|
+
<Grid lg={8} sm={8} spacing={10}>
|
348
|
+
|
349
|
+
<Stepper activeStep={activeStep} alternativeLabel>
|
350
|
+
|
351
|
+
{steps.map((label) => (
|
352
|
+
|
353
|
+
<Step key={label}>
|
354
|
+
|
355
|
+
<StepLabel>{label}</StepLabel>
|
356
|
+
|
357
|
+
</Step>
|
358
|
+
|
359
|
+
))}
|
360
|
+
|
361
|
+
</Stepper>
|
362
|
+
|
363
|
+
{activeStep === steps.length ? (
|
364
|
+
|
365
|
+
<div style={{ textAlign: "center" }}>
|
366
|
+
|
367
|
+
<Typography>全ステップの表示を完了</Typography>
|
368
|
+
|
369
|
+
<Button onClick={handleReset}>リセット</Button>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
) : (
|
374
|
+
|
375
|
+
<div>
|
376
|
+
|
377
|
+
<Typography>
|
378
|
+
|
379
|
+
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
380
|
+
|
381
|
+
</Typography>
|
382
|
+
|
383
|
+
<Button disabled={activeStep === 0} onClick={handleBack}>
|
384
|
+
|
385
|
+
戻る
|
386
|
+
|
387
|
+
</Button>
|
388
|
+
|
389
|
+
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
390
|
+
|
391
|
+
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
392
|
+
|
393
|
+
</Button>
|
394
|
+
|
395
|
+
</div>
|
396
|
+
|
397
|
+
)}
|
398
|
+
|
399
|
+
</Grid>
|
50
400
|
|
51
401
|
</Grid>
|
52
402
|
|
@@ -54,216 +404,6 @@
|
|
54
404
|
|
55
405
|
}
|
56
406
|
|
57
|
-
export default
|
407
|
+
export default Content;
|
58
408
|
|
59
409
|
```
|
60
|
-
|
61
|
-
**src / components / Header.js**
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
```
|
66
|
-
|
67
|
-
import React from "react";
|
68
|
-
|
69
|
-
import { AppBar, Toolbar } from "@mui/material";
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
const Header = () => {
|
74
|
-
|
75
|
-
return (
|
76
|
-
|
77
|
-
<AppBar position="static" style={{ backgroundColor: "primary" }}>
|
78
|
-
|
79
|
-
<Toolbar>React課題 ②</Toolbar>
|
80
|
-
|
81
|
-
</AppBar>
|
82
|
-
|
83
|
-
);
|
84
|
-
|
85
|
-
};
|
86
|
-
|
87
|
-
export default Header;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
```
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
**src / components / contents.js**
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
```
|
102
|
-
|
103
|
-
import React from "react";
|
104
|
-
|
105
|
-
import { Grid } from "@mui/material";
|
106
|
-
|
107
|
-
import Stepper from "@mui/material/Stepper";
|
108
|
-
|
109
|
-
import Step from "@mui/material/Step";
|
110
|
-
|
111
|
-
import StepLabel from "@mui/material/StepLabel";
|
112
|
-
|
113
|
-
import Button from "@mui/material/Button";
|
114
|
-
|
115
|
-
import Typography from "@mui/material/Typography";
|
116
|
-
|
117
|
-
import Basic from "./Basic";
|
118
|
-
|
119
|
-
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
120
|
-
|
121
|
-
import Optional from "./Optional";
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
function getSteps() {
|
126
|
-
|
127
|
-
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
const StepContent = ({ stepIndex, BasicProps, questionnaireProps, OptionalProps }) => {
|
134
|
-
|
135
|
-
switch (stepIndex) {
|
136
|
-
|
137
|
-
case 0:
|
138
|
-
|
139
|
-
return <Basic {...BasicProps} />;
|
140
|
-
|
141
|
-
case 1:
|
142
|
-
|
143
|
-
return <Questionnaire {...questionnaireProps} />;
|
144
|
-
|
145
|
-
case 2:
|
146
|
-
|
147
|
-
return <Optional {...OptionalProps} />;
|
148
|
-
|
149
|
-
case 3:
|
150
|
-
|
151
|
-
return (
|
152
|
-
|
153
|
-
<div style={{ textAlign: "center" }}>
|
154
|
-
|
155
|
-
<Basic {...BasicProps} />
|
156
|
-
|
157
|
-
<Questionnaire {...questionnaireProps} />
|
158
|
-
|
159
|
-
<Optional {...OptionalProps} />
|
160
|
-
|
161
|
-
</div>
|
162
|
-
|
163
|
-
);
|
164
|
-
|
165
|
-
default:
|
166
|
-
|
167
|
-
return "Unknown stepIndex";
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
};
|
172
|
-
|
173
|
-
function Content() {
|
174
|
-
|
175
|
-
const [activeStep, setActiveStep] = React.useState(0);
|
176
|
-
|
177
|
-
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
178
|
-
|
179
|
-
const steps = getSteps();
|
180
|
-
|
181
|
-
const handleNext = () => {
|
182
|
-
|
183
|
-
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
184
|
-
|
185
|
-
};
|
186
|
-
|
187
|
-
const handleBack = () => {
|
188
|
-
|
189
|
-
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
190
|
-
|
191
|
-
};
|
192
|
-
|
193
|
-
const handleReset = () => {
|
194
|
-
|
195
|
-
setActiveStep(0);
|
196
|
-
|
197
|
-
};
|
198
|
-
|
199
|
-
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
200
|
-
|
201
|
-
return (
|
202
|
-
|
203
|
-
<Grid container>
|
204
|
-
|
205
|
-
<Grid sm={2} />
|
206
|
-
|
207
|
-
<Grid lg={8} sm={8} spacing={10}>
|
208
|
-
|
209
|
-
<Stepper activeStep={activeStep} alternativeLabel>
|
210
|
-
|
211
|
-
{steps.map((label) => (
|
212
|
-
|
213
|
-
<Step key={label}>
|
214
|
-
|
215
|
-
<StepLabel>{label}</StepLabel>
|
216
|
-
|
217
|
-
</Step>
|
218
|
-
|
219
|
-
))}
|
220
|
-
|
221
|
-
</Stepper>
|
222
|
-
|
223
|
-
{activeStep === steps.length ? (
|
224
|
-
|
225
|
-
<div style={{ textAlign: "center" }}>
|
226
|
-
|
227
|
-
<Typography>全ステップの表示を完了</Typography>
|
228
|
-
|
229
|
-
<Button onClick={handleReset}>リセット</Button>
|
230
|
-
|
231
|
-
</div>
|
232
|
-
|
233
|
-
) : (
|
234
|
-
|
235
|
-
<div>
|
236
|
-
|
237
|
-
<Typography>
|
238
|
-
|
239
|
-
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
240
|
-
|
241
|
-
</Typography>
|
242
|
-
|
243
|
-
<Button disabled={activeStep === 0} onClick={handleBack}>
|
244
|
-
|
245
|
-
戻る
|
246
|
-
|
247
|
-
</Button>
|
248
|
-
|
249
|
-
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
250
|
-
|
251
|
-
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
252
|
-
|
253
|
-
</Button>
|
254
|
-
|
255
|
-
</div>
|
256
|
-
|
257
|
-
)}
|
258
|
-
|
259
|
-
</Grid>
|
260
|
-
|
261
|
-
</Grid>
|
262
|
-
|
263
|
-
);
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
export default Content;
|
268
|
-
|
269
|
-
```
|
5
文章訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
|
17
17
|
**問題解決のため行なったこと**
|
18
18
|
|
19
|
-
質問の回答はContent.js/case3の確認画面で表示できたが、
|
19
|
+
Questionnaire.jsの質問の回答はContent.js/case3の確認画面で表示できたが、
|
20
|
-
|
20
|
+
|
21
|
-
|
21
|
+
Questionnaireの実装と同じようにBasic Optional の実装を Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
22
22
|
|
23
23
|
|
24
24
|
|
4
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Basic.js Optional.js の質問及び答えた回答をContent.js / case3で表示したい
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**
|
5
|
+
**Basic.js Optional.js の質問及び答えた回答をContent.js case3で表示したい。**
|
6
6
|
|
7
7
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
8
8
|
|
@@ -10,17 +10,15 @@
|
|
10
10
|
|
11
11
|
**期待する動作**
|
12
12
|
|
13
|
-
|
13
|
+
Basic.js Optional.js の質問及び答えた回答をContent.js case3で表示したい。
|
14
14
|
|
15
15
|
|
16
16
|
|
17
17
|
**問題解決のため行なったこと**
|
18
18
|
|
19
|
-
各コンテンツのコンポーネントに応じたソースファイルを用意した。
|
20
|
-
|
21
|
-
質問
|
19
|
+
質問の回答はContent.js/case3の確認画面で表示できたが、
|
22
|
-
|
20
|
+
|
23
|
-
|
21
|
+
質問の実装と同じように基本情報の実装を Content.js/case3行なったが、同じように確認画面で表示できなかった。
|
24
22
|
|
25
23
|
|
26
24
|
|
@@ -116,380 +114,156 @@
|
|
116
114
|
|
117
115
|
import Typography from "@mui/material/Typography";
|
118
116
|
|
119
|
-
import
|
117
|
+
import Basic from "./Basic";
|
120
|
-
|
121
|
-
|
118
|
+
|
122
|
-
|
123
|
-
import FormControlLabel from "@mui/material/FormControlLabel";
|
124
|
-
|
125
|
-
import FormControl from "@mui/material/FormControl";
|
126
|
-
|
127
|
-
import FormLabel from "@mui/material/FormLabel";
|
128
|
-
|
129
|
-
import Tooltip from "@mui/material/Tooltip";
|
130
|
-
|
131
|
-
import
|
119
|
+
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
132
|
-
|
120
|
+
|
133
|
-
import
|
121
|
+
import Optional from "./Optional";
|
122
|
+
|
123
|
+
|
124
|
+
|
134
|
-
|
125
|
+
function getSteps() {
|
126
|
+
|
127
|
+
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
const StepContent = ({ stepIndex, BasicProps, questionnaireProps, OptionalProps }) => {
|
134
|
+
|
135
|
+
switch (stepIndex) {
|
136
|
+
|
137
|
+
case 0:
|
138
|
+
|
139
|
+
return <Basic {...BasicProps} />;
|
140
|
+
|
141
|
+
case 1:
|
142
|
+
|
135
|
-
|
143
|
+
return <Questionnaire {...questionnaireProps} />;
|
136
|
-
|
137
|
-
|
138
|
-
|
144
|
+
|
139
|
-
c
|
145
|
+
case 2:
|
140
|
-
|
141
|
-
|
146
|
+
|
142
|
-
|
143
|
-
|
147
|
+
return <Optional {...OptionalProps} />;
|
148
|
+
|
144
|
-
|
149
|
+
case 3:
|
150
|
+
|
151
|
+
return (
|
152
|
+
|
145
|
-
"
|
153
|
+
<div style={{ textAlign: "center" }}>
|
154
|
+
|
146
|
-
|
155
|
+
<Basic {...BasicProps} />
|
156
|
+
|
157
|
+
<Questionnaire {...questionnaireProps} />
|
158
|
+
|
159
|
+
<Optional {...OptionalProps} />
|
160
|
+
|
161
|
+
</div>
|
162
|
+
|
147
|
-
|
163
|
+
);
|
164
|
+
|
148
|
-
|
165
|
+
default:
|
166
|
+
|
149
|
-
|
167
|
+
return "Unknown stepIndex";
|
168
|
+
|
150
|
-
|
169
|
+
}
|
170
|
+
|
171
|
+
};
|
172
|
+
|
173
|
+
function Content() {
|
174
|
+
|
151
|
-
const
|
175
|
+
const [activeStep, setActiveStep] = React.useState(0);
|
176
|
+
|
152
|
-
|
177
|
+
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
178
|
+
|
179
|
+
const steps = getSteps();
|
180
|
+
|
153
|
-
const handle
|
181
|
+
const handleNext = () => {
|
154
|
-
|
182
|
+
|
155
|
-
setA
|
183
|
+
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
156
184
|
|
157
185
|
};
|
158
186
|
|
187
|
+
const handleBack = () => {
|
188
|
+
|
189
|
+
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
190
|
+
|
191
|
+
};
|
192
|
+
|
193
|
+
const handleReset = () => {
|
194
|
+
|
195
|
+
setActiveStep(0);
|
196
|
+
|
197
|
+
};
|
198
|
+
|
199
|
+
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
200
|
+
|
159
201
|
return (
|
160
202
|
|
161
|
-
<di
|
203
|
+
<Grid container>
|
204
|
+
|
162
|
-
|
205
|
+
<Grid sm={2} />
|
206
|
+
|
207
|
+
<Grid lg={8} sm={8} spacing={10}>
|
208
|
+
|
163
|
-
<
|
209
|
+
<Stepper activeStep={activeStep} alternativeLabel>
|
164
|
-
|
165
|
-
|
210
|
+
|
166
|
-
|
167
|
-
.filter((_, i) => i === 0 || answers[i - 1])
|
168
|
-
|
169
|
-
.map((a
|
211
|
+
{steps.map((label) => (
|
170
|
-
|
212
|
+
|
171
|
-
<
|
213
|
+
<Step key={label}>
|
172
|
-
|
214
|
+
|
173
|
-
<
|
215
|
+
<StepLabel>{label}</StepLabel>
|
174
|
-
|
175
|
-
|
216
|
+
|
176
|
-
|
177
|
-
<Typography>{answer === "yes" ? "はい" : "いいえ"}</Typography>
|
178
|
-
|
179
|
-
) : (
|
180
|
-
|
181
|
-
<RadioGroup
|
182
|
-
|
183
|
-
row
|
184
|
-
|
185
|
-
aria-label="gender"
|
186
|
-
|
187
|
-
name="row-radio-buttons-group"
|
188
|
-
|
189
|
-
onChange={(_evt, value) => {
|
190
|
-
|
191
|
-
handleAnswer(i, value);
|
192
|
-
|
193
|
-
}}
|
194
|
-
|
195
|
-
>
|
196
|
-
|
197
|
-
<FormControlLabel value="yes" control={<Radio />} label="はい" />
|
198
|
-
|
199
|
-
<FormControlLabel value="no" control={<Radio />} label="いいえ" />
|
200
|
-
|
201
|
-
|
217
|
+
</Step>
|
202
|
-
|
203
|
-
)}
|
204
|
-
|
205
|
-
</React.Fragment>
|
206
218
|
|
207
219
|
))}
|
208
220
|
|
209
|
-
</
|
221
|
+
</Stepper>
|
222
|
+
|
210
|
-
|
223
|
+
{activeStep === steps.length ? (
|
224
|
+
|
225
|
+
<div style={{ textAlign: "center" }}>
|
226
|
+
|
227
|
+
<Typography>全ステップの表示を完了</Typography>
|
228
|
+
|
229
|
+
<Button onClick={handleReset}>リセット</Button>
|
230
|
+
|
211
|
-
</div>
|
231
|
+
</div>
|
232
|
+
|
233
|
+
) : (
|
234
|
+
|
235
|
+
<div>
|
236
|
+
|
237
|
+
<Typography>
|
238
|
+
|
239
|
+
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
240
|
+
|
241
|
+
</Typography>
|
242
|
+
|
243
|
+
<Button disabled={activeStep === 0} onClick={handleBack}>
|
244
|
+
|
245
|
+
戻る
|
246
|
+
|
247
|
+
</Button>
|
248
|
+
|
249
|
+
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
250
|
+
|
251
|
+
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
252
|
+
|
253
|
+
</Button>
|
254
|
+
|
255
|
+
</div>
|
256
|
+
|
257
|
+
)}
|
258
|
+
|
259
|
+
</Grid>
|
260
|
+
|
261
|
+
</Grid>
|
212
262
|
|
213
263
|
);
|
214
264
|
|
215
|
-
};
|
216
|
-
|
217
|
-
function getSteps() {
|
218
|
-
|
219
|
-
return ["お客様の情報を入力してください", "以下にお答えください", "ご相談ください"];
|
220
|
-
|
221
265
|
}
|
222
266
|
|
223
|
-
|
224
|
-
|
225
|
-
const StepContent = ({ stepIndex, questionnaireProps }) => {
|
226
|
-
|
227
|
-
switch (stepIndex) {
|
228
|
-
|
229
|
-
case 0:
|
230
|
-
|
231
|
-
return (
|
232
|
-
|
233
|
-
<>
|
234
|
-
|
235
|
-
<div>
|
236
|
-
|
237
|
-
<FormControl component="fieldset">
|
238
|
-
|
239
|
-
<FormLabel component="legend">- 性別 -</FormLabel>
|
240
|
-
|
241
|
-
<RadioGroup row aria-label="gender" name="row-radio-buttons-group">
|
242
|
-
|
243
|
-
<FormControlLabel value="male" control={<Radio />} label="男性" />
|
244
|
-
|
245
|
-
<FormControlLabel value="female" control={<Radio />} label="女性" />
|
246
|
-
|
247
|
-
</RadioGroup>
|
248
|
-
|
249
|
-
</FormControl>
|
250
|
-
|
251
|
-
</div>
|
252
|
-
|
253
|
-
<div>
|
254
|
-
|
255
|
-
<FormLabel component="legend">- 生年月日 -</FormLabel>
|
256
|
-
|
257
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
258
|
-
|
259
|
-
<InputLabel htmlFor="grouped-native-select">year</InputLabel>
|
260
|
-
|
261
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
262
|
-
|
263
|
-
<option aria-label="None" value="" />
|
264
|
-
|
265
|
-
<optgroup label="year">
|
266
|
-
|
267
|
-
{Array.from(Array(2020), (_, num) => (
|
268
|
-
|
269
|
-
<option key={num} value={num + 1}>
|
270
|
-
|
271
|
-
{num + 1990}
|
272
|
-
|
273
|
-
</option>
|
274
|
-
|
275
|
-
))}
|
276
|
-
|
277
|
-
</optgroup>
|
278
|
-
|
279
|
-
</Select>
|
280
|
-
|
281
|
-
</FormControl>
|
282
|
-
|
283
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
284
|
-
|
285
|
-
<InputLabel htmlFor="grouped-native-select">month</InputLabel>
|
286
|
-
|
287
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
288
|
-
|
289
|
-
<option aria-label="None" value="" />
|
290
|
-
|
291
|
-
<optgroup label="month">
|
292
|
-
|
293
|
-
{Array.from(Array(12), (_, num) => (
|
294
|
-
|
295
|
-
<option key={num} value={num + 1}>
|
296
|
-
|
297
|
-
{num + 1}
|
298
|
-
|
299
|
-
</option>
|
300
|
-
|
301
|
-
))}
|
302
|
-
|
303
|
-
</optgroup>
|
304
|
-
|
305
|
-
</Select>
|
306
|
-
|
307
|
-
</FormControl>
|
308
|
-
|
309
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
310
|
-
|
311
|
-
<InputLabel htmlFor="grouped-native-select">day</InputLabel>
|
312
|
-
|
313
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
314
|
-
|
315
|
-
<option aria-label="None" value="" />
|
316
|
-
|
317
|
-
<optgroup label="day">
|
318
|
-
|
319
|
-
{Array.from(Array(12), (_, num) => (
|
320
|
-
|
321
|
-
<option key={num} value={num + 1}>
|
322
|
-
|
323
|
-
{num + 1}
|
324
|
-
|
325
|
-
</option>
|
326
|
-
|
327
|
-
))}
|
328
|
-
|
329
|
-
</optgroup>
|
330
|
-
|
331
|
-
</Select>
|
332
|
-
|
333
|
-
</FormControl>
|
334
|
-
|
335
|
-
</div>
|
336
|
-
|
337
|
-
</>
|
338
|
-
|
339
|
-
);
|
340
|
-
|
341
|
-
case 1:
|
342
|
-
|
343
|
-
return <Questionnaire {...questionnaireProps} />;
|
344
|
-
|
345
|
-
case 2:
|
346
|
-
|
347
|
-
return (
|
348
|
-
|
349
|
-
<Grid container>
|
350
|
-
|
351
|
-
<Grid sm={2} />
|
352
|
-
|
353
|
-
<Grid lg={8} sm={8} spacing={10}>
|
354
|
-
|
355
|
-
<Tooltip title="ご相談内容を記入することができます" placement="top-start" arrow>
|
356
|
-
|
357
|
-
<TextField
|
358
|
-
|
359
|
-
label="ご相談内容"
|
360
|
-
|
361
|
-
fullWidth
|
362
|
-
|
363
|
-
margin="normal"
|
364
|
-
|
365
|
-
rows={4}
|
366
|
-
|
367
|
-
multiline
|
368
|
-
|
369
|
-
variant="outlined"
|
370
|
-
|
371
|
-
placeholder="その他ご要望等あれば、ご記入ください"
|
372
|
-
|
373
|
-
/>
|
374
|
-
|
375
|
-
</Tooltip>
|
376
|
-
|
377
|
-
</Grid>
|
378
|
-
|
379
|
-
</Grid>
|
380
|
-
|
381
|
-
);
|
382
|
-
|
383
|
-
case 3:
|
384
|
-
|
385
|
-
return (
|
386
|
-
|
387
|
-
// I want to display the questions and answers from case0, case1, and case2 in case3.
|
388
|
-
|
389
|
-
);
|
390
|
-
|
391
|
-
default:
|
392
|
-
|
393
|
-
return "Unknown stepIndex";
|
394
|
-
|
395
|
-
}
|
396
|
-
|
397
|
-
};
|
398
|
-
|
399
|
-
function Content() {
|
400
|
-
|
401
|
-
const [activeStep, setActiveStep] = React.useState(0);
|
402
|
-
|
403
|
-
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
404
|
-
|
405
|
-
const steps = getSteps();
|
406
|
-
|
407
|
-
const handleNext = () => {
|
408
|
-
|
409
|
-
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
410
|
-
|
411
|
-
};
|
412
|
-
|
413
|
-
const handleBack = () => {
|
414
|
-
|
415
|
-
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
416
|
-
|
417
|
-
};
|
418
|
-
|
419
|
-
const handleReset = () => {
|
420
|
-
|
421
|
-
setActiveStep(0);
|
422
|
-
|
423
|
-
};
|
424
|
-
|
425
|
-
const buttonDisabled = activeStep === 1 && answers.some((a) => !a);
|
426
|
-
|
427
|
-
return (
|
428
|
-
|
429
|
-
<Grid container>
|
430
|
-
|
431
|
-
<Grid sm={2} />
|
432
|
-
|
433
|
-
<Grid lg={8} sm={8} spacing={10}>
|
434
|
-
|
435
|
-
<Stepper activeStep={activeStep} alternativeLabel>
|
436
|
-
|
437
|
-
{steps.map((label) => (
|
438
|
-
|
439
|
-
<Step key={label}>
|
440
|
-
|
441
|
-
<StepLabel>{label}</StepLabel>
|
442
|
-
|
443
|
-
</Step>
|
444
|
-
|
445
|
-
))}
|
446
|
-
|
447
|
-
</Stepper>
|
448
|
-
|
449
|
-
{activeStep === steps.length ? (
|
450
|
-
|
451
|
-
<div>
|
452
|
-
|
453
|
-
<Typography>全ステップの表示を完了</Typography>
|
454
|
-
|
455
|
-
<Button onClick={handleReset}>リセット</Button>
|
456
|
-
|
457
|
-
</div>
|
458
|
-
|
459
|
-
) : (
|
460
|
-
|
461
|
-
<div>
|
462
|
-
|
463
|
-
<Typography>
|
464
|
-
|
465
|
-
<StepContent stepIndex={activeStep} questionnaireProps={{ answers, setAnswers }} />
|
466
|
-
|
467
|
-
</Typography>
|
468
|
-
|
469
|
-
<Button disabled={activeStep === 0} onClick={handleBack}>
|
470
|
-
|
471
|
-
戻る
|
472
|
-
|
473
|
-
</Button>
|
474
|
-
|
475
|
-
<Button variant="contained" color="primary" onClick={handleNext} disabled={buttonDisabled}>
|
476
|
-
|
477
|
-
{activeStep === steps.length - 1 ? "送信" : "次へ"}
|
478
|
-
|
479
|
-
</Button>
|
480
|
-
|
481
|
-
</div>
|
482
|
-
|
483
|
-
)}
|
484
|
-
|
485
|
-
</Grid>
|
486
|
-
|
487
|
-
</Grid>
|
488
|
-
|
489
|
-
);
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
267
|
export default Content;
|
494
268
|
|
495
269
|
```
|
3
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
case0,case1,case2のの質問及び答えた回答をcase3で表示したい
|
test
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**Basicsjsの質問は、Confirm.js表示されるのだが、答えた回答は表示できていないので、
|
6
|
-
|
7
|
-
|
5
|
+
**case0,case1,case2の質問及び答えた回答をcase3で表示したいです。**
|
8
6
|
|
9
7
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
10
8
|
|
@@ -12,15 +10,89 @@
|
|
12
10
|
|
13
11
|
**期待する動作**
|
14
12
|
|
15
|
-
|
13
|
+
case0,case1,case2の質問及び答えた回答をcase3で表示したいです。
|
16
14
|
|
17
15
|
|
18
16
|
|
19
17
|
**問題解決のため行なったこと**
|
20
18
|
|
19
|
+
各コンテンツのコンポーネントに応じたソースファイルを用意した。
|
20
|
+
|
21
|
-
|
21
|
+
質問やアンケートの画面を確認画面に何とか表示できたが、
|
22
|
-
|
22
|
+
|
23
|
-
|
23
|
+
答えた回答の実装の仕方がわからなかったので、再度、Content.jsにまとめた。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
**App.js**
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
import { Grid } from "@mui/material";
|
32
|
+
|
33
|
+
import Header from "./components/Header";
|
34
|
+
|
35
|
+
import Content from "./components/Content";
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
function App() {
|
40
|
+
|
41
|
+
return (
|
42
|
+
|
43
|
+
<Grid container direction="column">
|
44
|
+
|
45
|
+
<Header />
|
46
|
+
|
47
|
+
<div style={{ padding: 30 }}>
|
48
|
+
|
49
|
+
<Content />
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</Grid>
|
54
|
+
|
55
|
+
);
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
export default App;
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
**src / components / Header.js**
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
import React from "react";
|
70
|
+
|
71
|
+
import { AppBar, Toolbar } from "@mui/material";
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
const Header = () => {
|
76
|
+
|
77
|
+
return (
|
78
|
+
|
79
|
+
<AppBar position="static" style={{ backgroundColor: "primary" }}>
|
80
|
+
|
81
|
+
<Toolbar>React課題 ②</Toolbar>
|
82
|
+
|
83
|
+
</AppBar>
|
84
|
+
|
85
|
+
);
|
86
|
+
|
87
|
+
};
|
88
|
+
|
89
|
+
export default Header;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
|
24
96
|
|
25
97
|
|
26
98
|
|
@@ -44,41 +116,277 @@
|
|
44
116
|
|
45
117
|
import Typography from "@mui/material/Typography";
|
46
118
|
|
47
|
-
import
|
119
|
+
import Radio from "@mui/material/Radio";
|
120
|
+
|
48
|
-
|
121
|
+
import RadioGroup from "@mui/material/RadioGroup";
|
122
|
+
|
123
|
+
import FormControlLabel from "@mui/material/FormControlLabel";
|
124
|
+
|
125
|
+
import FormControl from "@mui/material/FormControl";
|
126
|
+
|
127
|
+
import FormLabel from "@mui/material/FormLabel";
|
128
|
+
|
129
|
+
import Tooltip from "@mui/material/Tooltip";
|
130
|
+
|
49
|
-
import
|
131
|
+
import TextField from "@mui/material/TextField";
|
50
|
-
|
132
|
+
|
51
|
-
import
|
133
|
+
import InputLabel from "@mui/material/InputLabel";
|
52
|
-
|
134
|
+
|
53
|
-
import
|
135
|
+
import Select from "@mui/material/Select";
|
136
|
+
|
137
|
+
|
138
|
+
|
54
|
-
|
139
|
+
const QUESTIONS = [
|
140
|
+
|
55
|
-
|
141
|
+
"現在、生命保険に加入されていますか?",
|
142
|
+
|
143
|
+
"現在、入院中ですか。また、3ヶ月以内に医師の診察・検査の結果、入院・手術をすすめられたことがありますか?",
|
144
|
+
|
145
|
+
"過去、5年以内に病気やケガで手術を受けたことまたは継続して7日以上の入院をしたことはありますか?",
|
146
|
+
|
147
|
+
];
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
const Questionnaire = ({ answers, setAnswers }) => {
|
152
|
+
|
153
|
+
const handleAnswer = (answeredIndex, answer) => {
|
154
|
+
|
155
|
+
setAnswers(answers.map((e, i) => (i === answeredIndex ? answer : e)));
|
156
|
+
|
157
|
+
};
|
158
|
+
|
159
|
+
return (
|
160
|
+
|
161
|
+
<div>
|
162
|
+
|
163
|
+
<FormControl component="fieldset">
|
164
|
+
|
165
|
+
{answers
|
166
|
+
|
167
|
+
.filter((_, i) => i === 0 || answers[i - 1])
|
168
|
+
|
169
|
+
.map((answer, i) => (
|
170
|
+
|
171
|
+
<React.Fragment key={i}>
|
172
|
+
|
173
|
+
<FormLabel component="legend">{QUESTIONS[i]}</FormLabel>
|
174
|
+
|
175
|
+
{answer ? (
|
176
|
+
|
177
|
+
<Typography>{answer === "yes" ? "はい" : "いいえ"}</Typography>
|
178
|
+
|
179
|
+
) : (
|
180
|
+
|
181
|
+
<RadioGroup
|
182
|
+
|
183
|
+
row
|
184
|
+
|
185
|
+
aria-label="gender"
|
186
|
+
|
187
|
+
name="row-radio-buttons-group"
|
188
|
+
|
189
|
+
onChange={(_evt, value) => {
|
190
|
+
|
191
|
+
handleAnswer(i, value);
|
192
|
+
|
193
|
+
}}
|
194
|
+
|
195
|
+
>
|
196
|
+
|
197
|
+
<FormControlLabel value="yes" control={<Radio />} label="はい" />
|
198
|
+
|
199
|
+
<FormControlLabel value="no" control={<Radio />} label="いいえ" />
|
200
|
+
|
201
|
+
</RadioGroup>
|
202
|
+
|
203
|
+
)}
|
204
|
+
|
205
|
+
</React.Fragment>
|
206
|
+
|
207
|
+
))}
|
208
|
+
|
209
|
+
</FormControl>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
|
213
|
+
);
|
214
|
+
|
215
|
+
};
|
56
216
|
|
57
217
|
function getSteps() {
|
58
218
|
|
59
|
-
return ["お客様の情報を入力して
|
219
|
+
return ["お客様の情報を入力してください", "以下にお答えください", "ご相談ください"];
|
60
220
|
|
61
221
|
}
|
62
222
|
|
223
|
+
|
224
|
+
|
63
225
|
const StepContent = ({ stepIndex, questionnaireProps }) => {
|
64
226
|
|
65
227
|
switch (stepIndex) {
|
66
228
|
|
67
229
|
case 0:
|
68
230
|
|
231
|
+
return (
|
232
|
+
|
233
|
+
<>
|
234
|
+
|
235
|
+
<div>
|
236
|
+
|
237
|
+
<FormControl component="fieldset">
|
238
|
+
|
239
|
+
<FormLabel component="legend">- 性別 -</FormLabel>
|
240
|
+
|
241
|
+
<RadioGroup row aria-label="gender" name="row-radio-buttons-group">
|
242
|
+
|
243
|
+
<FormControlLabel value="male" control={<Radio />} label="男性" />
|
244
|
+
|
245
|
+
<FormControlLabel value="female" control={<Radio />} label="女性" />
|
246
|
+
|
247
|
+
</RadioGroup>
|
248
|
+
|
249
|
+
</FormControl>
|
250
|
+
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<div>
|
254
|
+
|
255
|
+
<FormLabel component="legend">- 生年月日 -</FormLabel>
|
256
|
+
|
257
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
258
|
+
|
259
|
+
<InputLabel htmlFor="grouped-native-select">year</InputLabel>
|
260
|
+
|
261
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
262
|
+
|
263
|
+
<option aria-label="None" value="" />
|
264
|
+
|
265
|
+
<optgroup label="year">
|
266
|
+
|
267
|
+
{Array.from(Array(2020), (_, num) => (
|
268
|
+
|
269
|
+
<option key={num} value={num + 1}>
|
270
|
+
|
271
|
+
{num + 1990}
|
272
|
+
|
273
|
+
</option>
|
274
|
+
|
275
|
+
))}
|
276
|
+
|
277
|
+
</optgroup>
|
278
|
+
|
279
|
+
</Select>
|
280
|
+
|
281
|
+
</FormControl>
|
282
|
+
|
283
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
284
|
+
|
285
|
+
<InputLabel htmlFor="grouped-native-select">month</InputLabel>
|
286
|
+
|
287
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
288
|
+
|
289
|
+
<option aria-label="None" value="" />
|
290
|
+
|
291
|
+
<optgroup label="month">
|
292
|
+
|
293
|
+
{Array.from(Array(12), (_, num) => (
|
294
|
+
|
295
|
+
<option key={num} value={num + 1}>
|
296
|
+
|
297
|
+
{num + 1}
|
298
|
+
|
299
|
+
</option>
|
300
|
+
|
301
|
+
))}
|
302
|
+
|
303
|
+
</optgroup>
|
304
|
+
|
305
|
+
</Select>
|
306
|
+
|
307
|
+
</FormControl>
|
308
|
+
|
309
|
+
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
310
|
+
|
311
|
+
<InputLabel htmlFor="grouped-native-select">day</InputLabel>
|
312
|
+
|
313
|
+
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
314
|
+
|
315
|
+
<option aria-label="None" value="" />
|
316
|
+
|
317
|
+
<optgroup label="day">
|
318
|
+
|
319
|
+
{Array.from(Array(12), (_, num) => (
|
320
|
+
|
321
|
+
<option key={num} value={num + 1}>
|
322
|
+
|
323
|
+
{num + 1}
|
324
|
+
|
325
|
+
</option>
|
326
|
+
|
327
|
+
))}
|
328
|
+
|
329
|
+
</optgroup>
|
330
|
+
|
331
|
+
</Select>
|
332
|
+
|
333
|
+
</FormControl>
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
69
|
-
|
337
|
+
</>
|
338
|
+
|
70
|
-
|
339
|
+
);
|
340
|
+
|
71
|
-
case 1:
|
341
|
+
case 1:
|
72
342
|
|
73
343
|
return <Questionnaire {...questionnaireProps} />;
|
74
344
|
|
75
345
|
case 2:
|
76
346
|
|
347
|
+
return (
|
348
|
+
|
349
|
+
<Grid container>
|
350
|
+
|
77
|
-
|
351
|
+
<Grid sm={2} />
|
352
|
+
|
78
|
-
|
353
|
+
<Grid lg={8} sm={8} spacing={10}>
|
354
|
+
|
355
|
+
<Tooltip title="ご相談内容を記入することができます" placement="top-start" arrow>
|
356
|
+
|
357
|
+
<TextField
|
358
|
+
|
359
|
+
label="ご相談内容"
|
360
|
+
|
361
|
+
fullWidth
|
362
|
+
|
363
|
+
margin="normal"
|
364
|
+
|
365
|
+
rows={4}
|
366
|
+
|
367
|
+
multiline
|
368
|
+
|
369
|
+
variant="outlined"
|
370
|
+
|
371
|
+
placeholder="その他ご要望等あれば、ご記入ください"
|
372
|
+
|
373
|
+
/>
|
374
|
+
|
375
|
+
</Tooltip>
|
376
|
+
|
377
|
+
</Grid>
|
378
|
+
|
379
|
+
</Grid>
|
380
|
+
|
381
|
+
);
|
382
|
+
|
79
|
-
case 3:
|
383
|
+
case 3:
|
80
|
-
|
384
|
+
|
81
|
-
return
|
385
|
+
return (
|
386
|
+
|
387
|
+
// I want to display the questions and answers from case0, case1, and case2 in case3.
|
388
|
+
|
389
|
+
);
|
82
390
|
|
83
391
|
default:
|
84
392
|
|
@@ -102,7 +410,7 @@
|
|
102
410
|
|
103
411
|
};
|
104
412
|
|
105
|
-
const handleBack = () => {
|
413
|
+
const handleBack = () => {
|
106
414
|
|
107
415
|
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
108
416
|
|
@@ -185,207 +493,3 @@
|
|
185
493
|
export default Content;
|
186
494
|
|
187
495
|
```
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
**src / components / Basics.js**
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
```
|
196
|
-
|
197
|
-
import React from "react";
|
198
|
-
|
199
|
-
import Radio from "@mui/material/Radio";
|
200
|
-
|
201
|
-
import RadioGroup from "@mui/material/RadioGroup";
|
202
|
-
|
203
|
-
import FormControlLabel from "@mui/material/FormControlLabel";
|
204
|
-
|
205
|
-
import FormControl from "@mui/material/FormControl";
|
206
|
-
|
207
|
-
import FormLabel from "@mui/material/FormLabel";
|
208
|
-
|
209
|
-
import InputLabel from "@mui/material/InputLabel";
|
210
|
-
|
211
|
-
import Select from "@mui/material/Select";
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
const Basic = () => {
|
216
|
-
|
217
|
-
return (
|
218
|
-
|
219
|
-
<>
|
220
|
-
|
221
|
-
<div style={{ textAlign: "center" }}>
|
222
|
-
|
223
|
-
<FormControl component="fieldset">
|
224
|
-
|
225
|
-
<FormLabel component="legend">- 性別 -</FormLabel>
|
226
|
-
|
227
|
-
<RadioGroup row aria-label="gender" name="row-radio-buttons-group">
|
228
|
-
|
229
|
-
<FormControlLabel value="male" control={<Radio />} label="男性" />
|
230
|
-
|
231
|
-
<FormControlLabel value="female" control={<Radio />} label="女性" />
|
232
|
-
|
233
|
-
</RadioGroup>
|
234
|
-
|
235
|
-
</FormControl>
|
236
|
-
|
237
|
-
</div>
|
238
|
-
|
239
|
-
<div style={{ textAlign: "center" }}>
|
240
|
-
|
241
|
-
<FormLabel component="legend">- 生年月日 -</FormLabel>
|
242
|
-
|
243
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
244
|
-
|
245
|
-
<InputLabel htmlFor="grouped-native-select">year</InputLabel>
|
246
|
-
|
247
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
248
|
-
|
249
|
-
<option aria-label="None" value="" />
|
250
|
-
|
251
|
-
<optgroup label="year">
|
252
|
-
|
253
|
-
{Array.from(Array(2020), (_, num) => (
|
254
|
-
|
255
|
-
<option key={num} value={num + 1}>
|
256
|
-
|
257
|
-
{num + 1990}
|
258
|
-
|
259
|
-
</option>
|
260
|
-
|
261
|
-
))}
|
262
|
-
|
263
|
-
</optgroup>
|
264
|
-
|
265
|
-
</Select>
|
266
|
-
|
267
|
-
</FormControl>
|
268
|
-
|
269
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
270
|
-
|
271
|
-
<InputLabel htmlFor="grouped-native-select">month</InputLabel>
|
272
|
-
|
273
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
274
|
-
|
275
|
-
<option aria-label="None" value="" />
|
276
|
-
|
277
|
-
<optgroup label="month">
|
278
|
-
|
279
|
-
{Array.from(Array(12), (_, num) => (
|
280
|
-
|
281
|
-
<option key={num} value={num + 1}>
|
282
|
-
|
283
|
-
{num + 1}
|
284
|
-
|
285
|
-
</option>
|
286
|
-
|
287
|
-
))}
|
288
|
-
|
289
|
-
</optgroup>
|
290
|
-
|
291
|
-
</Select>
|
292
|
-
|
293
|
-
</FormControl>
|
294
|
-
|
295
|
-
<FormControl sx={{ m: 1, minWidth: 120 }}>
|
296
|
-
|
297
|
-
<InputLabel htmlFor="grouped-native-select">day</InputLabel>
|
298
|
-
|
299
|
-
<Select native defaultValue="" id="grouped-native-select" label="Grouping">
|
300
|
-
|
301
|
-
<option aria-label="None" value="" />
|
302
|
-
|
303
|
-
<optgroup label="day">
|
304
|
-
|
305
|
-
{Array.from(Array(12), (_, num) => (
|
306
|
-
|
307
|
-
<option key={num} value={num + 1}>
|
308
|
-
|
309
|
-
{num + 1}
|
310
|
-
|
311
|
-
</option>
|
312
|
-
|
313
|
-
))}
|
314
|
-
|
315
|
-
</optgroup>
|
316
|
-
|
317
|
-
</Select>
|
318
|
-
|
319
|
-
</FormControl>
|
320
|
-
|
321
|
-
</div>
|
322
|
-
|
323
|
-
</>
|
324
|
-
|
325
|
-
);
|
326
|
-
|
327
|
-
};
|
328
|
-
|
329
|
-
export default Basic;
|
330
|
-
|
331
|
-
```
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
**src / components / Confirm.js**
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
```
|
340
|
-
|
341
|
-
import React from "react";
|
342
|
-
|
343
|
-
import Basic from "./Basic";
|
344
|
-
|
345
|
-
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
346
|
-
|
347
|
-
import Optional from "./Optional";
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
export const UserInputData = React.createContext();
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
function Confirm() {
|
356
|
-
|
357
|
-
const [currentState, setCurrentState] = React.useState({});
|
358
|
-
|
359
|
-
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
const value = {
|
364
|
-
|
365
|
-
currentState,
|
366
|
-
|
367
|
-
setCurrentState,
|
368
|
-
|
369
|
-
};
|
370
|
-
|
371
|
-
return (
|
372
|
-
|
373
|
-
<div style={{ textAlign: "center" }}>
|
374
|
-
|
375
|
-
<Basic />
|
376
|
-
|
377
|
-
<Questionnaire answers={answers} setAnswers={setAnswers} />
|
378
|
-
|
379
|
-
<Optional />
|
380
|
-
|
381
|
-
</div>
|
382
|
-
|
383
|
-
);
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
export default Confirm;
|
390
|
-
|
391
|
-
```
|
2
文章訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Basics
|
1
|
+
Basics.jsの質問及び答えた回答をConfirm.jsで表示したい
|
test
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
**Basics
|
5
|
+
**Basicsjsの質問は、Confirm.js表示されるのだが、答えた回答は表示できていないので、
|
6
|
-
|
6
|
+
|
7
|
-
Basics
|
7
|
+
Basics.jsの質問及び答えた回答をConfirm.jsで表示したいです。**
|
8
8
|
|
9
9
|
どのように実装したら良いかわからない状況で、詰まっています。 何方かアドバイスをお願いします。
|
10
10
|
|
@@ -12,13 +12,13 @@
|
|
12
12
|
|
13
13
|
**期待する動作**
|
14
14
|
|
15
|
-
Basics
|
15
|
+
Basics.jsの質問及び答えた回答をConfirm.jsで表示したいです。
|
16
16
|
|
17
17
|
|
18
18
|
|
19
19
|
**問題解決のため行なったこと**
|
20
20
|
|
21
|
-
Basics
|
21
|
+
Basics.jsをConfirm.jsで表示したかったので、それは何とか実装できたが、
|
22
22
|
|
23
23
|
質問及び答えた回答の実装の仕方がわからない。
|
24
24
|
|
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
unction getSteps() {
|
57
|
+
function getSteps() {
|
58
58
|
|
59
59
|
return ["お客様の情報を入力して下さい", "以下にお答え下さい", "ご相談下さい", "以下の内容をご確認下さい"];
|
60
60
|
|
@@ -332,7 +332,7 @@
|
|
332
332
|
|
333
333
|
|
334
334
|
|
335
|
-
**src / components /
|
335
|
+
**src / components / Confirm.js**
|
336
336
|
|
337
337
|
|
338
338
|
|
@@ -340,220 +340,48 @@
|
|
340
340
|
|
341
341
|
import React from "react";
|
342
342
|
|
343
|
-
import Typography from "@mui/material/Typography";
|
344
|
-
|
345
|
-
import
|
343
|
+
import Basic from "./Basic";
|
346
|
-
|
344
|
+
|
347
|
-
import
|
345
|
+
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
348
|
-
|
349
|
-
|
346
|
+
|
350
|
-
|
351
|
-
import FormControl from "@mui/material/FormControl";
|
352
|
-
|
353
|
-
import
|
347
|
+
import Optional from "./Optional";
|
354
|
-
|
355
|
-
|
356
|
-
|
348
|
+
|
349
|
+
|
350
|
+
|
357
|
-
export const
|
351
|
+
export const UserInputData = React.createContext();
|
358
|
-
|
352
|
+
|
353
|
+
|
354
|
+
|
359
|
-
|
355
|
+
function Confirm() {
|
360
|
-
|
361
|
-
|
356
|
+
|
362
|
-
|
363
|
-
"過去、5年以内に病気やケガで手術を受けたことまたは継続して7日以上の入院をしたことはありますか?",
|
364
|
-
|
365
|
-
];
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
const
|
357
|
+
const [currentState, setCurrentState] = React.useState({});
|
370
|
-
|
371
|
-
|
358
|
+
|
372
|
-
|
373
|
-
|
359
|
+
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
const value = {
|
364
|
+
|
365
|
+
currentState,
|
366
|
+
|
367
|
+
setCurrentState,
|
374
368
|
|
375
369
|
};
|
376
370
|
|
377
371
|
return (
|
378
372
|
|
379
|
-
<div>
|
380
|
-
|
381
|
-
|
373
|
+
<div style={{ textAlign: "center" }}>
|
382
|
-
|
383
|
-
|
374
|
+
|
384
|
-
|
385
|
-
.filter((_, i) => i === 0 || answers[i - 1])
|
386
|
-
|
387
|
-
.map((answer, i) => (
|
388
|
-
|
389
|
-
|
375
|
+
<Basic />
|
390
|
-
|
376
|
+
|
391
|
-
|
377
|
+
<Questionnaire answers={answers} setAnswers={setAnswers} />
|
392
|
-
|
393
|
-
|
378
|
+
|
394
|
-
|
395
|
-
<Typography>{answer === "yes" ? "はい" : "いいえ"}</Typography>
|
396
|
-
|
397
|
-
) : (
|
398
|
-
|
399
|
-
<RadioGroup
|
400
|
-
|
401
|
-
row
|
402
|
-
|
403
|
-
aria-label="gender"
|
404
|
-
|
405
|
-
name="row-radio-buttons-group"
|
406
|
-
|
407
|
-
onChange={(_evt, value) => {
|
408
|
-
|
409
|
-
handleAnswer(i, value);
|
410
|
-
|
411
|
-
}}
|
412
|
-
|
413
|
-
>
|
414
|
-
|
415
|
-
<FormControlLabel value="yes" control={<Radio />} label="はい" />
|
416
|
-
|
417
|
-
<FormControlLabel value="no" control={<Radio />} label="いいえ" />
|
418
|
-
|
419
|
-
|
379
|
+
<Optional />
|
420
|
-
|
421
|
-
)}
|
422
|
-
|
423
|
-
</React.Fragment>
|
424
|
-
|
425
|
-
))}
|
426
|
-
|
427
|
-
</FormControl>
|
428
380
|
|
429
381
|
</div>
|
430
382
|
|
431
383
|
);
|
432
384
|
|
433
|
-
};
|
434
|
-
|
435
|
-
export default Questionnaire;
|
436
|
-
|
437
|
-
```
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
**src / components / Optional.js**
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
```
|
446
|
-
|
447
|
-
import React from "react";
|
448
|
-
|
449
|
-
import { Grid } from "@mui/material";
|
450
|
-
|
451
|
-
import Tooltip from "@mui/material/Tooltip";
|
452
|
-
|
453
|
-
import TextField from "@mui/material/TextField";
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
const Optional = () => {
|
458
|
-
|
459
|
-
return (
|
460
|
-
|
461
|
-
<div>
|
462
|
-
|
463
|
-
<Grid container>
|
464
|
-
|
465
|
-
<Grid sm={2} />
|
466
|
-
|
467
|
-
<Grid lg={8} sm={8} spacing={10}>
|
468
|
-
|
469
|
-
<Tooltip title="ご相談内容を記入することができます" placement="top-start" arrow>
|
470
|
-
|
471
|
-
<TextField
|
472
|
-
|
473
|
-
label="ご相談内容"
|
474
|
-
|
475
|
-
fullWidth
|
476
|
-
|
477
|
-
margin="normal"
|
478
|
-
|
479
|
-
rows={4}
|
480
|
-
|
481
|
-
multiline
|
482
|
-
|
483
|
-
variant="outlined"
|
484
|
-
|
485
|
-
placeholder="その他ご要望等あれば、ご記入ください"
|
486
|
-
|
487
|
-
/>
|
488
|
-
|
489
|
-
</Tooltip>
|
490
|
-
|
491
|
-
</Grid>
|
492
|
-
|
493
|
-
</Grid>
|
494
|
-
|
495
|
-
</div>
|
496
|
-
|
497
|
-
);
|
498
|
-
|
499
|
-
};
|
500
|
-
|
501
|
-
export default Optional;
|
502
|
-
|
503
|
-
```
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
**src / components / Confirm.js**
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
```
|
512
|
-
|
513
|
-
import React from "react";
|
514
|
-
|
515
|
-
import Basic from "./Basic";
|
516
|
-
|
517
|
-
import Questionnaire, { QUESTIONS } from "./Questionnaire";
|
518
|
-
|
519
|
-
import Optional from "./Optional";
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
export const UserInputData = React.createContext();
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
function Confirm() {
|
528
|
-
|
529
|
-
const [currentState, setCurrentState] = React.useState({});
|
530
|
-
|
531
|
-
const [answers, setAnswers] = React.useState(Array(QUESTIONS.length).fill(null));
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
const value = {
|
536
|
-
|
537
|
-
currentState,
|
538
|
-
|
539
|
-
setCurrentState,
|
540
|
-
|
541
|
-
};
|
542
|
-
|
543
|
-
return (
|
544
|
-
|
545
|
-
<div style={{ textAlign: "center" }}>
|
546
|
-
|
547
|
-
<Basic />
|
548
|
-
|
549
|
-
<Questionnaire answers={answers} setAnswers={setAnswers} />
|
550
|
-
|
551
|
-
<Optional />
|
552
|
-
|
553
|
-
</div>
|
554
|
-
|
555
|
-
);
|
556
|
-
|
557
385
|
}
|
558
386
|
|
559
387
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|