Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

198 righe
11 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. FormLabel,
  6. Button
  7. } from '@mui/material';
  8. import * as React from "react";
  9. import * as FormatUtils from "utils/FormatUtils";
  10. import * as PaymentStatus from "utils/statusUtils/PaymentStatus";
  11. import Loadable from 'components/Loadable';
  12. const MainCard = Loadable(React.lazy(() => import('components/MainCard')));
  13. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  14. import DownloadIcon from '@mui/icons-material/Download';
  15. import {FormattedMessage, useIntl} from "react-intl";
  16. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  17. const PaymentDetails = ({ formData,doPrint,onDownload }) => {
  18. const intl = useIntl();
  19. const { locale } = intl;
  20. const [data, setData] = React.useState({});
  21. const [onReady, setOnReady] = React.useState(false);
  22. React.useEffect(() => {
  23. if (formData != null && formData != undefined && Object.keys(formData).length > 0) {
  24. setData(formData);
  25. }
  26. }, [formData]);
  27. React.useEffect(() => {
  28. if (formData != null && formData != undefined && Object.keys(formData).length > 0) {
  29. setOnReady(data != {});
  30. }
  31. }, [data]);
  32. const getPaymentMethod=()=>{
  33. let paymentmethod = data?.payload?.paymentdetail?.paymentmethod;
  34. if("01" == paymentmethod) return "PPS";
  35. if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card";
  36. if("04" == paymentmethod) return "FPS";
  37. return paymentmethod;
  38. }
  39. return (
  40. !onReady ?
  41. <LoadingComponent />
  42. :
  43. <MainCard elevation={0}
  44. border={false}
  45. content={false}
  46. >
  47. <Typography variant="h5" sx={{ textAlign: "center", mb: 2, borderBottom: "1px solid black" }}>
  48. <FormattedMessage id="payDetail"/>
  49. </Typography>
  50. <form>
  51. <Grid container >
  52. <Grid item>
  53. <Grid container >
  54. <Grid item xs={12} md={12} >
  55. <Grid container spacing={5} alignItems="center">
  56. <Grid item xs={6} md={6} sx={{ textAlign: "right", alignItems: 'center', color: "#000000" }}>
  57. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  58. <FormattedMessage id="status"/>:
  59. </FormLabel>
  60. </Grid>
  61. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  62. <FormLabel sx={{ display: 'flex', alignItems: 'center', color: "#000000" }}>
  63. {
  64. locale === 'en' ?
  65. PaymentStatus.getStatus_Eng(data.status)
  66. :
  67. PaymentStatus.getStatus_Cht(data.status)
  68. }
  69. </FormLabel>
  70. </Grid>
  71. </Grid>
  72. </Grid>
  73. <Grid item xs={12} md={12}>
  74. <Grid container spacing={5} >
  75. <Grid item xs={6} md={6} sx={{ textAlign: "right" }}>
  76. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  77. <FormattedMessage id="transactionNo" />:
  78. </FormLabel>
  79. </Grid>
  80. <Grid item xs={6} md={6} sx={{ textAlign: "left" }}>
  81. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  82. {data.payload?.transactionid}
  83. </FormLabel>
  84. </Grid>
  85. </Grid>
  86. </Grid>
  87. <Grid item xs={12} md={12}>
  88. <Grid container spacing={5}>
  89. <Grid item xs={6} md={6} sx={{textAlign: "right" }}>
  90. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  91. <FormattedMessage id="transactionDate" />:
  92. </FormLabel>
  93. </Grid>
  94. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  95. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  96. {data.transDateStr + " (DD/MM/YYYY)"}
  97. </FormLabel>
  98. </Grid>
  99. </Grid>
  100. </Grid>
  101. <Grid item xs={12} md={12}>
  102. <Grid container spacing={5}>
  103. <Grid item xs={6} md={6} sx={{ textAlign: "right" }}>
  104. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  105. <FormattedMessage id="transactionTime" />:
  106. </FormLabel>
  107. </Grid>
  108. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  109. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  110. {data.transTimeStr + " (HH:MI:SS)"}
  111. </FormLabel>
  112. </Grid>
  113. </Grid>
  114. </Grid>
  115. <Grid item xs={12} md={12}>
  116. <Grid container spacing={5}>
  117. <Grid item xs={6} md={6} sx={{ textAlign: "right" }}>
  118. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  119. <FormattedMessage id="paymentRefCode" />:
  120. </FormLabel>
  121. </Grid>
  122. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  123. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  124. {data.egisRefNo}
  125. </FormLabel>
  126. </Grid>
  127. </Grid>
  128. </Grid>
  129. <Grid item xs={12} md={12}>
  130. <Grid container spacing={5} >
  131. <Grid item xs={6} md={6} sx={{ textAlign: "right" }}>
  132. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  133. <FormattedMessage id="payTotalDeatail"/>:
  134. </FormLabel>
  135. </Grid>
  136. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  137. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  138. {"HK$ " + FormatUtils.currencyFormat(data.payload?.amount)}
  139. </FormLabel>
  140. </Grid>
  141. </Grid>
  142. </Grid>
  143. <Grid item xs={12} md={12}>
  144. <Grid container spacing={5} >
  145. <Grid item xs={6} md={6} sx={{ textAlign: "right" }}>
  146. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  147. <FormattedMessage id="payMethod"/>:
  148. </FormLabel>
  149. </Grid>
  150. <Grid item xs={6} md={6} sx={{textAlign: "left" }}>
  151. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  152. {getPaymentMethod()}
  153. </FormLabel>
  154. </Grid>
  155. </Grid>
  156. </Grid>
  157. {
  158. data.status == "APPR"
  159. ?
  160. <Grid item xs={12} md={12}>
  161. <Grid container spacing={5} alignItems="center">
  162. <Grid item xs={6} md={6} sx={{textAlign: "right" }}>
  163. <FormLabel sx={{ fontSize: "16px", color: "#000000" }}>
  164. <FormattedMessage id="payReceipt"/>:
  165. </FormLabel>
  166. </Grid>
  167. <Grid item xs={6} md={5} sx={{textAlign: "left" }}>
  168. {onDownload?
  169. <LoadingComponent disableText={true} alignItems="flex-start"/>
  170. :
  171. <Button className="printHidden" variant="contained" sx={{ mt:2 }} onClick={doPrint}>
  172. <DownloadIcon/>
  173. <Typography sx={{fontSize: "16px"}}>
  174. <FormattedMessage id="download"/>
  175. </Typography>
  176. </Button>
  177. }
  178. </Grid>
  179. </Grid>
  180. </Grid>
  181. : null
  182. }
  183. </Grid>
  184. </Grid>
  185. </Grid>
  186. </form>
  187. </MainCard>
  188. );
  189. };
  190. export default PaymentDetails;