change fields component & handle edit, delete, add data and save & change functional page doctor
This commit is contained in:
@@ -11,20 +11,14 @@ import {
|
||||
job,
|
||||
} from "./listSelector";
|
||||
|
||||
function Form({
|
||||
data,
|
||||
userInfo,
|
||||
insurance,
|
||||
errors,
|
||||
prevInfo,
|
||||
changeData,
|
||||
prevData,
|
||||
}) {
|
||||
function Form({ insurance, errors, changeData, information }) {
|
||||
const findVal = (list, name) =>
|
||||
data && list && list.length && list.find((g) => g.id === data[name]);
|
||||
console.log(errors);
|
||||
list &&
|
||||
list.length &&
|
||||
information &&
|
||||
information[name] &&
|
||||
list.find((g) => g.id === information[name]);
|
||||
const parsedUserInfo = getParsedUserInfo();
|
||||
console.log(parsedUserInfo);
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-x-[24px] gap-y-[10px]">
|
||||
@@ -36,7 +30,7 @@ function Form({
|
||||
name="work_phone"
|
||||
isTransparent={true}
|
||||
changeData={changeData}
|
||||
data={userInfo?.username}
|
||||
data={parsedUserInfo?.username}
|
||||
/>
|
||||
</Content>
|
||||
<Content error={errors?.national_code} title="کد ملی" isConfirmed={false}>
|
||||
@@ -47,8 +41,8 @@ function Form({
|
||||
name="national_code"
|
||||
isTransparent={true}
|
||||
changeData={changeData}
|
||||
data={data?.national_code}
|
||||
disable={prevInfo && prevInfo.national_code}
|
||||
data={information?.national_code}
|
||||
disable={information?.prev_data}
|
||||
/>
|
||||
</Content>
|
||||
<Content error={errors?.name} title="نام" isConfirmed={false}>
|
||||
@@ -57,7 +51,7 @@ function Form({
|
||||
isTransparent={true}
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
data={data?.name}
|
||||
data={information?.name}
|
||||
name="name"
|
||||
/>
|
||||
</Content>
|
||||
@@ -67,7 +61,7 @@ function Form({
|
||||
isTransparent={true}
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
data={data?.family}
|
||||
data={information?.family}
|
||||
name="family"
|
||||
/>
|
||||
</Content>
|
||||
@@ -86,7 +80,7 @@ function Form({
|
||||
<Content error={errors?.birthday} title="تاریخ تولد">
|
||||
<DateBirthday
|
||||
error={errors?.birthday}
|
||||
data={data?.birthday}
|
||||
data={information?.birthday}
|
||||
isConfirmed={false}
|
||||
changeData={changeData}
|
||||
/>
|
||||
@@ -97,18 +91,23 @@ function Form({
|
||||
isTransparent={true}
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
data={data?.fathers_name}
|
||||
data={information?.fathers_name}
|
||||
name="fathers_name"
|
||||
/>
|
||||
</Content>
|
||||
<Content title="نوع بیمه">
|
||||
<Content error={errors?.basic_insurance} title="نوع بیمه">
|
||||
<AutoSelector
|
||||
error={errors?.basic_insurance}
|
||||
updateData={(name, val) => {
|
||||
changeData([Number(val.id)], name);
|
||||
}}
|
||||
// value={findVal(insurance, "basic_insurance", true)?.name}
|
||||
value={insurance?.find(
|
||||
(g) => Number(g.id) === data.basic_insurance[0]
|
||||
(g) =>
|
||||
Number(g.id) ===
|
||||
(information?.basic_insurance
|
||||
? information?.basic_insurance[0]
|
||||
: false)
|
||||
)}
|
||||
name="basic_insurance"
|
||||
label="نوع بیمه"
|
||||
@@ -126,9 +125,9 @@ function Form({
|
||||
iconGray={true}
|
||||
type="number"
|
||||
changeData={changeData}
|
||||
data={data?.insurance_id}
|
||||
data={information?.insurance_id}
|
||||
name="insurance_id"
|
||||
// data={data?.supplementary_insurance}
|
||||
// data={information?.supplementary_insurance}
|
||||
// name="supplementary_insurance"
|
||||
/>
|
||||
</Content>
|
||||
@@ -162,7 +161,7 @@ function Form({
|
||||
iconGray={true}
|
||||
type="number"
|
||||
changeData={changeData}
|
||||
data={data?.home_phone}
|
||||
data={information?.home_phone}
|
||||
name="home_phone"
|
||||
/>
|
||||
</Content>
|
||||
@@ -170,10 +169,7 @@ function Form({
|
||||
<AutoSelector
|
||||
error={errors?.education}
|
||||
updateData={(name, value) =>
|
||||
changeData(
|
||||
education.find((g) => g.label === value).id,
|
||||
name
|
||||
)
|
||||
changeData(education.find((g) => g.label === value).id, name)
|
||||
}
|
||||
value={findVal(education, "education")}
|
||||
label="تحصیلات"
|
||||
@@ -199,7 +195,7 @@ function Form({
|
||||
type="number"
|
||||
iconGray={true}
|
||||
changeData={changeData}
|
||||
data={data?.work_phone}
|
||||
data={information?.work_phone}
|
||||
name="work_phone"
|
||||
/>
|
||||
</Content>
|
||||
|
||||
Reference in New Issue
Block a user