Skip to content

Commit

Permalink
Merge pull request #819 from alexstotsky/refactor-fund-col-getters
Browse files Browse the repository at this point in the history
(improvements) Funding sections
  • Loading branch information
ezewer authored Jun 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 9987511 + 5541591 commit 4a18103
Showing 4 changed files with 68 additions and 300 deletions.
134 changes: 25 additions & 109 deletions src/components/FundingCreditHistory/FundingCreditHistory.columns.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React from 'react'
import { Cell } from '@blueprintjs/table'

import { getSideMsg, getSideColor } from 'state/utils'
import { formatAmount, formatColor, fixedFloat } from 'ui/utils'
import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns'
import { getCell, getCellState, getColumnWidth } from 'utils/columns'

export const getColumns = ({
t,
@@ -20,15 +17,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('id', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { id } = filteredData[rowIndex]
return (
<Cell tooltip={getTooltipContent(id, t)}>
{id}
</Cell>
)
return getCell(id, t)
},
copyText: rowIndex => filteredData[rowIndex].id,
},
@@ -38,15 +29,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('symbol', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { symbol } = filteredData[rowIndex]
return (
<Cell tooltip={getTooltipContent(symbol, t)}>
{symbol}
</Cell>
)
return getCell(symbol, t)
},
copyText: rowIndex => filteredData[rowIndex].symbol,
},
@@ -56,16 +41,10 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('side', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { side } = filteredData[rowIndex]
const formattedSide = t(`fcredit.side.${getSideMsg(side)}`)
return (
<Cell tooltip={getTooltipContent(formattedSide, t)}>
{formatColor(formattedSide, getSideColor(side))}
</Cell>
)
return getCell(formatColor(formattedSide, getSideColor(side)), t, formattedSide)
},
copyText: rowIndex => t(`fcredit.side.${getSideMsg(filteredData[rowIndex].side)}`),
},
@@ -74,18 +53,9 @@ export const getColumns = ({
name: 'column.amount',
width: getColumnWidth('amount', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { amount } = filteredData[rowIndex]
return (
<Cell
className='bitfinex-text-align-right'
tooltip={getTooltipContent(fixedFloat(amount), t)}
>
{formatAmount(amount)}
</Cell>
)
return getCell(formatAmount(amount), t, fixedFloat(amount))
},
isNumericValue: true,
copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount),
@@ -96,15 +66,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('status', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { status } = filteredData[rowIndex]
return (
<Cell tooltip={getTooltipContent(status, t)}>
{status}
</Cell>
)
return getCell(status, t)
},
copyText: rowIndex => filteredData[rowIndex].status,
},
@@ -114,15 +78,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('type', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { type } = filteredData[rowIndex]
return (
<Cell tooltip={getTooltipContent(type, t)}>
{type}
</Cell>
)
return getCell(type, t)
},
copyText: rowIndex => filteredData[rowIndex].type,
},
@@ -131,18 +89,9 @@ export const getColumns = ({
name: 'column.rateperc',
width: getColumnWidth('rate', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { rate } = filteredData[rowIndex]
return (
<Cell
className='bitfinex-text-align-right'
tooltip={getTooltipContent(rate, t)}
>
{fixedFloat(rate)}
</Cell>
)
return getCell(fixedFloat(rate), t)
},
isNumericValue: true,
copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate),
@@ -153,18 +102,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('period', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const period = `${filteredData[rowIndex].period} ${t('column.days')}`
return (
<Cell
className='bitfinex-text-align-right'
tooltip={getTooltipContent(period, t)}
>
{period}
</Cell>
)
return getCell(period, t)
},
copyText: (rowIndex) => {
const days = t('column.days')
@@ -177,15 +117,9 @@ export const getColumns = ({
nameStr: `${t('column.opened')} (${timeOffset})`,
width: getColumnWidth('mtsOpening', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const timestamp = getFullTime(filteredData[rowIndex].mtsOpening)
return (
<Cell tooltip={getTooltipContent(timestamp, t)}>
{timestamp}
</Cell>
)
return getCell(timestamp, t)
},
copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsOpening),
},
@@ -195,15 +129,9 @@ export const getColumns = ({
nameStr: `${t('column.lastpayout')} (${timeOffset})`,
width: getColumnWidth('mtsLastPayout', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const timestamp = getFullTime(filteredData[rowIndex].mtsLastPayout)
return (
<Cell tooltip={getTooltipContent(timestamp, t)}>
{timestamp}
</Cell>
)
return getCell(timestamp, t)
},
copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsLastPayout),
},
@@ -213,15 +141,9 @@ export const getColumns = ({
className: 'align-left',
width: getColumnWidth('positionPair', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { positionPair } = filteredData[rowIndex]
return (
<Cell tooltip={getTooltipContent(positionPair, t)}>
{positionPair}
</Cell>
)
return getCell(positionPair, t)
},
copyText: rowIndex => filteredData[rowIndex].positionPair,
},
@@ -231,15 +153,9 @@ export const getColumns = ({
nameStr: `${t('column.date')} (${timeOffset})`,
width: getColumnWidth('mtsUpdate', columnsWidth),
renderer: (rowIndex) => {
if (isLoading || isNoData) {
return getCellState(isLoading, isNoData)
}
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate)
return (
<Cell tooltip={getTooltipContent(timestamp, t)}>
{timestamp}
</Cell>
)
return getCell(timestamp, t)
},
copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate),
},
Loading

0 comments on commit 4a18103

Please sign in to comment.