-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get level multiplier from server configs and reward description
- Loading branch information
Showing
6 changed files
with
131 additions
and
17 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
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
79 changes: 79 additions & 0 deletions
79
apps/renderer/src/modules/power/my-wallet-section/reward-description-modal.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,79 @@ | ||
import { from } from "dnum" | ||
import { useCallback } from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import { useServerConfigs } from "~/atoms/server-configs" | ||
import { useModalStack } from "~/components/ui/modal" | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "~/components/ui/table" | ||
import { getLevelMultiplier } from "~/lib/utils" | ||
import { Balance } from "~/modules/wallet/balance" | ||
import { Level } from "~/modules/wallet/level" | ||
|
||
export const useRewardDescriptionModal = () => { | ||
const { present } = useModalStack() | ||
const { t } = useTranslation("settings") | ||
const serverConfigs = useServerConfigs() | ||
|
||
return useCallback(() => { | ||
present({ | ||
content: () => ( | ||
<div className="relative size-full max-w-[700px] py-4"> | ||
<div> | ||
<p className="mb-6 font-semibold">{t("wallet.rewardDescription.description1")}</p> | ||
<p>1. {t("wallet.rewardDescription.description2")}</p> | ||
<Table className="my-6"> | ||
<TableHeader> | ||
<TableRow className="[&>th]:h-8"> | ||
<TableHead>{t("wallet.rewardDescription.level")}</TableHead> | ||
<TableHead>{t("wallet.rewardDescription.percentage")}</TableHead> | ||
<TableHead>{t("wallet.rewardDescription.reward")}</TableHead> | ||
<TableHead>{t("wallet.rewardDescription.total")}</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{serverConfigs?.DAILY_POWER_PERCENTAGES.map((percentage, index) => { | ||
const level = serverConfigs?.DAILY_POWER_PERCENTAGES.length - index - 1 | ||
return ( | ||
<TableRow key={percentage} className="[&>td]:py-2"> | ||
<TableCell> | ||
<Level level={level} /> | ||
</TableCell> | ||
<TableCell>{serverConfigs?.LEVEL_PERCENTAGES[index] * 100}%</TableCell> | ||
<TableCell>{getLevelMultiplier(level)}</TableCell> | ||
<TableCell> | ||
<Balance withSuffix> | ||
{ | ||
from( | ||
serverConfigs.DAILY_POWER_SUPPLY * | ||
serverConfigs?.DAILY_POWER_PERCENTAGES[level], | ||
18, | ||
)[0] | ||
} | ||
</Balance> | ||
</TableCell> | ||
</TableRow> | ||
) | ||
})} | ||
</TableBody> | ||
</Table> | ||
<p>2. {t("wallet.rewardDescription.description3")}</p> | ||
</div> | ||
</div> | ||
), | ||
title: t("wallet.rewardDescription.title"), | ||
overlay: true, | ||
overlayOptions: { | ||
blur: true, | ||
className: "bg-black/80", | ||
}, | ||
clickOutsideToDismiss: true, | ||
}) | ||
}, [serverConfigs, present, t]) | ||
} |
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
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