调整代码规范,增加兑换页面

This commit is contained in:
myf 2022-05-16 17:41:51 +08:00
parent f58a673d04
commit 4db2ece0f8
14 changed files with 174 additions and 33 deletions

View File

@ -1145,5 +1145,12 @@
"person": "人", "person": "人",
"Earnings will be cleared after forced cancellation. Confirm cancellation": "强制取消后收益将清空,是否确认取消", "Earnings will be cleared after forced cancellation. Confirm cancellation": "强制取消后收益将清空,是否确认取消",
"HighCitySwapInfo": "HIighCitySwap的诞生源于创始人Liu Bus对区块链技术的狂热追求他始终相信区块链技术能够得到更广泛的应用。为此他做了一个勇敢的决定放弃在其他领域的投资身心专注投入到区块链技术实践应用当中去将自己所熟悉的领域——互联网社交与区块链技术融合HighCitySwap由此诞生。这就是我们的开始感谢你们的支持HighCity团队将永远前行。", "HighCitySwapInfo": "HIighCitySwap的诞生源于创始人Liu Bus对区块链技术的狂热追求他始终相信区块链技术能够得到更广泛的应用。为此他做了一个勇敢的决定放弃在其他领域的投资身心专注投入到区块链技术实践应用当中去将自己所熟悉的领域——互联网社交与区块链技术融合HighCitySwap由此诞生。这就是我们的开始感谢你们的支持HighCity团队将永远前行。",
"After pledge, income will lock warehouse%times%": "质押后,收益将锁仓%times%" "After pledge, income will lock warehouse%times%": "质押后,收益将锁仓%times%",
"IDO exchange in the first phase": "第一期IDO兑换",
"Opening time of next exchange period:": "下期兑换开启时间:",
"Please enter the amount": "请输入金额",
"Exchange rate": "兑换比率",
"gross": "总量",
"remaining quantity": "剩余数量",
"Immediately change": "立即兑换"
} }

View File

