fix(appointment): extract insurance list from double-nested response
GET /api/v1/insurances returns success(['data' => items]) → the body is
{ data: { data: [...] } }, so after the interceptor unwraps once the
array lives at res.data.data, not res.data. The callers set the list to
the wrapper object, so insurance.find threw 'not a function'. Read
res.data.data and guard with Array.isArray in both the booking detail
form and the dashboard insurance loader.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -36,15 +36,17 @@ function Detail({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// دریافت لیست بیمه پایه
|
// دریافت لیست بیمه پایه
|
||||||
request.getInsuranceType().then((res) => {
|
request.getInsuranceType().then((res) => {
|
||||||
if (res && res.data) {
|
const items = res?.data?.data;
|
||||||
setInsurance(res.data);
|
if (Array.isArray(items)) {
|
||||||
|
setInsurance(items);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// دریافت لیست بیمه تکمیلی
|
// دریافت لیست بیمه تکمیلی
|
||||||
request.getSupplementaryInsurance().then((res) => {
|
request.getSupplementaryInsurance().then((res) => {
|
||||||
if (res && res.data) {
|
const items = res?.data?.data;
|
||||||
setSupplementaryInsurance(res.data);
|
if (Array.isArray(items)) {
|
||||||
|
setSupplementaryInsurance(items);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ function Information({ information, setInformation }) {
|
|||||||
const parsedUserInfo = getParsedUserInfo();
|
const parsedUserInfo = getParsedUserInfo();
|
||||||
|
|
||||||
request.getInsuranceType().then((res) => {
|
request.getInsuranceType().then((res) => {
|
||||||
if (res && res.data) {
|
const items = res?.data?.data;
|
||||||
setInsurance(res.data);
|
if (Array.isArray(items)) {
|
||||||
|
setInsurance(items);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user