From 205a73f785bec65dc62c678cb4ef2a75f6c58a3a Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 8 Mar 2024 13:06:02 +0800 Subject: [PATCH] update issue label --- src/pages/DemandNote/Create/SearchForm.js | 30 ++++++-- src/pages/DemandNote/Search/SearchForm.js | 31 ++++++-- .../DemandNote/Search_Public/SearchForm.js | 30 ++++++-- src/pages/Proof/Search_GLD/SearchForm.js | 31 ++++++-- src/pages/Proof/Search_Public/SearchForm.js | 28 +++++-- .../ApplyForm/PublicNoticeApplyForm.js | 7 +- src/pages/PublicNotice/ApplyForm/index.js | 55 +++++++++++--- .../PublicNotice/Search_GLD/SearchForm.js | 76 ++++++++++++------- .../auth-forms/IAmSmartFormWizard.js | 7 +- src/utils/DateUtils.js | 13 ++++ src/utils/FormatUtils.js | 2 + 11 files changed, 242 insertions(+), 68 deletions(-) diff --git a/src/pages/DemandNote/Create/SearchForm.js b/src/pages/DemandNote/Create/SearchForm.js index 88846cd..0db3334 100644 --- a/src/pages/DemandNote/Create/SearchForm.js +++ b/src/pages/DemandNote/Create/SearchForm.js @@ -16,6 +16,7 @@ import { useNavigate } from "react-router-dom"; import { notifyDownloadSuccess } from 'utils/CommonFunction'; import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; +import { useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -39,6 +40,9 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p const [issueCombo, setIssueCombo] = React.useState([]); const navigate = useNavigate() + const intl = useIntl(); + const { locale } = intl; + React.useEffect(() => { if (issueComboData && issueComboData.length > 0) { setIssueCombo(issueComboData); @@ -58,11 +62,27 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p }, [issueSelected]); function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } const onSubmit = () => { diff --git a/src/pages/DemandNote/Search/SearchForm.js b/src/pages/DemandNote/Search/SearchForm.js index 89912ce..319875e 100644 --- a/src/pages/DemandNote/Search/SearchForm.js +++ b/src/pages/DemandNote/Search/SearchForm.js @@ -13,6 +13,7 @@ import * as DateUtils from "utils/DateUtils"; import * as FormatUtils from "utils/FormatUtils"; import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; +import { useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -34,6 +35,10 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue const [minDueDate, setMinDueDate] = React.useState(searchCriteria.dueDateFrom); const [maxDueDate, setMaxDueDate] = React.useState(searchCriteria.dueDateTo); + const intl = useIntl(); + const { locale } = intl; + + const { reset, register, handleSubmit } = useForm() const onSubmit = (data) => { data.status = selectedLabelsString @@ -79,11 +84,27 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue } function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } return ( diff --git a/src/pages/DemandNote/Search_Public/SearchForm.js b/src/pages/DemandNote/Search_Public/SearchForm.js index 3dfe8d6..680f59e 100644 --- a/src/pages/DemandNote/Search_Public/SearchForm.js +++ b/src/pages/DemandNote/Search_Public/SearchForm.js @@ -20,7 +20,10 @@ import {ThemeProvider} from "@emotion/react"; const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData }) => { + const intl = useIntl(); + const { locale } = intl; + const [type, setType] = React.useState([]); const [issueSelected, setIssueSelected] = React.useState({}); const [issueCombo, setIssueCombo] = React.useState([]); @@ -63,13 +66,28 @@ const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData } function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } - return ( { @@ -77,13 +81,30 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss } function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } + return ( { const intl = useIntl(); + const { locale } = intl; + const [type, setType] = React.useState([]); const [status, setStatus] = React.useState(ComboData.proofStatus[0]); const [issueSelected, setIssueSelected] = React.useState({}); @@ -84,11 +86,27 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, issueComboData } function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } return ( diff --git a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js index 3e9d8c5..7dfbbb4 100644 --- a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js +++ b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js @@ -27,10 +27,11 @@ import {FormattedMessage, useIntl} from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // -const PublicNoticeApplyForm = ({ loadedData, selections }) => { +const PublicNoticeApplyForm = ({ loadedData, _selections }) => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); const [attachment, setAttachment] = React.useState({}); + const [selections, setsSelections] = React.useState(<>); const intl = useIntl(); const [val, setVal] = React.useState({}); @@ -57,6 +58,10 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""}); } + React.useEffect(() => { + setsSelections(_selections) + }, [_selections]); + const formik = useFormik({ enableReinitialize: true, initialValues: loadedData, diff --git a/src/pages/PublicNotice/ApplyForm/index.js b/src/pages/PublicNotice/ApplyForm/index.js index 405df4f..4428c06 100644 --- a/src/pages/PublicNotice/ApplyForm/index.js +++ b/src/pages/PublicNotice/ApplyForm/index.js @@ -2,8 +2,9 @@ import * as React from "react"; 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 DateUtils from "utils/DateUtils"; +import { useIntl } from "react-intl"; import { Grid, @@ -21,9 +22,14 @@ const PublicNoticeApplyForm = Loadable(lazy(() => import('./PublicNoticeApplyFor const ApplyForm = () => { const [userData, setUserData] = React.useState(null); + const [gazetteIssueList, setGazetteIssueList] = React.useState([]); + const [selections, setSelection] = React.useState([]); const [isLoading, setLoding] = React.useState(true); + const intl = useIntl(); + const { locale } = intl; + React.useEffect(() => { loadUserData(); }, []); @@ -43,22 +49,53 @@ const ApplyForm = () => { var selection = []; for (var i = 0; i < response?.gazetteIssueList?.length; i++) { let data = response.gazetteIssueList[i]; - let label = getIssueLabel(data); - selection.push(} label={label} />); + //let label = getIssueLabel(data); + selection.push(} label={getIssueLabel(data)} />); } + setGazetteIssueList(response?.gazetteIssueList); setSelection(selection); setUserData(response); } }); }; - function getIssueLabel(data) { - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + React.useEffect(() => { + if(gazetteIssueList?.length>0){ + var selection = []; + for (var i = 0; i < gazetteIssueList?.length; i++) { + let data = gazetteIssueList[i]; + let label = getIssueLabel(data); + selection.push(} label={label} />); + } + setSelection(selection); + } + }, [locale]); + + const getIssueLabel=(data)=> { + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } + React.useEffect(() => { if (userData !== null) setLoding(false); }, [userData]); @@ -73,7 +110,7 @@ const ApplyForm = () => { : ); }; diff --git a/src/pages/PublicNotice/Search_GLD/SearchForm.js b/src/pages/PublicNotice/Search_GLD/SearchForm.js index a55750d..499932e 100644 --- a/src/pages/PublicNotice/Search_GLD/SearchForm.js +++ b/src/pages/PublicNotice/Search_GLD/SearchForm.js @@ -11,8 +11,9 @@ import * as React from "react"; import * as ComboData from "utils/ComboData"; import * as DateUtils from "utils/DateUtils"; import * as FormatUtils from "utils/FormatUtils"; -import {ThemeProvider} from "@emotion/react"; -import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst"; +import { ThemeProvider } from "@emotion/react"; +import { PNSPS_BUTTON_THEME } from "../../../themes/buttonConst"; +import { useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -31,6 +32,9 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); + const intl = useIntl(); + const { locale } = intl; + const marginBottom = 2.5; const { reset, register, handleSubmit } = useForm() const onSubmit = (data) => { @@ -75,12 +79,28 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss reset(); } - function getIssueLabel(data) { - if (data == {}) return ""; - return data.issueYear - + " Vol. " + FormatUtils.zeroPad(data.volume, 3) - + ", No. " + FormatUtils.zeroPad(data.issueNo, 2) - + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + const getIssueLabel=(data)=> { + let issueYear = data.issueYear + let volume = data.volume; + let issueNo = data.issueNo; + let issueDate = data.issueDate; + if (locale === 'zh-HK') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; + } else if (locale === 'zh-CN') { + return issueYear + + " 第" + volume + "卷," + + " 第" + issueNo + "期," + + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; + } + return issueYear + + " Vol. " + FormatUtils.zeroPad(volume, 3) + + ", No. " + FormatUtils.zeroPad(issueNo, 2) + + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } return ( @@ -91,9 +111,9 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss >
- + {/*row 1*/} - + Search @@ -113,7 +133,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss /> - + - + To @@ -301,23 +321,23 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss {/*last row*/} - - - + + + - - - + + + diff --git a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js index 3cc339e..25a55ff 100644 --- a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js +++ b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js @@ -276,8 +276,7 @@ const CustomFormWizard = (props) => { const { handleSubmit } = useForm({}) const _onSubmit = () => { setLoding(true); - values.address4 = selectedAddress4 - values.address5 = selectedAddress5 + const userAddress = { "addressLine1": "", "addressLine2": "", @@ -288,8 +287,8 @@ const CustomFormWizard = (props) => { userAddress.addressLine1 = values.address1 userAddress.addressLine2 = values.address2 userAddress.addressLine3 = values.address3 - userAddress.district = values.address4 - userAddress.country = values.address5 + values.address4 = selectedAddress4 == null ? "" : selectedAddress4.key + values.address5 = selectedAddress5.key const userFaxNo = { "countryCode": values.faxCountryCode, diff --git a/src/utils/DateUtils.js b/src/utils/DateUtils.js index 2572448..3c417f9 100644 --- a/src/utils/DateUtils.js +++ b/src/utils/DateUtils.js @@ -1,5 +1,8 @@ import dayjs from 'dayjs'; +var days_ZH = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'] +var days_CN = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'] + export const datetimeStr = (date) =>{ return dateFormat(date,"YYYY-MM-DD HH:mm:ss") @@ -51,3 +54,13 @@ export const dateFormat = (date, format) =>{ date = convertToDate(date); return dayjs(date).format(format); }; + +export const getWeekdayStr_ZH = (date) =>{ + date = convertToDate(date); + return days_ZH[date.getDay()] +}; + +export const getWeekdayStr_CN = (date) =>{ + date = convertToDate(date); + return days_CN[date.getDay()] +}; diff --git a/src/utils/FormatUtils.js b/src/utils/FormatUtils.js index e4eb87b..15db9df 100644 --- a/src/utils/FormatUtils.js +++ b/src/utils/FormatUtils.js @@ -1,4 +1,5 @@ + export function currencyFormat(num) { let val = num ? num : 0; return val.toLocaleString('en-US', { @@ -15,3 +16,4 @@ export function zeroPad(num, places) { +