From e2837518c418042e66a5b47ca93ad8b5a2556d3b Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 19 Dec 2023 16:18:55 +0800 Subject: [PATCH] application deadline check --- src/pages/Payment/index.js | 41 +++++++- .../Details_Public/ApplicationDetailCard.js | 55 +++++++++-- .../ListPanel/PendingPaymentTab.js | 98 ++++++++++++++----- src/utils/ApiPathConst.js | 1 + 4 files changed, 162 insertions(+), 33 deletions(-) diff --git a/src/pages/Payment/index.js b/src/pages/Payment/index.js index 63ecaae..2e7b4b6 100644 --- a/src/pages/Payment/index.js +++ b/src/pages/Payment/index.js @@ -16,7 +16,8 @@ import { Grid, Typography, Stack, - Box + Box, + Dialog, DialogTitle, DialogContent, DialogActions, } from '@mui/material'; //icon @@ -64,6 +65,9 @@ const Index = () => { const [itemList, setItemList] = useState([]); const [onReady, setOnReady] = useState(false); + const [expiryDateErrText, setExpiryDateErrText] = React.useState(""); + const [expiryDateErr, setExpiryDateErr] = React.useState(false); + useEffect(() => { setAppIds(location.state?.appIdList ?? []) setTotalAmount(location.state?.amount ?? 2000) @@ -369,7 +373,24 @@ const Index = () => { }; const confirmPaymentHandle = () => () => { - setConfirmPayment(true); + HttpUtils.post({ + url: UrlUtils.POST_CHECK_APP_EXPRITY_DATE, + params: { + ids: appIds + }, + onSuccess: (responData) => { + if (responData.success == true) { + setConfirmPayment(true); + return; + } + let str = ""; + responData.msg.forEach((item) => { + str += "App: " + item.appNo + ", 到期日: " + DateUtils.datetimeStr_Cht(item.expiryDate) + "\n"; + }); + setExpiryDateErrText(str.split('\n').map(str => <>{str}
)); + setExpiryDateErr(true); + } + }); }; const getMethodImgClass = (method) => { @@ -524,6 +545,22 @@ const Index = () => { {/*row 2*/} +
+ setExpiryDateErr(false)} > + + 行動失敗 + + + { + expiryDateErrText + } + + + + + + +
); } diff --git a/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js b/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js index 32808ae..2b22348 100644 --- a/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js +++ b/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js @@ -24,12 +24,13 @@ import { lazy } from 'react'; const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); // import {useParams} from "react-router-dom"; import * as HttpUtils from "utils/HttpUtils" +import * as UrlUtils from "utils/ApiPathConst" import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils"; import * as DateUtils from "utils/DateUtils"; import * as FormatUtils from "utils/FormatUtils"; import { isORGLoggedIn, - } from "utils/Utils"; +} from "utils/Utils"; // import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined'; // import DoneIcon from '@mui/icons-material/Done'; @@ -45,6 +46,8 @@ const ApplicationDetailCard = ( } ) => { const [isPopUp, setIsPopUp] = useState(false); + const [errorText, setErrorText] = useState(""); + const [errorPopUp, setErrorPopUp] = useState(false); // const params = useParams(); const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({}); const [fee, setFee] = useState(0); @@ -97,6 +100,24 @@ const ApplicationDetailCard = ( setStatus("cancel") }; + const checkExprityDate = () => { + HttpUtils.post({ + url: UrlUtils.POST_CHECK_APP_EXPRITY_DATE, + params: { + ids: [currentApplicationDetailData.id] + }, + onSuccess: (responData) => { + if (responData.success == true) { + setIsPopUp(true); + return; + } + setErrorText("公共啟事申請已過期"); + setErrorPopUp(true); + } + }); + }; + + function doPayment() { setIsPopUp(false); navigate('/paymentPage', { state: { amount: fee, appIdList: [currentApplicationDetailData.id] } }); @@ -124,8 +145,10 @@ const ApplicationDetailCard = ( @@ -500,13 +523,13 @@ const ApplicationDetailCard = ( variant="contained" onClick={onDownloadClick()} title="下載" - style={{display:"flex-right"}} + style={{ display: "flex-right" }} sx={{ textTransform: 'capitalize', alignItems: 'end', }}> - - 下載 + + 下載 @@ -527,7 +550,7 @@ const ApplicationDetailCard = ( {currentApplicationDetailData.careOf} - : null + : null } @@ -557,6 +580,22 @@ const ApplicationDetailCard = ( +
+ setErrorPopUp(false)} > + + 行動失敗 + + + { + errorText + } + + + + + + +
); diff --git a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js index 29c2032..6e225bc 100644 --- a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js +++ b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js @@ -10,13 +10,15 @@ import { Dialog, DialogTitle, DialogContent, DialogActions, } from '@mui/material'; import { FiDataGrid } from "components/FiDataGrid"; +import * as HttpUtils from "utils/HttpUtils" +import * as UrlUtils from "utils/ApiPathConst" import * as DateUtils from "utils/DateUtils" import * as FormatUtils from "utils/FormatUtils" import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils"; import { useNavigate } from "react-router-dom"; import { isORGLoggedIn, - } from "utils/Utils"; +} from "utils/Utils"; // ==============================|| EVENT TABLE ||============================== // export default function SubmittedTab({ rows }) { @@ -27,6 +29,8 @@ export default function SubmittedTab({ rows }) { const [getCareOfList, setCareOfList] = React.useState([]); const [careOfComboList, setCareOfComboList] = React.useState([{}]); const [selectedCareOf, setSelectedCareOf] = React.useState(null); + const [expiryDateErrText, setExpiryDateErrText] = React.useState(""); + const [expiryDateErr, setExpiryDateErr] = React.useState(false); //const [amount, setAmount] = React.useState(0); const navigate = useNavigate() @@ -40,7 +44,7 @@ export default function SubmittedTab({ rows }) { key: index, id: obj.id, label: obj.careOf, - })); + })); // console.log(formattedData) setCareOfList(formattedData) }, []); @@ -51,11 +55,11 @@ export default function SubmittedTab({ rows }) { }, [getCareOfList]); React.useEffect(() => { - if(selectedCareOf != null){ + if (selectedCareOf != null) { const afteSelectedList = []; afteSelectedList.push(rows.find(obj => obj.id === selectedCareOf.id)); setRowList(afteSelectedList) - }else{ + } else { setRowList(rows) } }, [selectedCareOf]); @@ -64,6 +68,37 @@ export default function SubmittedTab({ rows }) { navigate('/publicNotice/' + params.id); }; + const handlePaymentBtn = () => { + let appIdList = []; + const datas = rows?.filter((row) => + selectedRowItems.includes(row.id) + ); + // console.log(datas) + for (var i = 0; i < datas?.length; i++) { + appIdList.push(datas[i].id); + } + HttpUtils.post({ + url: UrlUtils.POST_CHECK_APP_EXPRITY_DATE, + params: { + ids: appIdList + }, + onSuccess: (responData) => { + if (responData.success == true) { + setIsPopUp(true); + return; + } + let str = ""; + responData.msg.forEach((item) => { + str += "App: " + item.appNo + ", 到期日: " + DateUtils.datetimeStr_Cht(item.expiryDate) + "\n"; + }); + setExpiryDateErrText(str.split('\n').map(str => <>{str}
)); + setExpiryDateErr(true); + } + }); + + + }; + const columns = [ { id: 'appNo', @@ -109,18 +144,18 @@ export default function SubmittedTab({ rows }) { { id: 'remarks', field: 'remarks', - headerName: isORGLoggedIn()?"Care Of / 我的備註":"我的備註", + headerName: isORGLoggedIn() ? "Care Of / 我的備註" : "我的備註", flex: 3, renderCell: (params) => ( - isORGLoggedIn()? -
- Care Of: {params.row.careOf} - 我的備註: {params.row.remarks} -
: -
- {params.row.remarks} -
- ) + isORGLoggedIn() ? +
+ Care Of: {params.row.careOf} + 我的備註: {params.row.remarks} +
: +
+ {params.row.remarks} +
+ ) }, { id: 'fee', @@ -192,11 +227,11 @@ export default function SubmittedTab({ rows }) { } const firstCareOf = datas[0].careOf; const areAllCareOfEqual = datas.every(obj => obj.careOf === firstCareOf); - - if (appIdList.length>0&&areAllCareOfEqual){ + + if (appIdList.length > 0 && areAllCareOfEqual) { navigate('/paymentPage', { state: { amount: totalAmount, appIdList: appIdList } }); - }else{ + } else { setCheckCareOf(true); // console.log("The selected applications should be from the same Care of.") } @@ -219,7 +254,7 @@ export default function SubmittedTab({ rows }) { return ( <>
- {isORGLoggedIn()? + {isORGLoggedIn() ? Care Of: @@ -237,7 +272,7 @@ export default function SubmittedTab({ rows }) { renderInput={(params) => } /> - :null + : null } 'auto'} /> -
- +
+
@@ -282,16 +317,33 @@ export default function SubmittedTab({ rows }) { - You have been selected different Care of applications. Are you want to pay? + You have been selected different Care of applications. Are you want to pay? - +
+ +
+ setExpiryDateErr(false)} > + + 行動失敗 + + + { + expiryDateErrText + } + + + + + + +
); diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index fa2aef1..9106deb 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -60,6 +60,7 @@ export const GET_PUBLIC_NOTICE_LIST = apiPath+'/application/list'; export const GET_PUBLIC_NOTICE_LIST_ListByStatus = apiPath+'/application/status-list'; export const GET_PUBLIC_NOTICE_getApplyUser = apiPath+'/application/get-apply-user'; export const POST_PUBLIC_NOTICE_APPLY = apiPath+'/application/apply'; +export const POST_CHECK_APP_EXPRITY_DATE = apiPath+'/application/checkExprityDate'; //GLD User export const POST_ADMIN_USER_REGISTER = apiPath+'/user/registry';