61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
|
|
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 locationuser1 from '../APIexamples/locationuser1.json'
|
|
import locationuser2 from '../APIexamples/locationuser2.json'
|
|
import locationuser3 from '../APIexamples/locationuser3.json'
|
|
import locationuser4 from '../APIexamples/locationuser4.json'
|
|
|
|
import departureuser1 from '../APIexamples/departureuser1.json'
|
|
import departureuser2 from '../APIexamples/departureuser2.json'
|
|
import departureuser3 from '../APIexamples/departureuser3.json'
|
|
import departureuser4 from '../APIexamples/departureuser4.json'
|
|
|
|
import Button from './Button.js';
|
|
import disruptIcon from '../img/flash.svg';
|
|
import globalData from '../GlobalData.js';
|
|
|
|
class SelectUserButton extends Button {
|
|
selectUser = () => {
|
|
if(this.props.path === "user1"){
|
|
globData.user = user1
|
|
globData.stop = locationuser1.LocationList.StopLocation[0]
|
|
globData.stop.departures = [departureuser1.DepartureBoard.Departure]
|
|
}else if (this.props.path === "user2"){
|
|
globData.user = user2
|
|
globData.stop = locationuser2.LocationList.StopLocation[0]
|
|
globData.stop.departures = [departureuser2.DepartureBoard.Departure]
|
|
}else if (this.props.path === "user3"){
|
|
globData.user = user3
|
|
globData.stop = locationuser3.LocationList.StopLocation[0]
|
|
globData.stop.departures = [departureuser3.DepartureBoard.Departure]
|
|
}else if (this.props.path === "user4"){
|
|
globData.user = user4
|
|
globData.stop = locationuser4.LocationList.StopLocation[0]
|
|
globData.stop.departures = [departureuser4.DepartureBoard.Departure]
|
|
}
|
|
console.log(globData.stop)
|
|
}
|
|
|
|
updatePage = () => {
|
|
globalData.currentPage.forceUpdate();
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<Button onClick={[this.selectUser, this.updatePage]} className="disruptBtn">
|
|
<img src={disruptIcon} alt="" />
|
|
{this.props.username}
|
|
</Button>
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
export default SelectUserButton;
|