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:
hamed
2026-06-15 16:54:11 +03:30
co-authored by Claude Opus 4.8
parent e820cc88ee
commit 969e915815
2 changed files with 9 additions and 6 deletions
+6 -4
View File
@@ -36,15 +36,17 @@ function Detail({
useEffect(() => {
// دریافت لیست بیمه پایه
request.getInsuranceType().then((res) => {
if (res && res.data) {
setInsurance(res.data);
const items = res?.data?.data;
if (Array.isArray(items)) {
setInsurance(items);
}
});
// دریافت لیست بیمه تکمیلی
request.getSupplementaryInsurance().then((res) => {
if (res && res.data) {
setSupplementaryInsurance(res.data);
const items = res?.data?.data;
if (Array.isArray(items)) {
setSupplementaryInsurance(items);
}
});
}, []);
@@ -16,8 +16,9 @@ function Information({ information, setInformation }) {
const parsedUserInfo = getParsedUserInfo();
request.getInsuranceType().then((res) => {
if (res && res.data) {
setInsurance(res.data);
const items = res?.data?.data;
if (Array.isArray(items)) {
setInsurance(items);
}
});