// material-ui import { Grid, Typography, Stack, Button, Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; import * as UrlUtils from "utils/ApiPathConst"; import { useState } from "react"; import * as HttpUtils from "utils/HttpUtils"; import { useNavigate } from "react-router-dom"; import * as DateUtils from "utils/DateUtils" import * as FormatUtils from "utils/FormatUtils"; 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 { 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 = ({ record }) => { const navigate = useNavigate() const [isPopUp, setIsPopUp] = useState(false); const [paymentHoldedErrText, setPaymentHoldedErrText] = useState(""); const [paymentHoldedErr, setPaymentHoldedErr] = useState(false); const intl = useIntl(); 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 > 20 || item.status !== "APPR"); const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT"); 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: record.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 ( (
{/*row 1*/}

{DateUtils.datetimeStr(record?.proofPaymentDeadline)}

setIsPopUp(false)} PaperProps={{ sx: { minWidth: '40vw', maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '30vw' }, maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '50vh' } } }} > (HK$): {FormatUtils.currencyFormat(record.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;