change type field number in all page
This commit is contained in:
@@ -10,6 +10,11 @@ import AddLocationP from "@/components/icons/AddLocationP";
|
||||
import { Button } from "@mui/material";
|
||||
import ArrowLeftButtonP from "@/components/icons/ArrowLeftButtonP";
|
||||
|
||||
const validate_phone_number = {
|
||||
min: 1,
|
||||
max: 9999999999,
|
||||
};
|
||||
|
||||
function Form() {
|
||||
const [data, setData] = useState({
|
||||
name: { value: "احسان احمدی", isEdit: true },
|
||||
@@ -35,6 +40,13 @@ function Form() {
|
||||
},
|
||||
});
|
||||
|
||||
const updateNum = (value, type, name) => {
|
||||
const parseValue = +value;
|
||||
const { max } = validate_phone_number;
|
||||
const validateValue = parseValue > max ? data[name].value : value;
|
||||
changeData(validateValue, type, name);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start justify-start mt-[24px] md:mt-[28px] lg:mt-[32px] gap-[32px] md:gap-[40px] lg:gap-[48px]">
|
||||
<ul className="grid w-full grid-cols-1 md:grid-cols-2 gap-x-[48px] gap-y-[24px] md:gap-y-[28px] lg:gap-y-[32px]">
|
||||
@@ -51,9 +63,15 @@ function Form() {
|
||||
<EditField
|
||||
isTransparent={true}
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
changeData={updateNum}
|
||||
data={data?.national_code}
|
||||
noDisable={true}
|
||||
type="number"
|
||||
placeholder="کد ملی"
|
||||
name="national_code"
|
||||
props={{
|
||||
inputProps: validate_phone_number,
|
||||
}}
|
||||
/>
|
||||
</ContentText>
|
||||
<ContentText text="استان">
|
||||
@@ -86,24 +104,34 @@ function Form() {
|
||||
<ContentText text="شماره موبایل">
|
||||
<EditField
|
||||
isTransparent={true}
|
||||
placeholder="شماره موبایل"
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
changeData={updateNum}
|
||||
data={data?.phone}
|
||||
noDisable={true}
|
||||
type="number"
|
||||
placeholder="شماره موبایل"
|
||||
name="phone"
|
||||
props={{
|
||||
inputProps: validate_phone_number,
|
||||
}}
|
||||
/>
|
||||
</ContentText>
|
||||
<ContentText text="شماره حساب">
|
||||
<EditField
|
||||
isTransparent={true}
|
||||
placeholder="شماره حساب"
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
changeData={updateNum}
|
||||
data={data?.account_number}
|
||||
noDisable={true}
|
||||
type="number"
|
||||
placeholder="شماره حساب"
|
||||
name="account_number"
|
||||
props={{
|
||||
inputProps: validate_phone_number,
|
||||
}}
|
||||
/>
|
||||
</ContentText>
|
||||
<ContentText text="شهر">
|
||||
<ContentText text="بانک">
|
||||
<AutoCompleteSelect
|
||||
updateData={updateSelect}
|
||||
label="انتخاب کنید..."
|
||||
|
||||
Reference in New Issue
Block a user