import addNotification from "react-push-notification"; import globData from '../GlobalData.js'; import ex1 from '../APIexamples/disruption1.json' import ex2 from '../APIexamples/disruption2.json' import Button from './Button.js'; import disruptIcon from '../img/flash.svg'; import globalData from '../GlobalData.js' class DisruptionButton extends Button { state = { jsonLocation: this.props.path, disruption: "" } updatePage = () => { globalData.currentPage.forceUpdate(); } genDisrupt = () => { this.state.disruption = undefined if(this.state.jsonLocation === "ex1"){ for (let stopPoint of ex1.affectedStopPoints) { if(stopPoint.gid === globData.user.stoppointgid){ this.state.disruption = ex1; globData.stop.departures[0].newTime = ex1.time; globData.stop.departures[0].trafficInfo = ex1.title; } } } else if (this.state.jsonLocation === "ex2"){ for (let stopPoint of ex2.affectedStopPoints) { if(stopPoint.gid === globData.user.stoppointgid){ this.state.disruption = ex2; globData.stop.departures[0].newTime = ex2.time; globData.stop.departures[0].trafficInfo = ex2.title; } } } globData.disruption = this.state.disruption addNotification({ title: "Warning", subtitle: "This is a subtitle", message: "This is a very long message", theme: "blue", native: true, // when using native, your OS will handle theming. }); } render() { return ( ); } } export default DisruptionButton;