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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UIcode/package.json

Lines changed: 3 additions & 2 deletions
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

Lines changed: 0 additions & 4 deletions
This file was deleted.

UIcode/src/App/index.jsx

Lines changed: 0 additions & 1 deletion
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";
Lines changed: 15 additions & 0 deletions
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();
Lines changed: 21 additions & 0 deletions
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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 11 additions & 6 deletions
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}

0 commit comments

Comments
 (0)