You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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