import PropTypes from 'prop-types'; import React , { useState } from 'react'; import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; // 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, // 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 } from "utils/Utils"; import { handleLogoutFunction } from 'auth/index'; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst" // assets // import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons'; // import { AppBar } from '../../../../node_modules/@mui/material/index'; import { Link } from "react-router-dom"; const drawerWidth = 240; // const navItems = ['Home', 'About', 'Contact']; // ==============================|| MAIN LAYOUT - HEADER ||============================== // function Header(props) { const { window } = props; const [mobileOpen, setMobileOpen] = useState(false); const dispatch = useDispatch() const navigate = useNavigate() const handleDrawerToggle = () => { setMobileOpen((prevState) => !prevState); }; const handleLogout = async () => { dispatch(handleLogoutFunction()); //await handleLogoutFunction(); navigate('/login'); }; const getXML = () => () => { HttpUtils.get({ url: UrlUtils.GEN_GFMIS_XML + "/today?online=true", params:{}, onSuccess: (responseData) => { console.log(responseData) const parser = new DOMParser(); const xmlDoc = parser.parseFromString(responseData, 'application/xml'); const filename = xmlDoc.querySelector('FileHeader').getAttribute('H_Filename'); const blob = new Blob([responseData], { type: 'application/xml' }); // Create a download link const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = filename+'.xml'; // Append the link to the document body document.body.appendChild(link); // Programmatically click the link to trigger the download link.click(); // Clean up the link document.body.removeChild(link); } }); // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true") } const loginContent = ( isGLDLoggedIn() ?
  • Dashboard
  • Application
  • Proof
  • Payment
    • Payment Record
    • Download XML
    • Create DN
    • Demand Note
  • Client
    • Users (GLD)
    • Users (Individual)
    • Users (Organisation)
    • Organisation
    • User Group
  • Email Template
  • {/*
  • Logout
  • */}
    :
  • 主頁
  • 我的公共啟事
  • 校對記錄
  • {isPrimaryLoggedIn() ?
    付款記錄
    • 網上付款記錄
    • 繳款通知記錄
    : 網上付款記錄 }
  • 設定 {isPrimaryLoggedIn() ?
    • 公司/機構用戶記錄
    : <> }
  • {/*
  • 登出
  • */}
    ); const logoutContent = (
  • 登入
  • 申請
  • ); const drawer = ( isUserLoggedIn() ? PNSPS
    • 登出
    : PNSPS ); const container = window !== undefined ? () => window().document.body : undefined; return ( isUserLoggedIn() ? // User Login success {isGLDLoggedIn() ? PNSPS : 公共啟事提交 及繳費系統 公共啟事提交及繳費系統 } {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;