Skip to content

Commit

Permalink
Merge pull request #410 from balancer/feat/add-points-icon-pool-list
Browse files Browse the repository at this point in the history
feat: add points icon in pool list
  • Loading branch information
groninge01 authored Jan 15, 2025
2 parents b6d044c + 492dd11 commit da9eea3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/public/images/icons/pool-points.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/frontend-v3/public/images/icons/pool-points.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions packages/lib/modules/pool/PoolList/PoolListTable/PoolListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PaginatedTable } from '@repo/lib/shared/components/tables/PaginatedTabl
import { PoolListTableHeader } from './PoolListTableHeader'
import { PoolListTableRow } from './PoolListTableRow'
import { getPaginationProps } from '@repo/lib/shared/components/pagination/getPaginationProps'
import { PoolListItem } from '../../pool.types'
import { POOL_TAG_MAP, PoolListItem } from '../../pool.types'
import { Card, Skeleton } from '@chakra-ui/react'
import { useIsMounted } from '@repo/lib/shared/hooks/useIsMounted'
import { usePoolList } from '../PoolListProvider'
Expand Down Expand Up @@ -37,6 +37,10 @@ export function PoolListTable({ pools, count, loading }: Props) {

if (!isMounted) return <Skeleton height="500px" w="full" />

const needsMarginForPoints = pools.some(pool =>
pool.tags?.some(tag => tag && POOL_TAG_MAP.POINTS.includes(tag))
)

return (
<Card
alignItems="flex-start"
Expand All @@ -53,7 +57,14 @@ export function PoolListTable({ pools, count, loading }: Props) {
paginationProps={paginationProps}
renderTableHeader={() => <PoolListTableHeader {...rowProps} />}
renderTableRow={(item: PoolListItem, index) => {
return <PoolListTableRow keyValue={index} pool={item} {...rowProps} />
return (
<PoolListTableRow
keyValue={index}
needsMarginForPoints={needsMarginForPoints}
pool={item}
{...rowProps}
/>
)
}}
showPagination={showPagination}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Grid, GridItem, GridProps, HStack, Text } from '@chakra-ui/react'
import { Box, Grid, GridItem, GridProps, HStack, Text, Image } from '@chakra-ui/react'
import { PollListTableDetailsCell } from '@repo/lib/modules/pool/PoolList/PoolListTable/PollListTableDetailsCell'
import { TokenIcon } from '@repo/lib/modules/tokens/TokenIcon'
import FadeInOnView from '@repo/lib/shared/components/containers/FadeInOnView'
Expand All @@ -8,7 +8,7 @@ import { useCurrency } from '@repo/lib/shared/hooks/useCurrency'
import Link from 'next/link'
import { memo } from 'react'
import { usePoolMetadata } from '../../metadata/usePoolMetadata'
import { PoolListDisplayType, PoolListItem } from '../../pool.types'
import { POOL_TAG_MAP, PoolListDisplayType, PoolListItem } from '../../pool.types'
import { getPoolPath } from '../../pool.utils'
import { getUserTotalBalanceUsd } from '../../user-balance.helpers'
import { usePoolList } from '../PoolListProvider'
Expand All @@ -18,6 +18,7 @@ import { getUserReferenceTokens } from '../../pool-tokens.utils'
interface Props extends GridProps {
pool: PoolListItem
keyValue: number
needsMarginForPoints?: boolean
}

const MemoizedMainAprTooltip = memo(MainAprTooltip)
Expand Down Expand Up @@ -47,15 +48,16 @@ function PoolName({ pool }: { pool: PoolListItem }) {
)
}

export function PoolListTableRow({ pool, keyValue, ...rest }: Props) {
export function PoolListTableRow({ pool, keyValue, needsMarginForPoints, ...rest }: Props) {
const {
queryState: { userAddress },
displayType,
} = usePoolList()
const { name } = usePoolMetadata(pool)

const { toCurrency } = useCurrency()

const hasPoints = pool.tags?.some(tag => tag && POOL_TAG_MAP.POINTS.includes(tag))

return (
<FadeInOnView>
<Box
Expand Down Expand Up @@ -115,13 +117,24 @@ export function PoolListTableRow({ pool, keyValue, ...rest }: Props) {
</Text>
</GridItem>
<GridItem justifySelf="end" pr={{ base: 'md', xl: '0' }}>
<MemoizedMainAprTooltip
aprItems={pool.dynamicData.aprItems}
height="auto"
pool={pool}
poolId={pool.id}
textProps={{ fontWeight: 'medium', textAlign: 'right' }}
/>
<HStack gap="xxs" mr={needsMarginForPoints && !hasPoints ? '12px' : '0'}>
<MemoizedMainAprTooltip
aprItems={pool.dynamicData.aprItems}
height="auto"
pool={pool}
poolId={pool.id}
textProps={{ fontWeight: 'medium', textAlign: 'right' }}
/>
{hasPoints && (
<Image
alt="points"
h="15px"
ml="0.5"
src="/images/icons/pool-points.svg"
w="10px"
/>
)}
</HStack>
</GridItem>
</Grid>
</Link>
Expand Down
1 change: 1 addition & 0 deletions packages/lib/modules/pool/pool.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const POOL_TAG_MAP: { [key in PoolTagType]: string[] } = {
'POINTS_RENZO',
'POINTS_SWELL',
'POINTS_MODE',
'POINTS_RINGS',
],
VE8020: ['VE8020'],
BOOSTED: ['BOOSTED'],
Expand Down

0 comments on commit da9eea3

Please sign in to comment.