|
@@ -13,7 +13,7 @@ import { useEventPoint } from "@/hooks/useEventPoint";
|
|
|
import { useRouter } from "@/i18n/routing";
|
|
|
import { useSystemStore } from "@/stores/useSystemStore";
|
|
|
import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
-import { goBlankPage } from "@/utils";
|
|
|
+import { goBlankPage, inputNumber } from "@/utils";
|
|
|
import { Button, Dialog, Form, Input, Toast } from "antd-mobile";
|
|
|
import BigNumber from "bignumber.js";
|
|
|
import clsx from "clsx";
|
|
@@ -200,7 +200,13 @@ const Deposit = () => {
|
|
|
if (!confirmRes) return;
|
|
|
}
|
|
|
|
|
|
- if (!amount) return Toast.show({ content: t("form.amount") });
|
|
|
+ if (new BigNumber(amount).isLessThan(shopType.condition.min)) {
|
|
|
+ let msg = t("form.amountMinReg", { amount: shopType.condition.min });
|
|
|
+ return Toast.show({ content: msg });
|
|
|
+ }
|
|
|
+ if (!amount) {
|
|
|
+ return Toast.show({ content: t("form.amount") });
|
|
|
+ }
|
|
|
|
|
|
handleUserRecharge(false);
|
|
|
};
|
|
@@ -256,6 +262,36 @@ const Deposit = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const valuesChange = (data: any) => {
|
|
|
+ for (let key in data) {
|
|
|
+ switch (key) {
|
|
|
+ case "amount":
|
|
|
+ {
|
|
|
+ let curValue = data[key].trim();
|
|
|
+ let max = shopType.condition.max;
|
|
|
+ if (curValue > max) {
|
|
|
+ curValue = new BigNumber(max).toFixed(0, BigNumber.ROUND_DOWN);
|
|
|
+ }
|
|
|
+ const toValue = inputNumber(curValue, { max });
|
|
|
+ setAmount(toValue);
|
|
|
+ formInstanceRef.current?.setFieldValue(key, toValue);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "passport":
|
|
|
+ {
|
|
|
+ let curValue = data[key].trim();
|
|
|
+ const toValue = inputNumber(curValue, { length: 11, notNumber: true });
|
|
|
+ formInstanceRef.current?.setFieldValue(key, toValue);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ let curValue = data[key].trim();
|
|
|
+ formInstanceRef.current?.setFieldValue(key, curValue);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<div className={styles.depositePage}>
|
|
@@ -296,7 +332,12 @@ const Deposit = () => {
|
|
|
))}
|
|
|
</Swiper>
|
|
|
</div>
|
|
|
- <Form className="mt-[.1rem]" ref={formInstanceRef} onFinish={onFinish}>
|
|
|
+ <Form
|
|
|
+ className="mt-[.1rem]"
|
|
|
+ ref={formInstanceRef}
|
|
|
+ onFinish={onFinish}
|
|
|
+ onValuesChange={valuesChange}
|
|
|
+ >
|
|
|
{formProd && (
|
|
|
<Form.Item
|
|
|
name="amount"
|
|
@@ -315,7 +356,6 @@ const Deposit = () => {
|
|
|
<Input
|
|
|
type={"text"}
|
|
|
className={styles.amountInput}
|
|
|
- max={shopType?.condition?.max}
|
|
|
onChange={inputChange}
|
|
|
placeholder={`${shopType?.condition?.min}-${shopType?.condition?.max}`}
|
|
|
/>
|
|
@@ -367,6 +407,7 @@ const Deposit = () => {
|
|
|
name="name"
|
|
|
label="Nome"
|
|
|
className="mr-[.2rem] w-[1.5rem] border-b-[1px] border-[#3b4852]"
|
|
|
+ rules={[{ required: true }]}
|
|
|
>
|
|
|
<Input type={"text"} placeholder="Insira seu nome " />
|
|
|
</Form.Item>
|
|
@@ -374,6 +415,7 @@ const Deposit = () => {
|
|
|
name="lastname"
|
|
|
label="Sobrenome"
|
|
|
className="flex-1 border-b-[1px] border-[#3b4852]"
|
|
|
+ rules={[{ required: true }]}
|
|
|
>
|
|
|
<Input type={"text"} placeholder="Insira seu sobrenome" />
|
|
|
</Form.Item>
|
|
@@ -382,6 +424,7 @@ const Deposit = () => {
|
|
|
name="passport"
|
|
|
label="CPF ID"
|
|
|
className="border-b-[1px] border-[#3b4852]"
|
|
|
+ rules={[{ required: true }]}
|
|
|
>
|
|
|
<Input type={"text"} placeholder="Seu CPF(000.000.000-00)" />
|
|
|
</Form.Item>
|