Skip to content

Commit 6a218af

Browse files
committed
Results formatting
1 parent e551d3f commit 6a218af

File tree

20 files changed

+359
-51
lines changed

20 files changed

+359
-51
lines changed

UIcode/.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
REACT_APP_API_URL=
22
REACT_APP_GOOGLE_CLIENT_ID=
3-
REACT_APP_ENCLAVE_URL=https://safetrace.enigma.co
3+
REACT_APP_ENCLAVE_URL=https://safetrace.enigma.co
4+
REACT_APP_GOOGLE_MAPS_API_KEY=

UIcode/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ Then add the API URL to your `.env.development`
3030
echo "REACT_APP_GOOGLE_CLIENT_ID=119469794689-hhq7rpcmd88c7r5gkiom0u2pakfka3cd.apps.googleusercontent.com" >> .env.development
3131
```
3232

33+
Include the Enclave URL in your `.env.development`
34+
```bash
35+
echo "REACT_APP_ENCLAVE_URL=https://safetrace.enigma.co" >> .env.development
36+
```
37+
38+
Include Google Maps API Key in your `.env.development`, you can find instructions on how to obtain it here [https://developers.google.com/maps/documentation/javascript/get-api-key](https://developers.google.com/maps/documentation/javascript/get-api-key)
39+
40+
```bash
41+
echo "REACT_APP_GOOGLE_MAPS_API_KEY=AaLeiVHdICmJYzM8w8aSyEzo-TainZ3W3Ev2QfQ" >> .env.development
42+
```
43+
3344
Finally to run the client execute the following commands:
3445

3546
```bash

UIcode/package-lock.json

+96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UIcode/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"enigma-js": "^0.3.0",
76
"axios": "^0.19.2",
87
"bootstrap": "^4.4.1",
9-
"date-fns": "^2.11.1",
8+
"date-fns": "^2.12.0",
9+
"enigma-js": "^0.3.0",
1010
"eth-crypto": "^1.5.2",
1111
"jayson": "^3.2.0",
1212
"js-cookie": "^2.2.1",
@@ -19,6 +19,7 @@
1919
"react-router": "^5.1.2",
2020
"react-router-dom": "^4.1.2",
2121
"react-scripts": "^3.4.1",
22+
"react-spinners": "^0.8.1",
2223
"styled-components": "^5.0.1"
2324
},
2425
"scripts": {

UIcode/src/App/App.css

-4
This file was deleted.

UIcode/src/App/index.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import "./App.css";
32
import { BrowserRouter as Router, Switch } from "react-router-dom";
43
import DefaultLayout from "Layouts/Default";
54
import Home from "Pages/Home";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Flash {
2+
constructor() {
3+
this.state = {};
4+
}
5+
6+
get() {
7+
return this.state;
8+
}
9+
10+
set(message, type = "info") {
11+
this.state = { message, type };
12+
}
13+
}
14+
15+
export default new Flash();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import colors from "Theme/colors";
4+
import Flash from "./Flash";
5+
6+
const Msg = styled.span`
7+
color: ${(props) =>
8+
props.type === "success"
9+
? colors.success.main
10+
: props.type === "error"
11+
? colors.error.main
12+
: colors.text.main};
13+
`;
14+
15+
const FlashMessage = () => {
16+
const { message, type } = Flash.get();
17+
18+
return message ? <Msg type={type}>{message}</Msg> : null;
19+
};
20+
21+
export default FlashMessage;

UIcode/src/Components/Header/index.jsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ const Header = ({ className }) => {
7272
</StyledNavLink>
7373
</NavLi>
7474
<NavLi>
75-
<StyledNavLink to="/contribute">Contribute</StyledNavLink>
75+
<StyledNavLink
76+
to="/contribute"
77+
isActive={(match, location) => {
78+
return match || location.pathname === "/results";
79+
}}
80+
>
81+
Contribute
82+
</StyledNavLink>
7683
</NavLi>
7784
</NavUl>
7885

UIcode/src/Pages/Contribute/index.jsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { parseJsonFile, convertLocationData } from "Services/parser";
1212
import { report } from "Services/api";
1313
import { addData } from "Services/enclave";
1414
import Authorized from "Sections/Authorized";
15+
import Flash from "Components/FlashMessage/Flash";
1516

1617
const Wrapper = styled.div`
1718
padding-top: 50px;
@@ -26,6 +27,7 @@ const Contribute = ({ history }) => {
2627
const showButtons = step === 1;
2728

2829
const nextPage = () => setStep((step) => step + 1);
30+
const goToResultsPage = () => history.push("/results");
2931

3032
const sendReport = () =>
3133
report({
@@ -48,13 +50,14 @@ const Contribute = ({ history }) => {
4850
const handleFileSubmit = (file) => {
4951
parseJsonFile(file)
5052
.then((json) => {
51-
const data = convertLocationData(json);
52-
addData(me.encryptedUserId, JSON.stringify(data))
53+
const data = convertLocationData(json, testResult === "positive");
54+
addData(me._id, JSON.stringify(data))
5355
.then(() => {
54-
history.push(
55-
"/results",
56-
"Your data has been successfully shared with SafeTrace API."
56+
Flash.set(
57+
"Your data has been successfully shared with SafeTrace API.",
58+
"success"
5759
);
60+
goToResultsPage();
5861
})
5962
.catch(() => alert("An error occurred. Please try again"));
6063
})
@@ -76,7 +79,9 @@ const Contribute = ({ history }) => {
7679
};
7780

7881
const steps = [
79-
() => <Step1 submitReport={handleNextClick} viewResults={() => {}} />,
82+
() => (
83+
<Step1 submitReport={handleNextClick} viewResults={goToResultsPage} />
84+
),
8085
() => (
8186
<Step2
8287
selectedTestResult={testResult}

UIcode/src/Pages/Home/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Home extends React.Component {
44
render() {
55
return (
66
<div>
7-
<div className="centeralign">
7+
<div>
88
<Card border="light" style={{ width: "18rem" }}>
99
<Card.Body>
1010
<Card.Title>
+53-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,58 @@
11
import React from "react";
2+
import styled from "styled-components";
23

3-
const ResultsTable = () => {
4-
return <div></div>;
4+
const StyledTable = styled.table`
5+
width: 100%;
6+
border-collapse: collapse;
7+
table-layout: fixed;
8+
& > thead > tr > th {
9+
border: none;
10+
vertical-align: baseline;
11+
padding: 0.75rem;
12+
& > p {
13+
font-size: 14px;
14+
font-weight: normal;
15+
}
16+
}
17+
`;
18+
19+
const ResultsTable = ({ results }) => {
20+
return (
21+
<StyledTable>
22+
<thead>
23+
<tr>
24+
<th>Location</th>
25+
<th>Address</th>
26+
<th>
27+
Number of Matches
28+
<p>
29+
How many individuals who have COVID-19 have been in this location
30+
in the past 12 hours.
31+
</p>
32+
</th>
33+
<th>Date</th>
34+
<th>
35+
Time
36+
<p>
37+
the amount of time between your visit and the most recent match
38+
</p>
39+
</th>
40+
</tr>
41+
</thead>
42+
<tbody>
43+
{results &&
44+
results.map((result) => (
45+
<tr key={result.location + result.address + result.date}>
46+
<td>{result.location}</td>
47+
<td>{result.address}</td>
48+
<td>{result.numberOfMatches}</td>
49+
<td>{result.date}</td>
50+
<td>{result.time}</td>
51+
</tr>
52+
))}
53+
</tbody>
54+
</StyledTable>
55+
);
556
};
657

758
export default ResultsTable;

0 commit comments

Comments
 (0)