From fd8e406be02e7fdf9b96fc769c34c2fcd9ed7acd Mon Sep 17 00:00:00 2001 From: SakthivelG <sakthivel.govindan@tarento.com> Date: Thu, 24 Mar 2022 15:00:39 +0530 Subject: [PATCH] fix: defect id 57749 --- src/components/dashboard/Dashboard.js | 25 +++-- src/components/form/FormViewer.js | 18 ++-- src/components/status-bar/StatusBarLarge.tsx | 13 ++- src/layouts/Inspector/ConsentFormView.tsx | 2 +- .../Regulator/ReviewApplicationLayout.tsx | 4 +- src/pages/Inspector/InspectorApplications.tsx | 6 +- src/pages/Reviewer/ReviewerHome.tsx | 100 ++++++++++-------- 7 files changed, 96 insertions(+), 72 deletions(-) diff --git a/src/components/dashboard/Dashboard.js b/src/components/dashboard/Dashboard.js index 0f0ea35..230f998 100644 --- a/src/components/dashboard/Dashboard.js +++ b/src/components/dashboard/Dashboard.js @@ -21,6 +21,8 @@ class Dashboard extends Component { forms: [], myApplications: [], }; + + this.getInstituteApplications = this.getInstituteApplications.bind(); } formatDate(dateParam) { @@ -35,6 +37,12 @@ class Dashboard extends Component { } componentDidMount() { + setTimeout(() => { + this.getInstituteApplications(); + }, 500); + } + + getInstituteApplications = () => { if (Helper.getUserRole() === APP.ROLE.INSTITUTION) { FormService.get().then( (response) => { @@ -58,10 +66,8 @@ class Dashboard extends Component { ); // my applications section const myApplicationsReq = { - "searchObjects": [ - - ] - } + searchObjects: [], + }; FormService.getAllApplications(myApplicationsReq).then( (response2) => { if (response2.statusInfo.statusCode === APP.CODE.SUCCESS) { @@ -83,7 +89,7 @@ class Dashboard extends Component { } ); } - } + }; render() { return ( @@ -135,10 +141,7 @@ class Dashboard extends Component { btnText="View application" isLink={true} link={ - "/applications/" + - i.formId - + "/" + - i.applicationId + "/applications/" + i.formId + "/" + i.applicationId } /> </div> @@ -159,7 +162,9 @@ class Dashboard extends Component { <div className="col-md-2 col-sm-12 col-12 pt-5"> <button className="btn btn-default smf-btn-default float-right mr-0" - onClick={(e) => this.props.history.push("/available-forms")} + onClick={(e) => + this.props.history.push("/available-forms") + } > SEE ALL </button> diff --git a/src/components/form/FormViewer.js b/src/components/form/FormViewer.js index 2bf98d8..c8b1a2c 100644 --- a/src/components/form/FormViewer.js +++ b/src/components/form/FormViewer.js @@ -219,7 +219,8 @@ class FormViewer extends Component { let inputs = document.getElementsByTagName("input"); if ( this.props.match.params.applicationId === null || - this.props.match.params.applicationId === undefined + this.props.match.params.applicationId === undefined || + this.state.applicationDetails.status === LANG.FORM_STATUS.RETURNED ) { for (let m = 0; m < inputs.length; m++) { for (var key of Object.keys(existingFields)) @@ -377,7 +378,8 @@ class FormViewer extends Component { let flag = true; if ( (this.props.match.params.applicationId === null || - this.props.match.params.applicationId === undefined) && + this.props.match.params.applicationId === undefined || + this.state.applicationDetails.status === LANG.FORM_STATUS.RETURNED) && Helper.getUserRole() === APP.ROLE.INSTITUTION ) { for (let index = 0; index <= this.state.headingIndex; index++) { @@ -414,7 +416,8 @@ class FormViewer extends Component { // console.log("saveFields..."); if ( this.props.match.params.applicationId === null || - this.props.match.params.applicationId === undefined + this.props.match.params.applicationId === undefined || + this.state.applicationDetails.status === LANG.FORM_STATUS.RETURNED ) { let obj = this.state.formFields, order = ""; @@ -427,6 +430,7 @@ class FormViewer extends Component { }), {} ); + for (let i = 0; i < this.state.formFieldGroups[index].length; i++) { order = this.state.formFieldGroups[index][i]["order"]; obj["field_" + order] = @@ -479,6 +483,7 @@ class FormViewer extends Component { temp; var savedFields = this.state.formFields; var fields = this.state.formDetails.fields; + for (const key in savedFields) { temp = key.split("_"); for (let j = 0; j < fields.length; j++) { @@ -488,6 +493,7 @@ class FormViewer extends Component { } } } + var fieldGroups = {}; for (let i = 0; i < this.state.formHeadings.length; i++) { fieldGroups[this.state.formHeadings[i]] = {}; @@ -510,7 +516,7 @@ class FormViewer extends Component { }), }; // formDetails = JSON.stringify(formDetails); - // console.log(formDetails) + // console.log(formDetails); FormService.submit(formDetails).then( (response) => { // console.log(response); @@ -631,8 +637,8 @@ class FormViewer extends Component { : "" } comments={ - this.state.applicationDetails.comments - ? this.state.applicationDetails.comments + this.state.applicationDetails.notes + ? this.state.applicationDetails.notes : "" } showInspectionDetails={true} diff --git a/src/components/status-bar/StatusBarLarge.tsx b/src/components/status-bar/StatusBarLarge.tsx index 977813b..aeb623f 100644 --- a/src/components/status-bar/StatusBarLarge.tsx +++ b/src/components/status-bar/StatusBarLarge.tsx @@ -119,14 +119,15 @@ export const StatusBarLarge = ({ <div className="pt-1 pb-4 mx-3"> <div className="row"> <div className="col-12"> - {comments && + <p className={`${styles.review_comment} p-2 `}>{comments}</p> + {/* {comments && comments.map((c: any, i: any) => { return ( <p key={i} className={`${styles.review_comment} p-2 `}> {c.value} </p> ); - })} + })} */} </div> </div> </div> @@ -199,7 +200,9 @@ export const StatusBarLarge = ({ > {k.firstName[0] + k.lastName[0]} </div> - <p className="ps-2">{k.firstName + ' ' + k.lastName}</p> + <p className="ps-2"> + {k.firstName + " " + k.lastName} + </p> </div> </div> </div> @@ -229,7 +232,9 @@ export const StatusBarLarge = ({ > {k.firstName[0] + k.lastName[0]} </div> - <p className="ps-2">{k.firstName + ' ' + k.lastName}</p> + <p className="ps-2"> + {k.firstName + " " + k.lastName} + </p> </div> </div> </div> diff --git a/src/layouts/Inspector/ConsentFormView.tsx b/src/layouts/Inspector/ConsentFormView.tsx index 2b4bed8..05c0939 100644 --- a/src/layouts/Inspector/ConsentFormView.tsx +++ b/src/layouts/Inspector/ConsentFormView.tsx @@ -655,7 +655,7 @@ export const ConsentFormView = ({ : "" } comments={ - applicationData.comments ? applicationData.comments : "" + applicationData.notes ? applicationData.notes : "" } approvedNote={ applicationData.status !== LANG.FORM_STATUS.RETURNED && diff --git a/src/layouts/Regulator/ReviewApplicationLayout.tsx b/src/layouts/Regulator/ReviewApplicationLayout.tsx index 291e2d7..55cc734 100644 --- a/src/layouts/Regulator/ReviewApplicationLayout.tsx +++ b/src/layouts/Regulator/ReviewApplicationLayout.tsx @@ -492,7 +492,7 @@ export const ReviewApplicationLayout = ({ /> <ModalTwo id="rejectModal" - enableHandler={false} + enableHandler={true} enableSkip={false} ariaLabel="rejectModalLabel" showTextAreaLabel={false} @@ -584,7 +584,7 @@ export const ReviewApplicationLayout = ({ : "" } comments={ - applicationData.comments ? applicationData.comments : "" + applicationData.notes ? applicationData.notes : "" } approvedNote={ applicationData.status !== LANG.FORM_STATUS.RETURNED && diff --git a/src/pages/Inspector/InspectorApplications.tsx b/src/pages/Inspector/InspectorApplications.tsx index b2a0940..3bc76a0 100644 --- a/src/pages/Inspector/InspectorApplications.tsx +++ b/src/pages/Inspector/InspectorApplications.tsx @@ -143,7 +143,7 @@ export const InspectorApplications = ({ data }: InspectorApplicationsProps) => { ) { setPast((past) => [...past, i]); } - + if ( i.inspection.status === LANG.FORM_STATUS.LEAD_INSPECTION_COMPLETED && @@ -153,9 +153,9 @@ export const InspectorApplications = ({ data }: InspectorApplicationsProps) => { ) { i.inspection.assignedTo.map((m: any, n: number) => { if (m.id === userDetails.id) { - if (m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED) { + // if (m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED) { setPast((past) => [...past, i]); - } + // } return null; } return null; diff --git a/src/pages/Reviewer/ReviewerHome.tsx b/src/pages/Reviewer/ReviewerHome.tsx index 1d77d7b..b931554 100644 --- a/src/pages/Reviewer/ReviewerHome.tsx +++ b/src/pages/Reviewer/ReviewerHome.tsx @@ -5,6 +5,7 @@ import Notify from "../../helpers/notify"; import { FormService } from "../../services/form.service"; import { APP, LANG } from "../../constants"; import { BtnOne } from "../../components/buttons"; +import { useHistory } from "react-router-dom"; /** * Reviewer component renders @@ -54,58 +55,65 @@ export const ReviewerHome = ({ data }: ReviewerProps) => { >([]); const [showPendingApplications, setShowPendingApplications] = useState(false); + let history = useHistory(); + useEffect(() => { + setTimeout(() => { + getPendingApplications(); + }, 850); + }, [history]); + + const getPendingApplications = () => { const myApplicationsReq = { searchObjects: [], }; - setTimeout(() => { - FormService.getAllApplications(myApplicationsReq).then( - (response2) => { - if (response2.statusInfo.statusCode === APP.CODE.SUCCESS) { - let data = response2.responseData; - - let tempArray: any = []; - - data.map((m: any, n: number) => { - if ( - m.status === LANG.FORM_STATUS.NEW || - m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED - ) { - tempArray.push(m); - setShowPendingApplications(true); - } - return null; - }); - - setPendingApplications( - tempArray.length > 8 ? tempArray.splice(0, 8) : tempArray - ); - } else { - Notify.error(response2.statusInfo.errorMessage); - } - }, - (error) => { - error.statusInfo - ? Notify.error(error.statusInfo.errorMessage) - : Notify.error(error.message); + + FormService.getAllApplications(myApplicationsReq).then( + (response2) => { + if (response2.statusInfo.statusCode === APP.CODE.SUCCESS) { + let data = response2.responseData; + + let tempArray: any = []; + + data.map((m: any, n: number) => { + if ( + m.status === LANG.FORM_STATUS.NEW || + m.status === LANG.FORM_STATUS.INSPECTION_COMPLETED + ) { + tempArray.push(m); + setShowPendingApplications(true); + } + return null; + }); + + setPendingApplications( + tempArray.length > 8 ? tempArray.splice(0, 8) : tempArray + ); + } else { + Notify.error(response2.statusInfo.errorMessage); } - ); - FormService.getApplicationsStatusCount().then( - (response2: any) => { - if (response2.statusInfo.statusCode === APP.CODE.SUCCESS) { - setApplicationsMetrics(response2.responseData.keyValues); - } else { - Notify.error(response2.statusInfo.errorMessage); - } - }, - (error: any) => { - error.statusInfo - ? Notify.error(error.statusInfo.errorMessage) - : Notify.error(error.message); + }, + (error) => { + error.statusInfo + ? Notify.error(error.statusInfo.errorMessage) + : Notify.error(error.message); + } + ); + FormService.getApplicationsStatusCount().then( + (response2: any) => { + if (response2.statusInfo.statusCode === APP.CODE.SUCCESS) { + setApplicationsMetrics(response2.responseData.keyValues); + } else { + Notify.error(response2.statusInfo.errorMessage); } - ); - }, 800); - }, []); + }, + (error: any) => { + error.statusInfo + ? Notify.error(error.statusInfo.errorMessage) + : Notify.error(error.message); + } + ); + }; // Function to format the status label const formatLabel = (labelStatus: string) => { -- GitLab