25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

605 lines
36 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. // InputAdornment,
  7. Typography, FormLabel,
  8. OutlinedInput,
  9. Stack,
  10. Dialog, DialogTitle, DialogContent, DialogActions
  11. } from '@mui/material';
  12. // import MainCard from "../../components/MainCard";
  13. const MainCard = Loadable(lazy(() => import('components/MainCard')));
  14. import { useForm } from "react-hook-form";
  15. import { useNavigate } from "react-router-dom";
  16. import {
  17. useEffect,
  18. useState
  19. } from "react";
  20. // import Checkbox from "@mui/material/Checkbox";
  21. import Loadable from 'components/Loadable';
  22. import { lazy } from 'react';
  23. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  24. // import {useParams} from "react-router-dom";
  25. import * as HttpUtils from "utils/HttpUtils"
  26. import * as UrlUtils from "utils/ApiPathConst"
  27. import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
  28. import * as DateUtils from "utils/DateUtils";
  29. import * as FormatUtils from "utils/FormatUtils";
  30. import {
  31. isORGLoggedIn,
  32. } from "utils/Utils";
  33. // import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined';
  34. // import DoneIcon from '@mui/icons-material/Done';
  35. import CloseIcon from '@mui/icons-material/Close';
  36. import EditNoteIcon from '@mui/icons-material/EditNote';
  37. import DownloadIcon from '@mui/icons-material/Download';
  38. import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst";
  39. import {ThemeProvider} from "@emotion/react";
  40. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  41. const ApplicationDetailCard = (
  42. { applicationDetailData,
  43. setStatus,
  44. // updateUserObject,
  45. // isNewRecord
  46. }
  47. ) => {
  48. const [isPopUp, setIsPopUp] = useState(false);
  49. const [errorText, setErrorText] = useState("");
  50. const [errorPopUp, setErrorPopUp] = useState(false);
  51. // const params = useParams();
  52. const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
  53. const [fee, setFee] = useState(0);
  54. const [companyName, setCompanyName] = useState({});
  55. const [fileDetail, setfileDetail] = useState({});
  56. const [onReady, setOnReady] = useState(false);
  57. const [issueNum, setIssueNum] = useState("");
  58. const [issueDate, setIssueDate] = useState("");
  59. const { register,
  60. // getValues
  61. } = useForm();
  62. const navigate = useNavigate();
  63. useEffect(() => {
  64. //if user data from parent are not null
  65. // console.log(applicationDetailData)
  66. if (Object.keys(applicationDetailData).length > 0 && applicationDetailData.data !== null) {
  67. setCurrentApplicationDetailData(applicationDetailData.data);
  68. setCompanyName(applicationDetailData.companyName);
  69. setfileDetail(applicationDetailData.fileDetail);
  70. setIssueNum(applicationDetailData.gazetteIssueDetail.volume + "/" + applicationDetailData.gazetteIssueDetail.year
  71. + " No. " + applicationDetailData.gazetteIssueDetail.issueNo);
  72. setIssueDate(DateUtils.dateFormat(applicationDetailData.gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
  73. for (let i = 0; i < applicationDetailData.proofList.length; i++) {
  74. if (applicationDetailData.proofList[i].action == true) {
  75. setFee(applicationDetailData.proofList[i].fee);
  76. }
  77. }
  78. }
  79. }, [applicationDetailData]);
  80. useEffect(() => {
  81. //if state data are ready and assign to different field
  82. // console.log(currentApplicationDetailData)
  83. if (Object.keys(currentApplicationDetailData).length > 0) {
  84. setOnReady(true);
  85. }
  86. }, [currentApplicationDetailData]);
  87. const onDownloadClick = () => () => {
  88. HttpUtils.fileDownload({
  89. fileId: fileDetail.id,
  90. skey: fileDetail.skey,
  91. filename: fileDetail.filename,
  92. });
  93. };
  94. const cancelledClick = () => () => {
  95. setStatus("cancel")
  96. };
  97. const checkExprityDate = () => {
  98. HttpUtils.post({
  99. url: UrlUtils.POST_CHECK_APP_EXPRITY_DATE,
  100. params: {
  101. ids: [currentApplicationDetailData.id]
  102. },
  103. onSuccess: (responData) => {
  104. if (responData.success == true) {
  105. setIsPopUp(true);
  106. return;
  107. }
  108. setErrorText("公共啟事申請已過期");
  109. setErrorPopUp(true);
  110. }
  111. });
  112. };
  113. function doPayment() {
  114. setIsPopUp(false);
  115. navigate('/paymentPage', { state: { amount: fee, appIdList: [currentApplicationDetailData.id] } });
  116. }
  117. return (
  118. !onReady ?
  119. <LoadingComponent />
  120. :
  121. <MainCard elevation={0}
  122. border={false}
  123. content={false}
  124. >
  125. <Grid container spacing={1} direction="row">
  126. <Grid item xs={12}>
  127. <Stack
  128. direction="row"
  129. justifyContent="space-between"
  130. alignItems="center"
  131. spacing={2}
  132. mb={2}
  133. >
  134. {
  135. currentApplicationDetailData.status == "confirmed" ?
  136. <Button
  137. // size="large"
  138. variant="contained"
  139. onClick={() => { checkExprityDate(true) }}
  140. disabled={currentApplicationDetailData.status == "rejected"
  141. || currentApplicationDetailData.status == "cancelled"
  142. || currentApplicationDetailData.status == "paid"
  143. || currentApplicationDetailData.creditor}
  144. sx={{
  145. textTransform: 'capitalize',
  146. alignItems: 'end'
  147. }}>
  148. <EditNoteIcon />
  149. <Typography ml={1} variant="h5"> 支付</Typography>
  150. </Button>
  151. : null
  152. }
  153. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  154. <Button
  155. variant="contained"
  156. onClick={cancelledClick()}
  157. color="edit"
  158. disabled={currentApplicationDetailData.status !== "submitted"}
  159. title={"取消"}
  160. >
  161. <CloseIcon sx={{mr:1}} />
  162. 取消
  163. </Button>
  164. </ThemeProvider>
  165. </Stack>
  166. </Grid>
  167. </Grid>
  168. <Typography variant="h4" sx={{ mb: 2, borderBottom: "1px solid black" }}>
  169. 公共啟事申請資料
  170. </Typography>
  171. <form>
  172. <Grid container direction="column">
  173. <Grid item xs={12} md={12}>
  174. <Grid container direction="row" justifyContent="space-between"
  175. alignItems="center">
  176. <Grid item xs={12} sm={12} md={9} lg={6} sx={{ mb: 1 }}>
  177. <Grid container alignItems={"center"}>
  178. <Grid item xs={12} md={3} lg={3}
  179. sx={{ display: 'flex', alignItems: 'center' }}>
  180. <FormLabel><Typography variant="h5">申請編號:</Typography></FormLabel>
  181. </Grid>
  182. <Grid item xs={12} md={9} lg={9}>
  183. <FormControl variant="outlined" fullWidth disabled>
  184. <OutlinedInput
  185. fullWidth
  186. size="small"
  187. {...register("appNo",
  188. {
  189. value: currentApplicationDetailData.appNo,
  190. })}
  191. id='appNo'
  192. sx={{
  193. "& .MuiInputBase-input.Mui-disabled": {
  194. WebkitTextFillColor: "#000000",
  195. background: "#f8f8f8",
  196. },
  197. }}
  198. />
  199. </FormControl>
  200. </Grid>
  201. </Grid>
  202. </Grid>
  203. <Grid item xs={12} sm={12} md={9} lg={5} sx={{ mb: 1, ml: 1 }}>
  204. <Grid container alignItems={"center"}>
  205. <Grid item xs={12} md={3} lg={3}
  206. sx={{ display: 'flex', alignItems: 'center' }}>
  207. <FormLabel><Typography variant="h5">申請狀態:</Typography></FormLabel>
  208. </Grid>
  209. <Grid item xs={12} md={4} lg={4}>
  210. <FormControl variant="outlined">
  211. {StatusUtils.getStatusByText(currentApplicationDetailData.status)}
  212. </FormControl>
  213. </Grid>
  214. {
  215. currentApplicationDetailData.reason ?
  216. <Grid item xs={12} md={5} lg={5}>
  217. <Grid container alignItems={"center"}>
  218. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  219. <Grid item xs={12} md={7} lg={7}>
  220. <FormLabel><Typography variant="h5">原因:</Typography></FormLabel>
  221. </Grid>
  222. <Grid item xs={12} md={5} lg={5}>
  223. <FormControl variant="outlined" fullWidth disabled>
  224. <Typography id='reason' variant="h5">
  225. {currentApplicationDetailData.reason}
  226. </Typography>
  227. </FormControl>
  228. </Grid>
  229. </Stack>
  230. </Grid>
  231. </Grid>
  232. : ""
  233. }
  234. </Grid>
  235. </Grid>
  236. </Grid>
  237. <Grid container direction="row" justifyContent="space-between"
  238. alignItems="center">
  239. <Grid item xs={12} sm={12} md={9} lg={6} sx={{ mb: 1 }}>
  240. <Grid container alignItems={"center"}>
  241. <Grid item xs={12} md={3} lg={3}
  242. sx={{ display: 'flex', alignItems: 'center' }}>
  243. <FormLabel><Typography variant="h5">申請人:</Typography></FormLabel>
  244. </Grid>
  245. <Grid item xs={12} md={9} lg={9}>
  246. <FormControl variant="outlined" fullWidth disabled >
  247. {currentApplicationDetailData.orgId === null ?
  248. <OutlinedInput
  249. fullWidth
  250. size="small"
  251. {...register("contactPerson",
  252. {
  253. value: currentApplicationDetailData.contactPerson,
  254. })}
  255. id='contactPerson'
  256. sx={{
  257. "& .MuiInputBase-input.Mui-disabled": {
  258. WebkitTextFillColor: "#000000",
  259. background: "#f8f8f8",
  260. },
  261. }}
  262. /> :
  263. <OutlinedInput
  264. fullWidth
  265. size="small"
  266. {...register("companyName",
  267. {
  268. value: companyName.enCompanyName,
  269. })}
  270. id='companyName'
  271. sx={{
  272. "& .MuiInputBase-input.Mui-disabled": {
  273. WebkitTextFillColor: "#000000",
  274. background: "#f8f8f8",
  275. },
  276. }}
  277. />
  278. }
  279. </FormControl>
  280. </Grid>
  281. </Grid>
  282. </Grid>
  283. <Grid item xs={12} sm={12} md={9} lg={5} sx={{ mb: 1, ml: {lg:1} }}>
  284. <Grid container alignItems={"center"}>
  285. <Grid item xs={12} md={3} lg={3}
  286. sx={{ display: 'flex', alignItems: 'center' }}>
  287. <FormLabel><Typography variant="h5">憲報期數:</Typography></FormLabel>
  288. </Grid>
  289. <Grid item xs={12} md={9} lg={9}>
  290. <Stack direction="row">
  291. <FormControl variant="outlined" fullWidth disabled>
  292. <OutlinedInput
  293. size="small"
  294. {...register("issueNum",
  295. {
  296. value: issueNum,
  297. })}
  298. id='issueNum'
  299. sx={{
  300. "& .MuiInputBase-input.Mui-disabled": {
  301. WebkitTextFillColor: "#000000",
  302. background: "#f8f8f8",
  303. },
  304. }}
  305. />
  306. </FormControl>
  307. </Stack>
  308. </Grid>
  309. </Grid>
  310. </Grid>
  311. </Grid>
  312. <Grid container direction="row" justifyContent="space-between"
  313. alignItems="center">
  314. <Grid item xs={12} sm={12} md={9} lg={6} sx={{ mb: 1 }}>
  315. <Grid container alignItems={"center"}>
  316. <Grid item xs={12} md={3} lg={3}
  317. sx={{ display: 'flex', alignItems: 'center' }}>
  318. <FormLabel><Typography variant="h5">聯絡人:</Typography></FormLabel>
  319. </Grid>
  320. <Grid item xs={12} md={9} lg={9}>
  321. <FormControl variant="outlined" fullWidth disabled>
  322. <OutlinedInput
  323. fullWidth
  324. size="small"
  325. {...register("contactPerson",
  326. {
  327. value: currentApplicationDetailData.contactPerson,
  328. })}
  329. id='contactPerson'
  330. sx={{
  331. "& .MuiInputBase-input.Mui-disabled": {
  332. WebkitTextFillColor: "#000000",
  333. background: "#f8f8f8",
  334. },
  335. }}
  336. />
  337. </FormControl>
  338. </Grid>
  339. </Grid>
  340. </Grid>
  341. <Grid item xs={12} sm={12} md={9} lg={5} sx={{ mb: 1, ml: {lg:1} }}>
  342. <Grid container alignItems={"center"}>
  343. <Grid item xs={12} md={3} lg={3}
  344. sx={{ display: 'flex', alignItems: 'center' }}>
  345. <FormLabel><Typography variant="h5">發布日期:</Typography></FormLabel>
  346. </Grid>
  347. <Grid item xs={12} md={9} lg={9}>
  348. <Stack direction="row">
  349. <FormControl variant="outlined" fullWidth disabled>
  350. <OutlinedInput
  351. size="small"
  352. {...register("issueDate",
  353. {
  354. value: issueDate,
  355. })}
  356. id='issueDate'
  357. sx={{
  358. "& .MuiInputBase-input.Mui-disabled": {
  359. WebkitTextFillColor: "#000000",
  360. background: "#f8f8f8",
  361. },
  362. }}
  363. />
  364. </FormControl>
  365. </Stack>
  366. </Grid>
  367. </Grid>
  368. </Grid>
  369. </Grid>
  370. <Grid container direction="row" justifyContent="space-between"
  371. alignItems="center">
  372. <Grid item xs={12} sm={12} md={9} lg={6} sx={{ mb: 1, }}>
  373. <Grid container alignItems={"center"}>
  374. <Grid item xs={12} md={3} lg={3}
  375. sx={{ display: 'flex', alignItems: 'center' }}>
  376. <FormLabel><Typography variant="h5">聯絡電話:</Typography></FormLabel>
  377. </Grid>
  378. <Grid item xs={12} md={9} lg={9}>
  379. <Stack direction="row">
  380. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  381. <OutlinedInput
  382. size="small"
  383. {...register("countryCode",
  384. {
  385. value: currentApplicationDetailData.contactTelNo.countryCode,
  386. })}
  387. id='countryCode'
  388. sx={{
  389. "& .MuiInputBase-input.Mui-disabled": {
  390. WebkitTextFillColor: "#000000",
  391. background: "#f8f8f8",
  392. },
  393. }}
  394. />
  395. </FormControl>
  396. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  397. <OutlinedInput
  398. size="small"
  399. {...register("phoneNumber",
  400. {
  401. value: currentApplicationDetailData.contactTelNo.phoneNumber,
  402. })}
  403. id='phoneNumber'
  404. sx={{
  405. "& .MuiInputBase-input.Mui-disabled": {
  406. WebkitTextFillColor: "#000000",
  407. background: "#f8f8f8",
  408. },
  409. }}
  410. />
  411. </FormControl>
  412. </Stack>
  413. </Grid>
  414. </Grid>
  415. </Grid>
  416. {
  417. fee > 0 ?
  418. <Grid item xs={12} sm={12} md={9} lg={5} sx={{ mb: 1, ml: 1 }}>
  419. <Grid container alignItems={"center"}>
  420. <Grid item xs={12} md={3} lg={3}
  421. sx={{ display: 'flex', alignItems: 'center' }}>
  422. <FormLabel><Typography variant="h5">金額(HK$):</Typography></FormLabel>
  423. </Grid>
  424. <Grid item xs={12} md={9} lg={9}>
  425. <FormLabel><Typography variant="h5">{FormatUtils.currencyFormat(fee)}</Typography></FormLabel>
  426. </Grid>
  427. </Grid>
  428. </Grid>
  429. :
  430. <></>
  431. }
  432. </Grid>
  433. <Grid item xs={12} sm={12} md={9} lg={6} sx={{ mb: 1, }}>
  434. <Grid container alignItems={"center"}>
  435. <Grid item xs={12} md={3} lg={3}
  436. sx={{ display: 'flex', alignItems: 'center' }}>
  437. <FormLabel><Typography variant="h5">傳真號碼:</Typography></FormLabel>
  438. </Grid>
  439. <Grid item xs={12} sm={12} md={9} lg={9}>
  440. <Stack direction="row">
  441. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  442. <OutlinedInput
  443. size="small"
  444. {...register("countryCode",
  445. {
  446. value: currentApplicationDetailData.contactFaxNo.countryCode,
  447. })}
  448. id='countryCode'
  449. sx={{
  450. "& .MuiInputBase-input.Mui-disabled": {
  451. WebkitTextFillColor: "#000000",
  452. background: "#f8f8f8",
  453. },
  454. }}
  455. />
  456. </FormControl>
  457. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  458. <OutlinedInput
  459. size="small"
  460. {...register("faxNumber",
  461. {
  462. value: currentApplicationDetailData.contactFaxNo.faxNumber,
  463. })}
  464. id='faxNumber'
  465. sx={{
  466. "& .MuiInputBase-input.Mui-disabled": {
  467. WebkitTextFillColor: "#000000",
  468. background: "#f8f8f8",
  469. },
  470. }}
  471. />
  472. </FormControl>
  473. </Stack>
  474. </Grid>
  475. </Grid>
  476. </Grid>
  477. <Grid container direction="row" justifyContent="space-between"
  478. alignItems="center">
  479. <Grid item xs={12} sm={12} md={11} lg={11} mt={1}>
  480. <Grid container alignItems={"center"}>
  481. <Grid item xs={12} sm={12} md={12} lg={12}>
  482. <Grid container direction="row">
  483. <Grid item xs={12} sm={12} md={2.5} lg={1.6}
  484. sx={{ display: 'flex', alignItems: 'center' }}>
  485. <FormLabel><Typography variant="h5">稿件檔案:</Typography></FormLabel>
  486. </Grid>
  487. <Grid item xs={12} sm={12} md={9} lg={9} >
  488. <Grid container direction="row" alignItems="center" justifyContent="flex-start">
  489. <Grid item xs={12} sm={12} md={9} lg={9} sx={{ wordBreak: 'break-word' , }}>
  490. <FormControl variant="outlined" fullWidth >
  491. <Typography
  492. fullWidth
  493. id='fileName'
  494. variant="h5"
  495. >
  496. {fileDetail.filename}
  497. </Typography>
  498. </FormControl>
  499. </Grid>
  500. <Grid item xs={12} sm={12} md={3} lg={3} >
  501. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  502. <Button
  503. variant="contained"
  504. onClick={onDownloadClick()}
  505. title="下載"
  506. color="save"
  507. >
  508. <DownloadIcon sx={{ mr:1 }} />
  509. 下載
  510. </Button>
  511. </ThemeProvider>
  512. </Grid>
  513. </Grid>
  514. </Grid>
  515. </Grid>
  516. </Grid>
  517. </Grid>
  518. </Grid>
  519. </Grid>
  520. {isORGLoggedIn() ?
  521. <Grid item xs={12} md={9} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
  522. <Grid container alignItems={"center"}>
  523. <Grid item xs={12} md={3} lg={3}
  524. sx={{ display: 'flex', alignItems: 'center' }}>
  525. <FormLabel><Typography variant="h5">Care Of:</Typography></FormLabel>
  526. </Grid>
  527. <Grid item xs={12} md={9} lg={9}>
  528. <Typography variant="h5">{currentApplicationDetailData.careOf}</Typography>
  529. </Grid>
  530. </Grid>
  531. </Grid> : null
  532. }
  533. <Grid item xs={12} md={9} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
  534. <Grid container alignItems={"center"}>
  535. <Grid item xs={12} md={3} lg={3}
  536. sx={{ display: 'flex', alignItems: 'center' }}>
  537. <FormLabel><Typography variant="h5">備註:</Typography></FormLabel>
  538. </Grid>
  539. <Grid item xs={12} md={9} lg={9}>
  540. <Typography variant="h5">{currentApplicationDetailData.remarks}</Typography>
  541. </Grid>
  542. </Grid>
  543. </Grid>
  544. </Grid>
  545. </Grid>
  546. <div>
  547. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  548. <DialogTitle></DialogTitle>
  549. <Typography variant="h3" style={{ padding: '16px' }}>確認付款</Typography>
  550. <DialogContent style={{ display: 'flex', }}>
  551. <Stack direction="column" justifyContent="space-between">
  552. <Typography variant="h4">總額(HK$): {FormatUtils.currencyFormat(fee)}</Typography>
  553. </Stack>
  554. </DialogContent>
  555. <DialogActions>
  556. <Button onClick={() => setIsPopUp(false)}><Typography variant="h5">關閉</Typography></Button>
  557. <Button onClick={() => doPayment()}><Typography variant="h5">確認</Typography></Button>
  558. </DialogActions>
  559. </Dialog>
  560. </div>
  561. <div>
  562. <Dialog open={errorPopUp} onClose={() => setErrorPopUp(false)} >
  563. <DialogTitle></DialogTitle>
  564. <Typography variant="h2" style={{ padding: '16px' }}>行動失敗</Typography>
  565. <DialogContent style={{ display: 'flex', }}>
  566. <Stack direction="column" justifyContent="space-between">
  567. {
  568. errorText
  569. }
  570. </Stack>
  571. </DialogContent>
  572. <DialogActions>
  573. <Button onClick={() => setErrorPopUp(false)}><Typography variant="h5">關閉</Typography></Button>
  574. </DialogActions>
  575. </Dialog>
  576. </div>
  577. </form>
  578. </MainCard >
  579. );
  580. };
  581. export default ApplicationDetailCard;