From 2d2ec96533e81e4db083f83e794e9ed1b278c0fe Mon Sep 17 00:00:00 2001 From: williameriksson126 Date: Tue, 8 Dec 2020 12:10:08 +0100 Subject: [PATCH] Add: Multiple disruptions --- src/components/DisruptionButton.js | 18 +++++++++++++----- src/components/NavigationDrawer.js | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/DisruptionButton.js b/src/components/DisruptionButton.js index 63bdfcf..63f0171 100644 --- a/src/components/DisruptionButton.js +++ b/src/components/DisruptionButton.js @@ -3,7 +3,7 @@ import addNotification from "react-push-notification"; import globData from '../GlobalData.js'; import ex1 from '../APIexamples/disruption1.json' -import ex2 from '../APIexamples/disruption1.json' +import ex2 from '../APIexamples/disruption2.json' import Button from './Button.js'; import disruptIcon from '../img/flash.svg'; @@ -17,12 +17,20 @@ class DisruptionButton extends Button { genDisrupt = () => { this.state.disruption = "" - for (let stopPoint of ex1.affectedStopPoints) { - if(stopPoint.gid === globData.user.stoppointgid){ - this.state.disruption = ex1 + if(this.state.jsonLocation === "ex1"){ + for (let stopPoint of ex1.affectedStopPoints) { + if(stopPoint.gid === globData.user.stoppointgid){ + this.state.disruption = ex1 + } + } + } else if (this.state.jsonLocation === "ex2"){ + for (let stopPoint of ex2.affectedStopPoints) { + if(stopPoint.gid === globData.user.stoppointgid){ + this.state.disruption = ex2 + } } } - + console.log(this.state.disruption) globData.disruption = this.state.disruption diff --git a/src/components/NavigationDrawer.js b/src/components/NavigationDrawer.js index b3cfb5e..9bc3f5c 100644 --- a/src/components/NavigationDrawer.js +++ b/src/components/NavigationDrawer.js @@ -69,6 +69,7 @@ class NavigationDrawer extends Component { +
Projektgrupp 3 - Utmaning 7