Skip to content

Commit

Permalink
Add requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
koredefashokun committed Jul 11, 2023
1 parent 3a88f5d commit 70c9bb4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
10 changes: 6 additions & 4 deletions packages/app/src/sections/dashboard/FuturesHistoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ const FuturesHistoryTable: FC = () => {
header: () => <div>{t('dashboard.history.futures-history-table.pnl')}</div>,
accessorKey: 'netPnl',
cell: (cellProps) => {
const value = cellProps.getValue()

return conditionalRender(
cellProps.getValue(),
cellProps.getValue().eq(wei(0)) ? (
value,
value.eq(wei(0)) ? (
<PNL normal>--</PNL>
) : (
<PNL negative={cellProps.getValue().lt(wei(0))}>
{formatDollars(cellProps.getValue(), { maxDecimals: 2 })}
<PNL negative={value.lt(wei(0))}>
{formatDollars(value, { maxDecimals: 2 })}
</PNL>
)
)
Expand Down
14 changes: 1 addition & 13 deletions packages/app/src/sections/dashboard/FuturesMarketsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
formatDollars,
} from '@kwenta/sdk/utils'
import { wei } from '@synthetixio/wei'
import { Row } from '@tanstack/react-table'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
Expand All @@ -29,23 +28,12 @@ import {
import { useAppSelector } from 'state/hooks'
import { selectPreviousDayPrices, selectOffchainPricesInfo } from 'state/prices/selectors'
import { getSynthDescription } from 'utils/futures'
import { weiSortingFn } from 'utils/table'

type FuturesMarketsTableProps = {
search?: string
}

const weiSortingFn =
<T,>(key: keyof T) =>
(rowA: Row<T>, rowB: Row<T>) => {
const valA = rowA.original[key]
const valB = rowB.original[key]

const rowOne = valA ? wei(valA) : wei(0)
const rowTwo = valB ? wei(valB) : wei(0)

return rowOne.toNumber() > rowTwo.toNumber() ? 1 : -1
}

const sortBy = [{ id: 'dailyVolume', desc: true }]

const FuturesMarketsTable: React.FC<FuturesMarketsTableProps> = ({ search }) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/app/src/sections/leaderboard/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ const Leaderboard: FC<LeaderboardProps> = ({ compact, mobile }) => {
const leaderboardLoading = useAppSelector(selectLeaderboardLoading)
const leaderboardData = useAppSelector(selectLeaderboard)

// TODO: Separate search from the general list, to improve performance.
// This currently refetches the whole list when we search.

useFetchAction(() => fetchLeaderboard(searchTerm), { dependencies: [searchTerm] })

const pinRow = useMemo(() => {
Expand Down
14 changes: 14 additions & 0 deletions packages/app/src/utils/table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { wei } from '@synthetixio/wei'
import { Row } from '@tanstack/react-table'

export const weiSortingFn =
<T>(key: keyof T) =>
(rowA: Row<T>, rowB: Row<T>) => {
const valA = rowA.original[key]
const valB = rowB.original[key]

const rowOne = valA ? wei(valA) : wei(0)
const rowTwo = valB ? wei(valB) : wei(0)

return rowOne.toNumber() > rowTwo.toNumber() ? 1 : -1
}
12 changes: 6 additions & 6 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"useUnknownInCatchVariables": false,
},
"watchOptions": {
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true,
"excludeDirectories": ["**/node_modules", "dist"],
},
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true,
"excludeDirectories": ["**/node_modules", "dist"],
},
"include": ["src", "src/**/**.json"],
"exclude": ["node_modules"],
}

0 comments on commit 70c9bb4

Please sign in to comment.