Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

794 wiersze
32 KiB

  1. import PropTypes from 'prop-types';
  2. import React
  3. , { useState, useContext }
  4. from 'react';
  5. import { useDispatch } from "react-redux";
  6. import { useNavigate } from "react-router-dom";
  7. import { SysContext } from "components/SysSettingProvider"
  8. // material-ui
  9. // import { useTheme } from '@mui/material/styles';
  10. import {
  11. AppBar,
  12. // Container,
  13. Typography,
  14. Box,
  15. Stack,
  16. // IconButton,
  17. // Menu,
  18. // MenuItem,
  19. // Button,
  20. // Tooltip,
  21. // Avatar,
  22. // Stack,
  23. Toolbar,
  24. Divider,
  25. // List,
  26. // ListItem,
  27. // ListItemButton,
  28. // ListItemText,
  29. IconButton,
  30. Drawer, Grid,
  31. // useMediaQuery
  32. } from '@mui/material';
  33. import MenuIcon from '@mui/icons-material/Menu';
  34. import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
  35. // project import
  36. // import AppBarStyled from './AppBarStyled';
  37. // import HeaderContent from './HeaderContent';
  38. import Logo from 'components/Logo';
  39. import AdminLogo from 'components/AdminLogo';
  40. import MobileLogo from 'components/MobileLogo';
  41. //import Profile from './HeaderContent/Profile';
  42. import "assets/style/navbarStyles.css";
  43. import {
  44. isUserLoggedIn,
  45. isGLDLoggedIn,
  46. isPrimaryLoggedIn,
  47. isCreditorLoggedIn,
  48. isINDLoggedIn,
  49. isPasswordExpiry,
  50. haveOrgPaymentRecord,
  51. isORGLoggedIn,
  52. // getUserId
  53. } from "utils/Utils";
  54. import { handleLogoutFunction } from 'auth/index';
  55. import { isGranted, isGrantedAny } from "auth/utils";
  56. // assets
  57. // import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons';
  58. // import { AppBar } from '../../../../node_modules/@mui/material/index';
  59. import { Link } from "react-router-dom";
  60. import LocaleSelector from "./HeaderContent/LocaleSelector";
  61. import { FormattedMessage } from "react-intl";
  62. const drawerWidth = 300;
  63. // const navItems = ['Home', 'About', 'Contact'];
  64. // ==============================|| MAIN LAYOUT - HEADER ||============================== //
  65. function Header(props) {
  66. const { sysSetting } = useContext(SysContext);
  67. const { window } = props;
  68. const [mobileOpen, setMobileOpen] = useState(false);
  69. const dispatch = useDispatch()
  70. const navigate = useNavigate()
  71. const handleDrawerToggle = () => {
  72. setMobileOpen((prevState) => !prevState);
  73. };
  74. const handleLogout = async () => {
  75. await dispatch(handleLogoutFunction());
  76. //await handleLogoutFunction();
  77. await navigate('/login');
  78. };
  79. const loginContent = (
  80. isGLDLoggedIn() ?
  81. <div id="adminContent">
  82. {isPasswordExpiry() ?
  83. <div id="passwordExpiryedContent">
  84. <li>
  85. <Link className="manageUser" to={'/user/changePassword'}>
  86. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  87. <FormattedMessage id="userChangePassword" />
  88. </Typography>
  89. </Link>
  90. </li>
  91. </div>
  92. :
  93. <div id="adminContentList">
  94. <li>
  95. <Link className="dashboard" to='/dashboard'>
  96. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} >
  97. Dashboard
  98. </Typography>
  99. </Link>
  100. </li>
  101. <li>
  102. <Link className="application" to='/application/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Application</Typography></Link>
  103. </li>
  104. {
  105. isGrantedAny(["VIEW_PROOF", "MAINTAIN_PROOF"]) ?
  106. <li>
  107. <Link className="proof" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Proof</Typography></Link>
  108. </li>
  109. : <></>
  110. }
  111. {
  112. isGrantedAny(["MAINTAIN_PROOF", "MAINTAIN_PAYMENT", "MAINTAIN_RECON", "VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
  113. <li>
  114. <Link className="paymentTop" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Payment</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
  115. <ul className='dropdown'>
  116. {
  117. isGranted("MAINTAIN_PROOF") ?
  118. <li>
  119. <Link className="exportDemandNote" to='/paymentPage/exportGDN' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Export for GDN</Typography></Link>
  120. </li>
  121. :
  122. <></>
  123. }
  124. {
  125. isGranted("MAINTAIN_PAYMENT") ?
  126. <li>
  127. <Link className="application" to='/application/markAsPaid/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Mark Payment</Typography></Link>
  128. </li>
  129. :
  130. <></>
  131. }
  132. {
  133. isGranted("MAINTAIN_PAYMENT") ?
  134. <li>
  135. <Link className="payment" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Online Payment Record</Typography></Link>
  136. </li>
  137. :
  138. <></>
  139. }
  140. {
  141. isGranted("MAINTAIN_RECON") ?
  142. <>
  143. <li>
  144. <Link className="downloadXML" to='/gfmis/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>GFMIS Generate XML</Typography></Link>
  145. </li>
  146. </>
  147. :
  148. <></>
  149. }
  150. {
  151. isGranted("MAINTAIN_DEMANDNOTE") ?
  152. <li>
  153. <Link className="createDemandNote" to='/paymentPage/createDemandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Create Demand Note</Typography></Link>
  154. </li>
  155. :
  156. <></>
  157. }
  158. {
  159. isGrantedAny(["VIEW_DEMANDNOTE", "MAINTAIN_DEMANDNOTE"]) ?
  160. <li>
  161. <Link className="demandNote" to='/paymentPage/demandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Demand Note</Typography></Link>
  162. </li>
  163. :
  164. <></>
  165. }
  166. {
  167. isGranted("MAINTAIN_RECON") ?
  168. <>
  169. <li>
  170. <Link className="reconReport" to='/paymentPage/reconReport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Recon Report</Typography></Link>
  171. </li>
  172. </>
  173. :
  174. <></>
  175. }
  176. </ul>
  177. </li>
  178. :
  179. <></>
  180. }
  181. {
  182. isGrantedAny(["VIEW_USER", "MAINTAIN_USER", "VIEW_ORG", "MAINTAIN_ORG", "VIEW_GROUP", "MAINTAIN_GROUP"]) ?
  183. <li>
  184. <Link className="client" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Client</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
  185. <ul className='dropdown'>
  186. {
  187. isGrantedAny(["VIEW_USER", "MAINTAIN_USER"]) ?
  188. <>
  189. <li>
  190. <Link className="userSearchview" to='/userSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (GLD)</Typography></Link>
  191. </li>
  192. <li>
  193. <Link className="indUser" to='/indUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Individual)</Typography></Link>
  194. </li>
  195. <li>
  196. <Link className="orgUser" to='/orgUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Organisation)</Typography></Link>
  197. </li>
  198. </>
  199. :
  200. <></>
  201. }
  202. {
  203. isGrantedAny(["VIEW_ORG", "MAINTAIN_ORG"]) ?
  204. <li>
  205. <Link className="org" to='/org'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Organisation</Typography></Link>
  206. </li>
  207. :
  208. <></>
  209. }
  210. {
  211. isGrantedAny(["VIEW_GROUP", "MAINTAIN_GROUP"]) ?
  212. <li>
  213. <Link className="usergroupSearchview" to='/usergroupSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>User Group</Typography></Link>
  214. </li>
  215. :
  216. <></>
  217. }
  218. </ul>
  219. </li>
  220. :
  221. <></>
  222. }
  223. <li>
  224. <Link className="setting" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Settings</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1vw' }} /></Link>
  225. <ul className='dropdown'>
  226. <li>
  227. <Link className="userProfileGld" to='/user/profile'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>My Profile</Typography></Link>
  228. </li>
  229. <li>
  230. <Link className="manageUser" to={'/user/changePassword'}>
  231. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  232. <FormattedMessage id="userChangePassword" />
  233. </Typography>
  234. </Link>
  235. </li>
  236. {
  237. isGranted("MAINTAIN_GAZETTE_ISSUE") ?
  238. <>
  239. <li>
  240. <Link className="holidaySetting" to='/setting/holiday'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Holiday Settings</Typography></Link>
  241. </li>
  242. <li>
  243. <Link className="gazetteissueSetting" to='/setting/gazetteissuepage'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Gazette Issues</Typography></Link>
  244. </li>
  245. </>
  246. :
  247. <></>
  248. }
  249. {
  250. isGranted("MAINTAIN_ANNOUNCEMENT") ?
  251. <li>
  252. <Link className="announcement" to='/setting/announcement'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Announcement</Typography></Link>
  253. </li>
  254. :
  255. <></>
  256. }
  257. {isGranted("MAINTAIN_EMAIL") ?
  258. <li>
  259. <Link className="emailTemplate" to='/setting/emailTemplate'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Email Template</Typography></Link>
  260. </li>
  261. :
  262. <></>
  263. }
  264. {
  265. isGranted("MAINTAIN_DR") ?
  266. <li>
  267. <Link className="drImport" to='/setting/drImport'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>DR Import</Typography></Link>
  268. </li>
  269. :
  270. <></>
  271. }
  272. {
  273. isGranted("MAINTAIN_SETTING") ?
  274. <li>
  275. <Link className="systemSetting" to='/setting/sys'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>System Settings</Typography></Link>
  276. </li>
  277. :
  278. <></>
  279. }
  280. <li>
  281. <Link className="auditLogSetting" to='/setting/auditLog'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Audit Log</Typography></Link>
  282. </li>
  283. </ul>
  284. </li>
  285. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
  286. <li>
  287. <Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Logout</Typography></Link>
  288. </li>
  289. </Box>
  290. </div>
  291. }
  292. </div>
  293. :
  294. <div id="individualUserContent">
  295. {isPasswordExpiry() ?
  296. <div id="passwordExpiryedContent">
  297. <li>
  298. <Link className="manageUser" to={'/user/changePassword'}>
  299. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  300. <FormattedMessage id="userChangePassword" />
  301. </Typography>
  302. </Link>
  303. </li>
  304. </div>
  305. :
  306. <div id="individualUserContentList">
  307. <li>
  308. <Link className="dashboard" to='/dashboard'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  309. <FormattedMessage id="mainPage" />
  310. </Typography></Link>
  311. </li>
  312. <li>
  313. <Link className="myDocumet" to='/publicNotice'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  314. <FormattedMessage id="myPublicNotice" />
  315. </Typography></Link>
  316. </li>
  317. <li>
  318. <Link className="documentRecord" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  319. <FormattedMessage id="proofRecord" />
  320. </Typography></Link>
  321. </li>
  322. <li>
  323. {isCreditorLoggedIn() ?
  324. haveOrgPaymentRecord() ?
  325. <>
  326. <Link className="paymentRecord">
  327. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  328. <FormattedMessage id="paymentHistory" />
  329. </Typography>
  330. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  331. </Link>
  332. <ul className='dropdown'>
  333. <li>
  334. <Link className="manageOrgUser" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  335. <FormattedMessage id="onlinePaymentHistory" />
  336. </Typography></Link>
  337. </li>
  338. <li>
  339. <Link className="manageOrgUser" to='/paymentPage/demandNote'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  340. <FormattedMessage id="paymentInfoRecord" />
  341. </Typography></Link>
  342. </li>
  343. </ul>
  344. </>
  345. :
  346. <Link className="manageOrgUser" to='/paymentPage/demandNote'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  347. <FormattedMessage id="paymentInfoRecord" />
  348. </Typography></Link>
  349. :
  350. isORGLoggedIn() ?
  351. haveOrgPaymentRecord() ?
  352. <Link className="manageOrgUser" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  353. <FormattedMessage id="onlinePaymentHistory" />
  354. </Typography></Link>
  355. :
  356. <Link className="manageOrgUser" to='/paymentPage/demandNote'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  357. <FormattedMessage id="paymentInfoRecord" />
  358. </Typography></Link>
  359. :
  360. <Link className="manageOrgUser" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  361. <FormattedMessage id="onlinePaymentHistory" />
  362. </Typography></Link>
  363. }
  364. </li>
  365. <li>
  366. {isPrimaryLoggedIn() ?
  367. <>
  368. <Link className="userSetting" >
  369. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  370. <FormattedMessage id="setting" />
  371. </Typography>
  372. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  373. </Link>
  374. <ul className='dropdown' style={{ width: "max-content" }}>
  375. <li>
  376. <Link className="manageOrgUser" to='setting/manageUser'>
  377. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  378. <FormattedMessage id="companyOrUserRecord" />
  379. </Typography>
  380. </Link>
  381. </li>
  382. <li>
  383. <Link className="manageUser" to={'/orgUser'}>
  384. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  385. {/* <FormattedMessage id="companyOrUserRecord" /> */}
  386. <FormattedMessage id="userProfile" />
  387. </Typography>
  388. </Link>
  389. </li>
  390. <li>
  391. <Link className="manageUser" to={'/user/changePassword'}>
  392. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  393. <FormattedMessage id="userChangePassword" />
  394. </Typography>
  395. </Link>
  396. </li>
  397. <li>
  398. <Link className="manageUser" to={'/org'}>
  399. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  400. {/* <FormattedMessage id="companyOrUserRecord" /> */}
  401. <FormattedMessage id="organizationProfile" />
  402. </Typography>
  403. </Link>
  404. </li>
  405. </ul>
  406. </>
  407. :
  408. isINDLoggedIn() ?
  409. <>
  410. <Link className="userSetting" >
  411. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  412. <FormattedMessage id="setting" />
  413. </Typography>
  414. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  415. </Link>
  416. <ul className='dropdown' style={{ width: "max-content" }}>
  417. <li>
  418. <Link className="manageUser" to={'/indUser'}>
  419. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  420. {/* <FormattedMessage id="companyOrUserRecord" /> */}
  421. <FormattedMessage id="userProfile" />
  422. </Typography>
  423. </Link>
  424. </li>
  425. <li>
  426. <Link className="manageUser" to={'/user/changePassword'}>
  427. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  428. <FormattedMessage id="userChangePassword" />
  429. </Typography>
  430. </Link>
  431. </li>
  432. </ul>
  433. </>
  434. :
  435. <>
  436. <Link className="userSetting" >
  437. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  438. <FormattedMessage id="setting" />
  439. </Typography>
  440. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  441. </Link>
  442. <ul className='dropdown' style={{ width: "max-content" }}>
  443. <li>
  444. <Link className="manageUser" to={'/orgUser'}>
  445. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  446. <FormattedMessage id="userProfile" />
  447. </Typography>
  448. </Link>
  449. </li>
  450. <li>
  451. <Link className="manageUser" to={'/user/changePassword'}>
  452. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  453. <FormattedMessage id="userChangePassword" />
  454. </Typography>
  455. </Link>
  456. </li>
  457. </ul>
  458. </>
  459. }
  460. </li>
  461. </div>
  462. }
  463. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
  464. <li>
  465. <Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  466. <FormattedMessage id="logout" />
  467. </Typography></Link>
  468. </li>
  469. </Box>
  470. </div>
  471. );
  472. const logoutContent = (
  473. <div>
  474. <li>
  475. <Link className="login" to={'/aboutUs'}>
  476. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  477. <FormattedMessage id="aboutUs" />
  478. </Typography>
  479. </Link>
  480. </li>
  481. <li>
  482. <Link className="login" to='/login'>
  483. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  484. <FormattedMessage id="login" />
  485. </Typography>
  486. </Link>
  487. </li>
  488. {
  489. sysSetting?.allowRegistration ?
  490. <li>
  491. <Link className="register" to='/register'>
  492. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  493. <FormattedMessage id="register" />
  494. </Typography>
  495. </Link>
  496. </li>
  497. :
  498. <></>
  499. }
  500. </div>
  501. );
  502. const drawer = (
  503. isUserLoggedIn() ?
  504. <Stack id="sidebar" direction="column" justifyContent="center" alignItems="center" /*onClick={handleDrawerToggle}*/ sx={{ textAlign: 'center', width: '300px' }}>
  505. {/* <Typography variant="h6" sx={{ my: 2 }}>
  506. PNSPS
  507. </Typography> */}
  508. <Box sx={{ mr: 2, mt: 1, display: { md: 'none' } }}>
  509. <MobileLogo />
  510. <span id="mobileTitle" >PNSPS</span>
  511. </Box>
  512. <Divider />
  513. <ul id="sidebartop">
  514. {loginContent}
  515. </ul>
  516. <Divider />
  517. <ul id="sidebarbottom">
  518. <li>
  519. <Link className="logout" onClick={handleLogout}>
  520. <FormattedMessage id="logout" />
  521. </Link>
  522. </li>
  523. </ul>
  524. </Stack>
  525. :
  526. <Stack id="sidebar" direction="column" justifyContent="center" alignItems="center" onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
  527. <Box sx={{ mr: 2, mt: 1, display: { md: 'none' } }}>
  528. <MobileLogo />
  529. <span id="mobileTitle" >PNSPS</span>
  530. </Box>
  531. <Divider />
  532. <ul id="logoutContent">
  533. {logoutContent}
  534. </ul>
  535. <Divider />
  536. </Stack>
  537. );
  538. const container = window !== undefined ? () => window().document.body : undefined;
  539. return (
  540. isUserLoggedIn() ?
  541. // User Login success
  542. <Box>
  543. <AppBar component="nav">
  544. <Toolbar id="nav" width="100%">
  545. {isGLDLoggedIn()
  546. ? <Stack
  547. direction="row"
  548. justifyContent="flex-start"
  549. alignItems="center"
  550. spacing={0}
  551. sx={{ width: { xs: '100%', md: '5%' } }}
  552. >
  553. <Box mt={0.5} sx={{ flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  554. <AdminLogo />
  555. </Box>
  556. <IconButton
  557. color="inherit"
  558. aria-label="open drawer"
  559. edge="start"
  560. onClick={handleDrawerToggle}
  561. sx={{ mr: 2, display: { md: 'none' } }}
  562. >
  563. <MenuIcon style={{ color: '#0C489E' }} />
  564. </IconButton>
  565. <Box sx={{ flexGrow: 1, mr: 2, display: { sm: 'block', md: 'none' } }}>
  566. <Stack direction="row" justifyContent="space-between" alignItems="center" width="100%">
  567. <MobileLogo />
  568. <Stack justifyContent="flex-start" alignItems="flex-start" width="100%" ml={2}>
  569. <span id="mobileTitle">PNSPS</span>
  570. </Stack>
  571. <Stack justifyContent="flex-end" alignItems="center">
  572. <span style={{color:"#B11B1B",fontWeight:'bold',fontSize:'15px'}}>RESTRICTED</span>
  573. </Stack>
  574. </Stack>
  575. </Box>
  576. </Stack> :
  577. <Stack
  578. direction="row"
  579. justifyContent="flex-start"
  580. alignItems="center"
  581. spacing={0}
  582. sx={{ width: { xs: '100%', md: '25%' } }}
  583. >
  584. <Box sx={{ width: '450px', flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  585. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  586. <Logo />
  587. <Stack justifyContent="flex-start" alignItems="center">
  588. {/*<span id="systemTitle">公共啟事提交</span>*/}
  589. {/*<span id="systemTitle">及繳費系統</span>*/}
  590. <span id="systemTitle">
  591. <FormattedMessage id="PNSPS" />
  592. </span>
  593. </Stack>
  594. </Stack>
  595. </Box>
  596. <IconButton
  597. color="inherit"
  598. aria-label="open drawer"
  599. edge="start"
  600. onClick={handleDrawerToggle}
  601. sx={{ mr: 2, display: { md: 'none' } }}
  602. >
  603. <MenuIcon style={{ color: '#0C489E' }} />
  604. </IconButton>
  605. <Box sx={{ flexGrow: 1, mr: 2, display: { sm: 'block', md: 'none' } }}>
  606. <Stack direction="row" justifyContent="space-between" alignItems="center" width="100%">
  607. <MobileLogo />
  608. <Stack justifyContent="flex-start" alignItems="flex-start" width="100%" ml={2}>
  609. <span id="mobileTitle">
  610. <FormattedMessage id="PNSPS" />
  611. </span>
  612. </Stack>
  613. <Stack justifyContent="flex-end" alignItems="center">
  614. <LocaleSelector />
  615. </Stack>
  616. </Stack>
  617. </Box>
  618. </Stack>
  619. }
  620. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, width: "100%" }}>
  621. <Stack
  622. direction="row"
  623. justifyContent="space-between"
  624. alignItems="center"
  625. spacing={1}
  626. >
  627. <ul id="navbar" width="100%" >
  628. {loginContent}
  629. </ul>
  630. <Grid item>
  631. <Grid container direction="column"
  632. justifyContent="flex-end"
  633. alignItems="center"
  634. >
  635. {
  636. isGLDLoggedIn() ?
  637. <Grid item >
  638. <span style={{color:"#B11B1B",fontWeight:'bold',fontSize:'15px'}}>RESTRICTED</span>
  639. </Grid>
  640. :
  641. <Grid item>
  642. <LocaleSelector />
  643. </Grid>
  644. }
  645. {/*<Profile />*/}
  646. </Grid>
  647. </Grid>
  648. </Stack>
  649. </Box>
  650. </Toolbar>
  651. </AppBar>
  652. <Box component="nav">
  653. <Drawer
  654. container={container}
  655. variant="temporary"
  656. open={mobileOpen}
  657. onClose={handleDrawerToggle}
  658. ModalProps={{
  659. keepMounted: true, // Better open performance on mobile.
  660. }}
  661. sx={{
  662. display: { sm: 'block', md: 'none' },
  663. '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
  664. }}
  665. >
  666. {drawer}
  667. </Drawer>
  668. </Box>
  669. </Box> :
  670. <Box>
  671. <AppBar component="nav">
  672. <Toolbar id="nav" width="100%">
  673. <Stack
  674. direction="row"
  675. justifyContent="flex-start"
  676. alignItems="center"
  677. spacing={0}
  678. // width="100%"
  679. sx={{ width: { xs: '100%', md: '25%' } }}
  680. >
  681. <Box sx={{ flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  682. <Stack direction="row" justifyContent="flex-start" alignItems="center" >
  683. <Logo />
  684. <Stack justifyContent="flex-start" alignItems="center">
  685. <span id="systemTitle">
  686. <FormattedMessage id="PNSPS" />
  687. </span>
  688. </Stack>
  689. </Stack>
  690. </Box>
  691. <IconButton
  692. color="inherit"
  693. aria-label="open drawer"
  694. edge="start"
  695. onClick={handleDrawerToggle}
  696. sx={{ mr: 2, display: { md: 'none' } }}
  697. >
  698. <MenuIcon style={{ color: '#0C489E' }} />
  699. </IconButton>
  700. <Box sx={{ flexGrow: 1, mr: 2, display: { sm: 'block', md: 'none' } }}>
  701. <Stack direction="row" justifyContent="space-between" alignItems="center" width="100%">
  702. <MobileLogo />
  703. <Stack justifyContent="flex-start" alignItems="flex-start" width="100%" ml={2}>
  704. <span id="mobileTitle">
  705. <FormattedMessage id="PNSPS" />
  706. </span>
  707. </Stack>
  708. <Stack justifyContent="flex-end" alignItems="center">
  709. <LocaleSelector />
  710. </Stack>
  711. </Stack>
  712. </Box>
  713. </Stack>
  714. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, width: "75%" }}>
  715. <Stack
  716. direction="row"
  717. justifyContent="space-between"
  718. alignItems="center"
  719. spacing={1}
  720. >
  721. <ul id="navbar" width="100%" >
  722. {logoutContent}
  723. </ul>
  724. <LocaleSelector />
  725. {/*<Profile />*/}
  726. </Stack>
  727. </Box>
  728. </Toolbar>
  729. </AppBar>
  730. <Box component="nav">
  731. <Drawer
  732. container={container}
  733. variant="temporary"
  734. open={mobileOpen}
  735. onClose={handleDrawerToggle}
  736. ModalProps={{
  737. keepMounted: true, // Better open performance on mobile.
  738. }}
  739. sx={{
  740. display: { sm: 'block', md: 'none' },
  741. '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
  742. }}
  743. >
  744. {drawer}
  745. </Drawer>
  746. </Box>
  747. </Box>
  748. );
  749. }
  750. Header.propTypes = {
  751. /**
  752. * Injected by the documentation to work in an iframe.
  753. * You won't need it on your project.
  754. */
  755. window: PropTypes.func,
  756. };
  757. export default Header;