// material-ui import { Grid, Typography, Stack, Box // Button, // FormLabel, } from '@mui/material'; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; // import { useNavigate } from "react-router-dom"; // import FpsIcon from "assets/images/icons/fps.svg"; import { useLocation } from 'react-router-dom'; // import {paymentPath} from "auth/utils"; // import {poll} from "utils/Utils"; import * as DateUtils from "utils/DateUtils" import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); const PaymentDetails = Loadable(React.lazy(() => import('../Details_Public/PaymentDetails'))); const DataGrid = Loadable(React.lazy(() => import('../Details_Public/DataGrid'))); import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import {FormattedMessage,useIntl} from "react-intl"; const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } // ==============================|| DASHBOARD - DEFAULT ||============================== // const AckPage = () => { // const navigate = useNavigate() const location = useLocation(); // const [locationData, setLocationData] = React.useState({}); const [paymentData, setPaymentData] = React.useState({}); const [locationData, setLocationData] = React.useState({}); const [responeData, setResponeDataData] = React.useState({}); const [itemList, setItemList] = React.useState([]); // const [paymentId, setPaymentId] = React.useState(""); const [transactionData, setTransactionData] = React.useState({}); // const [transactionDate, setTransactionDate] = React.useState(""); // const [transactionTime, setTransactionTime] = React.useState(""); const [onReady, setOnReady] = React.useState(false); // const paymentStatusApi = "/api/payment/status/"; const [onDownload, setOnDownload] = React.useState(false); const intl = useIntl(); const { locale } = intl; React.useEffect(() => { if (location.state != undefined) { setLocationData(location.state) } }, []); React.useEffect(() => { if (Object.keys(locationData).length > 0){ loadForm(); } }, [locationData]); React.useEffect(() => { // console.log(responeData) if(Object.keys(responeData).length > 0){ setTransactionData(responeData) } }, [responeData]); React.useEffect(() => { // console.log(paymentData) // console.log(transactionData) if(Object.keys(transactionData).length > 0 ){ setOnReady(true); } }, [transactionData]); const loadForm = () => { // const dateTime = paymentData.transactionDateTime; // const date = new Date(dateTime); // const trnDate = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear(); // const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); // setTransactionDate(trnDate) // setTransactionTime(trnTime) // let transactionid = localStorage.getItem("transactionid") // let webtoken = localStorage.getItem("webtoken") let transactionid = locationData.transactionid HttpUtils.post({ url: UrlUtils.PAYMENT_CALLBACK_STATUS_API, params:{ "apprefid": transactionid, // "webtoken": webtoken, // "paymentId": localStorage.getItem("paymentId"), "transactionid":Number(transactionid) }, onSuccess: function(responseData){ localStorage.removeItem("webtoken"); localStorage.removeItem("transactionid"); responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, intl.formatMessage({id: "dateStrFormat"})); responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); setResponeDataData(responseData.transactionData) setItemList(responseData.paymentItemList) setPaymentData(responseData.data); // if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { // } // HttpUtils.post({ // url: UrlUtils.PAYMENT_SAVE, // params: { // id: localStorage.getItem("paymentId"), // transNo: responseData.transactionid, // transDateTime: new Date(responseData.paymentdetail.time).toISOString(), // egisRefNo: responseData.paymentdetail.paymentid, // status: responseData.paymentdetail.result.paymentstatuscode, // payload: responseData // }, // onSuccess: function (responseData2) { // responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); // responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); // setItemList(responseData2.paymentItemList) // setPaymentData(responseData2.data); // // localStorage.removeItem("paymentId"); // // setPaymentId(responseData2.id) // } // }); } }); // setTransactionData( // { // "amount": 999.99, // "currencycode": "HKD", // "paymentdetail": { // "attemptno": 1, // "channel": "MobileWallet", // "paymentid": "C202310268000681", // "paymentmethod": "04", // "result": { // "canretry": "Y", // "description": "CANC - Cancelled by user or Payment Server.", // "paymentstatuscode": "CANC", // "rejectreasoncode": "Payment Cancelled. [PAY-E-9022]" // }, // "subtype": "FPS", // "time": "2023-10-26T09:02:17Z[UTC]" // }, // "transactionid": "20231026170103921" // } // ) } const doPrint = () => { // window.print(); setOnDownload(true) const local = locale HttpUtils.fileDownload({ // url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local, url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+paymentData.id+"/"+local, onResponse:()=>{ setOnDownload(false) }, onError:()=>{ setOnDownload(false) } }); }; return ( !onReady ? : transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ? (
{/*row 1*/} {/* 您的申請和付款已收到 */} {/*row 2*/}
) : (transactionData.paymentdetail?.result?.paymentstatuscode === "CANC" ?
{/*row 1*/}
{/* 付款取消訊息: */}










{/*row 2*/}
:
{/*row 1*/}










{/*row 2*/}
) ); }; export default AckPage;