Commit 36017455 authored by Sakthivel G's avatar Sakthivel G
Browse files

Merge branch 'fixes-3.0.0' into 'release-3.0.0'

fix: resolve applications loading issue in inspector page

See merge request smf/smf-web!29
Showing with 55 additions and 52 deletions
+55 -52
......@@ -67,7 +67,7 @@ export const InspectorApplications = ({ data }: InspectorApplicationsProps) => {
setSelectedTab("Scheduled today");
}
let user: any = userDetails.length && JSON.parse(userDetails);
let user: any = userDetails && JSON.parse(userDetails);
setUserDetails(user);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
......@@ -100,68 +100,69 @@ export const InspectorApplications = ({ data }: InspectorApplicationsProps) => {
(response) => {
if (response.statusInfo.statusCode === APP.CODE.SUCCESS) {
response.responseData.map((i: any, j: number) => {
if (
i.inspection.status === LANG.FORM_STATUS.SENT_FOR_INSPECTION &&
i.inspection.leadInspector.includes(
userDetails && userDetails.id
)
) {
if (i.inspection) {
if (
moment(todayDate, "DD-MM-YYYY").isBefore(
moment(i.inspection.scheduledDate, "DD-MM-YYYY")
i.inspection.status ===
LANG.FORM_STATUS.SENT_FOR_INSPECTION &&
i.inspection.leadInspector.includes(
userDetails && userDetails.id
)
) {
setUpcoming((upcoming) => [...upcoming, i]);
} else if (
moment(todayDate, "DD-MM-YYYY").isSame(
moment(i.inspection.scheduledDate, "DD-MM-YYYY")
if (
moment(todayDate, "DD-MM-YYYY").isBefore(
moment(i.inspection.scheduledDate, "DD-MM-YYYY")
)
) {
setUpcoming((upcoming) => [...upcoming, i]);
} else if (
moment(todayDate, "DD-MM-YYYY").isSame(
moment(i.inspection.scheduledDate, "DD-MM-YYYY")
)
) {
setScheduledToday((today) => [...today, i]);
} else {
setPast((past) => [...past, i]);
}
}
if (
(i.inspection.status ===
LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED ||
i.inspection.status ===
LANG.FORM_STATUS.INSPECTION_COMPLETED) &&
i.inspection.leadInspector.includes(
userDetails && userDetails.id
)
) {
setScheduledToday((today) => [...today, i]);
} else {
setPast((past) => [...past, i]);
}
}
if (
(i.inspection.status ===
LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED ||
if (
i.inspection.status ===
LANG.FORM_STATUS.INSPECTION_COMPLETED) &&
i.inspection.leadInspector.includes(
userDetails && userDetails.id
)
) {
setPast((past) => [...past, i]);
}
if (
i.inspection.status === LANG.FORM_STATUS.INSPECTION_COMPLETED &&
i.inspection.assistingInspector.includes(
userDetails && userDetails.id
)
) {
setPast((past) => [...past, i]);
}
if (
i.inspection.status ===
LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED &&
i.inspection.assistingInspector.includes(
userDetails && userDetails.id
)
) {
// consol
i.inspection.assignedTo.map((m: any, n: number) => {
if (m.id === userDetails.id) {
// if (m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED) {
LANG.FORM_STATUS.INSPECTION_COMPLETED &&
i.inspection.assistingInspector.includes(
userDetails && userDetails.id
)
) {
setPast((past) => [...past, i]);
}
if (
i.inspection.status ===
LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED &&
i.inspection.assistingInspector.includes(
userDetails && userDetails.id
)
) {
i.inspection.assignedTo.map((m: any, n: number) => {
if (m.id === userDetails.id) {
// if (m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED) {
setPast((past) => [...past, i]);
// }
// }
return null;
}
return null;
}
return null;
});
});
}
}
return null;
});
} else {
......
......@@ -82,6 +82,7 @@ export const InspectorHome = ({ data }: InspectorProps) => {
if (response.statusInfo.statusCode === APP.CODE.SUCCESS) {
response.responseData.map((i: any, j: number) => {
if (
i.inspection &&
i.inspection.leadInspector.includes(
userDetails && userDetails.id
) &&
......@@ -121,6 +122,7 @@ export const InspectorHome = ({ data }: InspectorProps) => {
if (response.statusInfo.statusCode === APP.CODE.SUCCESS) {
response.responseData.map((i: any, j: number) => {
if (
i.inspection &&
i.inspection.status ===
LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED &&
!i.inspection.leadInspector.includes(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment