|
@@ -13,32 +13,34 @@ interface Props {
|
|
|
|
|
|
const DepositData: FC<Props> = (props) => {
|
|
|
const { deposits } = props;
|
|
|
- console.log(`🚀🚀🚀🚀🚀-> in DepositData.tsx on 16`, deposits);
|
|
|
const t = useTranslations("DepositPage");
|
|
|
|
|
|
const [activeType, setActiveType] = useState<DepositsTypes>(deposits[0]);
|
|
|
|
|
|
- let [amount, setAmount] = useState(0);
|
|
|
+ let [amount, setAmount] = useState("");
|
|
|
const ChangeAmount = (e: any) => {
|
|
|
let newAmount = e.target.value.replace(/[^0-9]/g, "");
|
|
|
if (newAmount > activeType.max_amount) newAmount = activeType.max_amount;
|
|
|
- if (newAmount < activeType.min_amount) newAmount = activeType.min_amount;
|
|
|
+ // if (newAmount < activeType.min_amount) newAmount = activeType.min_amount;
|
|
|
setAmount(newAmount);
|
|
|
};
|
|
|
|
|
|
const userRechargeRequest = async () => {
|
|
|
- if (amount < activeType.min_amount) return;
|
|
|
+ if (+amount < activeType.min_amount) {
|
|
|
+ Toast.show(`Min ${activeType.min_amount}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
let res = await getUserRechargeApi({
|
|
|
- amount: parseInt(amount as any),
|
|
|
+ amount: parseInt(amount),
|
|
|
channel_id: activeType.id,
|
|
|
});
|
|
|
if (res.code === 200) {
|
|
|
- setAmount(0);
|
|
|
+ setAmount("");
|
|
|
Toast.show({ icon: "success", content: t("RechargeSuc"), maskClickable: false });
|
|
|
}
|
|
|
};
|
|
|
const titleChangeHandler = (item: DepositsTypes, index: number) => {
|
|
|
- setAmount(0);
|
|
|
+ setAmount("");
|
|
|
setActiveType(item);
|
|
|
};
|
|
|
|
|
@@ -78,9 +80,9 @@ const DepositData: FC<Props> = (props) => {
|
|
|
<ul className="ul-box">
|
|
|
{activeType.products.map((item, index) => (
|
|
|
<li
|
|
|
- className={amount == item.amount ? "active" : ""}
|
|
|
+ className={+amount == item.amount ? "active" : ""}
|
|
|
key={index}
|
|
|
- onClick={() => setAmount(item.amount)}
|
|
|
+ onClick={() => setAmount(`${item.amount}`)}
|
|
|
>
|
|
|
{!!item.badge && <span className="hot"></span>}
|
|
|
<div className="amountContent">
|
|
@@ -96,10 +98,7 @@ const DepositData: FC<Props> = (props) => {
|
|
|
</div>
|
|
|
|
|
|
<div className="topUp">
|
|
|
- <ButtonOwn
|
|
|
- active={amount >= activeType.min_amount}
|
|
|
- callbackFun={userRechargeRequest}
|
|
|
- >
|
|
|
+ <ButtonOwn active={amount !== ""} callbackFun={userRechargeRequest}>
|
|
|
{t("DepositarAgora")}
|
|
|
</ButtonOwn>
|
|
|
<div className={"mt-[5px] text-[0.12rem] text-primary-color"}>
|