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

Pay.js 11 KiB

2年前
2年前
1年前
2年前
2年前
1年前
2年前
1年前
2年前
1年前
2年前
1年前
1年前
1年前
1年前
1年前
1年前
2年前
1年前
1年前
1年前
2年前
1年前
2年前
1年前
2年前
1年前
1年前
1年前
2年前
1年前
2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Button,
  7. Dialog, DialogTitle, DialogContent, DialogActions
  8. } from '@mui/material';
  9. import * as UrlUtils from "utils/ApiPathConst";
  10. import { useState } from "react";
  11. import * as HttpUtils from "utils/HttpUtils";
  12. import { useNavigate } from "react-router-dom";
  13. import * as DateUtils from "utils/DateUtils"
  14. import * as FormatUtils from "utils/FormatUtils";
  15. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  16. const BackgroundHead = {
  17. backgroundImage: `url(${titleBackgroundImg})`,
  18. width: '100%',
  19. height: '100%',
  20. backgroundSize: 'contain',
  21. backgroundRepeat: 'no-repeat',
  22. backgroundColor: '#0C489E',
  23. backgroundPosition: 'right'
  24. }
  25. import { PNSPS_BUTTON_THEME, PNSPS_LONG_BUTTON_THEME } from "../../../themes/buttonConst";
  26. import { ThemeProvider } from "@emotion/react";
  27. import { FormattedMessage, useIntl } from "react-intl";
  28. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  29. const Index = ({ record }) => {
  30. const navigate = useNavigate()
  31. const [isPopUp, setIsPopUp] = useState(false);
  32. const [paymentHoldedErrText, setPaymentHoldedErrText] = useState("");
  33. const [paymentHoldedErr, setPaymentHoldedErr] = useState(false);
  34. const intl = useIntl();
  35. function doPayment() {
  36. setIsPopUp(false);
  37. let appIdList = [record?.appId]
  38. handlePaymentCheck(appIdList)
  39. }
  40. const handlePaymentCheck = (appIdList) => {
  41. HttpUtils.post({
  42. url: UrlUtils.PAYMENT_CHECK,
  43. params: {
  44. appIds: appIdList
  45. },
  46. onSuccess: (responseData) => {
  47. const latestData = {};
  48. responseData.forEach(item => {
  49. const { appId, timeDiff } = item;
  50. if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) {
  51. latestData[appId] = item;
  52. }
  53. });
  54. const latestDataObjects = Object.values(latestData);
  55. const filteredData = latestDataObjects.filter(item => item.timeDiff > 20 || item.status !== "APPR");
  56. const filteredAppIds = filteredData.map(item => item.appId);
  57. const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId));
  58. const combinedAppIdsArray = [...appIdsNotInData, ...filteredAppIds];
  59. const readyToPayment = appIdList.every(appId => combinedAppIdsArray.includes(appId));
  60. if (readyToPayment) {
  61. navigate('/paymentPage', { state: { amount: record.fee, appIdList: appIdList } });
  62. } else {
  63. const appIdsInData = appIdList.filter(appId => !combinedAppIdsArray.some(item => item === appId));
  64. const HoldingApplication = latestDataObjects.filter(item => appIdsInData.includes(item.appId));
  65. const resultString = HoldingApplication.map(item => item.appNo).join(' , ');
  66. setPaymentHoldedErrText(resultString);
  67. // setPaymentHoldedErrText(intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: record.appNo }));
  68. setPaymentHoldedErr(true);
  69. }
  70. }
  71. });
  72. };
  73. return (
  74. (
  75. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  76. <Grid item xs={12} width="100%">
  77. <div style={BackgroundHead} width="100%" >
  78. <Stack direction="row" height='70px'>
  79. <Typography ml={15} color='#FFF' variant="h4" sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, pt: 2 }}>
  80. <FormattedMessage id="proofRecord" />
  81. </Typography>
  82. </Stack>
  83. </div>
  84. </Grid>
  85. {/*row 1*/}
  86. <Grid item xs={12} md={12} >
  87. <Grid container justifyContent="flex-start" alignItems="center" >
  88. <center>
  89. <Grid item xs={12} md={8} >
  90. <Typography variant="h3" sx={{ textAlign: "left", ml: 4, mr: 4, mt: 4, borderBottom: "1px solid black" }}>
  91. <FormattedMessage id="publicNoticePaymentProofDoneAndPaid" />
  92. </Typography>
  93. <Typography variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  94. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: 'MSG.payMsg1' }, { appNo: record.appNo }) }} />
  95. <br />
  96. <FormattedMessage id="MSG.payMsg2_1" />
  97. <span style={{ color: "red" }}>
  98. {DateUtils.datetimeStr(record?.proofPaymentDeadline)}
  99. </span>
  100. <FormattedMessage id="MSG.payMsg2_2" />
  101. <br />
  102. <br />
  103. <div dangerouslySetInnerHTML={{
  104. __html: intl.formatMessage({ id: 'MSG.payMsg3' },
  105. {
  106. issueYear: record?.issueYear,
  107. issueVolume: record?.issueVolume,
  108. issueNo: record?.issueNo,
  109. })
  110. }} />
  111. </Typography>
  112. <Typography variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  113. <FormattedMessage id="pleaseClickToPay" />:
  114. </Typography>
  115. <Typography variant="h4" sx={{ ml: 8, textAlign: "left" }}>
  116. <ThemeProvider theme={PNSPS_LONG_BUTTON_THEME}>
  117. <Button
  118. component="span"
  119. variant="contained"
  120. sx={{ ml: { md: 4, lg: 4 }, mr: 4 }}
  121. onClick={() => { setIsPopUp(true) }}
  122. >
  123. <FormattedMessage id="payInstantly" />
  124. </Button>
  125. </ThemeProvider>
  126. <FormattedMessage id="or" />
  127. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  128. <Button
  129. component="span"
  130. variant="contained"
  131. sx={{ ml: { sm: 4, md: 4, lg: 4 }, mr: 4, mt: { xs: 2, sm: 2 }, mb: { xs: 2, sm: 2 } }}
  132. onClick={() => {
  133. navigate("/publicNotice");
  134. }}
  135. >
  136. <FormattedMessage id="payLater" />
  137. </Button>
  138. (<FormattedMessage id="backToNoticePage" />)
  139. </ThemeProvider>
  140. </Typography>
  141. </Grid>
  142. </center>
  143. </Grid>
  144. </Grid>
  145. <div>
  146. <Dialog
  147. open={isPopUp}
  148. onClose={() => setIsPopUp(false)}
  149. PaperProps={{
  150. sx: {
  151. minWidth: '40vw',
  152. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '30vw' },
  153. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '50vh' }
  154. }
  155. }}
  156. >
  157. <DialogTitle>
  158. <Typography variant="h3" >
  159. <FormattedMessage id="payConfirm" />
  160. </Typography>
  161. </DialogTitle>
  162. <DialogContent style={{ display: 'flex', }}>
  163. <Stack direction="column" justifyContent="space-between">
  164. <Typography variant="h4">
  165. <FormattedMessage id="totalAmount" /> (HK$): {FormatUtils.currencyFormat(record.fee)}
  166. </Typography>
  167. </Stack>
  168. </DialogContent>
  169. <DialogActions>
  170. <Button onClick={() => setIsPopUp(false)}>
  171. <Typography variant="h5">
  172. <FormattedMessage id="close" />
  173. </Typography></Button>
  174. <Button onClick={() => doPayment()}><Typography variant="h5">
  175. <FormattedMessage id="confirm" />
  176. </Typography></Button>
  177. </DialogActions>
  178. </Dialog>
  179. </div>
  180. {/*row 2*/}
  181. <div>
  182. <Dialog
  183. open={paymentHoldedErr}
  184. onClose={() => setPaymentHoldedErr(false)}
  185. PaperProps={{
  186. sx: {
  187. minWidth: '40vw',
  188. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  189. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  190. }
  191. }}
  192. >
  193. <DialogTitle></DialogTitle>
  194. <Typography variant="h4" style={{ paddingLeft: '24px' }}><FormattedMessage id="MSG.actionFail" /></Typography>
  195. <DialogContent style={{ display: 'flex', }}>
  196. <Stack direction="column" justifyContent="space-between">
  197. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: paymentHoldedErrText }) }} />
  198. </Stack>
  199. </DialogContent>
  200. <DialogActions>
  201. <Button onClick={() => setPaymentHoldedErr(false)} aria-label={intl.formatMessage({ id: 'close' })}>
  202. <Typography variant="h5">
  203. <FormattedMessage id="close" />
  204. </Typography></Button>
  205. </DialogActions>
  206. </Dialog>
  207. </div>
  208. </Grid >
  209. )
  210. );
  211. };
  212. export default Index;