No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

237 líneas
11 KiB

  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 filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT");
  57. const filteredAppIds = filteredData.map(item => item.appId);
  58. const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId));
  59. const combinedAppIdsArray = [...appIdsNotInData, ...filteredAppIds];
  60. const readyToPayment = appIdList.every(appId => combinedAppIdsArray.includes(appId));
  61. if (readyToPayment) {
  62. navigate('/paymentPage', { state: { amount: record.fee, appIdList: appIdList } });
  63. } else {
  64. const appIdsInData = appIdList.filter(appId => !combinedAppIdsArray.some(item => item === appId));
  65. const HoldingApplication = latestDataObjects.filter(item => appIdsInData.includes(item.appId));
  66. const resultString = HoldingApplication.map(item => item.appNo).join(' , ');
  67. setPaymentHoldedErrText(resultString);
  68. // setPaymentHoldedErrText(intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: record.appNo }));
  69. setPaymentHoldedErr(true);
  70. }
  71. }
  72. });
  73. };
  74. return (
  75. (
  76. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  77. <Grid item xs={12} width="100%">
  78. <div style={BackgroundHead} width="100%" >
  79. <Stack direction="row" height='70px'>
  80. <Typography ml={15} color='#FFF' variant="h4" sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, pt: 2 }}>
  81. <FormattedMessage id="proofRecord" />
  82. </Typography>
  83. </Stack>
  84. </div>
  85. </Grid>
  86. {/*row 1*/}
  87. <Grid item xs={12} md={12} >
  88. <Grid container justifyContent="flex-start" alignItems="center" >
  89. <center>
  90. <Grid item xs={12} md={8} >
  91. <Typography variant="h3" sx={{ textAlign: "left", ml: 4, mr: 4, mt: 4, borderBottom: "1px solid black" }}>
  92. <FormattedMessage id="publicNoticePaymentProofDoneAndPaid" />
  93. </Typography>
  94. <Typography variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  95. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: 'MSG.payMsg1' }, { appNo: record.appNo }) }} />
  96. <br />
  97. <FormattedMessage id="MSG.payMsg2_1" />
  98. <span style={{ color: "red" }}>
  99. {DateUtils.datetimeStr(record?.proofPaymentDeadline)}
  100. </span>
  101. <FormattedMessage id="MSG.payMsg2_2" />
  102. <br />
  103. <br />
  104. <div dangerouslySetInnerHTML={{
  105. __html: intl.formatMessage({ id: 'MSG.payMsg3' },
  106. {
  107. issueYear: record?.issueYear,
  108. issueVolume: record?.issueVolume,
  109. issueNo: record?.issueNo,
  110. })
  111. }} />
  112. </Typography>
  113. <Typography variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  114. <FormattedMessage id="pleaseClickToPay" />:
  115. </Typography>
  116. <Typography variant="h4" sx={{ ml: 8, textAlign: "left" }}>
  117. <ThemeProvider theme={PNSPS_LONG_BUTTON_THEME}>
  118. <Button
  119. component="span"
  120. variant="contained"
  121. sx={{ ml: { md: 4, lg: 4 }, mr: 4 }}
  122. onClick={() => { setIsPopUp(true) }}
  123. >
  124. <FormattedMessage id="payInstantly" />
  125. </Button>
  126. </ThemeProvider>
  127. <FormattedMessage id="or" />
  128. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  129. <Button
  130. component="span"
  131. variant="contained"
  132. sx={{ ml: { sm: 4, md: 4, lg: 4 }, mr: 4, mt: { xs: 2, sm: 2 }, mb: { xs: 2, sm: 2 } }}
  133. onClick={() => {
  134. navigate("/publicNotice");
  135. }}
  136. >
  137. <FormattedMessage id="payLater" />
  138. </Button>
  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;