...
 
Commits (2)
......@@ -4,14 +4,21 @@ import style from './style';
class LeaderboardList extends Component {
sortLeaderboard = (leaderboard) => {
leaderboard.sort((a, b) => a.score < b.score);
}
render() {
let leaderboardNodes = this.props.data.map(leaderboard => {
const leaderboardData = this.props.data.slice();
this.sortLeaderboard(leaderboardData);
let leaderboardNodes = leaderboardData.map(leaderboard => {
return (
<Leaderboard name={ leaderboard.name } key={ leaderboard['_id'] }>
{ leaderboard.score}
</Leaderboard>
)
})
});
this.sortLeaderboard(leaderboardNodes);
return (
<div style={ style.leaderboardList }>
{ leaderboardNodes }
......
......@@ -3,14 +3,18 @@ import React from 'react';
import { StoreRow } from './store-row';
export class Stores extends React.Component {
sortStores = (stores) => {
return Array.from(Object.keys(stores)).sort((a, b) => a > b)
}
render(props) {
const stores = this.props.stores;
const orderedStores = this.sortStores(stores);
return <div className="storeContainer">
<h3>Stores</h3>
<div className="stores">
<div className="resources">
{ Array.from(Object.keys(stores)).map( storeItemName =>
{ orderedStores.map( storeItemName =>
<StoreRow key={storeItemName} storeItemName={storeItemName} storeItemProps={stores[storeItemName]} />
)}
</div>
......
......@@ -8,11 +8,7 @@ import LeaderboardBox from './leaderboard-box';
export class Village extends React.Component {
sortBuildings = (buildings) => {
buildings.sort((a, b) => a.priority > b.priority)
}
sortStores = (stores) => {
Array.from(Object.keys(stores)).sort((a, b) => a.name > b.name)
buildings.sort((a, b) => a.priority > b.priority);
}
constructor(props) {
......@@ -106,7 +102,7 @@ export class Village extends React.Component {
);
this.updateTheVillageStore(villageStore);
building.materialsInUse = true;
this.updateLog(building.materials.map(material => material + " -1" ))
this.updateLog(building.materials.map(material => material + " -1 " ))
};
addProduct = (buildingName, goods) => {
......@@ -426,7 +422,6 @@ export class Village extends React.Component {
render = () => {
const villageStore = this.props.villageStore;
this.sortStores(villageStore);
const buildings = this.props.buildings.slice();
this.sortBuildings(buildings);
const villagers = this.props.villagers.slice();
......