Minor modifications to Example API components and base classes
This commit is contained in:
parent
c36d6afea7
commit
31263e919e
@ -21,7 +21,8 @@ class App extends Component {
|
|||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<StationDisruption/>
|
<NearbyStation/>
|
||||||
|
<Disruption/>
|
||||||
<Route path="/" exact component={TicketsBuy} />
|
<Route path="/" exact component={TicketsBuy} />
|
||||||
<Route path="/tickets" exact component={Tickets} />
|
<Route path="/tickets" exact component={Tickets} />
|
||||||
<Route path="/ticketsBuy" exact component={TicketsBuy} />
|
<Route path="/ticketsBuy" exact component={TicketsBuy} />
|
||||||
|
24
src/classes/Disruption.js
Normal file
24
src/classes/Disruption.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
Denna klass är en modell för störningar.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Disruption {
|
||||||
|
constructor(startTime, locations, departures) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.affectedLines = affectedLines;
|
||||||
|
this.departures = departures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Från västtrafiks api ett element i listan av hållplatser ser ut som följande
|
||||||
|
"id": "string",
|
||||||
|
"lon": "string",
|
||||||
|
"idx": "string",
|
||||||
|
"weight": "string",
|
||||||
|
"name": "string",
|
||||||
|
"track": "string",
|
||||||
|
"lat": "string"
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default Disruption;
|
@ -9,6 +9,7 @@ class User {
|
|||||||
constructor(deviceId, location) {
|
constructor(deviceId, location) {
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
this.stoppointgid = stoppointgid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import AccessToken from '../classes/AccessToken'
|
import AccessToken from '../classes/AccessToken';
|
||||||
|
import StopComponent from './StopComponent';
|
||||||
|
import Stop from '../classes/Stop';
|
||||||
|
|
||||||
class NearbyStation extends React.Component {
|
class NearbyStation extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
@ -58,18 +60,11 @@ class NearbyStation extends React.Component {
|
|||||||
{this.state.long}
|
{this.state.long}
|
||||||
</h1>
|
</h1>
|
||||||
{this.state.stops.map((item) =>
|
{this.state.stops.map((item) =>
|
||||||
<div>
|
<StopComponent stop={item} />
|
||||||
<h1>
|
|
||||||
{item.name},
|
|
||||||
{item.id},
|
|
||||||
{item.lat},
|
|
||||||
{item.lon},
|
|
||||||
{item.track}
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NearbyStation
|
export default NearbyStation
|
||||||
|
19
src/components/StopComponent.js
Normal file
19
src/components/StopComponent.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React, {Component} from 'react';
|
||||||
|
|
||||||
|
class StopComponent extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>
|
||||||
|
{this.props.stop.name},
|
||||||
|
{this.props.stop.id},
|
||||||
|
{this.props.stop.lat},
|
||||||
|
{this.props.stop.lon},
|
||||||
|
{this.props.stop.track}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO Add css
|
||||||
|
export default StopComponent
|
Loading…
Reference in New Issue
Block a user