Skip to content

Commit

Permalink
Merge pull request #378 from JasonMHasperhoven/order-history-columns
Browse files Browse the repository at this point in the history
(improvement) Reorder grid columns and add formatting to inactive, price average
  • Loading branch information
robertkowalski authored May 4, 2021
2 parents 1a1de47 + 35ecc11 commit 54f4399
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 84 deletions.
90 changes: 25 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"resolve": "^1.10.0",
"sanitize-html": "^1.26.0",
"thread-loader": "^2.1.2",
"ufx-ui": "git+https://github.com/bitfinexcom/ufx-ui.git#v0.2.2",
"ufx-ui": "git+https://github.com/bitfinexcom/ufx-ui.git#v0.2.6",
"universal-analytics": "^0.4.20",
"uuid": "^8.3.2",
"workbox-webpack-plugin": "^5.0.0",
Expand Down
44 changes: 26 additions & 18 deletions src/components/OrderHistory/OrderHistory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react'
import _get from 'lodash/get'
import { OrderHistory as UfxOrderHistory, ORDER_HISTORY_COLUMNS } from 'ufx-ui'
import {
OrderHistory as UfxOrderHistory, ORDER_HISTORY_KEYS, PrettyValue, FullDate,
} from 'ufx-ui'
import { useSelector } from 'react-redux'
import Panel from '../../ui/Panel'
import { symbolToLabel, getPriceFromStatus, getFormatedStatus } from './OrderHistory.helpers'
Expand All @@ -19,7 +21,7 @@ const {
PRICE_AVERAGE,
PLACED,
STATUS,
} = ORDER_HISTORY_COLUMNS
} = ORDER_HISTORY_KEYS

export const ROW_MAPPING = {
[ID]: {
Expand All @@ -34,55 +36,61 @@ export const ROW_MAPPING = {
[ORIGINAL_AMOUNT]: {
hidden: true,
},
[PLACED]: {
hidden: true,
},
[ICON]: {
index: 0,
truncate: true,
},
[PRICE]: {
[PAIR]: {
index: 1,
truncate: true,
format: (value, _, data) => {
return symbolToLabel(_get(data, 'symbol'))
},
},
[AMOUNT]: {
index: 2,
truncate: true,
format: (value, _, data) => {
return _get(data, 'originalAmount')
},
// eslint-disable-next-line react/prop-types
// eslint-disable-next-line react/prop-types, react/display-name
renderer: ({ formattedValue }) => (formattedValue < 0
? <span className='hfui-red'>{formattedValue}</span>
: <span className='hfui-green'>{formattedValue}</span>
),
},
[TYPE]: {
[PRICE]: {
index: 3,
truncate: true,
},
[STATUS]: {
[PRICE_AVERAGE]: {
index: 4,
truncate: true,
format: (value, _, data) => {
return getFormatedStatus(_get(data, 'status'))
// eslint-disable-next-line react/display-name
format: (_value, _, data) => {
const value = getPriceFromStatus(_get(data, 'status'))
return <PrettyValue value={value} sigFig={5} fadeTrailingZeros />
},
},
[PRICE_AVERAGE]: {
[TYPE]: {
index: 5,
truncate: true,
format: (value, _, data) => {
return getPriceFromStatus(_get(data, 'status'))
},
cellStyle: { width: '20%' },
},
[PAIR]: {
[STATUS]: {
index: 6,
truncate: true,
format: (value, _, data) => {
return symbolToLabel(_get(data, 'symbol'))
return getFormatedStatus(_get(data, 'status'))
},
},
[PLACED]: {
index: 7,
// eslint-disable-next-line react/display-name
format: (value, _, data) => {
return <FullDate ts={_get(data, 'created')} />
},
},

}

export default function OrderHistory(props) {
Expand Down
6 changes: 6 additions & 0 deletions src/components/OrderHistory/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
font-size: 13px;
}
}

.ufx-responsive,
.ufx-order-history,
.ufx-table-wrapper {
height: 100%;
}

0 comments on commit 54f4399

Please sign in to comment.