Ver a proveniência

header auth handle

master
Anna Ho há 1 ano
ascendente
cometimento
e5431c58d0
7 ficheiros alterados com 276 adições e 158 eliminações
  1. +33
    -9
      src/auth/utils.js
  2. +0
    -1
      src/layout/MainLayout/Header/HeaderContent/index.js
  3. +202
    -106
      src/layout/MainLayout/Header/index.js
  4. +25
    -28
      src/pages/Proof/Reply_GLD/ApplicationDetails.js
  5. +2
    -2
      src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js
  6. +1
    -6
      src/pages/authentication/auth-forms/AuthLogin.js
  7. +13
    -6
      src/routes/GLDUserRoutes.js

+ 33
- 9
src/auth/utils.js Ver ficheiro

@@ -9,8 +9,8 @@ import useJwt from 'auth/jwt/coreUseJwt';
export const hostname = 'localhost';
const hostPort = '8090';
export const hostPath = `http://${hostname}:${hostPort}`;
export const apiPath = window.location.href.match("localhost:3000")?`${hostPath}/api`:(window.location.href.match(":3000")? "http://"+window.location.hostname+":8090/api":`/api`);
export const paymentPath = window.location.href.match("localhost:3000")?`${hostPath}/payment`:`/payment`;
export const apiPath = window.location.href.match("localhost:3000") ? `${hostPath}/api` : (window.location.href.match(":3000") ? "http://" + window.location.hostname + ":8090/api" : `/api`);
export const paymentPath = window.location.href.match("localhost:3000") ? `${hostPath}/payment` : `/payment`;

export const delBugMode = true;

