import { cleanBounsApi, toggleUserBounsApi } from "@/api/user";
import { usePollingStore } from "@/stores/usePollingStore";
import { useWalletStore } from "@/stores/useWalletStore";
import { percentage } from "@/utils/methods";
import { Dialog, ProgressBar, Toast } from "antd-mobile";
import { useTranslations } from "next-intl";
import React from "react";
import { shallow } from "zustand/shallow";
import "./style.scss";
const Progress = ({ percent, textColor = "#fff" }: { percent: number; textColor?: string }) => {
return (
);
};
export const WalletContent = ({
percentage,
type,
difference,
current,
textColor = "#fff",
}: {
percentage: number;
type: string;
difference: number;
current: number;
textColor?: string;
}) => {
const t = useTranslations("ProfilePage");
return (
{type}
R$
{current}
{t("modalBottomTips")}
{difference.toFixed(2)}
);
};
// 现金
export const BalanceContent = () => {
// const { wallet } = props;
const wallet = useWalletStore((state) => {
return {
score: state.wallet.score,
target_score_rollover: state.wallet.target_score_rollover,
current_score_rollover: state.wallet.current_score_rollover,
};
}, shallow);
const t = useTranslations("ProfilePage");
return (
<>
>
);
};
export const BonusContent = (props: { handleAcquire?: any }) => {
const { handleAcquire } = props;
const { setWallet, wallet } = useWalletStore((state) => ({
setWallet: state.setWallet,
wallet: state.wallet,
}));
const [switchValue, setSwitchValue] = React.useState(
wallet.is_open_no_bonus === 1 || false
);
const refresh = usePollingStore((state) => state.refresh);
const [isLoading, setIsLoading] = React.useState(false);
const t = useTranslations("ProfilePage");
const changeValue = async (value: boolean) => {
const confirmRes = await Dialog.confirm({
content: (
{value ? t("switchOpen") : t("switchClose")}
),
confirmText: t("sure"),
cancelText: t("cancel"),
bodyStyle: {
backgroundColor: "#373737",
color: "#fff",
},
bodyClassName: "customConfirm",
});
if (!confirmRes) return;
setIsLoading(true);
try {
const res = await toggleUserBounsApi(value ? 1 : 0);
if (!(res?.code && res?.data?.code === 0)) {
throw new Error("error");
}
setSwitchValue(value);
} finally {
setIsLoading(false);
}
};
const doHandle = async () => {
const confirmRes = await Dialog.confirm({
content: {t("clean")}
,
confirmText: t("sure"),
cancelText: t("cancel"),
bodyStyle: {
backgroundColor: "#373737",
color: "#fff",
},
bodyClassName: "customConfirm",
});
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({
content: str,
icon: "fail",
});
}
Toast.show({
content: t("success"),
icon: "success",
});
refresh && refresh();
};
return (
);
};
export const FreeContent = ({
handleAcquire,
textColor = "#fff",
}: {
handleAcquire?: any;
textColor?: string;
}) => {
// const { wallet, handleAcquire } = props;
const t = useTranslations("ProfilePage");
const { wallet } = useWalletStore((state) => ({
wallet: state.wallet,
}));
return (
);
};
export const ReplayContent = ({
handleAcquire,
textColor = "#fff",
}: {
handleAcquire?: any;
textColor?: string;
}) => {
const t = useTranslations("ProfilePage");
const { wallet } = useWalletStore((state) => ({
wallet: state.wallet,
}));
return (
);
};
// const WalletDescribeModal = () => {
// const [tipsStatus, setTipsStatus] = useState("Bonus");
// const tipsRef = useRef(null);
// const wallet: any = {};
// const t = useTranslations("ProfilePage");
//
// return (
//
//
// {t("modalTitle")}
//
// }
// >
// {/*现金*/}
// {tipsStatus === WalletEnum.Balance ? : null}
// {/* 彩金*/}
// {tipsStatus === WalletEnum.Bonus ? : null}
// {/* 免费币 */}
// {tipsStatus === WalletEnum.Free ? : null}
// {/* 重玩币 */}
// {tipsStatus === WalletEnum.Replay ? : null}
//
// );
// };
// export default WalletDescribeModal;