Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

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