From 3c0fc6fe1f319fafa93e12156df2f1f5d5ea0510 Mon Sep 17 00:00:00 2001 From: williameriksson126 Date: Tue, 8 Dec 2020 11:54:34 +0100 Subject: [PATCH] Add: Select user buttons --- src/APIexamples/user1.json | 2 +- src/APIexamples/user2.json | 2 +- src/APIexamples/user3.json | 2 +- src/APIexamples/user4.json | 2 +- src/components/DisruptionButton.js | 10 ++++----- src/components/NavigationDrawer.js | 5 +++++ src/components/SelectUserButton.js | 36 ++++++++++++++++++++++++++++++ 7 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 src/components/SelectUserButton.js diff --git a/src/APIexamples/user1.json b/src/APIexamples/user1.json index 0cb6458..4a13853 100644 --- a/src/APIexamples/user1.json +++ b/src/APIexamples/user1.json @@ -1,5 +1,5 @@ { "name":"1", "deviceId":"1", - "location":"9022014014754001" + "stoppointgid":"9022014014754001" } \ No newline at end of file diff --git a/src/APIexamples/user2.json b/src/APIexamples/user2.json index 4429791..be15eab 100644 --- a/src/APIexamples/user2.json +++ b/src/APIexamples/user2.json @@ -1,5 +1,5 @@ { "name":"2", "deviceId":"2", - "location":"9022014014020001" + "stoppointgid":"9022014014020001" } \ No newline at end of file diff --git a/src/APIexamples/user3.json b/src/APIexamples/user3.json index 4f5b8e2..a496cc3 100644 --- a/src/APIexamples/user3.json +++ b/src/APIexamples/user3.json @@ -1,5 +1,5 @@ { "name":"3", "deviceId":"3", - "location":"9022014014751001" + "stoppointgid":"9022014014751001" } \ No newline at end of file diff --git a/src/APIexamples/user4.json b/src/APIexamples/user4.json index 89089ba..7bcc5a5 100644 --- a/src/APIexamples/user4.json +++ b/src/APIexamples/user4.json @@ -1,5 +1,5 @@ { "name":"4", "deviceId":"4", - "location":"9021014014225000" + "stoppointgid":"9021014014225000" } \ No newline at end of file diff --git a/src/components/DisruptionButton.js b/src/components/DisruptionButton.js index d221792..63bdfcf 100644 --- a/src/components/DisruptionButton.js +++ b/src/components/DisruptionButton.js @@ -11,23 +11,21 @@ import disruptIcon from '../img/flash.svg'; class DisruptionButton extends Button { state = { jsonLocation: this.props.path, - user: globData.user, disruption: "" } genDisrupt = () => { - console.log(globData.disruption) + this.state.disruption = "" for (let stopPoint of ex1.affectedStopPoints) { - if(stopPoint.gid === this.state.user.stoppointgid){ + if(stopPoint.gid === globData.user.stoppointgid){ this.state.disruption = ex1 } } - + + console.log(this.state.disruption) globData.disruption = this.state.disruption - console.log(globData.disruption) - addNotification({ title: "Warning", subtitle: "This is a subtitle", diff --git a/src/components/NavigationDrawer.js b/src/components/NavigationDrawer.js index 5225cdc..b3cfb5e 100644 --- a/src/components/NavigationDrawer.js +++ b/src/components/NavigationDrawer.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import globalData from '../GlobalData.js'; import DisruptionButton from "./DisruptionButton.js"; +import SelectUserButton from "./SelectUserButton.js" import Popup from './Popup.js'; import Button from './Button.js'; @@ -63,6 +64,10 @@ class NavigationDrawer extends Component { example@gmail.com
diff --git a/src/components/SelectUserButton.js b/src/components/SelectUserButton.js new file mode 100644 index 0000000..213c03c --- /dev/null +++ b/src/components/SelectUserButton.js @@ -0,0 +1,36 @@ + +import globData from '../GlobalData.js'; + +import user1 from '../APIexamples/user1.json' +import user2 from '../APIexamples/user2.json' +import user3 from '../APIexamples/user3.json' +import user4 from '../APIexamples/user4.json' + +import Button from './Button.js'; +import disruptIcon from '../img/flash.svg'; + +class SelectUserButton extends Button { + selectUser = () => { + if(this.props.path === "user1"){ + globData.user = user1 + }else if (this.props.path === "user2"){ + globData.user = user2 + }else if (this.props.path === "user3"){ + globData.user = user3 + }else if (this.props.path === "user4"){ + globData.user = user4 + } + } + + render() { + return ( + + ); + } +} + + +export default SelectUserButton;