選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.js 19 KiB

2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. import PropTypes from 'prop-types';
  2. import React
  3. , { useState }
  4. from 'react';
  5. import { useDispatch } from "react-redux";
  6. import { useNavigate } from "react-router-dom";
  7. // material-ui
  8. // import { useTheme } from '@mui/material/styles';
  9. import {
  10. AppBar,
  11. // Container,
  12. Typography,
  13. Box,
  14. Stack,
  15. // IconButton,
  16. // Menu,
  17. // MenuItem,
  18. // Button,
  19. // Tooltip,
  20. // Avatar,
  21. // Stack,
  22. Toolbar,
  23. Divider,
  24. // List,
  25. // ListItem,
  26. // ListItemButton,
  27. // ListItemText,
  28. IconButton,
  29. Drawer, Grid,
  30. // useMediaQuery
  31. } from '@mui/material';
  32. import MenuIcon from '@mui/icons-material/Menu';
  33. import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
  34. // project import
  35. // import AppBarStyled from './AppBarStyled';
  36. // import HeaderContent from './HeaderContent';
  37. import Logo from 'components/Logo';
  38. import AdminLogo from 'components/AdminLogo';
  39. import MobileLogo from 'components/MobileLogo';
  40. import Profile from './HeaderContent/Profile';
  41. import "assets/style/navbarStyles.css";
  42. import {
  43. isUserLoggedIn,
  44. isGLDLoggedIn,
  45. isPrimaryLoggedIn,
  46. isCreditorLoggedIn,
  47. isINDLoggedIn,
  48. // isORGLoggedIn,
  49. // getUserId
  50. } from "utils/Utils";
  51. import { handleLogoutFunction } from 'auth/index';
  52. // assets
  53. // import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons';
  54. // import { AppBar } from '../../../../node_modules/@mui/material/index';
  55. import { Link } from "react-router-dom";
  56. import LocaleSelector from "./HeaderContent/LocaleSelector";
  57. import { FormattedMessage } from "react-intl";
  58. const drawerWidth = 240;
  59. // const navItems = ['Home', 'About', 'Contact'];
  60. // ==============================|| MAIN LAYOUT - HEADER ||============================== //
  61. function Header(props) {
  62. const { window } = props;
  63. const [mobileOpen, setMobileOpen] = useState(false);
  64. const dispatch = useDispatch()
  65. const navigate = useNavigate()
  66. const handleDrawerToggle = () => {
  67. setMobileOpen((prevState) => !prevState);
  68. };
  69. const handleLogout = async () => {
  70. dispatch(handleLogoutFunction());
  71. //await handleLogoutFunction();
  72. navigate('/login');
  73. };
  74. const loginContent = (
  75. isGLDLoggedIn() ?
  76. <div id="adminContent">
  77. <li>
  78. <Link className="dashboard" to='/dashboard'>
  79. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} >
  80. Dashboard
  81. </Typography>
  82. </Link>
  83. </li>
  84. <li>
  85. <Link className="application" to='/application/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>Application</Typography></Link>
  86. </li>
  87. <li>
  88. <Link className="proof" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Proof</Typography></Link>
  89. </li>
  90. <li>
  91. <Link className="client" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Payment</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} /></Link>
  92. <ul className='dropdown'>
  93. <li>
  94. <Link className="payment" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Payment Record</Typography></Link>
  95. </li>
  96. <li>
  97. <Link className="downloadXML" to='/gfmis/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>GFMIS Generate XML</Typography></Link>
  98. </li>
  99. <li>
  100. <Link className="createDemandNote" to='/paymentPage/createDemandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Create Demand Note</Typography></Link>
  101. </li>
  102. <li>
  103. <Link className="demandNote" to='/paymentPage/demandNote' ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Demand Note</Typography></Link>
  104. </li>
  105. </ul>
  106. </li>
  107. <li>
  108. <Link className="client" ><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Client</Typography><KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} /></Link>
  109. <ul className='dropdown'>
  110. <li>
  111. <Link className="userSearchview" to='/userSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (GLD)</Typography></Link>
  112. </li>
  113. <li>
  114. <Link className="indUser" to='/indUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Individual)</Typography></Link>
  115. </li>
  116. <li>
  117. <Link className="orgUser" to='/orgUser'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Users (Organisation)</Typography></Link>
  118. </li>
  119. <li>
  120. <Link className="org" to='/org'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>Organisation</Typography></Link>
  121. </li>
  122. <li>
  123. <Link className="usergroupSearchview" to='/usergroupSearchview'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2, mt: 1, mb: 1 }}>User Group</Typography></Link>
  124. </li>
  125. </ul>
  126. </li>
  127. <li>
  128. <Link className="emailTemplate" to='/emailTemplate'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 0 }}>Email Template</Typography></Link>
  129. </li>
  130. {/* <li>
  131. <Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>Logout</Typography></Link>
  132. </li> */}
  133. </div>
  134. :
  135. <div id="individualUserContent">
  136. <li>
  137. <Link className="dashboard" to='/dashboard'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  138. <FormattedMessage id="mainPage" />
  139. </Typography></Link>
  140. </li>
  141. <li>
  142. <Link className="myDocumet" to='/publicNotice'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  143. <FormattedMessage id="myPublicNotice" />
  144. </Typography></Link>
  145. </li>
  146. <li>
  147. <Link className="documentRecord" to='/proof/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  148. <FormattedMessage id="proofRecord" />
  149. </Typography></Link>
  150. </li>
  151. <li>
  152. {isCreditorLoggedIn() ?
  153. <>
  154. <Link className="paymentRecord">
  155. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  156. <FormattedMessage id="paymentHistory"/>
  157. </Typography>
  158. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  159. </Link>
  160. <ul className='dropdown'>
  161. <li>
  162. <Link className="manageOrgUser" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  163. <FormattedMessage id="onlinePaymentHistory" />
  164. </Typography></Link>
  165. </li>
  166. <li>
  167. <Link className="manageOrgUser" to='/paymentPage/demandNote'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>繳款通知記錄</Typography></Link>
  168. </li>
  169. </ul>
  170. </>
  171. :
  172. <Link className="manageOrgUser" to='/paymentPage/search'><Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }}>
  173. <FormattedMessage id="onlinePaymentHistory" />
  174. </Typography></Link>
  175. }
  176. </li>
  177. <li>
  178. {isPrimaryLoggedIn() ?
  179. <>
  180. <Link className="userSetting" >
  181. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  182. <FormattedMessage id="setting" />
  183. </Typography>
  184. <KeyboardArrowDownIcon sx={{ fontSize: '1.0rem' }} />
  185. </Link>
  186. <ul className='dropdown' style={{ width: "max-content" }}>
  187. <li>
  188. <Link className="manageOrgUser" to='setting/manageUser'>
  189. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  190. <FormattedMessage id="companyOrUserRecord" />
  191. </Typography>
  192. </Link>
  193. </li>
  194. </ul>
  195. </>
  196. :
  197. isINDLoggedIn()?
  198. <>
  199. <Link className="userSetting" >
  200. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  201. <FormattedMessage id="setting" />
  202. </Typography>
  203. </Link>
  204. <ul className='dropdown' style={{ width: "max-content" }}>
  205. <li>
  206. <Link className="manageUser" to={'/indUser'}>
  207. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  208. <FormattedMessage id="companyOrUserRecord" />
  209. </Typography>
  210. </Link>
  211. </li>
  212. </ul>
  213. </>
  214. :
  215. <>
  216. <Link className="userSetting" >
  217. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 1 }} onClick={(event) => console.log(event)}>
  218. <FormattedMessage id="setting" />
  219. </Typography>
  220. </Link>
  221. <ul className='dropdown' style={{ width: "max-content" }}>
  222. <li>
  223. <Link className="manageUser" to={'/orgUser'}>
  224. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  225. <FormattedMessage id="companyOrUserRecord" />
  226. </Typography>
  227. </Link>
  228. </li>
  229. </ul>
  230. </>
  231. }
  232. </li>
  233. {/* <li>
  234. <Link className="logout" onClick={handleLogout}><Typography variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>登出</Typography></Link>
  235. </li> */}
  236. </div>
  237. );
  238. const logoutContent = (
  239. <div>
  240. <li>
  241. <Link className="login" to='/login'>
  242. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  243. <FormattedMessage id="login" />
  244. </Typography>
  245. </Link>
  246. </li>
  247. <li>
  248. <Link className="register" to='/register'>
  249. <Typography style={{ opacity: 0.9 }} variant={"pnspsHeaderTitle"} sx={{ ml: 2 }}>
  250. <FormattedMessage id="register" />
  251. </Typography>
  252. </Link>
  253. </li>
  254. </div>
  255. );
  256. const drawer = (
  257. isUserLoggedIn() ?
  258. <Stack id="sidebar" direction="column" justifyContent="center" alignItems="center" /*onClick={handleDrawerToggle}*/ sx={{ textAlign: 'center' }}>
  259. <Typography variant="h6" sx={{ my: 2 }}>
  260. PNSPS
  261. </Typography>
  262. <Divider />
  263. <ul id="sidebartop">
  264. {loginContent}
  265. </ul>
  266. <Divider />
  267. <ul id="sidebarbottom">
  268. <li>
  269. <Link className="logout" onClick={handleLogout}>
  270. <FormattedMessage id="logout" />
  271. </Link>
  272. </li>
  273. </ul>
  274. </Stack>
  275. :
  276. <Stack id="sidebar" direction="column" justifyContent="center" alignItems="center" onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
  277. <Typography variant="h6" sx={{ my: 2 }}>
  278. PNSPS
  279. </Typography>
  280. <Divider />
  281. <ul id="sidebartop">
  282. {logoutContent}
  283. </ul>
  284. <Divider />
  285. </Stack>
  286. );
  287. const container = window !== undefined ? () => window().document.body : undefined;
  288. return (
  289. isUserLoggedIn() ?
  290. // User Login success
  291. <Box>
  292. <AppBar component="nav">
  293. <Toolbar id="nav" width="100%">
  294. {isGLDLoggedIn()
  295. ? <Stack
  296. direction="row"
  297. justifyContent="flex-start"
  298. alignItems="center"
  299. spacing={0}
  300. >
  301. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
  302. <AdminLogo />
  303. </Box>
  304. <IconButton
  305. color="inherit"
  306. aria-label="open drawer"
  307. edge="start"
  308. onClick={handleDrawerToggle}
  309. sx={{ mr: 2, display: { md: 'none' } }}
  310. >
  311. <MenuIcon style={{ color: '#0C489E' }} />
  312. </IconButton>
  313. <Box sx={{ mr: 2, display: { md: 'none' } }}>
  314. <MobileLogo />
  315. <span id="mobileTitle" >PNSPS</span>
  316. </Box>
  317. </Stack> :
  318. <Stack
  319. direction="row"
  320. justifyContent="flex-start"
  321. alignItems="center"
  322. spacing={0}
  323. >
  324. <Box sx={{ width: '260px', flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  325. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  326. <Logo />
  327. <Stack justifyContent="flex-start" alignItems="center">
  328. {/*<span id="systemTitle">公共啟事提交</span>*/}
  329. {/*<span id="systemTitle">及繳費系統</span>*/}
  330. <span id="systemTitle">
  331. <FormattedMessage id="PNSPS" />
  332. </span>
  333. </Stack>
  334. </Stack>
  335. </Box>
  336. <IconButton
  337. color="inherit"
  338. aria-label="open drawer"
  339. edge="start"
  340. onClick={handleDrawerToggle}
  341. sx={{ mr: 2, display: { md: 'none' } }}
  342. >
  343. <MenuIcon style={{ color: '#0C489E' }} />
  344. </IconButton>
  345. <Box sx={{ mr: 2, display: { md: 'none' } }}>
  346. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  347. <MobileLogo />
  348. <span id="mobileTitle" >
  349. <FormattedMessage id="PNSPS" />
  350. </span>
  351. </Stack>
  352. </Box>
  353. </Stack>
  354. }
  355. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, width: "100%" }}>
  356. <Stack
  357. direction="row"
  358. justifyContent="space-between"
  359. alignItems="center"
  360. spacing={1}
  361. >
  362. <ul id="navbar" width="100%" >
  363. {loginContent}
  364. </ul>
  365. <Grid item>
  366. <Grid container direction="row" >
  367. {
  368. isGLDLoggedIn() ?
  369. <Grid item />
  370. :
  371. <LocaleSelector />
  372. }
  373. <Profile />
  374. </Grid>
  375. </Grid>
  376. </Stack>
  377. </Box>
  378. </Toolbar>
  379. </AppBar>
  380. <Box component="nav">
  381. <Drawer
  382. container={container}
  383. variant="temporary"
  384. open={mobileOpen}
  385. onClose={handleDrawerToggle}
  386. ModalProps={{
  387. keepMounted: true, // Better open performance on mobile.
  388. }}
  389. sx={{
  390. display: { sm: 'block', md: 'none' },
  391. '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
  392. }}
  393. >
  394. {drawer}
  395. </Drawer>
  396. </Box>
  397. </Box> :
  398. <Box>
  399. <AppBar component="nav">
  400. <Toolbar id="nav" width="100%">
  401. <Stack
  402. direction="row"
  403. justifyContent="flex-start"
  404. alignItems="center"
  405. spacing={0}
  406. >
  407. <Box sx={{ flexGrow: 1, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  408. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  409. <Logo />
  410. <Stack justifyContent="flex-start" alignItems="center">
  411. <span id="systemTitle">
  412. <FormattedMessage id="PNSPS" />
  413. </span>
  414. </Stack>
  415. </Stack>
  416. </Box>
  417. <IconButton
  418. color="inherit"
  419. aria-label="open drawer"
  420. edge="start"
  421. onClick={handleDrawerToggle}
  422. sx={{ mr: 2, display: { md: 'none' } }}
  423. >
  424. <MenuIcon style={{ color: '#0C489E' }} />
  425. </IconButton>
  426. <Box sx={{ flexGrow: 1, mr: 2, display: { sm: 'block', md: 'none' } }}>
  427. <Stack direction="row" justifyContent="space-between" alignItems="center">
  428. <MobileLogo />
  429. <Stack justifyContent="flex-start" alignItems="center">
  430. <span id="mobileTitle">
  431. <FormattedMessage id="PNSPS" />
  432. </span>
  433. </Stack>
  434. <Stack justifyContent="flex-end" alignItems="center">
  435. <LocaleSelector />
  436. </Stack>
  437. </Stack>
  438. </Box>
  439. </Stack>
  440. <Box sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, width: "75%" }}>
  441. <Stack
  442. direction="row"
  443. justifyContent="space-between"
  444. alignItems="center"
  445. spacing={1}
  446. >
  447. <ul id="navbar" width="100%" >
  448. {logoutContent}
  449. </ul>
  450. <LocaleSelector />
  451. {/* <Profile /> */}
  452. </Stack>
  453. </Box>
  454. </Toolbar>
  455. </AppBar>
  456. <Box component="nav">
  457. <Drawer
  458. container={container}
  459. variant="temporary"
  460. open={mobileOpen}
  461. onClose={handleDrawerToggle}
  462. ModalProps={{
  463. keepMounted: true, // Better open performance on mobile.
  464. }}
  465. sx={{
  466. display: { sm: 'block', md: 'none' },
  467. '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
  468. }}
  469. >
  470. {drawer}
  471. </Drawer>
  472. </Box>
  473. </Box>
  474. );
  475. }
  476. Header.propTypes = {
  477. /**
  478. * Injected by the documentation to work in an iframe.
  479. * You won't need it on your project.
  480. */
  481. window: PropTypes.func,
  482. };
  483. export default Header;