Commit d85d481b authored by devendra's avatar devendra
Browse files

Fix: User deails cache issue

Showing with 28 additions and 29 deletions
+28 -29
......@@ -19,8 +19,8 @@ interface LoginState {
userName: any;
userInfo: any;
}
const userRole = Helper.getUserRole();
class Header extends Component<LoginProps, LoginState> {
userRole: any;
constructor(props: any) {
super(props);
this.state = {
......@@ -28,6 +28,7 @@ class Header extends Component<LoginProps, LoginState> {
userInfo: {},
};
this.logout = this.logout.bind(this);
this.userRole = Helper.getUserRole();
}
componentDidMount() {
......@@ -141,7 +142,7 @@ class Header extends Component<LoginProps, LoginState> {
HOME
</Link>
</li>
{userRole === APP.ROLE.INSTITUTION && (
{this.userRole === APP.ROLE.INSTITUTION && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/applications"}
......@@ -157,7 +158,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{userRole === APP.ROLE.INSTITUTION && (
{this.userRole === APP.ROLE.INSTITUTION && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/available-forms"}
......@@ -173,7 +174,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
{(this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) && (
<>
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
......@@ -206,7 +207,7 @@ class Header extends Component<LoginProps, LoginState> {
</li>
</>
)}
{userRole === APP.ROLE.INSPECTOR && (
{this.userRole === APP.ROLE.INSPECTOR && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/all-applications"}
......@@ -222,7 +223,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
{(this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) && (
<li className="">
<Link
to={"/analytics"}
......
......@@ -12,7 +12,6 @@ import { CardTwo } from "../cards";
/**
* Dashboard component
*/
const userRole = Helper.getUserRole();
class Dashboard extends Component {
constructor(props) {
super(props);
......@@ -21,7 +20,7 @@ class Dashboard extends Component {
forms: [],
myApplications: [],
};
this.userRole = Helper.getUserRole();
this.getInstituteApplications = this.getInstituteApplications.bind();
}
......@@ -43,7 +42,7 @@ class Dashboard extends Component {
}
getInstituteApplications = () => {
if (userRole === APP.ROLE.INSTITUTION) {
if (this.userRole === APP.ROLE.INSTITUTION) {
FormService.get().then(
(response) => {
if (response.statusInfo.statusCode === APP.CODE.SUCCESS) {
......@@ -96,7 +95,7 @@ class Dashboard extends Component {
return (
<Fragment>
<Header history={this.props.history} />
{userRole === APP.ROLE.INSTITUTION && (
{this.userRole === APP.ROLE.INSTITUTION && (
<Fragment>
<div className="container-fluid main-container">
<div className="container dashboard-inner-container pt-3 pb-3">
......@@ -199,7 +198,7 @@ class Dashboard extends Component {
</div>
</Fragment>
)}
{/* {(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
{/* {(this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) && (
<Fragment>
<div className="container-fluid">
<div className="container dashboard-inner-container">
......@@ -295,9 +294,9 @@ class Dashboard extends Component {
)} */}
{/* Inspector portal */}
{userRole === APP.ROLE.INSPECTOR && <InspectorHome />}
{this.userRole === APP.ROLE.INSPECTOR && <InspectorHome />}
{/* Inspector portal */}
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && <ReviewerHome />}
{(this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) && <ReviewerHome />}
</Fragment>
);
}
......
......@@ -22,7 +22,6 @@ import { CardThree } from "../cards";
import { TextAreaField } from "../form-elements";
// import { BtnTwo } from "../buttons";
// const $ = window.$;
const userRole = Helper.getUserRole();
class FormViewer extends Component {
constructor(props) {
super(props);
......@@ -38,6 +37,7 @@ class FormViewer extends Component {
showSaveAsDraft: true,
breadCrumbData: [],
};
this.userRole = Helper.getUserRole();
this.toggleSideBar = this.toggleSideBar.bind(this);
this.loadFormDetails = this.loadFormDetails.bind(this);
this.saveFields = this.saveFields.bind(this);
......@@ -61,7 +61,7 @@ class FormViewer extends Component {
this.props.match.params.applicationId !== null &&
this.props.match.params.applicationId !== undefined
) {
if (userRole === APP.ROLE.INSTITUTION) {
if (this.userRole === APP.ROLE.INSTITUTION) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -69,7 +69,7 @@ class FormViewer extends Component {
],
});
}
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
if (this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -81,7 +81,7 @@ class FormViewer extends Component {
this.populateForm(this.props.match.params.applicationId);
}, 50);
} else {
if (userRole === APP.ROLE.INSTITUTION) {
if (this.userRole === APP.ROLE.INSTITUTION) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -89,7 +89,7 @@ class FormViewer extends Component {
],
});
}
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
if (this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -327,7 +327,7 @@ class FormViewer extends Component {
this.props.match.params.applicationId !== undefined
) {
// if regulator disable form
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
if (this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) {
setTimeout(() => {
this.disableFormElements();
}, 300);
......@@ -335,7 +335,7 @@ class FormViewer extends Component {
// if institute,
// if status: Draft - enable form edit & show 'save as draft'
if (
userRole === APP.ROLE.INSTITUTION &&
this.userRole === APP.ROLE.INSTITUTION &&
(this.state.applicationDetails.status === LANG.FORM_STATUS.DRAFT ||
this.state.applicationDetails.status === LANG.FORM_STATUS.RETURNED)
) {
......@@ -350,7 +350,7 @@ class FormViewer extends Component {
// if institute,
// if status: not Draft - disable form edit & hide 'save as draft'
if (
userRole === APP.ROLE.INSTITUTION &&
this.userRole === APP.ROLE.INSTITUTION &&
this.state.applicationDetails.status !== LANG.FORM_STATUS.DRAFT &&
this.state.applicationDetails.status !== LANG.FORM_STATUS.RETURNED
) {
......@@ -392,7 +392,7 @@ class FormViewer extends Component {
(this.props.match.params.applicationId === null ||
this.props.match.params.applicationId === undefined ||
this.state.applicationDetails.status === LANG.FORM_STATUS.RETURNED) &&
userRole === APP.ROLE.INSTITUTION
this.userRole === APP.ROLE.INSTITUTION
) {
for (let index = 0; index <= this.state.headingIndex; index++) {
if (!flag) break;
......@@ -868,7 +868,7 @@ class FormViewer extends Component {
// this.props.match.params.applicationId !== null &&
// this.props.match.params.applicationId !== undefined
// ) &&
userRole === APP.ROLE.INSTITUTION &&
this.userRole === APP.ROLE.INSTITUTION &&
this.state.showSaveAsDraft && (
<button
className="btn btn-outline smf-btn-default mb-3"
......@@ -888,7 +888,7 @@ class FormViewer extends Component {
// this.props.match.params.applicationId !== null &&
// this.props.match.params.applicationId !== undefined
// ) &&
userRole === APP.ROLE.INSTITUTION &&
this.userRole === APP.ROLE.INSTITUTION &&
this.state.showSaveAsDraft &&
this.state.headingIndex ===
this.state.formHeadings.length - 1 && (
......
......@@ -44,10 +44,8 @@ const FORM_STATUS = [
"Inspection completed",
"Approved"
];
const userRole = Helper.getUserRole();
class ReviewerApplications extends Component<ReviewerApplicationsProps, ReviewerApplicationsState> {
userRole: any;
constructor(props: any) {
super(props);
......@@ -56,11 +54,12 @@ class ReviewerApplications extends Component<ReviewerApplicationsProps, Reviewer
filteredApplications: [],
currentStatus: "New"
};
this.userRole = Helper.getUserRole();
this.filterApplications = this.filterApplications.bind(this);
}
componentDidMount() {
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
if (this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) {
let data = {
"searchObjects": [
]
......@@ -125,7 +124,7 @@ class ReviewerApplications extends Component<ReviewerApplicationsProps, Reviewer
<Fragment>
<Header history={this.props.history} />
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
{(this.userRole === APP.ROLE.REGULATOR || this.userRole === APP.ROLE.SUPER_ADMIN) && (
<Fragment>
<div className="container-fluid">
<div className="container dashboard-inner-container">
......
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