Commit d287f95d authored by devendra's avatar devendra
Browse files

Feat: Role lables are updated

Showing with 74 additions and 40 deletions
+74 -40
......@@ -19,6 +19,7 @@ interface LoginState {
userName: any;
userInfo: any;
}
const userRole = Helper.getUserRole();
class Header extends Component<LoginProps, LoginState> {
constructor(props: any) {
super(props);
......@@ -140,7 +141,7 @@ class Header extends Component<LoginProps, LoginState> {
HOME
</Link>
</li>
{Helper.getUserRole() === APP.ROLE.INSTITUTION && (
{userRole === APP.ROLE.INSTITUTION && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/applications"}
......@@ -156,7 +157,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{Helper.getUserRole() === APP.ROLE.INSTITUTION && (
{userRole === APP.ROLE.INSTITUTION && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/available-forms"}
......@@ -172,7 +173,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{Helper.getUserRole() === APP.ROLE.REGULATOR && (
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
<>
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
......@@ -205,7 +206,7 @@ class Header extends Component<LoginProps, LoginState> {
</li>
</>
)}
{Helper.getUserRole() === APP.ROLE.INSPECTOR && (
{userRole === APP.ROLE.INSPECTOR && (
<li className="mr-3 mr-sm-2 mr-md-5 mr-lg-5">
<Link
to={"/all-applications"}
......@@ -221,7 +222,7 @@ class Header extends Component<LoginProps, LoginState> {
</Link>
</li>
)}
{Helper.getUserRole() === APP.ROLE.REGULATOR && (
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
<li className="">
<Link
to={"/analytics"}
......
......@@ -12,7 +12,7 @@ import { CardTwo } from "../cards";
/**
* Dashboard component
*/
const userRole = Helper.getUserRole();
class Dashboard extends Component {
constructor(props) {
super(props);
......@@ -43,7 +43,7 @@ class Dashboard extends Component {
}
getInstituteApplications = () => {
if (Helper.getUserRole() === APP.ROLE.INSTITUTION) {
if (userRole === APP.ROLE.INSTITUTION) {
FormService.get().then(
(response) => {
if (response.statusInfo.statusCode === APP.CODE.SUCCESS) {
......@@ -92,10 +92,11 @@ class Dashboard extends Component {
};
render() {
return (
<Fragment>
<Header history={this.props.history} />
{Helper.getUserRole() === APP.ROLE.INSTITUTION && (
{userRole === APP.ROLE.INSTITUTION && (
<Fragment>
<div className="container-fluid main-container">
<div className="container dashboard-inner-container pt-3 pb-3">
......@@ -198,7 +199,7 @@ class Dashboard extends Component {
</div>
</Fragment>
)}
{/* {Helper.getUserRole() === APP.ROLE.REGULATOR && (
{/* {(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
<Fragment>
<div className="container-fluid">
<div className="container dashboard-inner-container">
......@@ -294,9 +295,9 @@ class Dashboard extends Component {
)} */}
{/* Inspector portal */}
{Helper.getUserRole() === APP.ROLE.INSPECTOR && <InspectorHome />}
{userRole === APP.ROLE.INSPECTOR && <InspectorHome />}
{/* Inspector portal */}
{Helper.getUserRole() === APP.ROLE.REGULATOR && <ReviewerHome />}
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && <ReviewerHome />}
</Fragment>
);
}
......
......@@ -22,7 +22,7 @@ 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);
......@@ -61,7 +61,7 @@ class FormViewer extends Component {
this.props.match.params.applicationId !== null &&
this.props.match.params.applicationId !== undefined
) {
if (Helper.getUserRole() === APP.ROLE.INSTITUTION) {
if (userRole === APP.ROLE.INSTITUTION) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -69,7 +69,7 @@ class FormViewer extends Component {
],
});
}
if (Helper.getUserRole() === APP.ROLE.REGULATOR) {
if (userRole === APP.ROLE.REGULATOR || 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 (Helper.getUserRole() === APP.ROLE.INSTITUTION) {
if (userRole === APP.ROLE.INSTITUTION) {
this.setState({
breadCrumbData: [
{ title: "HOME", url: "/dashboard", icon: "" },
......@@ -89,7 +89,7 @@ class FormViewer extends Component {
],
});
}
if (Helper.getUserRole() === APP.ROLE.REGULATOR) {
if (userRole === APP.ROLE.REGULATOR || 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 (Helper.getUserRole() === APP.ROLE.REGULATOR) {
if (userRole === APP.ROLE.REGULATOR || 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 (
Helper.getUserRole() === APP.ROLE.INSTITUTION &&
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 (
Helper.getUserRole() === APP.ROLE.INSTITUTION &&
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) &&
Helper.getUserRole() === APP.ROLE.INSTITUTION
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
// ) &&
Helper.getUserRole() === APP.ROLE.INSTITUTION &&
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
// ) &&
Helper.getUserRole() === APP.ROLE.INSTITUTION &&
userRole === APP.ROLE.INSTITUTION &&
this.state.showSaveAsDraft &&
this.state.headingIndex ===
this.state.formHeadings.length - 1 && (
......
......@@ -400,7 +400,7 @@ export const InspectionScheduleModal = ({
<div className="col-sm-12 col-md-12 col-lg-6">
<div className={`${stylesTwo.text_area_one} p-3`}>
<div className="mb-3">
<HeadingFive heading="Add lead inspector" count={1} />
<HeadingFive heading="Add lead assessor" count={1} />
</div>
<div className="row">
<div className="col-9">
......@@ -480,7 +480,7 @@ export const InspectionScheduleModal = ({
<div className={`${stylesTwo.text_area_one} p-3 mt-3`}>
<div className="mb-3">
<HeadingFive heading="Add assisting inspectors" count={2} />
<HeadingFive heading="Add assisting assessor" count={2} />
</div>
<div className="row">
<div className="col-sm-12 col-md-9 col-lg-9">
......
......@@ -182,7 +182,7 @@ export const StatusBarLarge = ({
</div>
<div className="pt-2">
<label className={`${styles.status_bar_custom_heading}`}>
Lead inspector
Lead assessor
</label>
<div className="pt-3">
{inspectionData &&
......@@ -214,7 +214,7 @@ export const StatusBarLarge = ({
</div>
<div className="pt-2">
<label className={`${styles.status_bar_custom_heading}`}>
Assisting inspector
Assisting assessor
</label>
<div className="pt-3">
{inspectionData &&
......
......@@ -12,6 +12,13 @@ export const APP = {
INSTITUTION: "Institution",
REGULATOR: "Regulator", // reviewer
INSPECTOR: "Inspector",
SUPER_ADMIN: "Super Admin",
},
ROLE_LABEL: { //Update ROLE object with correct label once Inspector and assistant inspector is changes to Medical and Non-Medical assessor and assistant inspector role is removed
INSTITUTION: "Institute",
REGULATOR: "Admin", // reviewer
INSPECTOR: "Assessor",
SUPER_ADMIN: "Super Admin",
},
ROUTES: {
DASHBOARD: "/dashboard",
......
import { APP } from "../constants";
const getRoleLabel = (roleName: string) => {
switch(roleName.toLowerCase()) {
case APP.ROLE.REGULATOR.toLowerCase():
return APP.ROLE_LABEL.REGULATOR;
case APP.ROLE.INSTITUTION.toLowerCase():
return APP.ROLE_LABEL.INSTITUTION;
case APP.ROLE.INSPECTOR.toLowerCase():
return APP.ROLE_LABEL.INSPECTOR;
case APP.ROLE.SUPER_ADMIN.toLowerCase():
return APP.ROLE_LABEL.SUPER_ADMIN;
}
}
export default { getRoleLabel };
\ No newline at end of file
......@@ -60,6 +60,7 @@ export const ConsentFormView = ({
useRecoilState(sideMenuLabelAtom);
const reviewerNote = useRecoilState(modalTwoTextAreaAtom);
const userRole = Helper.getUserRole();
let history = useHistory();
......@@ -596,7 +597,7 @@ export const ConsentFormView = ({
applicationId={applicationData.applicationId}
/>
{Helper.getUserRole() === APP.ROLE.REGULATOR && (
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
<InspectionScheduleModal
id="sendToInspectionEdit"
showTextAreaLabel={false}
......@@ -707,7 +708,7 @@ export const ConsentFormView = ({
<label
className={`${styles.status_bar_custom_heading}`}
>
Lead inspector
Lead assessor
</label>
<div className="pt-3">
{applicationData &&
......@@ -747,7 +748,7 @@ export const ConsentFormView = ({
<label
className={`${styles.status_bar_custom_heading}`}
>
Assisting inspector
Assisting assessor
</label>
<div className="pt-3">
{applicationData &&
......
......@@ -163,7 +163,7 @@ export const InspectionSummaryLayout = ({
{/* Inspectors list */}
<div className="pt-2">
<label className={`${stylesThree.status_bar_custom_heading}`}>
Lead inspector
Lead assessor
</label>
<div className="pt-3">
{data &&
......@@ -199,7 +199,7 @@ export const InspectionSummaryLayout = ({
</div>
<div className="pt-2">
<label className={`${stylesThree.status_bar_custom_heading}`}>
Assisting inspector
Assisting assessor
</label>
<div className="pt-3">
{data &&
......
......@@ -54,6 +54,7 @@ export const ReviewApplicationLayout = ({
useRecoilState(sideMenuLabelAtom);
const reviewerNote = useRecoilState(modalTwoTextAreaAtom);
const userRole = Helper.getUserRole();
let history = useHistory();
......@@ -536,7 +537,7 @@ export const ReviewApplicationLayout = ({
applicationId={applicationData.applicationId}
/>
{Helper.getUserRole() === APP.ROLE.REGULATOR && (
{(userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) && (
<InspectionScheduleModal
id="sendToInspectionEdit"
showTextAreaLabel={false}
......@@ -634,7 +635,7 @@ export const ReviewApplicationLayout = ({
<label
className={`${styles.status_bar_custom_heading}`}
>
Lead inspector
Lead assessor
</label>
<div className="pt-3">
{applicationData &&
......@@ -674,7 +675,7 @@ export const ReviewApplicationLayout = ({
<label
className={`${styles.status_bar_custom_heading}`}
>
Assisting inspector
Assisting assessor
</label>
<div className="pt-3">
{applicationData &&
......
......@@ -6,6 +6,7 @@ import { Link } from "react-router-dom";
import { BtnTwo } from "../../components/buttons";
import { APP } from "../../constants";
import Notify from "../../helpers/notify";
import Util from "../../helpers/util";
import { UserService } from "../../services/user.service";
interface userProps {
......@@ -155,7 +156,7 @@ export const Users = ({ data }: userProps) => {
{user.roles.map((role, i) => {
return (
<span key={i}>
<span>{role.name}</span>
<span>{Util.getRoleLabel(role.name)}</span>
{i !== user.roles.length - 1 && <span>,</span>}
</span>
);
......
......@@ -29,6 +29,7 @@ export const RegulatorAllApplications = ({
const [currentData, setCurrentData] = useRecoilState(selectedTabDataAtom);
const [tabData, setTabData] = useState<any[]>([]);
const [selectedTab, setSelectedTab] = useRecoilState(selectedTabAtom);
const userRole = Helper.getUserRole();
let history = useHistory();
......@@ -96,7 +97,7 @@ export const RegulatorAllApplications = ({
}, [currentData]);
const getSelectedTabData = () => {
if (Helper.getUserRole() === APP.ROLE.REGULATOR) {
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
let data = {
searchObjects: [],
};
......
......@@ -7,6 +7,7 @@ import Header from "../../components/common/Header"
import { HeadingOne } from "../../components/headings"
import { APP } from "../../constants";
import Notify from "../../helpers/notify";
import Util from "../../helpers/util";
import { UserService } from "../../services/user.service";
interface userProps {
......@@ -117,8 +118,9 @@ export const CreateUser = ({ data }: userProps) => {
(response2) => {
if (response2.statusInfo && response2.statusInfo.statusCode === APP.CODE.SUCCESS) {
if (isEdit) {
let rolesUpdated:any = []
let rolesUpdated:any = [];
userEdit && userEdit.roles.map((role: any, index: number) => {
rolesUpdated = response2.responseData.map((r: IRole, i: number) => {
if (r.id === role.id) {
return { ...r, isChecked: true }
......@@ -293,7 +295,7 @@ export const CreateUser = ({ data }: userProps) => {
}
checked={role.isChecked ? true : false} onChange={e => onAddingRole(e, key)}
/>
{" " + role.name}
{" " + Util.getRoleLabel(role.name)}
</label>
</div>
))}
......
......@@ -45,6 +45,8 @@ const FORM_STATUS = [
"Approved"
];
const userRole = Helper.getUserRole();
class ReviewerApplications extends Component<ReviewerApplicationsProps, ReviewerApplicationsState> {
constructor(props: any) {
super(props);
......@@ -58,7 +60,7 @@ class ReviewerApplications extends Component<ReviewerApplicationsProps, Reviewer
}
componentDidMount() {
if (Helper.getUserRole() === APP.ROLE.REGULATOR) {
if (userRole === APP.ROLE.REGULATOR || userRole === APP.ROLE.SUPER_ADMIN) {
let data = {
"searchObjects": [
]
......@@ -123,7 +125,7 @@ class ReviewerApplications extends Component<ReviewerApplicationsProps, Reviewer
<Fragment>
<Header history={this.props.history} />
{Helper.getUserRole() === APP.ROLE.REGULATOR && (
{(userRole === APP.ROLE.REGULATOR || 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