From e517fbdc522f02798b9af4cfdea2a36ceeb601b0 Mon Sep 17 00:00:00 2001 From: groninge Date: Mon, 27 Jan 2025 13:04:08 +0000 Subject: [PATCH] add basic relic card --- .../lib/modules/reliquary/Reliquary.tsx | 31 ++----- .../modules/reliquary/components/Relic.tsx | 93 +++++++++++++++++++ 2 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 apps/beets-frontend-v3/lib/modules/reliquary/components/Relic.tsx diff --git a/apps/beets-frontend-v3/lib/modules/reliquary/Reliquary.tsx b/apps/beets-frontend-v3/lib/modules/reliquary/Reliquary.tsx index fd214b4aa..84b3ef2fa 100644 --- a/apps/beets-frontend-v3/lib/modules/reliquary/Reliquary.tsx +++ b/apps/beets-frontend-v3/lib/modules/reliquary/Reliquary.tsx @@ -1,38 +1,19 @@ 'use client' -import { Box, VStack, CardBody, Card } from '@chakra-ui/react' +import { VStack } from '@chakra-ui/react' import { useGetRelicPositionsOfOwner } from './hooks/useGetRelicPositionsOfOwner' import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql' -import { useGetPositionForId } from './hooks/useGetPositionForId' -import { useGetLevelOnUpdate } from './hooks/useGetLevelOnUpdate' -import { useGetLevelInfo } from './hooks/useGetLevelInfo' -import { useGetDepositImpact } from './hooks/useGetDepositImpact' -import { useGetReliquaryFarmSnapshots } from './hooks/useGetReliquaryFarmSnapshots' +import { Relic } from './components/Relic' const CHAIN = GqlChain.Sonic export function Reliquary() { // onchain - const { positions } = useGetRelicPositionsOfOwner(CHAIN) - const { position } = useGetPositionForId(CHAIN, '16') - const { levelOnUpdate } = useGetLevelOnUpdate(CHAIN, '16') - const { maturityThresholds } = useGetLevelInfo(CHAIN, '0') - const depositImpact = useGetDepositImpact(CHAIN, '1', '16') - - // api - const { query } = useGetReliquaryFarmSnapshots() - - console.log({ positions, position, levelOnUpdate, maturityThresholds, depositImpact, query }) + const { relics } = useGetRelicPositionsOfOwner(CHAIN) return ( - - - - - TEST - - - - + + {relics?.map(relic => )} + ) } diff --git a/apps/beets-frontend-v3/lib/modules/reliquary/components/Relic.tsx b/apps/beets-frontend-v3/lib/modules/reliquary/components/Relic.tsx new file mode 100644 index 000000000..e26534cac --- /dev/null +++ b/apps/beets-frontend-v3/lib/modules/reliquary/components/Relic.tsx @@ -0,0 +1,93 @@ +'use client' + +import { + Card, + CardHeader, + CardBody, + VStack, + HStack, + Text, + Heading, + CardFooter, + Button, +} from '@chakra-ui/react' +import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql' +import { fNum } from '@repo/lib/shared/utils/numbers' +import { formatUnits } from 'viem' +import { useGetPendingReward } from '../hooks/useGetPendingReward' +import Countdown from 'react-countdown' +import { ReliquaryFarmPosition } from '../reliquary.types' +import { useGetLevelInfo } from '../hooks/useGetLevelInfo' +import { relicGetMaturityProgress } from '../reliquary.helpers' + +const RELIC_LEVEL_NAMES = [ + 'The Initiate', + 'The Neophyte', + 'The Wanderer', + 'The Rebel', + 'The Skeptic', + 'The Apprentice', + 'The Journeyman', + 'The Savant', + 'The Creator', + 'The Scholar', + 'The Awakened', +] + +type RelicProps = { + chain: GqlChain + relic: ReliquaryFarmPosition +} + +export function Relic({ chain, relic }: RelicProps) { + const { amount: pendingReward } = useGetPendingReward(chain, relic.relicId) + const { maturityThresholds } = useGetLevelInfo(chain, relic.relicId) + + const { levelUpDate } = relicGetMaturityProgress(relic, maturityThresholds || []) + + return ( + + + + + Level {relic.level + 1} - {RELIC_LEVEL_NAMES[relic.level]} + + Relic #{relic.relicId} + + + + + + Amount: + {`${fNum('token', relic.amount)} fBEETS`} + + + Pending rewards: + {`${fNum('token', formatUnits(pendingReward || 0n, 18))} BEETS`} + + + Time to next level: + + + + + + + + + + + + + + + + ) +}