From ae78d2ea7ad9e00ae6ecbf8502ce7e019430ba90 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Mon, 17 Nov 2025 04:14:35 +0800 Subject: [PATCH] update payment date checking --- src/pages/Proof/Reply_Public/ProofForm.js | 310 +++++++++--------- .../ApplyForm/PublicNoticeApplyForm.js | 203 ++++++------ src/pages/PublicNotice/ApplyForm/index.js | 66 +--- src/utils/Utils.js | 47 ++- 4 files changed, 295 insertions(+), 331 deletions(-) diff --git a/src/pages/Proof/Reply_Public/ProofForm.js b/src/pages/Proof/Reply_Public/ProofForm.js index 9be9aab..151337c 100644 --- a/src/pages/Proof/Reply_Public/ProofForm.js +++ b/src/pages/Proof/Reply_Public/ProofForm.js @@ -28,8 +28,9 @@ import { ThemeProvider } from "@emotion/react"; import { FormattedMessage, useIntl } from "react-intl"; import { isDummyLoggedIn, - checkIsOnlyOnlinePaymentByIssueDate, - checkPaymentSuspention + checkIsOnlyOnlinePayment, + checkPaymentSuspention, + checkIsNoPaymentByCreateDate, } from "utils/Utils" const UploadFileTable = Loadable(React.lazy(() => import('./UploadFileTable'))); @@ -51,7 +52,8 @@ const FormPanel = ({ formData }) => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); const [isOnlyOnlinePayment, setOnlyOnlinePayment] = React.useState(); - + const [isNoPayment, setNoPayment] = React.useState(); + const navigate = useNavigate() const params = useParams(); // const dft = locale === 'en' ? "DD MMMM YYYY" : "YYYY年MM月DD日"; @@ -65,12 +67,16 @@ const FormPanel = ({ formData }) => { React.useEffect(() => { if (formData) { + // console.log("formData", formData) setData(formData); - setOnlyOnlinePayment(checkIsOnlyOnlinePaymentByIssueDate(formData.issueDate)) + setOnlyOnlinePayment(checkIsOnlyOnlinePayment()) + setNoPayment(checkIsNoPaymentByCreateDate(formData.created)) if (isDummyLoggedIn()) { set_paymentMethod("demandNote") - } else if (checkIsOnlyOnlinePaymentByIssueDate(formData.issueDate)){ + } else if (checkIsOnlyOnlinePayment()){ set_paymentMethod("online") + } else if (checkIsNoPaymentByCreateDate(formData.created)){ + set_paymentMethod("demandNote") } } }, [formData]); @@ -414,156 +420,160 @@ const FormPanel = ({ formData }) => { : <> - - - - - - - - - - - - - - - - - - {!isOnlyOnlinePayment? - <> - - - - - - - - - - + + + + + + + + + + + + + + :null + } + + +
- { - set_paymentMethod("online") - }} - /> - - - {checkPaymentSuspention()? - - { - locale === 'en' ? - `${DateUtils.dateFormat(formData.reviseDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "a.m.")?.replace("pm", "p.m.")}` - : - `${DateUtils.dateFormat(formData.reviseDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "上午")?.replace("pm", "下午").replace("00分", "")}` - }{ - locale === 'en' ? - `${DateUtils.dateFormat(formData.proofPaymentDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "a.m.")?.replace("pm", "p.m.")}` - : - `${DateUtils.dateFormat(formData.proofPaymentDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "上午")?.replace("pm", "下午").replace("00分", "")}` - } - -
- {isOverDnReviseDeadline() ? - <> : - { - set_paymentMethod("demandNote") - }} - /> - } - - -
{ - setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payDn" })) - setWarningText( - <>: -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
- -
{DateUtils.dateFormat(formData.closingDateOff, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"5:00 p.m.":"下午5時"}{DateUtils.dateFormat(formData.closingDateOff, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"5:00 p.m.":"下午5時"} - -
- { - isOverNpgoReviseDeadline() ? + {isNoPayment ? + null + : + + + + + + + + + + + + + + + + + + {!isOnlyOnlinePayment? + <> + + - - - - - - :null - } - - -
+ { + set_paymentMethod("online") + }} + /> + + + {checkPaymentSuspention()? + + { + locale === 'en' ? + `${DateUtils.dateFormat(formData.reviseDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "a.m.")?.replace("pm", "p.m.")}` + : + `${DateUtils.dateFormat(formData.reviseDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "上午")?.replace("pm", "下午").replace("00分", "")}` + }{ + locale === 'en' ? + `${DateUtils.dateFormat(formData.proofPaymentDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "a.m.")?.replace("pm", "p.m.")}` + : + `${DateUtils.dateFormat(formData.proofPaymentDeadline, intl.formatMessage({ id: "datetimeFormate" }))?.replace("am", "上午")?.replace("pm", "下午").replace("00分", "")}` + } + +
+ {isOverDnReviseDeadline() ? <> : { - set_paymentMethod("office") + set_paymentMethod("demandNote") }} /> - } - - -
{ - setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payNPGOPopUpTitle" })) - setWarningText( - <>: -
    -
  • -
  • -
  • -
  • -
- - ); - setIsWarningPopUp(true); - }}>
-
{DateUtils.dateFormat(formData.closingDate, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"11:30 a.m.":"上午11時30分"}{DateUtils.dateFormat(formData.closingDate, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"12:00 p.m.":"下午12時"} - -
-
+ } +
+ +
{ + setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payDn" })) + setWarningText( + <>: +
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
{DateUtils.dateFormat(formData.closingDateOff, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"5:00 p.m.":"下午5時"}{DateUtils.dateFormat(formData.closingDateOff, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"5:00 p.m.":"下午5時"} + +
+ { + isOverNpgoReviseDeadline() ? + <> : + { + set_paymentMethod("office") + }} + /> + } + + +
{ + setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payNPGOPopUpTitle" })) + setWarningText( + <>: +
    +
  • +
  • +
  • +
  • +
+ + ); + setIsWarningPopUp(true); + }}>
+
{DateUtils.dateFormat(formData.closingDate, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"11:30 a.m.":"上午11時30分"}{DateUtils.dateFormat(formData.closingDate, intl.formatMessage({ id: "dateStrFormat" }))} {locale ==='en'?"12:00 p.m.":"下午12時"} + +
+
+ } {/*
diff --git a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js index 43dd481..947e96f 100644 --- a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js +++ b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js @@ -20,9 +20,10 @@ import ForwardIcon from '@mui/icons-material/Forward'; import { isORGLoggedIn, isDummyLoggedIn, - // isCreditorLoggedIn, - checkIsOnlyOnlinePaymentByIssueDate, - // checkIsOnlyOnlinePaymentApply, + isCreditorLoggedIn, + // checkIsOnlyOnlinePaymentByIssueDate, + checkIsOnlyOnlinePayment, + checkMarkAsCreditClient, } from "utils/Utils"; import { useNavigate } from "react-router-dom"; @@ -89,7 +90,7 @@ const PublicNoticeApplyForm = ({ loadedData, _selections, gazetteIssueList }) => if (data.id == issueId) { setCloseDate(data.closingDate) setClosingDateOff(data.closingDateOff) - setOnlyOnlinePayment(checkIsOnlyOnlinePaymentByIssueDate(data.issueDate)) + setOnlyOnlinePayment(checkIsOnlyOnlinePayment()) break; } @@ -360,101 +361,105 @@ const PublicNoticeApplyForm = ({ loadedData, _selections, gazetteIssueList }) => - - - - - - - - - - - - - - {!isOnlyOnlinePayment? - <> - - - - - - - - - - - :null - } - -
- -
{ - setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payOnline" })) - setWarningText( - <>: -
    -
  • -
  • -
  • -
- - ); - setIsWarningPopUp(true); - }}>
-
{DateUtils.dateFormat(closeDate, dft)} {locale==='en'?"2:00 p.m.":"下午2時"} - -
-
{ - setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payDn" })) - setWarningText( - <>: -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
- -
{DateUtils.dateFormat(closingDateOff, dft)} {locale==='en'?"5:00 p.m.":"下午5時"} - -
-
{ - setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payNPGOPopUpTitle" })) - setWarningText( - <>: -
    -
  • -
  • -
  • -
  • -
- - ); - setIsWarningPopUp(true); - }}>
-
{DateUtils.dateFormat(closeDate, dft)} {locale==='en'?"12:00 p.m.":"下午12時"} - -
-
+ {isCreditorLoggedIn() && checkMarkAsCreditClient()? + null + : + + + + + + + + + + + + + + {!isOnlyOnlinePayment? + <> + + + + + + + + + + + :null + } + +
+ +
{ + setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payOnline" })) + setWarningText( + <>: +
    +
  • +
  • +
  • +
+ + ); + setIsWarningPopUp(true); + }}>
+
{DateUtils.dateFormat(closeDate, dft)} {locale==='en'?"2:00 p.m.":"下午2時"} + +
+
{ + setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payDn" })) + setWarningText( + <>: +
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
{DateUtils.dateFormat(closingDateOff, dft)} {locale==='en'?"5:00 p.m.":"下午5時"} + +
+
{ + setWarningTitle(intl.formatMessage({ id: "paymentMeans" }) + ": " + intl.formatMessage({ id: "payNPGOPopUpTitle" })) + setWarningText( + <>: +
    +
  • +
  • +
  • +
  • +
+ + ); + setIsWarningPopUp(true); + }}>
+
{DateUtils.dateFormat(closeDate, dft)} {locale==='en'?"12:00 p.m.":"下午12時"} + +
+
+ } import('./PublicNoticeApplyFor import { // isORGLoggedIn, isDummyLoggedIn, - checkIsOnlyOnlinePaymentByIssueDate, - checkIsOnlyOnlinePayment + // checkIsOnlyOnlinePaymentByIssueDate, + // checkIsOnlyOnlinePayment // isCreditorLoggedIn } from "utils/Utils"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -58,62 +58,14 @@ const ApplyForm = () => { response["faxNumber"] = ""; } - if (response?.gazetteIssueList) { - const issueList = response.gazetteIssueList; - - // check each issue - const allTrue = issueList.every((d) => - checkIsOnlyOnlinePaymentByIssueDate(d.issueDate) - ); - - if (allTrue){ - if (checkIsOnlyOnlinePayment()) { - const selection = issueList.map((data) => ( - } - label={getIssueLabel(data)} - /> - )); - setGazetteIssueList(issueList); - setSelection(selection); - } else { - //setGazetteIssueList(issueList); - //setSelection([]); - } - } else { - let selection = []; - for (let i = 0; i < response.gazetteIssueList.length; i++) { - let data = response.gazetteIssueList[i]; - // only add if false - if (!checkIsOnlyOnlinePaymentByIssueDate(data.issueDate)) { - selection.push( - } - label={getIssueLabel(data)} - /> - ); - } - if (checkIsOnlyOnlinePayment()){ - if (!checkIsOnlyOnlinePaymentByIssueDate(data.issueDate)) { - selection.push( - } - label={getIssueLabel(data)} - /> - ); - } - } - } - setGazetteIssueList(issueList); - setSelection(selection); - } + var selection = []; + for (var i = 0; i < response?.gazetteIssueList?.length; i++) { + let data = response.gazetteIssueList[i]; + //let label = getIssueLabel(data); + selection.push(} label={getIssueLabel(data)} />); } + setGazetteIssueList(response?.gazetteIssueList); + setSelection(selection); setUserData(response); // setOnlyOnlinePayment(checkIsOnlyOnlinePayment()) } diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 37fa027..3da8f64 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -195,7 +195,7 @@ export const isPasswordExpiry = () =>{ export const checkIsOnlyOnlinePaymentByIssueDate = (date) => { // const targetDate = new Date(2025, 7, 1, 0, 0, 0) //2026-01-28T08:00:00.000Z hardcode - const targetDate = new Date(2025, 9, 17, 0, 0, 0) //2025-10-17T08:00:00.000Z + const targetDate = new Date(2026, 0, 28, 0, 0, 0) //2026-01-28T08:00:00.000Z const checkDate = DateUtils.convertToDate(date) if (isDummyLoggedIn()){ return false; @@ -210,14 +210,14 @@ export const checkIsOnlyOnlinePaymentByIssueDate = (date) => { } export const checkIsOnlyOnlinePayment = () => { - // const targetDate = new Date(2025, 28, 0, 0, 0, 0) // hardcode - const targetDate = new Date(2025, 9, 8, 0, 0, 0) // hardcode + // const targetDate = new Date(2025, 10, 17, 0, 0, 0) // hardcode + const targetDate = new Date(2026, 0, 28, 0, 0, 0) // hardcode new Date(2026, 0, 28, 0, 0, 0) 28 Jan 2026 const checkDate = DateUtils.convertToDate(new Date()) if (isDummyLoggedIn()){ return false; } - console.log(checkDate) - console.log(targetDate) + // console.log(checkDate) + // console.log(targetDate) if (checkDate >= targetDate) { return true } else { @@ -225,32 +225,29 @@ export const checkIsOnlyOnlinePayment = () => { } } -export const checkIsOnlyOnlinePaymentApply = (tickAccept) => { - // const targetDate = new Date(2025, 28, 0, 0, 0, 0) // hardcode - const targetDate = new Date(2025, 9, 8, 0, 0, 0) // hardcode +export const checkMarkAsCreditClient = () => { + // const targetDate = new Date(2025, 10, 17, 0, 0, 0) // hardcode + const targetDate = new Date(2026, 0, 27, 0, 0, 0) // hardcode new Date(2026, 0, 28, 0, 0, 0) 28 Jan 2026 const checkDate = DateUtils.convertToDate(new Date()) - if (isDummyLoggedIn()){ - return false; - } - // console.log(checkDate) // console.log(targetDate) - if(tickAccept){ - if (checkDate >= targetDate) { - return false - } else{ - return true; - } - }else { - return true; + // console.log(checkDate >= targetDate) + if (checkDate >= targetDate) { + return true + } else { + return false; } } -export const checkMarkAsCreditClient = () => { - const targetDate = new Date(2025, 9, 8, 0, 0, 0) // hardcode - const checkDate = DateUtils.convertToDate(new Date()) +export const checkIsNoPaymentByCreateDate = (date) => { + // const targetDate = new Date(2025, 10, 18, 0, 0, 0) //2026-01-28T08:00:00.000Z hardcode + const targetDate = new Date(2026, 0, 27, 0, 0, 0) //2026-01-28T08:00:00.000Z + const checkDate = DateUtils.convertToDate(date) + if (isDummyLoggedIn()){ + return false; + } + // console.log(checkDate) // console.log(targetDate) - // console.log(checkDate >= targetDate) - if (checkDate >= targetDate) { + if (checkDate <= targetDate && isCreditorLoggedIn()) { return true } else { return false;