import PropTypes from 'prop-types'; import React , { useState, useContext } from 'react'; import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; import { SysContext } from "components/SysSettingProvider" // material-ui // import { useTheme } from '@mui/material/styles'; import { AppBar, // Container, Typography, Box, Stack, // IconButton, // Menu, // MenuItem, // Button, // Tooltip, // Avatar, // Stack, Toolbar, Divider, // List, // ListItem, // ListItemButton, // ListItemText, IconButton, Drawer, Grid, // useMediaQuery } from '@mui/material'; import MenuIcon from '@mui/icons-material/Menu'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; // project import // import AppBarStyled from './AppBarStyled'; // import HeaderContent from './HeaderContent'; import Logo from 'components/Logo'; import AdminLogo from 'components/AdminLogo'; import MobileLogo from 'components/MobileLogo'; //import Profile from './HeaderContent/Profile'; import "assets/style/navbarStyles.css"; import { isUserLoggedIn, isGLDLoggedIn, isPrimaryLoggedIn, isCreditorLoggedIn, isINDLoggedIn, isPasswordExpiry, haveOrgPaymentRecord, isORGLoggedIn, // getUserId } from "utils/Utils"; import { handleLogoutFunction } from 'auth/index'; import { isGranted, isGrantedAny } from "auth/utils"; // assets // import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons'; // import { AppBar } from '../../../../node_modules/@mui/material/index'; import { Link } from "react-router-dom"; import LocaleSelector from "./HeaderContent/LocaleSelector"; import { FormattedMessage } from "react-intl"; const drawerWidth = 300; // const navItems = ['Home', 'About', 'Contact']; // ==============================|| MAIN LAYOUT - HEADER ||============================== // function Header(props) { const { sysSetting } = useContext(SysContext); const { window } = props; const [mobileOpen, setMobileOpen] = useState(false); const dispatch = useDispatch() const navigate = useNavigate() const handleDrawerToggle = () => { setMobileOpen((prevState) => !prevState); }; const handleLogout = async () => { await dispatch(handleLogoutFunction()); //await handleLogoutFunction(); await navigate('/login'); }; const loginContent = ( isGLDLoggedIn() ?
{isPasswordExpiry() ?
  • :
  • Dashboard
  • Application
  • { isGrantedAny(["VIEW_PROOF", "MAINTAIN_PROOF"]) ?
  • Proof
  • : <> } { isGrantedAny(["MAINTAIN_PROOF", "MAINTAIN_PAYMENT", "MAINTAIN_RECON", "VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
  • Payment
      { isGranted("MAINTAIN_PROOF") ?
    • Export for GDN
    • : <> } { isGranted("MAINTAIN_PAYMENT") ?
    • Mark Payment
    • : <> } { isGranted("MAINTAIN_PAYMENT") ?
    • Online Payment Record
    • : <> } { isGranted("MAINTAIN_RECON") ? <>
    • GFMIS Generate XML
    • : <> } { isGranted("MAINTAIN_DEMANDNOTE") ?
    • Create Demand Note
    • : <> } { isGrantedAny(["VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
    • Demand Note
    • : <> } { isGranted("MAINTAIN_RECON") ? <>
    • Recon Report
    • : <> }
  • : <> } { isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_ORG", "MAINTAIN_ORG", "VIEW_GROUP", "MAINTAIN_GROUP"]) ?
  • Client
      { isGrantedAny(["VIEW_USER", "MAINTAIN_USER"]) ? <>
    • Users (GLD)
    • Users (Individual)
    • Users (Organisation)
    • : <> } { isGrantedAny(["VIEW_ORG", "MAINTAIN_ORG"]) ?
    • Organisation
    • : <> } { isGrantedAny(["VIEW_GROUP", "MAINTAIN_GROUP"]) ?
    • User Group
    • : <> }
  • : <> }
  • Settings
    • My Profile
    • { isGranted("MAINTAIN_GAZETTE_ISSUE") ? <>
    • Holiday Settings
    • Gazette Issues
    • : <> } { isGranted("MAINTAIN_ANNOUNCEMENT") ?
    • Announcement
    • : <> } {isGranted("MAINTAIN_EMAIL") ?
    • Email Template
    • : <> } { isGranted("MAINTAIN_DR") ?
    • DR Import
    • : <> } { isGranted("MAINTAIN_SETTING") ?
    • System Settings
    • : <> }
    • Audit Log
  • Logout
  • }
    :
    {isPasswordExpiry() ?
  • :
  • {isCreditorLoggedIn() ? haveOrgPaymentRecord() ? <>
    : : isORGLoggedIn() ? haveOrgPaymentRecord() ? : : }
  • {isPrimaryLoggedIn() ? <> console.log(event)}>
    • {/* */}
    • {/* */}
    : isINDLoggedIn() ? <> console.log(event)}>
    • {/* */}
    : <> console.log(event)}>
    }
  • }
  • ); const logoutContent = (
  • { sysSetting?.allowRegistration ?
  • : <> }
    ); const drawer = ( isUserLoggedIn() ? {/* PNSPS */} PNSPS
    : PNSPS ); const container = window !== undefined ? () => window().document.body : undefined; return ( isUserLoggedIn() ? // User Login success {isGLDLoggedIn() ? PNSPS RESTRICTED : {/*公共啟事提交*/} {/*及繳費系統*/} } { isGLDLoggedIn() ? RESTRICTED : } {/**/} {drawer} : {/**/} {drawer} ); } Header.propTypes = { /** * Injected by the documentation to work in an iframe. * You won't need it on your project. */ window: PropTypes.func, }; export default Header;