DRY sorting
This commit is contained in:
parent
b02be2e3e3
commit
54e17ea494
|
|
@ -3,6 +3,7 @@ import {Match} from './Match';
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {getGroup} from '../redux/tournamentApi';
|
import {getGroup} from '../redux/tournamentApi';
|
||||||
import {notify} from 'react-notify-toast';
|
import {notify} from 'react-notify-toast';
|
||||||
|
import {sortMatchesByPositionAscending} from '../utils/sorting';
|
||||||
|
|
||||||
export default class GroupStage extends Component {
|
export default class GroupStage extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
@ -35,17 +36,6 @@ function ShowMatchesToggleButton(props) {
|
||||||
</Button>);
|
</Button>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortMatchesByPositionAscending() {
|
|
||||||
return (a, b) => {
|
|
||||||
if (a.position < b.position) {
|
|
||||||
return -1;
|
|
||||||
} else if (a.position > b.position) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Group extends Component {
|
export class Group extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {getRequest} from './backendApi';
|
import {getRequest} from './backendApi';
|
||||||
import {getState} from '../api';
|
import {getState} from '../api';
|
||||||
|
import {sortMatchesByPositionAscending} from '../utils/sorting';
|
||||||
|
|
||||||
export function getTournament(code, successCallback, errorCallback) {
|
export function getTournament(code, successCallback, errorCallback) {
|
||||||
getRequest(getState(), '/tournaments/' + code)
|
getRequest(getState(), '/tournaments/' + code)
|
||||||
|
|
@ -71,18 +72,6 @@ function convertTournament(apiTournament) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertPlayoffStage(apiStage) {
|
function convertPlayoffStage(apiStage) {
|
||||||
function sortMatchesByPositionAscending() {
|
|
||||||
return (a, b) => {
|
|
||||||
if (a.position < b.position) {
|
|
||||||
return -1;
|
|
||||||
} else if (a.position > b.position) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: apiStage.id,
|
id: apiStage.id,
|
||||||
level: apiStage.level,
|
level: apiStage.level,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
export function sortMatchesByPositionAscending() {
|
||||||
|
return (a, b) => {
|
||||||
|
if (a.position < b.position) {
|
||||||
|
return -1;
|
||||||
|
} else if (a.position > b.position) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue