Update page when changing user
This commit is contained in:
parent
211257ac67
commit
8e21856eb2
@ -8,6 +8,7 @@ import user4 from '../APIexamples/user4.json'
|
||||
|
||||
import Button from './Button.js';
|
||||
import disruptIcon from '../img/flash.svg';
|
||||
import globalData from '../GlobalData.js';
|
||||
|
||||
class SelectUserButton extends Button {
|
||||
selectUser = () => {
|
||||
@ -20,11 +21,15 @@ class SelectUserButton extends Button {
|
||||
}else if (this.props.path === "user4"){
|
||||
globData.user = user4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updatePage = () => {
|
||||
globalData.currentPage.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Button onClick={[this.selectUser]} className="disruptBtn">
|
||||
<Button onClick={[this.selectUser, this.updatePage]} className="disruptBtn">
|
||||
<img src={disruptIcon} alt="" />
|
||||
<span>{this.props.username}</span>
|
||||
</Button>
|
||||
|
@ -2,9 +2,12 @@ import React, { Component } from 'react';
|
||||
|
||||
import Header from '../Header.js';
|
||||
import MainArea from '../MainArea.js';
|
||||
import globalData from '../../GlobalData.js';
|
||||
|
||||
class Tickets extends Component {
|
||||
render() {
|
||||
globalData.currentPage = this;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header title="Biljetter" />
|
||||
|
@ -9,8 +9,12 @@ import clockIcon from '../../img/clock.svg';
|
||||
import calendarIcon from '../../img/calendar.svg';
|
||||
import recurringIcon from '../../img/redo.svg';
|
||||
|
||||
import globalData from '../../GlobalData.js';
|
||||
|
||||
class TicketsBuy extends Component {
|
||||
render() {
|
||||
globalData.currentPage = this;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header title="Köp biljett" />
|
||||
|
@ -10,15 +10,21 @@ import globalData from '../../GlobalData.js';
|
||||
|
||||
|
||||
class TrafficInfo extends Component {
|
||||
state = {
|
||||
stop: globalData.stop
|
||||
};
|
||||
|
||||
render() {
|
||||
globalData.currentPage = this;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header title="Trafikinfo" />
|
||||
<TopMenu>
|
||||
<StopTitle stop={globalData.stop} />
|
||||
<StopTitle stop={this.state.stop} />
|
||||
</TopMenu>
|
||||
<MainArea>
|
||||
<TrafficList departures={globalData.stop.departures} />
|
||||
<TrafficList departures={this.state.stop.departures} />
|
||||
</MainArea>
|
||||
</>
|
||||
);
|
||||
|
@ -7,8 +7,12 @@ import TripSelector from '../TripSelector.js';
|
||||
|
||||
import '../css/TripSelector.css';
|
||||
|
||||
import globalData from '../../GlobalData.js';
|
||||
|
||||
class Travel extends Component {
|
||||
render() {
|
||||
globalData.currentPage = this;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header title="Reseplanering" />
|
||||
|
Loading…
Reference in New Issue
Block a user