import { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { Collapse } from 'react-vant' import Button from '~/components/Button' import { eth_pledgeProducts } from '~/contract/api' import { useRouter } from '~/hooks/useRouter' import '~/styles/home.scss' import { openGitBook } from '~/utils' import { toString } from '~/utils/wei' const Home = () => { const { push } = useRouter() const { t } = useTranslation() const [pledgeList, setPledgeList] = useState([ { day: 180, rate: 1408 }, { day: 270, rate: 1521 }, { day: 360, rate: 1623 }, ]) const [pledgeIndex, setPledgeIndex] = useState(0) const pledgeHelp = useMemo(() => [ { title: '1. Stake', desc: 'Choose a staking plan' }, { title: '2. Receive NFT', desc: 'NFT as a stake certificate to withdraw daily staking rewards' }, { title: '3. Maturity', desc: 'Holding NFT can redeem all staking amount' }, ], []) const collapseData = useMemo(() => [ { title: 'Why should I stake Filecoin?', desc: 'FAQ1' }, { title: 'What can I do with the NFT after receiving it?', desc: 'FAQ2' }, { title: 'Where do my reward from staking come from?', desc: 'FAQ3' }, ], []) const getData = async () => { const res = await eth_pledgeProducts() res.data && setPledgeList(res.data) } useEffect(() => { getData() }, []) return (
{t('STAKE TO EARN')}
{ pledgeList.map((item, index) => (
setPledgeIndex(index)} className={`mr-1 tabs-box row-center ${pledgeIndex === index && 'active-tab-box'}`} >{item.day} {t('Days')}
)) }
push('/pledge', { index: pledgeIndex })}>
{t('Annualized Percentage Rate (APR)')}
{toString(pledgeList[pledgeIndex].rate,2)}%
{t('Upcoming Soon')}
{t('Flexible Staking Subscription')}
{t('90 Days Staking Subscriptiong')}
{t('How It Works')}
{ pledgeHelp.map((item, index) => (
{t(item.title)}
{t(item.desc)}
)) }
{t('Refer To Earn')}
{t('Up To 7% of Referees Staking Rewards')}
{ push('/myPledge') }}>
{t('By sharing your referral code and introducing your friends to SOFIL and stake, you can earn referral rewards and withdraw everyday.')}
{t('FAQs')}
{ collapseData.map((item, index) => ( {t(item.desc)} )) }
) } interface BinancePagProps { title?: string; color?: string } const BinancePag = (props: BinancePagProps) => { const { t } = useTranslation() const { title, color } = props return (
Binance-Peg Filecoin
FIL
) } export default Home