fix(dashboard): guard select .find().id crashes in account form
Clearing the blood type / education / insurance selects made .find(...).id (and val.id) read .id on undefined, crashing the account form. Use optional chaining with empty-string/empty-array fallbacks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -110,7 +110,7 @@ function Form({ insurance, errors, changeData, information }) {
|
|||||||
<DefaultSelect
|
<DefaultSelect
|
||||||
error={errors?.basic_insurance}
|
error={errors?.basic_insurance}
|
||||||
updateData={(name, val) => {
|
updateData={(name, val) => {
|
||||||
changeData([Number(val.id)], name);
|
changeData(val?.id ? [Number(val.id)] : [], name);
|
||||||
}}
|
}}
|
||||||
value={insurance?.find(
|
value={insurance?.find(
|
||||||
(g) =>
|
(g) =>
|
||||||
@@ -144,7 +144,7 @@ function Form({ insurance, errors, changeData, information }) {
|
|||||||
<DefaultSelect
|
<DefaultSelect
|
||||||
error={errors?.blood_type}
|
error={errors?.blood_type}
|
||||||
updateData={(name, value) =>
|
updateData={(name, value) =>
|
||||||
changeData(blood_group.find((g) => g.label === value).id, name)
|
changeData(blood_group.find((g) => g.label === value)?.id ?? "", name)
|
||||||
}
|
}
|
||||||
value={findVal(blood_group, "blood_type")}
|
value={findVal(blood_group, "blood_type")}
|
||||||
label="گروه خونی"
|
label="گروه خونی"
|
||||||
@@ -178,7 +178,7 @@ function Form({ insurance, errors, changeData, information }) {
|
|||||||
<DefaultSelect
|
<DefaultSelect
|
||||||
error={errors?.education}
|
error={errors?.education}
|
||||||
updateData={(name, value) =>
|
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")}
|
value={findVal(education, "education")}
|
||||||
label="تحصیلات"
|
label="تحصیلات"
|
||||||
|
|||||||
Reference in New Issue
Block a user