fix(dashboard): account selects store option id, not label match
DefaultSelect's onChange passes the whole option object {label,id}, but
the gender/blood_type/marital/education/job handlers compared it as a
string (education/blood via find(g=>g.label===value), others via ===),
so the value never stored — education in particular always saved empty.
Read option?.id uniformly across all five selects.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -74,9 +74,7 @@ function Form({ insurance, errors, changeData, information }) {
|
||||
<Content req={true} error={errors?.gender} title="جنسیت">
|
||||
<DefaultSelect
|
||||
error={errors?.gender}
|
||||
updateData={(name, data) =>
|
||||
changeData(data === "زن" ? "female" : "male", name)
|
||||
}
|
||||
updateData={(name, option) => changeData(option?.id ?? "", name)}
|
||||
value={findVal(gender, "gender")}
|
||||
label="جنسیت"
|
||||
name="gender"
|
||||
@@ -143,9 +141,7 @@ function Form({ insurance, errors, changeData, information }) {
|
||||
<Content req={true} error={errors?.blood_type} title="گروه خونی">
|
||||
<DefaultSelect
|
||||
error={errors?.blood_type}
|
||||
updateData={(name, value) =>
|
||||
changeData(blood_group.find((g) => g.label === value)?.id ?? "", name)
|
||||
}
|
||||
updateData={(name, option) => changeData(option?.id ?? "", name)}
|
||||
value={findVal(blood_group, "blood_type")}
|
||||
label="گروه خونی"
|
||||
name="blood_type"
|
||||
@@ -155,9 +151,7 @@ function Form({ insurance, errors, changeData, information }) {
|
||||
<Content req={true} error={errors?.marital_status} title="وضعیت تاهل">
|
||||
<DefaultSelect
|
||||
error={errors?.marital_status}
|
||||
updateData={(name, value) =>
|
||||
changeData(value === "متاهل" ? "married" : "single", name)
|
||||
}
|
||||
updateData={(name, option) => changeData(option?.id ?? "", name)}
|
||||
value={findVal(marital_status, "marital_status")}
|
||||
label="وضعیت تاهل"
|
||||
name="marital_status"
|
||||
@@ -177,9 +171,7 @@ function Form({ insurance, errors, changeData, information }) {
|
||||
<Content req={true} error={errors?.education} title="تحصیلات">
|
||||
<DefaultSelect
|
||||
error={errors?.education}
|
||||
updateData={(name, value) =>
|
||||
changeData(education.find((g) => g.label === value)?.id ?? "", name)
|
||||
}
|
||||
updateData={(name, option) => changeData(option?.id ?? "", name)}
|
||||
value={findVal(education, "education")}
|
||||
label="تحصیلات"
|
||||
name="education"
|
||||
@@ -189,9 +181,7 @@ function Form({ insurance, errors, changeData, information }) {
|
||||
<Content req={true} error={errors?.job} title="شغل">
|
||||
<DefaultSelect
|
||||
error={errors?.job}
|
||||
updateData={(name, value) =>
|
||||
changeData(value === "آزاد" ? "azad" : "dolati", name)
|
||||
}
|
||||
updateData={(name, option) => changeData(option?.id ?? "", name)}
|
||||
value={findVal(job, "job")}
|
||||
label="شغل"
|
||||
name="job"
|
||||
|
||||
Reference in New Issue
Block a user