Skip to content

Commit

Permalink
chore: use kyberscore/tag p2
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Oct 3, 2023
1 parent f93f005 commit 8c10ddd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/pages/TrueSightV2/components/SearchWithDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { formatTokenPrice } from '../utils'
import WatchlistButton from './WatchlistButton'

const formatTokenType = (token: ITokenList): ITokenSearchResult => {
const kyberScore3D = token.kyberScore3D?.[token.kyberScore3D.length - 1]
return {
assetId: token.assetId,
name: token.name,
Expand All @@ -34,8 +33,8 @@ const formatTokenType = (token: ITokenList): ITokenSearchResult => {
price: token.price,
priceChange24h: token.priceChange24H,
kyberScore: {
score: kyberScore3D?.kyberScore || 0,
label: kyberScore3D?.tag || '',
score: token.kyberScore || 0,
label: token.kyberScoreTag || '',
},
}
}
Expand Down
15 changes: 4 additions & 11 deletions src/pages/TrueSightV2/components/SmallKyberScoreMeter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ const GaugeValue = styled.div`
justify-content: center;
bottom: 6px;
`
function SmallKyberScoreMeter({
data,
disabledTooltip,
token,
}: {
data?: IKyberScoreChart
disabledTooltip?: boolean
token: ITokenList
}) {
function SmallKyberScoreMeter({ disabledTooltip, token }: { disabledTooltip?: boolean; token: ITokenList }) {
const data: IKyberScoreChart | undefined = token?.kyberScore3D?.[token.kyberScore3D.length - 1]
const value = token?.kyberScore
const theme = useTheme()
const emptyColor = theme.darkMode ? theme.subText + '30' : theme.border + '60'
Expand Down Expand Up @@ -69,11 +62,11 @@ function SmallKyberScoreMeter({
<Text>
KyberScore:{' '}
<span style={{ color: calculateValueToColor(value || 0, theme) }}>
{value || '--'} ({data.tag || t`Not Applicable`})
{value || '--'} ({token.kyberScoreTag || t`Not Applicable`})
</span>
</Text>
<Text>
Token Price: <span style={{ color: theme.text }}>{formatTokenPrice(data.price || 0)}</span>
Token Price: <span style={{ color: theme.text }}>{formatTokenPrice(token.price || 0)}</span>
</Text>
</Column>
) : (
Expand Down
12 changes: 4 additions & 8 deletions src/pages/TrueSightV2/components/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { NETWORK_IMAGE_URL, NETWORK_TO_CHAINID, Z_INDEX_KYBER_AI } from 'pages/T
import useKyberAIAssetOverview from 'pages/TrueSightV2/hooks/useKyberAIAssetOverview'
import { useFundingRateQuery, useHolderListQuery, useLiveDexTradesQuery } from 'pages/TrueSightV2/hooks/useKyberAIData'
import { TechnicalAnalysisContext } from 'pages/TrueSightV2/pages/TechnicalAnalysis'
import { IHolderList, IKyberScoreChart, ILiveTrade, ITokenList, KyberAITimeframe } from 'pages/TrueSightV2/types'
import { IHolderList, ILiveTrade, ITokenList, KyberAITimeframe } from 'pages/TrueSightV2/types'
import {
calculateValueToColor,
formatLocaleStringNum,
Expand Down Expand Up @@ -580,7 +580,6 @@ const WidgetTokenRow = ({
const theme = useTheme()
const navigate = useNavigate()

const latestKyberScore: IKyberScoreChart | undefined = token?.kyberScore3D?.[token.kyberScore3D.length - 1]
const hasMutipleChain = token?.addresses?.length > 1
const [showSwapMenu, setShowSwapMenu] = useState(false)

Expand Down Expand Up @@ -689,9 +688,9 @@ const WidgetTokenRow = ({
</td>
<td>
<Column style={{ alignItems: 'center', width: '110px' }}>
<SmallKyberScoreMeter data={latestKyberScore} token={token} disabledTooltip={token.symbol === 'KNC'} />
<SmallKyberScoreMeter token={token} disabledTooltip={token.symbol === 'KNC'} />
<Text color={calculateValueToColor(token.kyberScore || 0, theme)} fontSize="14px" fontWeight={500}>
{latestKyberScore?.tag || t`Not Applicable`}
{token?.kyberScoreTag || t`Not Applicable`}
</Text>
</Column>
</td>
Expand Down Expand Up @@ -1105,7 +1104,6 @@ export const TokenListInShareModalTable = ({
</thead>
<tbody>
{data.map((token, index) => {
const latestKyberscore = token.kyberScore3D ? token.kyberScore3D[token.kyberScore3D.length - 1] : null
return (
<tr key={token.symbol + index} style={{ height: '50px' }}>
<td style={{ padding: '16px 0px 16px 10px', color: theme.subText }}>{index + 1 + startIndex}</td>
Expand Down Expand Up @@ -1147,9 +1145,7 @@ export const TokenListInShareModalTable = ({
</td>
{!mobileMode && (
<td style={{ textAlign: 'right' }}>
<Text color={calculateValueToColor(latestKyberscore?.kyberScore || 0, theme)}>
{latestKyberscore?.kyberScore}
</Text>
<Text color={calculateValueToColor(token?.kyberScore || 0, theme)}>{token?.kyberScore}</Text>
</td>
)}
</tr>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ const TokenRow = React.memo(function TokenRow({
})
}

const latestKyberScore: IKyberScoreChart | undefined = token?.kyberScore3D?.[token.kyberScore3D.length - 1]
return (
<tr key={token.assetId} ref={rowRef} onClick={handleRowClick} style={{ position: 'relative' }}>
<td>
Expand Down Expand Up @@ -557,9 +556,9 @@ const TokenRow = React.memo(function TokenRow({
</td>
<td>
<Column style={{ alignItems: 'center', width: '110px' }}>
<SmallKyberScoreMeter data={latestKyberScore} token={token} />
<SmallKyberScoreMeter token={token} />
<Text color={calculateValueToColor(token.kyberScore || 0, theme)} fontSize="14px" fontWeight={500}>
{latestKyberScore?.tag || 'Not Applicable'}
{token?.kyberScoreTag || 'Not Applicable'}
</Text>
</Column>
</td>
Expand Down

0 comments on commit 8c10ddd

Please sign in to comment.