Update page when changing user

This commit is contained in:
André Wahlberg 2020-12-10 10:43:43 +01:00
parent 211257ac67
commit 8e21856eb2
5 changed files with 26 additions and 4 deletions

View File

@ -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>

View File

@ -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" />

View File

@ -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" />

View File

@ -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>
</>
);

View File

@ -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" />