refactor: add gender selection to Form component and update DefaultSelect for improved option handling
This commit is contained in:
@@ -9,6 +9,8 @@ const defaultData = {
|
||||
phone: { value: "", isEdit: false },
|
||||
national_code: { value: "", isEdit: true },
|
||||
name: { value: "", isEdit: true },
|
||||
family: { value: "", isEdit: true },
|
||||
gender: { value: "", isEdit: true },
|
||||
basic_insurance: { value: "", isEdit: true },
|
||||
};
|
||||
|
||||
@@ -58,7 +60,9 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
||||
value: res.national_code || "",
|
||||
isEdit: res.national_code ? false : true,
|
||||
},
|
||||
name: { value: `${res.name} ${res.family}`, isEdit: true },
|
||||
name: { value: res.name || "", isEdit: true },
|
||||
family: { value: res.family || "", isEdit: true },
|
||||
gender: { value: res.gender || "", isEdit: true },
|
||||
basic_insurance: {
|
||||
value: res.basic_insurance,
|
||||
isEdit: true,
|
||||
@@ -68,7 +72,17 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
||||
setPrevData(newData);
|
||||
}
|
||||
} catch (error) {
|
||||
// خطا در دریافت پروفایل
|
||||
// اگر 404 بود، فقط شماره موبایل را نگه میداریم و بقیه قابل ویرایش میشوند
|
||||
if (error?.response?.status === 404) {
|
||||
setData(prev => ({
|
||||
...prev,
|
||||
national_code: { value: "", isEdit: true },
|
||||
name: { value: "", isEdit: true },
|
||||
family: { value: "", isEdit: true },
|
||||
gender: { value: "", isEdit: true },
|
||||
basic_insurance: { value: "", isEdit: true },
|
||||
}));
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -100,7 +114,9 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
||||
value: res.national_code || "",
|
||||
isEdit: res.national_code ? false : true,
|
||||
},
|
||||
name: { value: `${res.name} ${res.family}`, isEdit: true },
|
||||
name: { value: res.name || "", isEdit: true },
|
||||
family: { value: res.family || "", isEdit: true },
|
||||
gender: { value: res.gender || "", isEdit: true },
|
||||
basic_insurance: {
|
||||
value: res.basic_insurance,
|
||||
isEdit: true,
|
||||
@@ -110,7 +126,17 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
||||
setPrevData(newData);
|
||||
}
|
||||
} catch (error) {
|
||||
// خطا در دریافت پروفایل
|
||||
// اگر 404 بود، فقط شماره موبایل را نگه میداریم و بقیه قابل ویرایش میشوند
|
||||
if (error?.response?.status === 404) {
|
||||
setData(prev => ({
|
||||
...prev,
|
||||
national_code: { value: "", isEdit: true },
|
||||
name: { value: "", isEdit: true },
|
||||
family: { value: "", isEdit: true },
|
||||
gender: { value: "", isEdit: true },
|
||||
basic_insurance: { value: "", isEdit: true },
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user