From 103b909ab843a9ec4fdd7ad3b5658a575aa99c08 Mon Sep 17 00:00:00 2001 From: mac Date: Wed, 22 May 2024 16:54:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/home/index.tsx | 31 +++++++++++++++++++++++-------- src/pages/pledge/index.tsx | 6 +++--- src/router/layout/index.tsx | 2 ++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index 3f7bc47..c3d7307 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -11,7 +11,7 @@ import { toString } from '~/utils/wei' const Home = () => { const { push } = useRouter() - const { t } = useTranslation() + const { t, i18n } = useTranslation() const [pledgeList, setPledgeList] = useState([ { day: 180, rate: 1408 }, @@ -37,9 +37,24 @@ const Home = () => { res.data && setPledgeList(res.data) } + const renderTitle = () => { + if (i18n.language === 'en') { + return ( +
Up To 7% of Referees Staking Rewards
+ ) + } + if (i18n.language === 'hk') { + return ( +
高達質押人賺取的 7%
+ ) + } + return
高达质押人赚取的 7%
+ } + useEffect(() => { getData() }, []) + return (
@@ -71,7 +86,7 @@ const Home = () => {
{t('Annualized Percentage Rate (APR)')}
-
{toString(pledgeList[pledgeIndex].rate,2)}%
+
{toString(pledgeList[pledgeIndex].rate, 2)}%
@@ -107,13 +122,13 @@ const Home = () => {
{t('Refer To Earn')}
-
+
{ + push('/myPledge') + }}> -
-
{t('Up To 7% of Referees Staking Rewards')}
-
{ - push('/myPledge') - }}> +
+
{renderTitle()}
+
{t('By sharing your referral code and introducing your friends to SOFIL and stake, you can earn referral rewards and withdraw everyday.')}
diff --git a/src/pages/pledge/index.tsx b/src/pages/pledge/index.tsx index e5f5a05..ca06627 100644 --- a/src/pages/pledge/index.tsx +++ b/src/pages/pledge/index.tsx @@ -42,10 +42,10 @@ const Pledge = () => { const navbarRefs = useRef(document.querySelector('.layout .header')) const handleInput = (e: React.ChangeEvent) => { - let value = e.target.value.replace(/[^\d]/g, '') - setAmount(value) + let value = e.target.value + setAmount(toFixed2(value, 0)) } - + const getData = async () => { const res = await eth_pledgeProducts() res.data && setPledgeList(res.data) diff --git a/src/router/layout/index.tsx b/src/router/layout/index.tsx index 8eb2ad2..f17ea19 100644 --- a/src/router/layout/index.tsx +++ b/src/router/layout/index.tsx @@ -7,6 +7,7 @@ import { useEffect } from 'react'; import store from '~/store'; import { initContract } from '~/contract'; import { useTranslation } from 'react-i18next'; +import { SOFIL_LANGUAGE } from '~/language'; const LayoutRouter = () => { @@ -46,6 +47,7 @@ const LayoutRouter = () => { if (pathname === 'zh' || pathname === 'hk' || pathname === 'en') { i18n.changeLanguage(pathname) push('/', null, true) + window.sessionStorage.setItem(SOFIL_LANGUAGE, pathname) } }