|
@@ -1,14 +1,7 @@
|
|
|
"use client";
|
|
|
import { GameListRep, GameRequest } from "@/api/home";
|
|
|
import { userInfoApi } from "@/api/login";
|
|
|
-import {
|
|
|
- UserInfoRep,
|
|
|
- UserVipInfo,
|
|
|
- Wallet,
|
|
|
- cleanBounsApi,
|
|
|
- getUserMoneyApi,
|
|
|
- getUserTransferApi,
|
|
|
-} from "@/api/user";
|
|
|
+import { UserInfoRep, cleanBounsApi, getUserTransferApi } from "@/api/user";
|
|
|
import {
|
|
|
BalanceContent,
|
|
|
BonusContent,
|
|
@@ -18,6 +11,8 @@ import {
|
|
|
import TipsModal, { ModalProps } from "@/components/TipsModal";
|
|
|
import useGame from "@/hooks/useGame";
|
|
|
import { Link, useRouter } from "@/i18n/routing";
|
|
|
+import { usePollingStore } from "@/stores/usePollingStore";
|
|
|
+import { useVipStore } from "@/stores/useVipStore";
|
|
|
import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
import { WalletEnum } from "@/types";
|
|
|
import { vipImages } from "@/utils/constant";
|
|
@@ -29,12 +24,10 @@ import { Fragment, useEffect, useRef, useState } from "react";
|
|
|
|
|
|
type Props = {
|
|
|
userInfo: UserInfoRep;
|
|
|
- userMoney: Wallet;
|
|
|
- userVip: UserVipInfo;
|
|
|
};
|
|
|
-const VipCard = (props: { userVip: UserVipInfo }) => {
|
|
|
- const { userVip } = props;
|
|
|
+const VipCard = () => {
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
+ const userVip = useVipStore((state) => state.vipData);
|
|
|
|
|
|
// Vip 图标
|
|
|
const vipIconElement = vipImages.map((item, index) => {
|
|
@@ -83,8 +76,9 @@ const VipCard = (props: { userVip: UserVipInfo }) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const WalletCard = (props: { userMoney: Wallet }) => {
|
|
|
- const { userMoney } = props;
|
|
|
+const WalletCard = () => {
|
|
|
+ // const { userMoney } = props;
|
|
|
+ const userMoney = useWalletStore((state) => state.wallet);
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
const tcdoe = useTranslations();
|
|
|
|
|
@@ -223,7 +217,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
|
|
|
</div>
|
|
|
<div className="num">
|
|
|
<span className="uppercase">brl </span>
|
|
|
- <span>{userMoney.score || 0.0}</span>
|
|
|
+ <span>{userMoney?.score || 0.0}</span>
|
|
|
</div>
|
|
|
</section>
|
|
|
</div>
|
|
@@ -232,7 +226,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
|
|
|
onClick={() => modalHandler(WalletEnum.Bonus)}
|
|
|
>
|
|
|
<Badge
|
|
|
- content={userMoney.is_point_transfer ? Badge.dot : null}
|
|
|
+ content={userMoney?.is_point_transfer ? Badge.dot : null}
|
|
|
style={{ right: "10px" }}
|
|
|
>
|
|
|
<div className="wallet-right-icon">
|
|
@@ -246,7 +240,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
|
|
|
</div>
|
|
|
<div className="num">
|
|
|
<span className="uppercase">brl </span>
|
|
|
- <span>{userMoney.point || 0.0}</span>
|
|
|
+ <span>{userMoney?.point || 0.0}</span>
|
|
|
</div>
|
|
|
</section>
|
|
|
</div>
|
|
@@ -359,27 +353,29 @@ const NoBounsWarn = ({ visible, onClose, onConfirm }: any) => {
|
|
|
);
|
|
|
};
|
|
|
export const ProfileHeader = (props: Props) => {
|
|
|
- const { userInfo, userVip } = props;
|
|
|
+ const { userInfo } = props;
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
-
|
|
|
- const { wallet, setWallet } = useWalletStore((state) => ({
|
|
|
- wallet: state.wallet,
|
|
|
- setWallet: state.setWallet,
|
|
|
- }));
|
|
|
+ const target_point_rollover = useWalletStore((state) => state.wallet?.target_point_rollover);
|
|
|
+ const score = useWalletStore((state) => state.wallet?.score);
|
|
|
+ const point = useWalletStore((state) => state.wallet?.point);
|
|
|
+ const no_bonus_config = useWalletStore((state) => state.wallet?.no_bonus_config);
|
|
|
+ const refresh = usePollingStore((state) => state.refresh);
|
|
|
const router = useRouter();
|
|
|
const [isShowNoBounsWarn, setIsShowNoBounsWarn] = useState(false);
|
|
|
const [isShowed, setIsShowed] = useState(false);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- const curMul = wallet.target_point_rollover / ((wallet?.score || 0) + (wallet.point || 0));
|
|
|
- const config = wallet.no_bonus_config;
|
|
|
+ const curMul = target_point_rollover / ((score || 0) + (point || 0));
|
|
|
+
|
|
|
+ const config = no_bonus_config;
|
|
|
if (curMul >= (config || 0) && !isShowed) {
|
|
|
setIsShowNoBounsWarn(true);
|
|
|
setIsShowed(true);
|
|
|
}
|
|
|
- }, [wallet]);
|
|
|
+ }, []);
|
|
|
|
|
|
const handler = () => {
|
|
|
- if (!!wallet.score) {
|
|
|
+ if (!!score) {
|
|
|
router.push("/withdraw");
|
|
|
} else {
|
|
|
Toast.show("no money ");
|
|
@@ -404,8 +400,9 @@ export const ProfileHeader = (props: Props) => {
|
|
|
content: t("success"),
|
|
|
icon: "success",
|
|
|
});
|
|
|
- const walletRes = await getUserMoneyApi();
|
|
|
- setWallet(walletRes?.data);
|
|
|
+ // const walletRes = await getUserMoneyApi();
|
|
|
+ // setWallet(walletRes?.data);
|
|
|
+ refresh && refresh();
|
|
|
};
|
|
|
|
|
|
return (
|
|
@@ -436,9 +433,9 @@ export const ProfileHeader = (props: Props) => {
|
|
|
></Link>
|
|
|
</div>
|
|
|
{/*vipcard*/}
|
|
|
- <VipCard userVip={userVip} />
|
|
|
+ <VipCard />
|
|
|
|
|
|
- <WalletCard userMoney={wallet} />
|
|
|
+ <WalletCard />
|
|
|
</div>
|
|
|
|
|
|
<div className="link">
|