204 lines
6.1 KiB
JavaScript
204 lines
6.1 KiB
JavaScript
import { getParsedUserInfo } from "@/helper";
|
|
import Content from "./Content";
|
|
import DateBirthday from "./DateBirthday";
|
|
import AutoSelector from "./component/AutoSelector";
|
|
import Field from "./component/Field";
|
|
import {
|
|
gender,
|
|
blood_group,
|
|
marital_status,
|
|
education,
|
|
job,
|
|
} from "./listSelector";
|
|
|
|
function Form({ insurance, errors, changeData, information }) {
|
|
const findVal = (list, name) =>
|
|
list &&
|
|
list.length &&
|
|
information &&
|
|
information[name] &&
|
|
list.find((g) => g.id === information[name]);
|
|
const parsedUserInfo = getParsedUserInfo();
|
|
|
|
return (
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-x-[24px] gap-y-[10px]">
|
|
<Content title="شماره موبایل" isConfirmed={true}>
|
|
<Field
|
|
type="number"
|
|
disable={true}
|
|
iconGray={true}
|
|
name="work_phone"
|
|
isTransparent={true}
|
|
changeData={changeData}
|
|
data={parsedUserInfo?.username}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.national_code} title="کد ملی" isConfirmed={false}>
|
|
<Field
|
|
error={errors?.national_code}
|
|
type="number"
|
|
iconGray={true}
|
|
name="national_code"
|
|
isTransparent={true}
|
|
changeData={changeData}
|
|
data={information?.national_code}
|
|
disable={information?.prev_data}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.name} title="نام" isConfirmed={false}>
|
|
<Field
|
|
error={errors?.name}
|
|
isTransparent={true}
|
|
iconGray={true}
|
|
changeData={changeData}
|
|
data={information?.name}
|
|
name="name"
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.family} title="نام خانوادگی" isConfirmed={false}>
|
|
<Field
|
|
error={errors?.family}
|
|
isTransparent={true}
|
|
iconGray={true}
|
|
changeData={changeData}
|
|
data={information?.family}
|
|
name="family"
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.gender} title="جنسیت">
|
|
<AutoSelector
|
|
error={errors?.gender}
|
|
updateData={(name, data) =>
|
|
changeData(data === "زن" ? "female" : "male", name)
|
|
}
|
|
value={findVal(gender, "gender")}
|
|
label="جنسیت"
|
|
name="gender"
|
|
list={gender}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.birthday} title="تاریخ تولد">
|
|
<DateBirthday
|
|
error={errors?.birthday}
|
|
data={information?.birthday}
|
|
isConfirmed={false}
|
|
changeData={changeData}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.fathers_name} title="نام پدر" isConfirmed={false}>
|
|
<Field
|
|
error={errors?.fathers_name}
|
|
isTransparent={true}
|
|
iconGray={true}
|
|
changeData={changeData}
|
|
data={information?.fathers_name}
|
|
name="fathers_name"
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.basic_insurance} title="نوع بیمه">
|
|
<AutoSelector
|
|
error={errors?.basic_insurance}
|
|
updateData={(name, val) => {
|
|
changeData([Number(val.id)], name);
|
|
}}
|
|
value={insurance?.find(
|
|
(g) =>
|
|
Number(g.id) ===
|
|
(information?.basic_insurance
|
|
? information?.basic_insurance[0]
|
|
: false)
|
|
)}
|
|
name="basic_insurance"
|
|
label="نوع بیمه"
|
|
list={insurance}
|
|
/>
|
|
</Content>
|
|
<Content
|
|
error={errors?.insurance_id}
|
|
title="شماره بیمه"
|
|
isConfirmed={false}
|
|
>
|
|
<Field
|
|
error={errors?.insurance_id}
|
|
isTransparent={true}
|
|
iconGray={true}
|
|
type="number"
|
|
changeData={changeData}
|
|
data={information?.insurance_id}
|
|
name="insurance_id"
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.blood_type} title="گروه خونی">
|
|
<AutoSelector
|
|
error={errors?.blood_type}
|
|
updateData={(name, value) =>
|
|
changeData(blood_group.find((g) => g.label === value).id, name)
|
|
}
|
|
value={findVal(blood_group, "blood_type")}
|
|
label="گروه خونی"
|
|
name="blood_type"
|
|
list={blood_group}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.marital_status} title="وضعیت تاهل">
|
|
<AutoSelector
|
|
error={errors?.marital_status}
|
|
updateData={(name, value) =>
|
|
changeData(value === "متاهل" ? "married" : "single", name)
|
|
}
|
|
value={findVal(marital_status, "marital_status")}
|
|
label="وضعیت تاهل"
|
|
name="marital_status"
|
|
list={marital_status}
|
|
/>
|
|
</Content>
|
|
<Content title="تلفن منزل" isConfirmed={false}>
|
|
<Field
|
|
isTransparent={true}
|
|
iconGray={true}
|
|
type="number"
|
|
changeData={changeData}
|
|
data={information?.home_phone}
|
|
name="home_phone"
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.education} title="تحصیلات">
|
|
<AutoSelector
|
|
error={errors?.education}
|
|
updateData={(name, value) =>
|
|
changeData(education.find((g) => g.label === value).id, name)
|
|
}
|
|
value={findVal(education, "education")}
|
|
label="تحصیلات"
|
|
name="education"
|
|
list={education}
|
|
/>
|
|
</Content>
|
|
<Content error={errors?.job} title="شغل">
|
|
<AutoSelector
|
|
error={errors?.job}
|
|
updateData={(name, value) =>
|
|
changeData(value === "آزاد" ? "azad" : "dolati", name)
|
|
}
|
|
value={findVal(job, "job")}
|
|
label="شغل"
|
|
name="job"
|
|
list={job}
|
|
/>
|
|
</Content>
|
|
<Content title="تلفن محل کار" isConfirmed={false}>
|
|
<Field
|
|
isTransparent={true}
|
|
type="number"
|
|
iconGray={true}
|
|
changeData={changeData}
|
|
data={information?.work_phone}
|
|
name="work_phone"
|
|
/>
|
|
</Content>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default Form;
|