您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PaymentDetails.js 11 KiB

1 个月前
1 个月前
1 个月前
1 个月前
2 年前
1 个月前
1 个月前
1 个月前
1 个月前
1 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. FormLabel,
  6. Button,
  7. Dialog,
  8. DialogTitle,
  9. DialogContent,
  10. DialogActions,
  11. Box
  12. } from '@mui/material';
  13. import * as React from "react";
  14. import * as FormatUtils from "utils/FormatUtils";
  15. import * as PaymentStatus from "utils/statusUtils/PaymentStatus";
  16. import * as DateUtils from "utils/DateUtils";
  17. import * as HttpUtils from "utils/HttpUtils";
  18. import { PAYMENT_MARK_AS_PAID } from "utils/ApiPathConst";
  19. import Loadable from 'components/Loadable';
  20. const MainCard = Loadable(React.lazy(() => import('components/MainCard')));
  21. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  22. import DownloadIcon from '@mui/icons-material/Download';
  23. import {useIntl} from "react-intl";
  24. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  25. const PaymentDetails = ({ formData, doPrint, onDownload, onRefresh }) => {
  26. const intl = useIntl();
  27. const [data, setData] = React.useState({});
  28. const [onReady, setOnReady] = React.useState(false);
  29. const [confirmOpen, setConfirmOpen] = React.useState(false);
  30. const [markingPaid, setMarkingPaid] = React.useState(false);
  31. // const { locale } = intl;
  32. React.useEffect(() => {
  33. if (formData != null && formData != undefined && Object.keys(formData).length > 0) {
  34. setData(formData);
  35. }
  36. }, [formData]);
  37. React.useEffect(() => {
  38. if (formData != null && formData != undefined && Object.keys(formData).length > 0) {
  39. setOnReady(data != {});
  40. }
  41. }, [data]);
  42. const getPaymentMethod=()=>{
  43. let paymentmethod = data.payload?.paymentdetail.paymentmethod;
  44. if("01" == paymentmethod) return "PPS";
  45. if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card";
  46. if("04" == paymentmethod) return "FPS";
  47. if (data.payMethod === "04,BCFP,FPS") return "FPS";
  48. return paymentmethod;
  49. }
  50. const showMarkAsPaid = data.status === "REJT" && getPaymentMethod() === "FPS";
  51. const handleMarkAsPaid = () => {
  52. setMarkingPaid(true);
  53. HttpUtils.post({
  54. url: PAYMENT_MARK_AS_PAID + "/" + data.id,
  55. onSuccess: () => {
  56. setConfirmOpen(false);
  57. setMarkingPaid(false);
  58. if (onRefresh) {
  59. onRefresh();
  60. }
  61. },
  62. onError: () => {
  63. setMarkingPaid(false);
  64. }
  65. });
  66. };
  67. return (
  68. !onReady ?
  69. <LoadingComponent />
  70. :
  71. <MainCard elevation={0}
  72. border={false}
  73. content={false}
  74. >
  75. <Box sx={{ display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, borderBottom: "1px solid black" }}>
  76. <Typography variant="h5" sx={{ textAlign: "left" }}>
  77. Payment Details
  78. </Typography>
  79. {showMarkAsPaid && (
  80. <Button
  81. className="printHidden"
  82. variant="contained"
  83. color="primary"
  84. onClick={() => setConfirmOpen(true)}
  85. >
  86. Mark as Paid
  87. </Button>
  88. )}
  89. </Box>
  90. <form>
  91. <Grid container>
  92. <Grid item xs={12} md={12} >
  93. <Grid container alignItems="center">
  94. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right", alignItems: 'center', color: "#000000" }}>
  95. <FormLabel sx={{ color: "#000000" }}>
  96. Status:
  97. </FormLabel>
  98. </Grid>
  99. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  100. <FormLabel sx={{ display: 'flex', alignItems: 'center', color: "#000000" }}>
  101. {PaymentStatus.getStatus_Eng(data.status)}
  102. </FormLabel>
  103. </Grid>
  104. </Grid>
  105. </Grid>
  106. <Grid item xs={12} md={12}>
  107. <Grid container >
  108. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  109. <FormLabel sx={{ color: "#000000" }}>
  110. Payment No.:
  111. </FormLabel>
  112. </Grid>
  113. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  114. <FormLabel sx={{ color: "#000000" }}>
  115. {data.payload?.transactionid}
  116. </FormLabel>
  117. </Grid>
  118. </Grid>
  119. </Grid>
  120. <Grid item xs={12} md={12}>
  121. <Grid container >
  122. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  123. <FormLabel sx={{ color: "#000000" }}>
  124. Payment Date:
  125. </FormLabel>
  126. </Grid>
  127. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  128. <FormLabel sx={{ color: "#000000" }}>
  129. {DateUtils.dateFormat(data.transDateStr, intl.formatMessage({id: "dateStrFormat"})) +" ("+intl.formatMessage({id: "dateStrFormat"})+")"}
  130. </FormLabel>
  131. </Grid>
  132. </Grid>
  133. </Grid>
  134. <Grid item xs={12} md={12}>
  135. <Grid container >
  136. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  137. <FormLabel sx={{ color: "#000000" }}>
  138. Payment Time:
  139. </FormLabel>
  140. </Grid>
  141. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  142. <FormLabel sx={{ color: "#000000" }}>
  143. {data.transTimeStr + " (HH:MI:SS)"}
  144. </FormLabel>
  145. </Grid>
  146. </Grid>
  147. </Grid>
  148. <Grid item xs={12} md={12}>
  149. <Grid container >
  150. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  151. <FormLabel sx={{ color: "#000000" }}>
  152. Payment Reference No.:
  153. </FormLabel>
  154. </Grid>
  155. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  156. <FormLabel sx={{ color: "#000000" }}>
  157. {data.egisRefNo}
  158. </FormLabel>
  159. </Grid>
  160. </Grid>
  161. </Grid>
  162. <Grid item xs={12} md={12}>
  163. <Grid container >
  164. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  165. <FormLabel sx={{ color: "#000000" }}>
  166. Payment Amount:
  167. </FormLabel>
  168. </Grid>
  169. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  170. <FormLabel sx={{ color: "#000000" }}>
  171. {"$ " + FormatUtils.currencyFormat(data.payload?.amount)}
  172. </FormLabel>
  173. </Grid>
  174. </Grid>
  175. </Grid>
  176. <Grid item xs={12} md={12}>
  177. <Grid container >
  178. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  179. <FormLabel sx={{ color: "#000000" }}>
  180. Payment Method:
  181. </FormLabel>
  182. </Grid>
  183. <Grid item xs={6} md={5} sx={{ml:5, textAlign: "left" }}>
  184. <FormLabel sx={{ color: "#000000" }}>
  185. {getPaymentMethod()}
  186. </FormLabel>
  187. </Grid>
  188. </Grid>
  189. </Grid>
  190. {
  191. data.status == "APPR"
  192. ?
  193. <Grid item xs={12} md={12}>
  194. <Grid container alignItems="center">
  195. <Grid item xs={6} md={6} sx={{ml:-5, textAlign: "right" }}>
  196. <FormLabel sx={{ color: "#000000" }}>
  197. Payment Receipt:
  198. </FormLabel>
  199. </Grid>
  200. <Grid item xs={6} md={5} sx={{ml:5,textAlign: "left" }}>
  201. <Button className="printHidden" variant="contained" disabled={onDownload} sx={{ mt:2 }} onClick={doPrint}>
  202. <DownloadIcon/>
  203. <Typography sx={{fontSize: "16px"}}>Download</Typography>
  204. </Button>
  205. </Grid>
  206. </Grid>
  207. </Grid>
  208. : null
  209. }
  210. </Grid>
  211. </form>
  212. <Dialog
  213. open={confirmOpen}
  214. onClose={() => !markingPaid && setConfirmOpen(false)}
  215. >
  216. <DialogTitle>Confirm</DialogTitle>
  217. <DialogContent>
  218. <Typography variant="h5" sx={{ padding: '16px' }}>
  219. {`Are you sure to mark as paid for Payment No. ${data.transNo || data.payload?.transactionid} ?`}
  220. </Typography>
  221. </DialogContent>
  222. <DialogActions>
  223. <Button onClick={() => setConfirmOpen(false)} disabled={markingPaid}>
  224. <Typography variant="h5">Cancel</Typography>
  225. </Button>
  226. <Button onClick={handleMarkAsPaid} disabled={markingPaid}>
  227. <Typography variant="h5">Confirm</Typography>
  228. </Button>
  229. </DialogActions>
  230. </Dialog>
  231. </MainCard>
  232. );
  233. };
  234. export default PaymentDetails;