From 35daecbf3357fb515ef2c851a01c96d14d5766df Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 9 Oct 2024 19:09:46 +0800 Subject: [PATCH] add auth --- src/components/FiDataGrid.js | 2 +- src/layout/MainLayout/Header/index.js | 39 ++- src/pages/GazetteIssue/index.js | 59 ++-- src/pages/Holiday/index.js | 50 +-- .../Details_GLD/ApplicationDetailCard.js | 292 +++++++++--------- .../Details_GLD/ClientDetailCard.js | 2 +- .../Details_GLD/GazetteDetailCard.js | 53 ++-- src/pages/PublicNotice/Search_GLD/DataGrid.js | 21 +- src/pages/User/DetailPage/UserGroupTable.js | 4 +- src/pages/User/DetailPage/index.js | 2 +- .../UserInformationCard_Individual.js | 6 +- .../UserInformationCard_Organization.js | 8 +- src/pages/User/GLDUserProfile/index.js | 4 +- src/pages/User/SearchPage/UserSearchForm.js | 2 +- src/pages/User/SearchPage/UserTable.js | 2 +- src/routes/GLDUserRoutes.js | 17 +- src/routes/SettingRoutes.js | 12 +- src/utils/ApiPathConst.js | 1 + 18 files changed, 311 insertions(+), 265 deletions(-) diff --git a/src/components/FiDataGrid.js b/src/components/FiDataGrid.js index 69b6d7a..82545f0 100644 --- a/src/components/FiDataGrid.js +++ b/src/components/FiDataGrid.js @@ -95,7 +95,7 @@ export function FiDataGrid({ rows, columns, sx, autoHeight, if (customPageSize) { setPageSize(customPageSize); } - console.log(_doLoad) + // console.log(_doLoad) if (_doLoad !== undefined && Object.keys(_doLoad).length==0 ){ setLoading(false) if (applyGridOnReady !== undefined){ diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 88bca62..c017a65 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -109,9 +109,13 @@ function Header(props) { -
  • - Application -
  • + { + isGrantedAny(["VIEW_APPLICATION", "MAINTAIN_APPLICATION"]) ? +
  • + Application +
  • + : <> + } { isGrantedAny(["VIEW_PROOF", "MAINTAIN_PROOF"]) ?
  • @@ -198,12 +202,12 @@ function Header(props) { } { - isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_ORG", "MAINTAIN_ORG", "VIEW_GROUP", "MAINTAIN_GROUP"]) ? + isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_ORG", "MAINTAIN_ORG", "VIEW_GROUP", "MAINTAIN_GROUP", "VIEW_GLD_USER", "VIEW_IND_USER", "VIEW_ORG_USER", "MAINTAIN_GLD_USER", "MAINTAIN_IND_USER", "MAINTAIN_ORG_USER"]) ?
  • Client
      { - isGrantedAny(["VIEW_USER", "MAINTAIN_USER"]) ? + isGrantedAny(["VIEW_USER","MAINTAIN_USER"]) ? <>
    • Users (GLD) @@ -216,9 +220,27 @@ function Header(props) {
    • : - <> + <> + { + isGrantedAny(["VIEW_GLD_USER" ,"MAINTAIN_GLD_USER"]) ? +
    • + Users (GLD) +
    • : <> + } + { + isGrantedAny(["VIEW_IND_USER", "MAINTAIN_IND_USER"]) ? +
    • + Users (Individual) +
    • : <> + } + { + isGrantedAny(["VIEW_ORG_USER", "MAINTAIN_ORG_USER"]) ? +
    • + Users (Organisation) +
    • : <> + } + } - { isGrantedAny(["VIEW_ORG", "MAINTAIN_ORG"]) ?
    • @@ -227,7 +249,6 @@ function Header(props) { : <> } - { isGrantedAny(["VIEW_GROUP", "MAINTAIN_GROUP"]) ?
    • @@ -256,7 +277,7 @@ function Header(props) {
    • { - isGranted("MAINTAIN_GAZETTE_ISSUE") ? + isGranted("VIEW_GAZETTE_ISSUE", "MAINTAIN_GAZETTE_ISSUE") ? <>
    • Holiday Settings diff --git a/src/pages/GazetteIssue/index.js b/src/pages/GazetteIssue/index.js index 6d5da21..8c68610 100644 --- a/src/pages/GazetteIssue/index.js +++ b/src/pages/GazetteIssue/index.js @@ -31,6 +31,7 @@ import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; import { dateStr_Year } from "utils/DateUtils"; import { notifySaveSuccess } from 'utils/CommonFunction'; +import { isGrantedAny } from "auth/utils"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -192,35 +193,37 @@ const Index = () => { /> } - - - - { - readFile(event) - }} - /> - - - - - - + onChange={(event) => { + readFile(event) + }} + /> + + + + + + :null + } {/*row 1*/} { - - - { - readFile(event) - }} - /> - - - + onChange={(event) => { + readFile(event) + }} + /> + + + :null + } diff --git a/src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js b/src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js index feb3037..2b27dbb 100644 --- a/src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js +++ b/src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js @@ -32,6 +32,7 @@ import EditNoteIcon from '@mui/icons-material/EditNote'; import DownloadIcon from '@mui/icons-material/Download'; import ReplayIcon from '@mui/icons-material/Replay'; import { notifyDownloadSuccess } from 'utils/CommonFunction'; +import { isGrantedAny } from "auth/utils"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const ApplicationDetailCard = ( @@ -196,116 +197,101 @@ const ApplicationDetailCard = ( content={false} > {verified && currentApplicationDetailData.status !== "notAccepted" ? - - - - {currentApplicationDetailData.status === "reviewed" && isGranted("MAINTAIN_PROOF") ? - : - null - } - - - - - { - !(orgDetail?.creditor) && currentApplicationDetailData.creditor && currentApplicationDetailData.status === "published" ? - <> - - - : - <> - } - {currentApplicationDetailData.status === "submitted" || currentApplicationDetailData.status == "reviewed" ? - <> + isGrantedAny("MAINTAIN_APPLICATION") ? + + + + {currentApplicationDetailData.status === "reviewed" && isGranted("MAINTAIN_PROOF") ? - { - proofId == null || proofId == 0? + onClick={() => { onProofClick() }} + sx={{ + textTransform: 'capitalize', + alignItems: 'end' + }}> + + Create Proof + : + null + } + + + + + { + !(orgDetail?.creditor) && currentApplicationDetailData.creditor && currentApplicationDetailData.status === "published" ? + <> - : - null - } - : - (currentApplicationDetailData.status == "confirmed" && currentApplicationDetailData.creditor == 1) ? + + : + <> + } + {currentApplicationDetailData.status === "submitted" || currentApplicationDetailData.status == "reviewed" ? <> - - - : - (currentApplicationDetailData.status == "confirmed" && currentApplicationDetailData.creditor == 0) ? + { + proofId == null || proofId == 0? + + : + null + } + : + (currentApplicationDetailData.status == "confirmed" && currentApplicationDetailData.creditor == 1) ? <> + - - - : null - ) - - } - - - : null + (currentApplicationDetailData.status == "confirmed" && currentApplicationDetailData.creditor == 0) ? + <> + + + : + ( + (currentApplicationDetailData.status == "paid" && currentApplicationDetailData.creditor == 0) ? + <> + + + + : null + ) + + } + + + + : null + : null } Application Details diff --git a/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js b/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js index 3b914da..5f74986 100644 --- a/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js +++ b/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js @@ -145,7 +145,7 @@ const ClientDetailCard = ( content={false} sx={{ xs: "12", md: "7" }}> - {isGrantedAny(["VIEW_USER", "MAINTAIN_USER"]) ? + {isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_IND_USER", "VIEW_ORG_USER", "MAINTAIN_IND_USER", "MAINTAIN_ORG_USER"]) ? import('../../extra-pages/LoadingComponent'))); import * as DateUtils from "utils/DateUtils"; import EditNoteIcon from '@mui/icons-material/EditNote'; - +import { isGrantedAny } from "auth/utils"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const GazetteDetailCard = ( { applicationDetailData, @@ -89,31 +89,34 @@ const GazetteDetailCard = ( content={false} > {verified && currentStatus != "notAccepted" ? - - - - - + isGrantedAny("MAINTAIN_APPLICATION") ? + + + + + + - - : null} + : null + : null + } Gazette Details diff --git a/src/pages/PublicNotice/Search_GLD/DataGrid.js b/src/pages/PublicNotice/Search_GLD/DataGrid.js index 5b7962b..c73c4b1 100644 --- a/src/pages/PublicNotice/Search_GLD/DataGrid.js +++ b/src/pages/PublicNotice/Search_GLD/DataGrid.js @@ -18,6 +18,8 @@ import { FiDataGrid } from "components/FiDataGrid"; import { notifyActionSuccess, clickableLink } from 'utils/CommonFunction'; import { FormattedMessage, useIntl } from "react-intl"; import * as utils from "auth/utils" +import { isGrantedAny } from "auth/utils"; + // ==============================|| EVENT TABLE ||============================== // export default function SearchPublicNoticeTable({ searchCriteria, applyGridOnReady }) { @@ -161,14 +163,17 @@ export default function SearchPublicNoticeTable({ searchCriteria, applyGridOnRea return (<>
      - - - + {isGrantedAny(["MAINTAIN_APPLICATION"]) ? + + + + :null + } { diff --git a/src/pages/User/DetailPage/index.js b/src/pages/User/DetailPage/index.js index 8f0da7b..87b93ee 100644 --- a/src/pages/User/DetailPage/index.js +++ b/src/pages/User/DetailPage/index.js @@ -268,7 +268,7 @@ const UserMaintainPage = () => { {/*bottom button*/} { - isGrantedAny(["MAINTAIN_USER"]) ? + isGrantedAny(["MAINTAIN_USER", "MAINTAIN_GLD_USER"]) ? { diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js index 8f06c78..1e48d10 100644 --- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js @@ -268,7 +268,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
      {/*top button*/} { - isGrantedAny("MAINTAIN_USER") ? + isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) ? {editMode ? @@ -430,7 +430,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { Verified: { - !isGrantedAny("MAINTAIN_USER") || currentUserData.verifiedBy || editMode ? + !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) || currentUserData.verifiedBy || editMode ? {FieldUtils.initField({ valueName: "verifiedStatus", @@ -601,7 +601,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { { - !isGrantedAny("MAINTAIN_USER") || editMode ? + !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) || editMode ? {FieldUtils.initField({ valueName: "status", diff --git a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js index b578345..53c3073 100644 --- a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js +++ b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js @@ -179,7 +179,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => {/*top button*/} - {isGrantedAny("MAINTAIN_USER") ? + {isGrantedAny(["MAINTAIN_USER", "MAINTAIN_ORG_USER"]) ? {editMode ? @@ -352,7 +352,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => { - !isGrantedAny("MAINTAIN_USER") || currentUserData.verifiedBy || editMode ? + !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_ORG_USER"]) || currentUserData.verifiedBy || editMode ? {FieldUtils.initField({ valueName: "verifiedStatus", @@ -411,7 +411,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => Status: { - !isGrantedAny("MAINTAIN_USER") || editMode ? + !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_ORG_USER"]) || editMode ? {FieldUtils.initField({ valueName: "status", @@ -467,6 +467,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => {currentUserData.orgId == null ? + isGrantedAny("MAINTAIN_ORG")?