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.
 
 

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