@@ -31,7 +31,7 @@ export const iAmSmartCallbackPath = () => {
let hostname = window.location.hostname;
if (hostname.match("pnspsuat")) {
hostname = "pnspsuat.gld.gov.hk";
}else{
} else {
hostname = "pnspsdev.gld.gov.hk";
}
return hostname;
@@ -85,13 +85,37 @@ export const isUserLoggedIn = () => {

export const getUserData = () => JSON.parse(localStorage.getItem('userData'));

export const checkAuth = (auth) => {
const abilities= getUserData()?getUserData()["abilities"]:null;
if(abilities == null || abilities.length==0) return false;
for(let i= 0; i<abilities.length; i++){
if(auth == abilities[i]) return true;
export const isGranted = (auth) => {
const abilities = getUserData() ? getUserData()["abilities"] : null;
if (abilities == null || abilities.length == 0) return false;
if (!Array.isArray(auth)) return _checkAuth(abilities, auth);
if (auth.length > abilities.length) return false;
let haveAuth = true;
for (let i = 0; i < auth.length; i++) {
haveAuth = _checkAuth(abilities, auth[i])
if (!haveAuth) return haveAuth;
}
return haveAuth;
};

const _checkAuth = (abilities, auth) => {
for (let i = 0; i < abilities.length; i++) {
if (auth == abilities[i].actionSubjectCombo) return true;
}
return false;
}

export const isGrantedAny = (auth) => {
const abilities = getUserData() ? getUserData()["abilities"] : null;
if (abilities == null || abilities.length == 0) return false;
if (!Array.isArray(auth)) return _checkAuth(abilities, auth);
let haveAuth = false;
for (let i = 0; i < auth.length; i++) {
haveAuth = _checkAuth(abilities, auth[i])
if (haveAuth) return haveAuth;
}
return haveAuth;
};

/**
@@ -110,5 +134,5 @@ export const getHomeRouteForLoggedInUser = (userRole) => {
};

// open payment record
export const local = {en:"en-us", zh:"zh-hk", cn:"zh-cn"};
export const local = { en: "en-us", zh: "zh-hk", cn: "zh-cn" };
export const preferpaymentmethods = ['visa', 'mastercard', 'pps', 'creditcard', 'fps'];

+ 0
- 1
src/layout/MainLayout/Header/HeaderContent/index.js Ver ficheiro

@@ -9,7 +9,6 @@ import { Button ,Box } from '@mui/material';
import Profile from './Profile';
import LocaleSelector from "./LocaleSelector";
import {FormattedMessage} from "react-intl";
import React from "react";
// import Notification from './Notification';
// import MobileSection from './MobileSection';



+ 202
- 106
src/layout/MainLayout/Header/index.js Ver ficheiro

@@ -41,16 +41,17 @@ import AdminLogo from 'components/AdminLogo';
import MobileLogo from 'components/MobileLogo';
//import Profile from './HeaderContent/Profile';
import "assets/style/navbarStyles.css";
import {
isUserLoggedIn,
isGLDLoggedIn,
isPrimaryLoggedIn,
import {
isUserLoggedIn,
isGLDLoggedIn,
isPrimaryLoggedIn,
isCreditorLoggedIn,
isINDLoggedIn,
// isORGLoggedIn,
// getUserId
} from "utils/Utils";
import { handleLogoutFunction } from 'auth/index';
import { isGranted, isGrantedAny } from "auth/utils";

// assets
// import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons';
@@ -93,80 +94,175 @@ function Header(props) {
<li>
<Link className="application" to='/application/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Application</Typography></Link>
</li>
<li>
<Link className="proof" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Proof</Typography></Link>
</li>
<li>
<Link className="paymentTop" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Payment</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
<ul className='dropdown'>
<li>
<Link className="payment" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Online Payment Record</Typography></Link>
</li>
{
isGrantedAny(["VIEW_PROOF", "MAINTAIN_PROOF"]) ?
<li>
<Link className="downloadXML" to='/gfmis/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>GFMIS Generate XML</Typography></Link>
</li>
<li>
<Link className="reconReport" to='/paymentPage/reconReport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Recon Report</Typography></Link>
</li>
<li>
<Link className="createDemandNote" to='/paymentPage/createDemandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Create Demand Note</Typography></Link>
</li>
<li>
<Link className="demandNote" to='/paymentPage/demandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Demand Note</Typography></Link>
</li>
</ul>
</li>
<li>
<Link className="client" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Client</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
<ul className='dropdown'>
<li>
<Link className="userSearchview" to='/userSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (GLD)</Typography></Link>
</li>
<li>
<Link className="indUser" to='/indUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Individual)</Typography></Link>
</li>
<li>
<Link className="orgUser" to='/orgUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Organisation)</Typography></Link>
<Link className="proof" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Proof</Typography></Link>
</li>
: <></>
}

{
isGrantedAny(["MAINTAIN_PAYMENT", "MAINTAIN_RECON", "VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
<li>
<Link className="org" to='/org'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Organisation</Typography></Link>
<Link className="paymentTop" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Payment</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
<ul className='dropdown'>
{
isGranted("MAINTAIN_PAYMENT") ?
<li>
<Link className="payment" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Online Payment Record</Typography></Link>
</li>
:
<></>
}

{
isGranted("MAINTAIN_RECON") ?
<>
<li>
<Link className="downloadXML" to='/gfmis/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>GFMIS Generate XML</Typography></Link>
</li>
<li>
<Link className="reconReport" to='/paymentPage/reconReport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Recon Report</Typography></Link>
</li>
</>

:
<></>
}

{
isGranted("MAINTAIN_DEMANDNOTE") ?
<li>
<Link className="createDemandNote" to='/paymentPage/createDemandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Create Demand Note</Typography></Link>
</li>
:
<></>
}

{
isGrantedAny(["VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
<li>
<Link className="demandNote" to='/paymentPage/demandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Demand Note</Typography></Link>
</li>
:
<></>
}

</ul>
</li>
:
<></>
}

{
isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_ORG", "MAINTAIN_ORG", "VIEW_GROUP", "MAINTAIN_GROUP"]) ?
<li>
<Link className="usergroupSearchview" to='/usergroupSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>User Group</Typography></Link>
<Link className="client" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Client</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
<ul className='dropdown'>
{
isGrantedAny(["VIEW_USER", "MAINTAIN_USER"]) ?
<>
<li>
<Link className="userSearchview" to='/userSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (GLD)</Typography></Link>
</li>
<li>
<Link className="indUser" to='/indUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Individual)</Typography></Link>
</li>
<li>
<Link className="orgUser" to='/orgUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Organisation)</Typography></Link>
</li>
</>
:
<></>
}

{
isGrantedAny(["VIEW_ORG", "MAINTAIN_ORG"]) ?
<li>
<Link className="org" to='/org'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Organisation</Typography></Link>
</li>
:
<></>
}

{
isGrantedAny(["VIEW_GROUP", "MAINTAIN_GROUP"]) ?
<li>
<Link className="usergroupSearchview" to='/usergroupSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>User Group</Typography></Link>
</li>
:
<></>
}

</ul>
</li>
:
<></>
}


</ul>
</li>
<li>
<Link className="setting" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Settings</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
<ul className='dropdown'>
<li>
<Link className="userProfileGld" to='/user/profile'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>My Profile</Typography></Link>
</li>
<li>
<Link className="holidaySetting" to='/setting/holiday'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Holiday Settings</Typography></Link>
</li>
<li>
<Link className="gazetteissueSetting" to='/setting/gazetteissuepage'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Gazette Issues</Typography></Link>
</li>
<li>
<Link className="announcement" to='/setting/announcement'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Announcement</Typography></Link>
</li>
<li>
<Link className="emailTemplate" to='/setting/emailTemplate'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Email Template</Typography></Link>
</li>
<li>
<Link className="drImport" to='/setting/drImport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>DR Import</Typography></Link>
</li>
<li>
<Link className="systemSetting" to='/setting/sys'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>System Settings</Typography></Link>
</li>
{
isGranted("MAINTAIN_GAZETTE_ISSUE") ?
<>
<li>
<Link className="holidaySetting" to='/setting/holiday'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Holiday Settings</Typography></Link>
</li>
<li>
<Link className="gazetteissueSetting" to='/setting/gazetteissuepage'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Gazette Issues</Typography></Link>
</li>
</>
:
<></>
}

{
isGranted("MAINTAIN_ANNOUNCEMENT") ?
<li>
<Link className="announcement" to='/setting/announcement'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Announcement</Typography></Link>
</li>
:
<></>
}

{isGranted("MAINTAIN_EMAIL") ?
<li>
<Link className="emailTemplate" to='/setting/emailTemplate'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Email Template</Typography></Link>
</li>
:
<></>
}

{
isGranted("MAINTAIN_DR") ?
<li>
<Link className="drImport" to='/setting/drImport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>DR Import</Typography></Link>
</li>
:
<></>
}

{
isGranted("MAINTAIN_SETTING") ?
<li>
<Link className="systemSetting" to='/setting/sys'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>System Settings</Typography></Link>
</li>
:
<></>
}

<li>
<Link className="auditLogSetting" to='/setting/auditLog'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Audit Log</Typography></Link>
</li>
</ul>
</li>
<Box sx={{display: {xs: 'none', sm: 'none', md: 'block'}}}>
<Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
<li>
<Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Logout</Typography></Link>
</li>
@@ -194,7 +290,7 @@ function Header(props) {
<>
<Link className="paymentRecord">
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
<FormattedMessage id="paymentHistory"/>
<FormattedMessage id="paymentHistory" />
</Typography>
<KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
</Link>
@@ -254,46 +350,46 @@ function Header(props) {
</ul>
</>
:
isINDLoggedIn()?
<>
<Link className="userSetting" >
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
<FormattedMessage id="setting" />
</Typography>
<KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
</Link>
<ul className='dropdown' style={{ width: "max-content" }}>
<li>
<Link className="manageUser" to={'/indUser'}>
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
{/* <FormattedMessage id="companyOrUserRecord" /> */}
<FormattedMessage id="userProfile" />
</Typography>
</Link>
</li>
</ul>
</>
:
<>
<Link className="userSetting" >
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
<FormattedMessage id="setting" />
</Typography>
<KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
</Link>
<ul className='dropdown' style={{ width: "max-content" }}>
<li>
<Link className="manageUser" to={'/orgUser'}>
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
<FormattedMessage id="userProfile" />
</Typography>
</Link>
</li>
</ul>
</>
isINDLoggedIn() ?
<>
<Link className="userSetting" >
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
<FormattedMessage id="setting" />
</Typography>
<KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
</Link>
<ul className='dropdown' style={{ width: "max-content" }}>
<li>
<Link className="manageUser" to={'/indUser'}>
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
{/* <FormattedMessage id="companyOrUserRecord" /> */}
<FormattedMessage id="userProfile" />
</Typography>
</Link>
</li>
</ul>
</>
:
<>
<Link className="userSetting" >
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
<FormattedMessage id="setting" />
</Typography>
<KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
</Link>
<ul className='dropdown' style={{ width: "max-content" }}>
<li>
<Link className="manageUser" to={'/orgUser'}>
<Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
<FormattedMessage id="userProfile" />
</Typography>
</Link>
</li>
</ul>
</>
}
</li>
<Box sx={{display: {xs: 'none', sm: 'none', md: 'block'}}}>
<Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
<li>
<Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
<FormattedMessage id="logout" />
@@ -328,7 +424,7 @@ function Header(props) {
{/* <Typography variant="h6" sx={{ my: 2 }}>
PNSPS
</Typography> */}
<Box sx={{ mr: 2, mt:1, display: { md: 'none' } }}>
<Box sx={{ mr: 2, mt: 1, display: { md: 'none' } }}>
<MobileLogo />
<span id="mobileTitle" >PNSPS</span>
</Box>
@@ -347,7 +443,7 @@ function Header(props) {
</Stack>
:
<Stack id="sidebar" direction="column" justifyContent="center" alignItems="center" onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
<Box sx={{ mr: 2, mt:1, display: { md: 'none' } }}>
<Box sx={{ mr: 2, mt: 1, display: { md: 'none' } }}>
<MobileLogo />
<span id="mobileTitle" >PNSPS</span>
</Box>
@@ -395,7 +491,7 @@ function Header(props) {
justifyContent="flex-start"
alignItems="center"
spacing={0}
sx={{width:{xs:'100%',md:'25%'}}}
sx={{ width: { xs: '100%', md: '25%' } }}
>
<Box sx={{ width: '260px', flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
<Stack direction="row" justifyContent="flex-start" alignItems="center">
@@ -447,8 +543,8 @@ function Header(props) {
</ul>

<Grid item>
<Grid container direction="column"
justifyContent="flex-end"
<Grid container direction="column"
justifyContent="flex-end"
alignItems="center"
>
{
@@ -493,7 +589,7 @@ function Header(props) {
alignItems="center"
spacing={0}
// width="100%"
sx={{width:{xs:'100%',md:'25%'}}}
sx={{ width: { xs: '100%', md: '25%' } }}
>
<Box sx={{ flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
<Stack direction="row" justifyContent="flex-start" alignItems="center" >
@@ -542,7 +638,7 @@ function Header(props) {
</ul>
<LocaleSelector />

{/*<Profile />*/}
{/*<Profile />*/}
</Stack>
</Box>
</Toolbar>


+ 25
- 28
src/pages/Proof/Reply_GLD/ApplicationDetails.js Ver ficheiro

@@ -11,14 +11,15 @@ import {
} from '@mui/material';

import { useFormik } from 'formik';
import * as React from "react";
import {isGranted} from "auth/utils";
import {useState,useEffect,lazy} from "react";
import * as HttpUtils from "utils/HttpUtils"
import * as UrlUtils from "utils/ApiPathConst"
import * as DateUtils from "utils/DateUtils"
import * as FormatUtils from "utils/FormatUtils"
import { useParams } from "react-router-dom";
import Loadable from 'components/Loadable';
const MainCard = Loadable(React.lazy(() => import('components/MainCard')));
const MainCard = Loadable(lazy(() => import('components/MainCard')));
import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
import FileList from "components/FileList"
// ==============================|| DASHBOARD - DEFAULT ||============================== //
@@ -31,14 +32,12 @@ const ApplicationDetailCard = ({

const params = useParams();

const [data, setData] = React.useState({});
const [cancelPopUp, setCancelPopUp] = React.useState(false);
//const [proofId, setProofId] = React.useState();
const [data, setData] = useState({});
const [cancelPopUp, setCancelPopUp] = useState(false);

React.useEffect(() => {
useEffect(() => {
if (formData) {
setData(formData);
//setProofId(formData.id);
}
}, [formData]);

@@ -69,31 +68,26 @@ const ApplicationDetailCard = ({
/>;
}

const confirmCancel = () =>{
const confirmCancel = () => {
setCancelPopUp(false);
HttpUtils.get({
url: UrlUtils.CANCEL_PROOF+"/"+params.id,
onSuccess: function(){
url: UrlUtils.CANCEL_PROOF + "/" + params.id,
onSuccess: function () {
window.location.reload(false);
}
});
}

const doCancel = () =>{
const doCancel = () => {
setCancelPopUp(true);
}

const genProof = () =>{
// window.open(UrlUtils.GEN_GAZETTE_PROOF);
const genProof = () => {
HttpUtils.fileDownload({
url: UrlUtils.GEN_GAZETTE_PROOF+"/"+params.id
url: UrlUtils.GEN_GAZETTE_PROOF + "/" + params.id
});
}

// React.useEffect(()=>{
// if (document.getElementById("applicationDetailsMainCard")) setBackButtonPos(`${document.getElementById("applicationDetailsMainCard")?.getBoundingClientRect().left / 3}px`)
// },[document.getElementById("applicationDetailsMainCard")])

return (
<MainCard
id={"applicationDetailsMainCard"}
@@ -116,16 +110,19 @@ const ApplicationDetailCard = ({
>
<Typography variant="h5">Proof Slip</Typography>
</Button>
<Button
component="span"
variant="contained"
size="large"
color="error"
disabled={showCancelBtn}
onClick={doCancel}
>
<Typography variant="h5">Cancel</Typography>
</Button>
{
isGranted(["MAINTAIN_PROOF"]) ? <Button
component="span"
variant="contained"
size="large"
color="error"
disabled={showCancelBtn}
onClick={doCancel}
>
<Typography variant="h5">Cancel</Typography>
</Button> : <></>
}


</Stack>



+ 2
- 2
src/pages/PublicNotice/Details_GLD/ApplicationDetailCard.js Ver ficheiro

@@ -8,7 +8,7 @@ import {
Stack,
Dialog, DialogTitle, DialogContent, DialogActions, InputAdornment,
} from '@mui/material';
import { delBugMode } from "auth/utils";
import {isGranted, delBugMode } from "auth/utils";
const MainCard = Loadable(lazy(() => import('components/MainCard')));
import { useForm } from "react-hook-form";
import {
@@ -168,7 +168,7 @@ const ApplicationDetailCard = (
spacing={2}
mb={2}
>
{currentApplicationDetailData.status === "reviewed" ?
{currentApplicationDetailData.status === "reviewed" && isGranted("MAINTAIN_PROOF") ?
<Button
// size="large"
variant="contained"


+ 1
- 6
src/pages/authentication/auth-forms/AuthLogin.js Ver ficheiro

@@ -75,11 +75,6 @@ const AuthLogin = () => {
console.log(response.data);
setPosts(response.data);

let abilities = [];
for(let i=0; i<response.data.abilities?.length; i++){
abilities[i] = response.data.abilities[i].actionSubjectCombo;
}

const userData = {
id: response.data.id,
fullenName: response.data.name,
@@ -87,7 +82,7 @@ const AuthLogin = () => {
email: response.data.email,
type: response.data.type,
role: response.data.role,
abilities: abilities,
abilities: response.data.abilities,
//avatar: require('src/assets/images/users/avatar-3.png').default,
}
// const abilities = response.data.abilities


+ 13
- 6
src/routes/GLDUserRoutes.js Ver ficheiro

@@ -4,7 +4,7 @@ import { lazy } from 'react';
import Loadable from 'components/Loadable';
// import MainLayout from 'layout/MainLayout';
const MainLayout = Loadable(lazy(() => import('layout/MainLayout')));
import {checkAuth} from "auth/utils";
import {isGranted, isGrantedAny} from "auth/utils";

// render - dashboard
const DashboardDefault = Loadable(lazy(() => import('pages/Dashboard/GLD')));
@@ -55,22 +55,29 @@ const GLDUserRoutes = {
path: '/application/search',
element: <ApplicationSearch/>
},
checkAuth("VIEW_PROOF") || checkAuth("MAINTAIN_PROOF")?{

isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{
path: '/proof/search',
element: <ProofSearch/>
}:{},

isGranted("MAINTAIN_PROOF")?
{
path: '/proof/create/:id',
element: <ProofCreate_FromApp/>
},
{
}:{},

isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{
path: '/proof/reply/:id',
element: <ProofReply_GLD/>
},
}:{},

isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?
{
path: '/paymentPage/search',
element: <PaymentSearch_GLD/>
},
}:{},
{
path: '/paymentPage/details/:id',
element: <PaymentDetails_GLD/>


Carregando…
Cancelar
Guardar