-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chefilip
committed
Jul 10, 2023
1 parent
85b7865
commit ccd6e81
Showing
13 changed files
with
437 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
apps/web/src/views/FixedStaking/components/FixedStakingCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { useTranslation } from '@pancakeswap/localization' | ||
import { CardBody, Flex, Heading, StarFillIcon, Tag, Box, Button } from '@pancakeswap/uikit' | ||
import { StyledCard } from '@pancakeswap/uikit/src/widgets/Pool' | ||
import CurrencyLogo from 'components/Logo/CurrencyLogo' | ||
import BigNumber from 'bignumber.js' | ||
|
||
import { FixedStakingCardBody } from './FixedStakingCardBody' | ||
import { FixedStakingActions } from './FixedStakingActions' | ||
import { HarvestFixedStaking } from './HarvestFixedStaking' | ||
import { FixedStakingModal } from './FixedStakingModal' | ||
import { InlineText } from './InlineText' | ||
import { FixedStakingPool, StakedPosition } from '../type' | ||
|
||
export function FixedStakingCard({ | ||
pool, | ||
stakedPositions, | ||
}: { | ||
pool: FixedStakingPool | ||
stakedPositions: StakedPosition[] | ||
}) { | ||
const { t } = useTranslation() | ||
|
||
const stakePosition = stakedPositions.find((position) => position.pool.token.address === pool.token.address) | ||
|
||
return ( | ||
<StyledCard> | ||
<Flex px="24px" pt="24px" alignItems="center" justifyContent="space-between"> | ||
<> | ||
<CurrencyLogo currency={pool.token} size="56px" /> | ||
<Box> | ||
<Heading color="secondary" scale="lg" textAlign="end"> | ||
{pool.token.symbol} | ||
</Heading> | ||
{new BigNumber(pool.boostDayPercent).gt(0) ? ( | ||
<Tag outline variant="success" startIcon={<StarFillIcon width="18px" color="success" />}> | ||
vCAKE Boost | ||
</Tag> | ||
) : null} | ||
</Box> | ||
</> | ||
</Flex> | ||
<CardBody> | ||
<FixedStakingCardBody pool={pool}> | ||
{stakePosition ? ( | ||
<> | ||
<Box display="inline"> | ||
<InlineText color="secondary" bold fontSize="12px"> | ||
{`${pool.token.symbol} `} | ||
</InlineText> | ||
<InlineText color="textSubtle" textTransform="uppercase" bold fontSize="12px"> | ||
{t('Earned')} | ||
</InlineText> | ||
</Box> | ||
<HarvestFixedStaking | ||
lockPeriod={pool.lockPeriod} | ||
unlockTime={stakePosition.timestampEndLockPeriod} | ||
stakePositionUserInfo={stakePosition.userInfo} | ||
token={pool.token} | ||
poolIndex={pool.poolIndex} | ||
/> | ||
</> | ||
) : null} | ||
{stakePosition ? ( | ||
<> | ||
<Box display="inline"> | ||
<InlineText color="secondary" bold fontSize="12px"> | ||
{`${pool.token.symbol} `} | ||
</InlineText> | ||
<InlineText color="textSubtle" textTransform="uppercase" bold fontSize="12px"> | ||
{t('Staked')} | ||
</InlineText> | ||
</Box> | ||
<FixedStakingActions | ||
poolIndex={pool.poolIndex} | ||
lockPeriod={pool.lockPeriod} | ||
unlockTime={stakePosition.timestampEndLockPeriod} | ||
stakePositionUserInfo={stakePosition.userInfo} | ||
token={pool.token} | ||
/> | ||
</> | ||
) : ( | ||
<FixedStakingModal lockPeriod={pool.lockPeriod} poolIndex={pool.poolIndex} stakingToken={pool.token}> | ||
{(openModal) => <Button onClick={openModal}>{t('Stake')}</Button>} | ||
</FixedStakingModal> | ||
)} | ||
</FixedStakingCardBody> | ||
</CardBody> | ||
</StyledCard> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.