From 184e2e3240d58c19de74b59f449d5760a391e1a6 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 16 Oct 2024 03:28:02 +0800 Subject: [PATCH] feat: display level in power page --- .../my-wallet-section/claim-daily-reward.tsx | 4 +- .../modules/power/my-wallet-section/index.tsx | 153 +++++++++--------- apps/renderer/src/modules/wallet/level.tsx | 18 ++- locales/settings/en.json | 1 + 4 files changed, 96 insertions(+), 80 deletions(-) diff --git a/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx b/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx index 5572acf41..9754e1731 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx @@ -4,9 +4,10 @@ import { Trans, useTranslation } from "react-i18next" import { Button } from "~/components/ui/button" import { Tooltip, TooltipContent } from "~/components/ui/tooltip" import { DAILY_CLAIM_AMOUNT } from "~/constants" +import { Level } from "~/modules/wallet/level" import { useClaimCheck, useClaimWalletDailyRewardMutation } from "~/queries/wallet" -export const ClaimDailyReward = () => { +export const ClaimDailyReward = ({ level }: { level: number }) => { const mutation = useClaimWalletDailyRewardMutation() const { t } = useTranslation("settings") @@ -23,6 +24,7 @@ export const ClaimDailyReward = () => { disabled={!canClaim} > {canClaim ? t("wallet.claim.button.claim") : t("wallet.claim.button.claimed")} + diff --git a/apps/renderer/src/modules/power/my-wallet-section/index.tsx b/apps/renderer/src/modules/power/my-wallet-section/index.tsx index 0b67388c7..e558a503e 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/index.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/index.tsx @@ -10,6 +10,7 @@ import { apiClient } from "~/lib/api-fetch" import { cn } from "~/lib/utils" import { SettingSectionTitle } from "~/modules/settings/section" import { Balance } from "~/modules/wallet/balance" +import { Level } from "~/modules/wallet/level" import { useWallet, wallet as walletActions } from "~/queries/wallet" import { ClaimDailyReward } from "./claim-daily-reward" @@ -47,84 +48,84 @@ export const MyWalletSection = () => { } return ( <> -
-
-
- - - ), - }} - /> -

{t("wallet.power.dailyClaim", { amount: DAILY_CLAIM_AMOUNT })}

-
- - - -
-
- - {BigInt(myWallet.dailyPowerToken || 0n) + BigInt(myWallet.cashablePowerToken || 0n)} - - -
-
- - -
-
- - -
- - {t("wallet.balance.withdrawable")} - - - - {myWallet.cashablePowerToken} - -
-
- - -

{t("wallet.balance.withdrawableTooltip")}

-
-
-
+ ), + }} + /> +

{t("wallet.power.dailyClaim", { amount: DAILY_CLAIM_AMOUNT })}

+ + + + + +
+
+ + {BigInt(myWallet.dailyPowerToken || 0n) + BigInt(myWallet.cashablePowerToken || 0n)} + + +
+
+ + +
+
+ + +
+ + {t("wallet.balance.withdrawable")} + + + + {myWallet.cashablePowerToken} + +
+
+ + +

{t("wallet.balance.withdrawableTooltip")}

+
+
+
) diff --git a/apps/renderer/src/modules/wallet/level.tsx b/apps/renderer/src/modules/wallet/level.tsx index 8ad96275f..9b2e8a387 100644 --- a/apps/renderer/src/modules/wallet/level.tsx +++ b/apps/renderer/src/modules/wallet/level.tsx @@ -1,9 +1,21 @@ +import { cn } from "~/lib/utils" + export const multiples = [0.1, 1, 2, 5, 18] -export const Level = ({ level, isLoading }: { level: number; isLoading?: boolean }) => { +export const Level = ({ + level, + isLoading, + hideIcon, + className, +}: { + level: number + isLoading?: boolean + hideIcon?: boolean + className?: string +}) => { return ( -
- +
+ {!hideIcon && } {isLoading ? ( ) : ( diff --git a/locales/settings/en.json b/locales/settings/en.json index ddc9fe628..9742c0d2f 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -218,6 +218,7 @@ "titles.profile": "Profile", "titles.shortcuts": "Shortcuts", "wallet.address.title": "Your Address", + "wallet.balance.level": "Your Level", "wallet.balance.title": "Your Balance", "wallet.balance.withdrawable": "Withdrawable", "wallet.balance.withdrawableTooltip": "Withdrawable Power includes both the tips you've received and the Power you've recharged.",