From 0fabe9ea6a2469d0ca47274a26c0e35a045fdfaf Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 29 Feb 2024 11:53:25 +0800 Subject: [PATCH] brExpiryDate value should after current date --- .../DetailPage/OrganizationCard.js | 102 +++--- .../OrganizationCard_loadFromUser.js | 294 ++++++++++-------- src/pages/User/SearchPage/UserSearchForm.js | 13 - 3 files changed, 216 insertions(+), 193 deletions(-) diff --git a/src/pages/Organization/DetailPage/OrganizationCard.js b/src/pages/Organization/DetailPage/OrganizationCard.js index 94ff845..13f6d8f 100644 --- a/src/pages/Organization/DetailPage/OrganizationCard.js +++ b/src/pages/Organization/DetailPage/OrganizationCard.js @@ -2,7 +2,7 @@ import { Grid, Button, Checkbox, FormControlLabel, Typography, Dialog, DialogTitle, DialogContent, DialogActions, - FormHelperText + FormHelperText, TextField, } from '@mui/material'; // import { FormControlLabel } from '@material-ui/core'; import MainCard from "components/MainCard"; @@ -10,6 +10,7 @@ import * as React from "react"; import { useFormik } from 'formik'; import * as yup from 'yup'; import { useEffect, useState } from "react"; +import * as DateUtils from 'utils/DateUtils'; import * as HttpUtils from 'utils/HttpUtils'; import * as UrlUtils from "utils/ApiPathConst"; import * as FieldUtils from "utils/FieldUtils"; @@ -19,8 +20,8 @@ import Loadable from 'components/Loadable'; import { lazy } from 'react'; import { notifySaveSuccess } from 'utils/CommonFunction'; import { useIntl } from "react-intl"; -import {PNSPS_BUTTON_THEME} from "themes/buttonConst"; -import {ThemeProvider} from "@emotion/react"; +import { PNSPS_BUTTON_THEME } from "themes/buttonConst"; +import { ThemeProvider } from "@emotion/react"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -48,12 +49,12 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { return {errorMsg} } - function getMaxErrStr(num, fieldname){ - return displayErrorMsg(intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""})); + function getMaxErrStr(num, fieldname) { + return displayErrorMsg(intl.formatMessage({ id: 'noMoreThenNWords' }, { num: num, fieldname: fieldname ? intl.formatMessage({ id: fieldname }) + ": " : "" })); } - function getRequiredErrStr(fieldname){ - return displayErrorMsg(intl.formatMessage({ id: 'require'},{fieldname:fieldname?intl.formatMessage({ id: fieldname}):""})); + function getRequiredErrStr(fieldname) { + return displayErrorMsg(intl.formatMessage({ id: 'require' }, { fieldname: fieldname ? intl.formatMessage({ id: fieldname }) : "" })); } const formik = useFormik({ @@ -83,11 +84,11 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { }), }), onSubmit: values => { - if (values.country==null){ - setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'})) + if (values.country == null) { + setErrorMsg(intl.formatMessage({ id: 'pleaseFillInCountry' })) } else { - if (values.country.key ==1 && values.district == null){ - setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'})) + if (values.country.key == 1 && values.district == null) { + setErrorMsg(intl.formatMessage({ id: 'pleaseFillInDistrict' })) } else { HttpUtils.post({ url: UrlUtils.POST_ORG_SAVE_PATH, @@ -124,7 +125,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { setEditMode(false); } }); - } + } } } }); @@ -204,24 +205,24 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { : <> - - - - - - + + + + + } @@ -244,13 +245,13 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { currentUserData.creditor ? - + : @@ -331,12 +332,29 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { - {FieldUtils.getDateField({ - label: FieldUtils.notNullFieldLabel("Expiry Date:"), - valueName: "brExpiryDate", - disabled: (!editMode && !createMode), - form: formik - })} + + + {FieldUtils.notNullFieldLabel("Expiry Date:")} + + + + + + diff --git a/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js b/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js index c9fa273..9f67e23 100644 --- a/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js +++ b/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js @@ -2,12 +2,13 @@ import { Grid, Button, Typography, Dialog, DialogTitle, DialogContent, DialogActions, - FormHelperText + FormHelperText, TextField } from '@mui/material'; import MainCard from "components/MainCard"; import * as React from "react"; import * as yup from 'yup'; import { useEffect, useState } from "react"; +import * as DateUtils from 'utils/DateUtils'; import * as HttpUtils from 'utils/HttpUtils'; import * as UrlUtils from "utils/ApiPathConst"; import * as FieldUtils from "utils/FieldUtils"; @@ -18,7 +19,7 @@ const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingCo import Loadable from 'components/Loadable'; import { lazy } from 'react'; import { notifyCreateSuccess } from 'utils/CommonFunction'; -import {useIntl} from "react-intl"; +import { useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -48,34 +49,34 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { enableReinitialize: true, initialValues: currentUserData, validationSchema: yup.object().shape({ - enCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))).required(displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))), - chCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'userRequireChineseName'}))).nullable(), - addressLine1: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), + enCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))), + chCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({ id: 'userRequireChineseName' }))).nullable(), + addressLine1: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine1' }))), addressLine2: yup.string().max(40).nullable(), addressLine3: yup.string().max(40).nullable(), - fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))).nullable(), - tel_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))), - phoneNumber: yup.string().min(8, displayErrorMsg(intl.formatMessage({id: 'requiredValidNumber'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireContactNumber'}))), + fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))).nullable(), + tel_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))), + phoneNumber: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'requiredValidNumber' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireContactNumber' }))), faxNumber: yup.string().min(8).nullable(), - brExpiryDate: yup.string().min(8).required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertValidityDate'}))), - brNo: yup.string().max(8).required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertNumber'}))) - .test('checkBrNoFormat', displayErrorMsg(`${intl.formatMessage({id: 'pleaseFillInValidBusinessRegCertNumber'})} (e.g. 12341234)`), function (value) { - var brNo_pattern = /[0-9]{8}/ - if (value !== undefined) { - if (value.match(brNo_pattern)) { - return true - } else { - return false + brExpiryDate: yup.string().min(8).required(displayErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' }))), + brNo: yup.string().max(8).required(displayErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertNumber' }))) + .test('checkBrNoFormat', displayErrorMsg(`${intl.formatMessage({ id: 'pleaseFillInValidBusinessRegCertNumber' })} (e.g. 12341234)`), function (value) { + var brNo_pattern = /[0-9]{8}/ + if (value !== undefined) { + if (value.match(brNo_pattern)) { + return true + } else { + return false + } } - } - }), + }), }), onSubmit: values => { - if (values.country==null){ - setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'})) + if (values.country == null) { + setErrorMsg(intl.formatMessage({ id: 'pleaseFillInCountry' })) } else { - if (values.country.key ==1 && values.district == null){ - setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'})) + if (values.country.key == 1 && values.district == null) { + setErrorMsg(intl.formatMessage({ id: 'pleaseFillInDistrict' })) } else { HttpUtils.post({ url: UrlUtils.POST_ORG_SAVE_PATH, @@ -107,7 +108,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { } }, onSuccess: function (responseData) { - if(responseData.msg){ + if (responseData.msg) { setFailText(responseData.msg); setIsFailPopUp(true); return; @@ -143,131 +144,148 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => {
-
- {!onReady? - - : - - {/*top*/} - - - - - - {/*top*/} + + {!onReady ? + + : + + {/*top*/} + + + + + + {/*top*/} - - - - {errorMsg} - - - - - - {FieldUtils.getTextField({ - label: "BR No.:", - valueName: "brNo", - form: formik - })} - + + + + {errorMsg} + + + - + + {FieldUtils.getTextField({ + label: "BR No.:", + valueName: "brNo", + form: formik + })} + - - {FieldUtils.getTextField({ - label: FieldUtils.notNullFieldLabel("Name (Eng):"), - valueName: "enCompanyName", - form: formik - })} - + - - {FieldUtils.getTextField({ - label: "Name (Ch):", - valueName: "chCompanyName", - form: formik - })} - + + {FieldUtils.getTextField({ + label: FieldUtils.notNullFieldLabel("Name (Eng):"), + valueName: "enCompanyName", + form: formik + })} + - - {FieldUtils.getDateField({ - label: FieldUtils.notNullFieldLabel("Expiry Date:"), - valueName: "brExpiryDate", - form: formik - })} - + + {FieldUtils.getTextField({ + label: "Name (Ch):", + valueName: "chCompanyName", + form: formik + })} + - - {FieldUtils.getTextField({ - label: FieldUtils.notNullFieldLabel("Contact Person:"), - valueName: "contactPerson", - form: formik - })} - + + + + {FieldUtils.notNullFieldLabel("Expiry Date:")} + + + + + - - {FieldUtils.getPhoneField({ - label: FieldUtils.notNullFieldLabel("Contact Tel:"), - valueName: { - code: "tel_countryCode", - num: "phoneNumber" - }, - form: formik - })} - + - - {FieldUtils.getPhoneField({ - label: "Fax No:", - valueName: { - code: "fax_countryCode", - num: "faxNumber" - }, - form: formik - })} - + + {FieldUtils.getTextField({ + label: FieldUtils.notNullFieldLabel("Contact Person:"), + valueName: "contactPerson", + form: formik + })} + - - {FieldUtils.getComboField({ - label: FieldUtils.notNullFieldLabel("Country:"), - valueName: "country", - dataList: ComboData.country, - getOptionLabel: (option) => option.type? intl.formatMessage({ id: option.type}) : "", - form: formik - })} - + + {FieldUtils.getPhoneField({ + label: FieldUtils.notNullFieldLabel("Contact Tel:"), + valueName: { + code: "tel_countryCode", + num: "phoneNumber" + }, + form: formik + })} + - - {FieldUtils.getComboField({ - label: FieldUtils.notNullFieldLabel("District:"), - valueName: "district", - dataList: ComboData.district, - getOptionLabel: (option) => option.type? intl.formatMessage({ id: option.type}) : "", - form: formik - })} - + + {FieldUtils.getPhoneField({ + label: "Fax No:", + valueName: { + code: "fax_countryCode", + num: "faxNumber" + }, + form: formik + })} + - - {FieldUtils.getAddressField({ - label: FieldUtils.notNullFieldLabel("Address:"), - valueName: ["addressLine1", "addressLine2", "addressLine3"], - form: formik - })} - - - } - + + {FieldUtils.getComboField({ + label: FieldUtils.notNullFieldLabel("Country:"), + valueName: "country", + dataList: ComboData.country, + getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "", + form: formik + })} + + + + {FieldUtils.getComboField({ + label: FieldUtils.notNullFieldLabel("District:"), + valueName: "district", + dataList: ComboData.district, + getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "", + form: formik + })} + + + + {FieldUtils.getAddressField({ + label: FieldUtils.notNullFieldLabel("Address:"), + valueName: ["addressLine1", "addressLine2", "addressLine3"], + form: formik + })} + + + } +
diff --git a/src/pages/User/SearchPage/UserSearchForm.js b/src/pages/User/SearchPage/UserSearchForm.js index a971b67..7d8b1e9 100644 --- a/src/pages/User/SearchPage/UserSearchForm.js +++ b/src/pages/User/SearchPage/UserSearchForm.js @@ -46,7 +46,6 @@ const UserSearchForm = ({ applySearch }) => { enName: data.fullenName, post: data.post, email: data.email, - phone: data.phone, locked: locked, }; applySearch(temp); @@ -136,18 +135,6 @@ const UserSearchForm = ({ applySearch }) => { /> - - - -