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

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