|
@@ -1,32 +1,33 @@
|
|
|
"use client";
|
|
|
-import { DepositsTypes } from "@/api/depositsApi";
|
|
|
+import { Pay } from "@/api/promo";
|
|
|
import { getUserRechargeApi } from "@/api/user";
|
|
|
import Box from "@/components/Box";
|
|
|
+import ButtonOwn from "@/components/ButtonOwn";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
+import "@/styles/deposit.scss";
|
|
|
import { neReg } from "@/utils";
|
|
|
import { Form, Input, Toast } from "antd-mobile";
|
|
|
import { FormInstance } from "antd-mobile/es/components/form";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
-import { FC, Fragment, useRef, useState } from "react";
|
|
|
-
|
|
|
-import ButtonOwn from "@/components/ButtonOwn";
|
|
|
-import "@/styles/deposit.scss";
|
|
|
import Image from "next/image";
|
|
|
+import { FC, Fragment, useRef, useState } from "react";
|
|
|
interface Props {
|
|
|
- deposits: DepositsTypes[];
|
|
|
+ deposits: Pay[];
|
|
|
}
|
|
|
const DepositData: FC<Props> = (props) => {
|
|
|
const { deposits } = props;
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in DepositData.tsx on 19`, deposits);
|
|
|
const t = useTranslations();
|
|
|
const userInfo = useUserInfoStore((state) => state.userInfo);
|
|
|
|
|
|
- const count = 2;
|
|
|
// 选中类型
|
|
|
- const [activeType, setActiveType] = useState<DepositsTypes>(deposits[0]);
|
|
|
+ const [activeType, setActiveType] = useState<Pay>(deposits[0]);
|
|
|
+
|
|
|
+ const count = activeType.num === 0 ? "MAX" : activeType.num;
|
|
|
|
|
|
const formInstanceRef = useRef<FormInstance>(null);
|
|
|
let [amount, setAmount] = useState<number | undefined>(undefined);
|
|
|
- const titleChangeHandler = (item: DepositsTypes, index: number) => {
|
|
|
+ const titleChangeHandler = (item: Pay, index: number) => {
|
|
|
setAmount(undefined);
|
|
|
setActiveType(item);
|
|
|
formInstanceRef.current?.resetFields();
|
|
@@ -50,8 +51,9 @@ const DepositData: FC<Props> = (props) => {
|
|
|
});
|
|
|
};
|
|
|
const onValuesChange = (changeValues: any) => {
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in DepositData.tsx on 53`, changeValues);
|
|
|
if (changeValues.amount) {
|
|
|
- setAmount(changeValues.amount);
|
|
|
+ setAmount(+changeValues.amount);
|
|
|
}
|
|
|
};
|
|
|
const amountChange = (value: number) => {
|
|
@@ -59,15 +61,15 @@ const DepositData: FC<Props> = (props) => {
|
|
|
setAmount(value);
|
|
|
};
|
|
|
const amountValidator = (rules: any, value: any) => {
|
|
|
- if (!value) return Promise.reject(new Error(t("form.amount")));
|
|
|
- if (+value < activeType.min_amount)
|
|
|
- return Promise.reject(
|
|
|
- new Error(t("form.amountMinReg", { amount: activeType.min_amount }))
|
|
|
- );
|
|
|
- if (+value > activeType.max_amount)
|
|
|
- return Promise.reject(
|
|
|
- new Error(t("form.amountMaxReg", { amount: activeType.max_amount }))
|
|
|
- );
|
|
|
+ // if (!value) return Promise.reject(new Error(t("form.amount")));
|
|
|
+ // if (+value < activeType.min_amount)
|
|
|
+ // return Promise.reject(
|
|
|
+ // new Error(t("form.amountMinReg", { amount: activeType.min_amount }))
|
|
|
+ // );
|
|
|
+ // if (+value > activeType.max_amount)
|
|
|
+ // return Promise.reject(
|
|
|
+ // new Error(t("form.amountMaxReg", { amount: activeType.max_amount }))
|
|
|
+ // );
|
|
|
return Promise.resolve();
|
|
|
};
|
|
|
|
|
@@ -153,23 +155,19 @@ const DepositData: FC<Props> = (props) => {
|
|
|
label=""
|
|
|
rules={[{ required: true, type: "number", validator: amountValidator }]}
|
|
|
>
|
|
|
- <Input
|
|
|
- placeholder={`${t("DepositPage.Montante")}(BRL): Mín. ${activeType.min_amount}`}
|
|
|
- type={"number"}
|
|
|
- maxLength={activeType.max_amount}
|
|
|
- />
|
|
|
+ <Input placeholder={t("DepositPage.Montante")} type={"number"} />
|
|
|
</Form.Item>
|
|
|
|
|
|
<div className={"flex flex-col"}>
|
|
|
<div className={"flex-1"}>
|
|
|
<ul className="ul-box">
|
|
|
- {activeType.products.map((item, index) => (
|
|
|
+ {activeType.condition.map((item, index) => (
|
|
|
<li
|
|
|
- className={amount == item.amount ? "active" : ""}
|
|
|
+ className={amount === item.amount ? "active" : ""}
|
|
|
key={index}
|
|
|
onClick={() => amountChange(item.amount)}
|
|
|
>
|
|
|
- {!!item.badge && <span className="hot"></span>}
|
|
|
+ {/*{!!item.badge && <span className="hot"></span>}*/}
|
|
|
<div className="amountContent">
|
|
|
{/* <span className="iconfont icon-unit-brl"></span> */}
|
|
|
<span className="iconfont">R$</span>
|