// material-ui import { Grid, Typography, Stack, Button, Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; import * as UrlUtils from "utils/ApiPathConst"; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import { useParams } from "react-router-dom"; import { useNavigate } from "react-router-dom"; import * as DateUtils from "utils/DateUtils" import * as FormatUtils from "utils/FormatUtils"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } import { // useEffect, useState } from "react"; import { PNSPS_BUTTON_THEME, // PNSPS_LONG_BUTTON_THEME } from "../../../themes/buttonConst"; import { ThemeProvider } from "@emotion/react"; import { FormattedMessage, useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const Index = () => { const params = useParams(); const navigate = useNavigate() const [fee, setFee] = useState(0); const [record, setRecord] = React.useState({}); const [onReady, setOnReady] = React.useState(false); const [isPopUp, setIsPopUp] = useState(false); const [paymentHoldedErrText, setPaymentHoldedErrText] = React.useState(""); const [paymentHoldedErr, setPaymentHoldedErr] = React.useState(false); const intl = useIntl(); React.useEffect(() => { loadForm(); }, []); React.useEffect(() => { setOnReady(true); }, [record]); const loadForm = () => { if (params.id > 0) { HttpUtils.get({ url: UrlUtils.GET_PROOF_PAY + "/" + params.id, onSuccess: (responseData) => { // if (!responseData.data?.id) { // navigate("/proof/search"); // } setRecord(responseData.data); setFee(responseData.data.fee); }, onError: () => { } }); } } function doPayment() { setIsPopUp(false); let appIdList = [record?.appId] handlePaymentCheck(appIdList) } const handlePaymentCheck = (appIdList) => { HttpUtils.post({ url: UrlUtils.PAYMENT_CHECK, params: { appIds: appIdList }, onSuccess: (responseData) => { const latestData = {}; responseData.forEach(item => { const { appId, timeDiff } = item; if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) { latestData[appId] = item; } }); const latestDataObjects = Object.values(latestData); const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR"); const filteredAppIds = filteredData.map(item => item.appId); const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId)); const combinedAppIdsArray = [...appIdsNotInData, ...filteredAppIds]; const readyToPayment = appIdList.every(appId => combinedAppIdsArray.includes(appId)); if (readyToPayment) { navigate('/paymentPage', { state: { amount: fee, appIdList: appIdList } }); } else { const appIdsInData = appIdList.filter(appId => !combinedAppIdsArray.some(item => item === appId)); const HoldingApplication = latestDataObjects.filter(item => appIdsInData.includes(item.appId)); const resultString = HoldingApplication.map(item => item.appNo).join(' , '); setPaymentHoldedErrText(resultString); // setPaymentHoldedErrText(intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: record.appNo })); setPaymentHoldedErr(true); } } }); }; return ( !onReady ? : (
{/*row 1*/}



setIsPopUp(false)} PaperProps={{ sx: { minWidth: '40vw', maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '30vw' }, maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '50vh' } } }} > ($): {FormatUtils.currencyFormat(fee)}
{/*row 2*/}
setPaymentHoldedErr(false)} PaperProps={{ sx: { minWidth: '40vw', maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } } }} >
) ); }; export default Index;