year il y a 2 mois
Parent
commit
e7deea2b83

+ 4 - 0
src/api/depositsApi.ts

@@ -71,6 +71,10 @@ export interface ShopItem {
     name: string;
     img: string;
     pay_channel: PayChannel[];
+    condition: {
+        min: number;
+        max: number;
+    };
 }
 
 export const getShopListApi = () => {

+ 24 - 14
src/app/[locale]/(TabBar)/deposit/DepositData.tsx

@@ -25,6 +25,7 @@ interface Props {
     channel?: PayChannel[];
     currentChannel?: PayChannel;
     setChannel?: (data: PayChannel) => void;
+    currentShop?: ShopInfo;
 }
 
 const getDepositApi = async () => {
@@ -40,7 +41,7 @@ const getDepositApi = async () => {
         });
 };
 const DepositData: FC<Props> = (props) => {
-    const { shopInfo, channel, currentChannel, setChannel } = props;
+    const { shopInfo, channel, currentChannel, setChannel, currentShop } = props;
     const t = useTranslations();
     // const router = useRouter();
     const userInfo = useUserInfoStore((state) => state.userInfo);
@@ -100,6 +101,7 @@ const DepositData: FC<Props> = (props) => {
             setFormData(params);
             return;
         }
+
         handleUserRecharge(false, params);
     };
     // const handleUserRecharge = (type: boolean) => {};
@@ -141,16 +143,24 @@ const DepositData: FC<Props> = (props) => {
         setAmount(value);
     };
     const amountValidator = (rules: any, value: any) => {
-        if (!value) return Promise.reject(new Error(t("form.amount")));
-        if (shopInfo?.condition) {
-            if (+value < shopInfo.condition.min)
-                return Promise.reject(
-                    new Error(t("form.amountMinReg", { amount: shopInfo.condition.min }))
-                );
-            if (+value > shopInfo.condition.max)
-                return Promise.reject(
-                    new Error(t("form.amountMaxReg", { amount: shopInfo.condition.max }))
-                );
+        if (!value) {
+            let msg = t("form.amount");
+            Toast.show({ content: msg, maskClickable: false });
+
+            return Promise.reject(new Error(msg));
+        }
+        if (currentShop?.condition) {
+            if (+value < currentShop.condition.min) {
+                let msg = t("form.amountMinReg", { amount: currentShop.condition.min });
+                Toast.show({ content: msg, maskClickable: false });
+
+                return Promise.reject(new Error(msg));
+            }
+            if (+value > currentShop.condition.max) {
+                let msg = t("form.amountMaxReg", { amount: currentShop.condition.max });
+                Toast.show({ content: msg, maskClickable: false });
+                return Promise.reject(new Error(msg));
+            }
         }
 
         return Promise.resolve();
@@ -224,12 +234,12 @@ const DepositData: FC<Props> = (props) => {
                         name="amount"
                         label=""
                         rules={[{ required: true, type: "number", validator: amountValidator }]}
-                        // style={{ display: shopInfo?.type === 2 ? "block" : "none" }}
+                        style={{ display: shopInfo?.type === 2 ? "block" : "none" }}
                     >
                         <Input
-                            placeholder={`${t("DepositPage.Montante")}: (${shopInfo?.condition?.min}-${shopInfo?.condition?.max})`}
+                            placeholder={`${t("DepositPage.Montante")}: (${currentShop?.condition?.min}-${currentShop?.condition?.max})`}
                             type={"number"}
-                            maxLength={shopInfo?.condition?.max}
+                            maxLength={currentShop?.condition?.max}
                         />
                     </Form.Item>
 

+ 1 - 0
src/app/[locale]/(TabBar)/deposit/page.tsx

@@ -80,6 +80,7 @@ const Deposit = () => {
                         setChannel={doChangeChannel}
                         shopInfo={shopInfo}
                         channel={currentShop?.pay_channel || []}
+                        currentShop={currentShop}
                     />
                 )}
                 {loading && (