You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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