|
1 | 1 | import React from "react"; |
2 | | -import RadioGroup from "Components/RadioGroup"; |
3 | 2 | import { useState } from "react"; |
4 | | -import DatePicker from "Components/DatePicker"; |
5 | 3 | import styled from "styled-components"; |
6 | 4 | import Button from "Components/Common/Button"; |
7 | 5 | import Row from "Components/Grid/Row"; |
| 6 | +import Step1 from "./Step1"; |
| 7 | +import Step2 from "./Step2"; |
8 | 8 |
|
9 | | -const Box = styled.div` |
10 | | - width: 500px; |
| 9 | +const Wrapper = styled.div` |
| 10 | + padding-top: 50px; |
11 | 11 | `; |
| 12 | + |
12 | 13 | const Contribute = () => { |
13 | | - const [selected, setSelected] = useState("positive"); |
14 | | - const [date, setDate] = useState(new Date()); |
| 14 | + const [step, setStep] = useState(0); |
| 15 | + const [selectedTestResult, setSelectedTestResult] = useState("positive"); |
| 16 | + const [testDate, setTestDate] = useState(new Date()); |
| 17 | + |
| 18 | + const showButtons = step !== 0; |
| 19 | + |
| 20 | + const handleNextClick = () => setStep(step => step + 1); |
| 21 | + const handleBackClick = () => setStep(step => step - 1); |
15 | 22 |
|
16 | | - const handleDayChange = day => { |
17 | | - setDate(day); |
18 | | - }; |
| 23 | + const steps = [ |
| 24 | + () => <Step1 submitReport={handleNextClick} viewResults={() => {}} />, |
| 25 | + () => ( |
| 26 | + <Step2 |
| 27 | + selectedTestResult={selectedTestResult} |
| 28 | + onTestResultChange={setSelectedTestResult} |
| 29 | + testDate={testDate} |
| 30 | + onTestDateChange={setTestDate} |
| 31 | + /> |
| 32 | + ) |
| 33 | + ]; |
| 34 | + const CurrentStep = steps[step]; |
19 | 35 |
|
20 | 36 | return ( |
21 | | - <div> |
22 | | - <h2>Self Report</h2> |
23 | | - <hr /> |
24 | | - <Box> |
25 | | - <h3>Do you have test results for COVID-19?</h3> |
26 | | - <p> |
27 | | - All data is private and anonymous. You can still report your data to |
28 | | - this map if you haven’t taken a test, and update test results later.{" "} |
29 | | - </p> |
30 | | - <RadioGroup selected={selected} onChange={setSelected}> |
31 | | - {[ |
32 | | - { |
33 | | - label: "Positive", |
34 | | - value: "positive" |
35 | | - }, |
36 | | - { |
37 | | - label: "Negative", |
38 | | - value: "negative" |
39 | | - }, |
40 | | - { |
41 | | - label: "I have not been tested", |
42 | | - value: "not_tested" |
43 | | - } |
44 | | - ]} |
45 | | - </RadioGroup> |
46 | | - </Box> |
47 | | - <hr /> |
48 | | - <Box> |
49 | | - <h2>What date was the test administered?</h2> |
50 | | - <DatePicker selectedDay={date} onDayChange={handleDayChange} /> |
51 | | - </Box> |
52 | | - <Row> |
53 | | - <Button color="secondary">Back</Button> |
54 | | - <Button color="primary">Next</Button> |
55 | | - </Row> |
56 | | - </div> |
| 37 | + <Wrapper> |
| 38 | + <CurrentStep /> |
| 39 | + {showButtons && ( |
| 40 | + <Row> |
| 41 | + <Button color="secondary" onClick={handleBackClick}> |
| 42 | + Back |
| 43 | + </Button> |
| 44 | + <Button color="primary" onClick={handleNextClick}> |
| 45 | + Next |
| 46 | + </Button> |
| 47 | + </Row> |
| 48 | + )} |
| 49 | + </Wrapper> |
57 | 50 | ); |
58 | 51 | }; |
59 | 52 |
|
|
0 commit comments