diff --git a/src/status/PeerBandwidthTable.js b/src/status/PeerBandwidthTable.js index ff88d4558..0a816d7c0 100644 --- a/src/status/PeerBandwidthTable.js +++ b/src/status/PeerBandwidthTable.js @@ -24,9 +24,7 @@ export class PeerBandwidthTable extends Component { getSorter ({ field, direction }) { return (a, b) => { - if (a.bw[field].gt(b.bw[field])) return direction - if (a.bw[field].lt(b.bw[field])) return -direction - return 0 + return a.bw[field] - b.bw[field] } } diff --git a/src/status/PeerBandwidthTable.stories.js b/src/status/PeerBandwidthTable.stories.js new file mode 100644 index 000000000..f1e493a34 --- /dev/null +++ b/src/status/PeerBandwidthTable.stories.js @@ -0,0 +1,70 @@ +import React from 'react' +import PeerBandwidthTableComponent from './PeerBandwidthTable.js' +import { Provider } from 'redux-bundler-react' +import { composeBundlesRaw } from 'redux-bundler' + +const defaultState = { + peerBandwidthPeers: [ + { + id: 'peer1', + bw: { + rateIn: 1000, + rateOut: 500, + totalIn: 10000, + totalOut: 5000 + } + }, + { + id: 'peer2', + bw: { + rateIn: 10, + rateOut: 5, + totalIn: 10000, + totalOut: 5000 + } + } + ], + peerLocations: { + peer1: { + country_name: 'United States', + country_code: 'US' + }, + peer2: { + country_name: 'Canada', + country_code: 'CA' + } + } +} + +const getStore = composeBundlesRaw({ + name: 'peerBandwidth', + selectPeerBandwidthPeers: state => state.peerBandwidth.peerBandwidthPeers, + selectPeerLocations: state => state.peerBandwidth.peerLocations, + reducer: (state, { type, payload }) => state ?? defaultState +}) +const store = getStore({ peerBandwidth: defaultState }) + +/** + * @type {import('@storybook/react').Meta} + */ +export default { + title: 'Status/PeerBandwidthTable', + component: PeerBandwidthTableComponent, + decorators: [ + (Story) => ( + + + + ) + ] +} + +/** + * @type {import('@storybook/react').StoryObj} + */ +export const PeerBandwidthTable = { + args: { + peerBandwidthPeers: defaultState.peerBandwidthPeers, + peerLocations: defaultState.peerLocations + } +}