|
@@ -1,4 +1,5 @@
|
|
|
-import { Wallet, cleanBounsApi, toggleUserBounsApi } from "@/api/user";
|
|
|
+import { Wallet, cleanBounsApi, getUserMoneyApi, toggleUserBounsApi } from "@/api/user";
|
|
|
+import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
import { percentage } from "@/utils/methods";
|
|
|
import { Dialog, ProgressBar, Switch, Toast } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
@@ -70,8 +71,11 @@ export const BalanceContent = (props: { wallet: Wallet }) => {
|
|
|
|
|
|
export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) => {
|
|
|
const { wallet, handleAcquire } = props;
|
|
|
- const [switchValue, setSwitchValue] = React.useState<boolean>(wallet.is_open_no_bonus || false);
|
|
|
+ const [switchValue, setSwitchValue] = React.useState<boolean>(
|
|
|
+ wallet.is_open_no_bonus === 1 || false
|
|
|
+ );
|
|
|
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
|
|
+ const { setWallet } = useWalletStore((state) => ({ setWallet: state.setWallet }));
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
|
|
|
const changeValue = async (value: boolean) => {
|
|
@@ -113,6 +117,7 @@ export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) =>
|
|
|
});
|
|
|
if (!confirmRes) return;
|
|
|
const res = await cleanBounsApi(1);
|
|
|
+
|
|
|
if (res?.code && [6001, 6002].includes(res?.data?.code)) {
|
|
|
const str = t(`bouns${res?.data?.code}`);
|
|
|
Toast.show({
|
|
@@ -120,6 +125,12 @@ export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) =>
|
|
|
icon: "fail",
|
|
|
});
|
|
|
}
|
|
|
+ Toast.show({
|
|
|
+ content: t("success"),
|
|
|
+ icon: "success",
|
|
|
+ });
|
|
|
+ const walletRes = await getUserMoneyApi();
|
|
|
+ setWallet(walletRes?.data);
|
|
|
};
|
|
|
|
|
|
return (
|