@@ -96,6 +96,7 @@ const CustomFormWizard = (props) => {
const email = document.getElementById("email-login")
const [checkEmail, setCheckEmail] = useState(false)
const [checkEmailBlur, setCheckEmailBlur] = useState(false)
const [districtErrStr, setDistrictErrStr] = useState("")
const idDocTypeComboList = ComboData.idDocType;
const termsAndCon = "此網址由香港特別行政區政府物流服務署製作及管理。本署會盡力確保網址上的資料無誤,\n"
@@ -291,6 +292,10 @@ const CustomFormWizard = (props) => {
props.setUpdateValid(isValid)
}, [isValid])
useEffect(() => {
props.setUpdateValid(isValid)
}, [isValid])
useEffect(() => {
checkDataField(values)
}, [
@@ -298,6 +303,14 @@ const CustomFormWizard = (props) => {
selectedAddress4, selectedAddress5,
termsAndConAccept, termsAndConNotAccept, fileList])
useEffect(()=>{
setDistrictErrStr("");
if(selectedAddress5?.type === "hongKong"){
if(selectedAddress4 ==null || selectedAddress4 == ""|| selectedAddress4 == {})
setDistrictErrStr(getRequiredErrStr("district"))
}
},[selectedAddress4, selectedAddress5])
useEffect(() => {
props.step == 2 ? _onSubmit() : null;
if (captchaImg == "")
@@ -528,6 +541,13 @@ const CustomFormWizard = (props) => {
return <Typography variant="errorMessage1">{errorMsg}</Typography>
}
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}):""}));
}
const formik = useFormik({
initialValues: ({
username: '',
@@ -551,23 +571,23 @@ const CustomFormWizard = (props) => {
captchaField: ''
}),
validationSchema: yup.object().shape({
username: yup.string().min(6, displayErrorMsg(intl.formatMessage({ id: 'atLeast6CharAccount' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireUsername' })))
username: yup.string().min(6, displayErrorMsg(intl.formatMessage({ id: 'atLeast6CharAccount' }))).max(30, getMaxErrStr(30)). required(displayErrorMsg(intl.formatMessage({ id: 'requireUsername' })))
.matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg(intl.formatMessage({ id: 'noSpecialCharAccount' })) })
.matches(/^\S*$/, { message: displayErrorMsg(intl.formatMessage({ id: 'noSpaceAccount' })) }),
password: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'atLeast8CharPassword' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requirePassword' })))
password: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'atLeast8CharPassword' }))).max(60, getMaxErrStr(60)). required(displayErrorMsg(intl.formatMessage({ id: 'requirePassword' })))
.matches(/^\S*$/, { message: displayErrorMsg(intl.formatMessage({ id: 'noSpacePassword' })) })
.matches(/^(?=.*[a-z])/, { message: displayErrorMsg(intl.formatMessage({ id: 'atLeastOneSmallLetter' })) })
.matches(/^(?=.*[A-Z])/, { message: displayErrorMsg(intl.formatMessage({ id: 'atLeastOneCapLetter' })) })
.matches(/^(?=.*[0-9])/, { message: displayErrorMsg(intl.formatMessage({ id: 'atLeast1Number' })) })
.matches(/^(?=.*[!@#%&])/, { message: displayErrorMsg(intl.formatMessage({ id: 'atLeast1SpecialChar' })) }),
confirmPassword: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'atLeast8CharPassword' }))).required(displayErrorMsg(intl.formatMessage({ id: 'pleaseConfirmPassword' }))).oneOf([yup.ref('password'), null], displayErrorMsg(intl.formatMessage({ id: 'samePassword' }))),
enName: yup.string().max(255 ).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))),
chName: yup.string().max(6).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireChineseName' }))),
address1: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine1' }))),
address2: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine2' }) )),
address3: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine3' }) )),
email: yup.string().email(displayErrorMsg(intl.formatMessage({ id: 'validEmailFormat' }))).max(255 ).required(displayErrorMsg(intl.formatMessage({ id: 'requireEmail' }))),
emailConfirm: yup.string().email(displayErrorMsg(intl.formatMessage({ id: 'validEmailFormat' }))).max(255 ).required(displayErrorMsg(intl.formatMessage({ id: 'requireEmail' }))).oneOf([yup.ref('email'), null], displayErrorMsg(intl.formatMessage({ id: 'validSameEmail' }))),
enName: yup.string().max(40, getMaxErrStr(40) ).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))),
chName: yup.string().max(6, getMaxErrStr(6) ).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireChineseName' }))),
address1: yup.string().max(40, getMaxErrStr(40, "addressLine1") ).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine1' }))),
address2: yup.string().max(40, getMaxErrStr(40, "addressLine2" )),
address3: yup.string().max(40, getMaxErrStr(40, "addressLine3" )),
email: yup.string().email(displayErrorMsg(intl.formatMessage({ id: 'validEmailFormat' }))).max(128, getMaxErrStr(128) ).required(displayErrorMsg(intl.formatMessage({ id: 'requireEmail' }))),
emailConfirm: yup.string().email(displayErrorMsg(intl.formatMessage({ id: 'validEmailFormat' }))).max(128, getMaxErrStr(128) ).required(displayErrorMsg(intl.formatMessage({ id: 'requireEmail' }))).oneOf([yup.ref('email'), null], displayErrorMsg(intl.formatMessage({ id: 'validSameEmail' }))),
idNo: yup.string().required(displayErrorMsg(`${intl.formatMessage({ id: 'require' })}${selectedIdDocInputType}${intl.formatMessage({ id: 'number' })}`))
.matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg(`${selectedIdDocInputType}${intl.formatMessage({ id: 'noSpecialCharacter' })}`) })
.matches(/^\S*$/, { message: displayErrorMsg(`${selectedIdDocInputType}${intl.formatMessage({ id: 'noSpace' })}`) })
@@ -622,8 +642,8 @@ const CustomFormWizard = (props) => {
}
}
}),
checkDigit: yup.string().max(1).required(displayErrorMsg(intl.formatMessage({ id: 'requiredNumberInQuote' }))),
idDocType: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({ id: 'requireIdDocType' }))),
checkDigit: yup.string().max(1, getMaxErrStr(1) ).required(displayErrorMsg(intl.formatMessage({ id: 'requiredNumberInQuote' }))),
idDocType: yup.string().max(255, getMaxErrStr(255) ).required(displayErrorMsg(intl.formatMessage({ id: 'requireIdDocType' }))),
phoneCountryCode: yup.string().min(2, displayErrorMsg(intl.formatMessage({ id: 'requireAtLeast2Number' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))),
// faxCountryCode: yup.string().min(3,'請輸入3位數字'),
phone: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'requireAtLeast8Number' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireContactNumber' }))),
@@ -1146,6 +1166,7 @@ const CustomFormWizard = (props) => {
value={formik.values.address2}
name="address2"
onChange={formik.handleChange}
onBlur={formik.handleBlur}
placeholder={intl.formatMessage({ id: 'addressLine2' })}
inputProps={{
onKeyDown: (e) => {
@@ -1162,6 +1183,7 @@ const CustomFormWizard = (props) => {
value={formik.values.address3}
name="address3"
onChange={formik.handleChange}
onBlur={formik.handleBlur}
placeholder={intl.formatMessage({ id: 'addressLine3' })}
inputProps={{
onKeyDown: (e) => {
@@ -1177,6 +1199,8 @@ const CustomFormWizard = (props) => {
value={selectedAddress4}
options={ComboData.district}
disabled={checkCountry}
error={Boolean(districtErrStr)}
onBlur={formik.handleBlur}
getOptionLabel={(option) => option.type ? intl.formatMessage({ id: option.type }) : ""}
onChange={(event, newValue) => {
setSelectedAddress4(newValue);
@@ -1228,6 +1252,11 @@ const CustomFormWizard = (props) => {
{formik.errors.address3}
</FormHelperText>
)}
{districtErrStr!= "" && (
<FormHelperText error >
{districtErrStr}
</FormHelperText>
)}
</Stack>
</Grid>
<Grid item xs={12} mt={1} mb={1}>
@@ -1711,7 +1740,7 @@ const CustomFormWizard = (props) => {
{formik.values.address3}
</Typography>
: null}
{selectedAddress5.label === "hongKong" ?
{selectedAddress5.type === "hongKong" ?
<Stack direction="row">
<Typography variant="pnspsFormHeader" color={theme.palette.grey[600]} id="preview-address4-signup">
<FormattedMessage id="region" />: