sort cryp names
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
// eslint-disable-next-line
|
||||
const preact = require('preact');
|
||||
|
||||
const { stringSort } = require('./../utils');
|
||||
const nameSort = stringSort('name');
|
||||
|
||||
function CrypList({ cryps, activeItem, sendCombatPve, sendItemUse }) {
|
||||
if (!cryps) return <div>not ready</div>;
|
||||
const crypPanels = cryps.map(cryp => (
|
||||
const crypPanels = cryps.sort(nameSort).map(cryp => (
|
||||
|
||||
<div key={cryp.id}
|
||||
className="tile is-vertical box"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// eslint-disable-next-line
|
||||
const preact = require('preact');
|
||||
|
||||
function renderSpawnButton({ account, sendCrypSpawn }) {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
const key = require('keymaster');
|
||||
const { connect } = require('preact-redux');
|
||||
const actions = require('./actions');
|
||||
|
||||
console.log(key);
|
||||
|
||||
function setupKeys(store) {
|
||||
store.subscribe(function mapKeys() {
|
||||
const state = store.getState();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
const get = require('lodash/get');
|
||||
|
||||
const stringSort = (k, desc) => {
|
||||
if (desc) {
|
||||
return (a, b) => {
|
||||
if (!get(a, k)) return 1;
|
||||
if (!get(b, k)) return -1;
|
||||
return get(b, k).localeCompare(get(a, k));
|
||||
};
|
||||
}
|
||||
return (a, b) => {
|
||||
if (!get(a, k)) return 1;
|
||||
if (!get(b, k)) return -1;
|
||||
return get(a, k).localeCompare(get(b, k));
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
stringSort,
|
||||
}
|
||||
Reference in New Issue
Block a user