@ -54,6 +54,7 @@ const Referral = lazy(() => import('./views/Referral'))
const Board = lazy(() => import('./views/Board')) const Board = lazy(() => import('./views/Board'))
const Nft = lazy(() => import('./views/Nft')) const Nft = lazy(() => import('./views/Nft'))
const Announcement = lazy(() => import('./views/Announcement')) const Announcement = lazy(() => import('./views/Announcement'))
const Exchange = lazy(() => import('./views/Exchange'))
// This config is required for number formatting // This config is required for number formatting
BigNumber.config({ BigNumber.config({
@ -99,6 +100,9 @@ const App: React.FC = () => {
<Route path="/pools"> <Route path="/pools">
<Pools /> <Pools />
</Route> </Route>
<Route path="/exchange">
<Exchange />
</Route>
<Route path="/referral"> <Route path="/referral">
<Referral /> <Referral />
</Route> </Route>

View File

@ -28,8 +28,13 @@ const config: (t: ContextApi['t']) => MenuEntry[] = (t) => [
{ {
label: t('Exchange'), label: t('Exchange'),
icon: 'FarmIcon', icon: 'FarmIcon',
href: 'https://pancake.kiemtienonline360.com/#/swap', href: '/exchange',
}, },
// {
// label: t('Exchange'),
// icon: 'FarmIcon',
// href: 'https://pancake.kiemtienonline360.com/#/swap',
// },
{ {
label: t('Liquidity'), label: t('Liquidity'),
icon: 'FarmIcon', icon: 'FarmIcon',

View File

@ -8,7 +8,7 @@ export default {
56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95', 56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95',
}, },
boardChef: { boardChef: {
97: '0xb4451b4f3cb37dd31abf9876b4325e595c11f302', 97: '0x126935cae1988efbf8e310abe6be1f9046eaf0ac',
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约
}, },
boardRewardChef: { boardRewardChef: {

View File

@ -1272,5 +1272,12 @@
"person": "person", "person": "person",
"Earnings will be cleared after forced cancellation. Confirm cancellation": "Earnings will be cleared after forced cancellation. Confirm cancellation", "Earnings will be cleared after forced cancellation. Confirm cancellation": "Earnings will be cleared after forced cancellation. Confirm cancellation",
"HighCitySwapInfo": "HIighCitySwap was born from the fanatical pursuit of blockchain technology by its founder Liu Bus, who always believes that blockchain technology can be applied more widely. For this reason, he made a brave decision to give up investment in other fields and focus on the practice and application of blockchain technology. He fused his familiar field -- Internet social interaction with blockchain technology and thus HighCitySwap was born. This is our beginning, thank you for your support, the HighCity team will always move forward.", "HighCitySwapInfo": "HIighCitySwap was born from the fanatical pursuit of blockchain technology by its founder Liu Bus, who always believes that blockchain technology can be applied more widely. For this reason, he made a brave decision to give up investment in other fields and focus on the practice and application of blockchain technology. He fused his familiar field -- Internet social interaction with blockchain technology and thus HighCitySwap was born. This is our beginning, thank you for your support, the HighCity team will always move forward.",
"After pledge, income will lock warehouse%times%": "After pledge, income will lock warehouse%times%" "After pledge, income will lock warehouse%times%": "After pledge, income will lock warehouse%times%",
"IDO exchange in the first phase": "第一期IDO兑换",
"Opening time of next exchange period:": "Opening time of next exchange period:",
"Please enter the amount": "Please enter the amount",
"Exchange rate": "Exchange rate",
"gross": "gross",
"remaining quantity": "remaining quantity",
"Immediately change": "Immediately change"
} }

View File

@ -90,7 +90,7 @@ const ListItem: React.FC<InfoProps> = ({ title, content, publishTime, top = fals
<TableInfo> <TableInfo>
<FlexTitle> <FlexTitle>
<TextTitle>{title}</TextTitle> <TextTitle>{title}</TextTitle>
{top ? <TextTop>{t('top')}</TextTop> : ''} {top && <TextTop>{t('top')}</TextTop>}
</FlexTitle> </FlexTitle>
<TextInfo>{content}</TextInfo> <TextInfo>{content}</TextInfo>
</TableInfo> </TableInfo>

View File

@ -98,24 +98,20 @@ interface NodeCardProps {
board: any board: any
removed: boolean removed: boolean
provider?: ProviderType provider?: ProviderType
accountData?: string account?: string
boardsData?: any boardsData?: any
} }
const BoardCard: React.FC<NodeCardProps> = ({ board, accountData, boardsData }) => { const BoardCard: React.FC<NodeCardProps> = ({ board, account, boardsData }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [countDown, setCountDown] = useState('') const [countDown, setCountDown] = useState('')
useEffect(() => { useEffect(() => {
const interval = setInterval(() => { setTimeout(() => {
if (board.userData?.unlockTime) { if (board.userData?.unlockTime) {
if (countDown === t('End of the lock up')) {
clearInterval(interval)
}
const time = board.userData?.unlockTime * 1000 const time = board.userData?.unlockTime * 1000
countDownFun(time - 1) countDownFun(time - 1)
} }
}, 1000) }, 1000)
return () => clearInterval(interval)
}, [countDown, board]) }, [countDown, board])
const countDownFun = (date) => { const countDownFun = (date) => {
@ -142,14 +138,14 @@ const BoardCard: React.FC<NodeCardProps> = ({ board, accountData, boardsData })
amount={board.userData?.amount} amount={board.userData?.amount}
/> />
<ContentDiv> <ContentDiv>
{accountData && ( {account && (
<InfoDiv> <InfoDiv>
<FlexText name={t('HCC Currency amount')} value={board.userData?.amount as number} /> <FlexText name={t('HCC Currency amount')} value={board.userData?.amount as number} />
{board.pid === 1 && board.userData?.amount ? <FlexText name={t('Lock up time')} value={countDown} /> : ''} {board.pid === 1 && board.userData?.amount ? <FlexText name={t('Lock up time')} value={countDown} /> : ''}
<FlexText name={t('possess LP')} value={board.userData?.amount / boardsData?.curAmount || 0} /> <FlexText name={t('possess LP')} value={board.userData?.amount / boardsData?.curAmount || 0} />
</InfoDiv> </InfoDiv>
)} )}
<CardActionsContainer board={board} accountData={accountData} /> <CardActionsContainer board={board} account={account} />
</ContentDiv> </ContentDiv>
{/* <Divider /> {/* <Divider />
<ExpandableSectionButton <ExpandableSectionButton

View File

@ -10,6 +10,7 @@ import { useBoardUser, usePriceCakeBusd, usePriceHccUsdt } from 'state/hooks'
import { TOKEN_SYMBOL } from 'config/index' import { TOKEN_SYMBOL } from 'config/index'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useAccount } from 'state/userInfo/hooks'
import { BIG_ZERO } from 'utils/bigNumber' import { BIG_ZERO } from 'utils/bigNumber'
import { getBalanceNumber, getBalanceAmount } from 'utils/formatBalance' import { getBalanceNumber, getBalanceAmount } from 'utils/formatBalance'
@ -32,20 +33,19 @@ const PriceCoin = styled.div`
interface NodeCardActionsProps { interface NodeCardActionsProps {
board: Boards board: Boards
provider?: ProviderType provider?: ProviderType
accountData?: string account?: string
} }
const CardActions: React.FC<NodeCardActionsProps> = ({ board, accountData }) => { const CardActions: React.FC<NodeCardActionsProps> = ({ board, account }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [requestedApproval, setRequestedApproval] = useState(false) const [requestedApproval, setRequestedApproval] = useState(false)
const pid = board.pid const pid = board.pid
const { allowance, tokenBalance, stakedBalance, estimatedProfit } = useBoardUser(pid) const { allowance, tokenBalance, stakedBalance, estimatedProfit } = useBoardUser(pid)
const isApproved = accountData && allowance && allowance.isGreaterThan(0) const isApproved = account && allowance && allowance.isGreaterThan(0)
const tokenContract = useERC20(getAddress(board.tokenAddresses)) const tokenContract = useERC20(getAddress(board.tokenAddresses))
const { onApprove } = useApproveBoard(tokenContract, pid) const { onApprove } = useApproveBoard(tokenContract, pid)
const { account } = useWeb3React()
const rawEarningsBalance = account ? getBalanceAmount(new BigNumber(estimatedProfit)).toNumber() : BIG_ZERO const rawEarningsBalance = account ? getBalanceAmount(new BigNumber(estimatedProfit)).toNumber() : BIG_ZERO
const displayBalance = rawEarningsBalance.toFixed(3, BigNumber.ROUND_DOWN) const displayBalance = rawEarningsBalance.toFixed(3, BigNumber.ROUND_DOWN)
const hccPriceUsdt = usePriceHccUsdt() const hccPriceUsdt = usePriceHccUsdt()
@ -59,11 +59,10 @@ const CardActions: React.FC<NodeCardActionsProps> = ({ board, accountData }) =>
console.error(e) console.error(e)
} }
}, [onApprove]) }, [onApprove])
const [totalPrice, setTotalPrice] = useState(0) // const [totalPrice, setTotalPrice] = useState(0)
useMemo(() => { const totalPrice = useMemo(() => {
setTotalPrice(getBalanceAmount(new BigNumber(board?.userData?.receiveReward)).toNumber() + Number(displayBalance)) return getBalanceAmount(new BigNumber(board?.userData?.receiveReward)).toNumber() + Number(displayBalance)
}, [board]) }, [board])
const renderApprovalOrStakeButton = () => { const renderApprovalOrStakeButton = () => {
return isApproved ? ( return isApproved ? (
<> <>
@ -106,7 +105,7 @@ const CardActions: React.FC<NodeCardActionsProps> = ({ board, accountData }) =>
) )
} }
return <Action>{!accountData ? <UnlockButton mt="8px" width="100%" /> : renderApprovalOrStakeButton()}</Action> return <Action>{!account ? <UnlockButton mt="8px" width="100%" /> : renderApprovalOrStakeButton()}</Action>
} }
export default CardActions export default CardActions

View File

@ -49,13 +49,12 @@ const StakeAction: React.FC<NodeCardActionsProps> = ({ stakedBalance, tokenBalan
}, [userData, minStakeAmount, tokenDecimals]) }, [userData, minStakeAmount, tokenDecimals])
const [unlockTimeTxt, setUnlockTimeTxt] = useState('') const [unlockTimeTxt, setUnlockTimeTxt] = useState('')
const onBaseConfig = async () => { const getLockUpTime = async () => {
const times = await getBaseConfig() const times = await getBaseConfig()
formatSeconds(Number(times)) formatSeconds(Number(times))
} }
const formatSeconds = (value: number) => { const formatSeconds = (value: number) => {
console.log('value:', value)
const second = value const second = value
// 分 // 分
let minute: any = 0 let minute: any = 0
@ -63,7 +62,6 @@ const StakeAction: React.FC<NodeCardActionsProps> = ({ stakedBalance, tokenBalan
if (second > 60) { if (second > 60) {
// 获取分钟除以60取整数得到整数分钟 // 获取分钟除以60取整数得到整数分钟
minute = second / 60 minute = second / 60
console.log(parseInt(minute))
// 获取秒数,秒数取佘,得到整数秒数 // 获取秒数,秒数取佘,得到整数秒数
const ss = second % 60 const ss = second % 60
// 如果分钟大于60将分钟转换成小时 // 如果分钟大于60将分钟转换成小时
@ -79,7 +77,7 @@ const StakeAction: React.FC<NodeCardActionsProps> = ({ stakedBalance, tokenBalan
} }
} }
useEffect(() => { useEffect(() => {
onBaseConfig() getLockUpTime()
}, []) }, [])
const [onPresentDeposit] = useModal( const [onPresentDeposit] = useModal(
<DepositModal <DepositModal

View File

@ -83,7 +83,6 @@ const Boards: React.FC = () => {
return { return {
pid: boardConfig.pid, pid: boardConfig.pid,
curAmount: getBalanceAmount(new BigNumber(boardPoolInfo.curAmount._hex)).toNumber(), curAmount: getBalanceAmount(new BigNumber(boardPoolInfo.curAmount._hex)).toNumber(),
receiveReward: boardsList.filter((n) => boardConfig.pid === n.pid),
holderNum: new BigNumber(boardPoolInfo?.holderNum?._hex).toNumber(), holderNum: new BigNumber(boardPoolInfo?.holderNum?._hex).toNumber(),
waitWithdrawAmount: getBalanceAmount(new BigNumber(waitWithdrawAmount.balance._hex)).toNumber(), waitWithdrawAmount: getBalanceAmount(new BigNumber(waitWithdrawAmount.balance._hex)).toNumber(),
totalReward: getBalanceAmount(new BigNumber(boardPoolInfo?.totalReward?._hex)).toNumber(), totalReward: getBalanceAmount(new BigNumber(boardPoolInfo?.totalReward?._hex)).toNumber(),
@ -92,12 +91,10 @@ const Boards: React.FC = () => {
) )
let total = 0 let total = 0
let waitWithdrawAmountValue = 0
let totalReward = 0 let totalReward = 0
boardsData.forEach((item) => { boardsData.forEach((item) => {
total += item.curAmount total += item.curAmount
totalReward += item.totalReward totalReward += item.totalReward
waitWithdrawAmountValue += item.waitWithdrawAmount
if (item.pid === 1) { if (item.pid === 1) {
setBoardNum(item.holderNum) setBoardNum(item.holderNum)
} else if (item.pid === 2) { } else if (item.pid === 2) {
@ -121,7 +118,7 @@ const Boards: React.FC = () => {
<div> <div>
<FlexLayout> <FlexLayout>
{boardsList.map((board, index) => ( {boardsList.map((board, index) => (
<BoardCard boardsData={boardsDataList[index]} key={board.pid} board={board} accountData={account} removed /> <BoardCard boardsData={boardsDataList[index]} key={board.pid} board={board} account={account} removed />
))} ))}
</FlexLayout> </FlexLayout>
</div> </div>

View File

@ -0,0 +1,68 @@
import React, { useMemo, useState, useEffect } from 'react'
import styled, { keyframes } from 'styled-components'
import { useTranslation } from 'contexts/Localization'
import { Flex, Text, Button } from '@pancakeswap/uikit'
import { useAccount } from 'state/userInfo/hooks'
import UnlockButton from 'components/UnlockButton'
import ExchangeInput from './ExchangeInput'
const FCard = styled.div`
width: 650px;
background: ${(props) => props.theme.card.background};
border-radius: 32px;
box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
position: relative;
text-align: center;
padding: 50px 70px;
`
const HeaderText = styled(Text)`
font-size: 48px;
color: #280d5f;
`
const TimeText = styled(Text)`
color: #7a6eaa;
font-size: 22px;
`
const RateText = styled(Text)`
font-size: 30px;
color: #280d5f;
`
const RateNumber = styled(Text)`
font-size: 30px;
color: #1fc7d4;
`
const FooterButton = styled(Button)`
margin-top: 50px;
`
const ExchangeCard: React.FC = () => {
const { t } = useTranslation()
const account = useAccount()
return (
<FCard>
<HeaderText>{t('IDO exchange in the first phase')}</HeaderText>
<TimeText>{t('Opening time of next exchange period:')}2022.5.16 00:00</TimeText>
<ExchangeInput name="USDT" />
<Flex alignItems="center" justifyContent="center" marginTop={20}>
<RateText>{t('Exchange rate')}</RateText>
<RateNumber>1USDT=100HCC</RateNumber>
</Flex>
<Flex alignItems="center" justifyContent="center">
<Text color="textSubtle">{t('gross')}100000HCC</Text>
<Text color="textSubtle" marginLeft={20}>
{t('remaining quantity')}100000HCC
</Text>
</Flex>
<ExchangeInput name="HCC" />
<FooterButton>{account ? <Button>{t('Immediately change')}</Button> : <UnlockButton />}</FooterButton>
</FCard>
)
}
export default ExchangeCard

View File

@ -0,0 +1,38 @@
import React from 'react'
import styled from 'styled-components'
import { Text, Input } from '@pancakeswap/uikit'
import { useTranslation } from 'contexts/Localization'
const PriceContent = styled.div`
height: 148px;
background: rgba(238, 234, 244, 0.39);
border: 1px solid #d7caec;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.16);
border-radius: 18px;
padding: 23px 20px;
margin-top: 20px;
`
const CoinText = styled(Text)`
font-size: 26px;
color: #333333;
text-align: left;
margin-bottom: 20px;
`
interface InputProps {
name: string
value?: number | string
}
const ExchangeInput: React.FC<InputProps> = ({ name, value }) => {
const { t } = useTranslation()
return (
<PriceContent>
<CoinText>{name}</CoinText>
<Input value={value} placeholder={t('Please enter the amount')} />
</PriceContent>
)
}
export default ExchangeInput

View File

@ -0,0 +1,22 @@
import React, { useState, useEffect } from 'react'
import styled from 'styled-components'
import ExchangeCard from './components/ExchangeCard'
const PageContent = styled.div`
min-height: calc(100vh - 64px);
background-image: url('/images/recommend/bg.svg');
background-size: cover;
background-repeat: no-repeat;
display: flex;
align-items: center;
justify-content: center;
`
const Exchange: React.FC = () => {
return (
<PageContent>
<ExchangeCard />
</PageContent>
)
}
export default Exchange

View File

@ -66,12 +66,12 @@ const BuyNftModal: React.FC<BuyNftModalProps> = ({ onDismiss }) => {
const [price, setPrice] = useState('') const [price, setPrice] = useState('')
const [link, setLink] = useState('') const [link, setLink] = useState('')
const onContract = async () => { const getLinkAddress = async () => {
const data = await getContract() const data = await getContract()
setLink(data) setLink(data)
} }
useEffect(() => { useEffect(() => {
onContract() getLinkAddress()
}, []) }, [])
useMemo(() => { useMemo(() => {
const priceList = [] const priceList = []