|
@@ -103,20 +103,29 @@ const CustomFormWizard = (props) => { |
|
|
const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false); |
|
|
const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false); |
|
|
const [isValid, setisValid] = useState(false); |
|
|
const [isValid, setisValid] = useState(false); |
|
|
const [checkCountry, setCheckCountry] = useState(false); |
|
|
const [checkCountry, setCheckCountry] = useState(false); |
|
|
|
|
|
|
|
|
const username = document.getElementById("username-login") |
|
|
const username = document.getElementById("username-login") |
|
|
const [checkUsername, setCheckUsername] = useState(false); |
|
|
const [checkUsername, setCheckUsername] = useState(false); |
|
|
const [checkUsernameBlur, setCheckUsernameBlur] = useState(false) |
|
|
const [checkUsernameBlur, setCheckUsernameBlur] = useState(false) |
|
|
|
|
|
|
|
|
const idDocNumber = document.getElementById("idNo-login") |
|
|
const idDocNumber = document.getElementById("idNo-login") |
|
|
const [checkIdDocNumber, setCheckIdDocNumber] = useState(false) |
|
|
const [checkIdDocNumber, setCheckIdDocNumber] = useState(false) |
|
|
const [checkIdDocNumberBlur, setCheckIdDocNumberBlur] = useState(false) |
|
|
const [checkIdDocNumberBlur, setCheckIdDocNumberBlur] = useState(false) |
|
|
|
|
|
|
|
|
const [idDocHKIDNumber, setIdDocHKIDNumber] = useState(document.getElementById("idNo-hkid-login")) |
|
|
const [idDocHKIDNumber, setIdDocHKIDNumber] = useState(document.getElementById("idNo-hkid-login")) |
|
|
const [checkIdDocHKIDNumberBlur, setCheckIdDocHKIDNumberBlur] = useState(false) |
|
|
const [checkIdDocHKIDNumberBlur, setCheckIdDocHKIDNumberBlur] = useState(false) |
|
|
|
|
|
|
|
|
const [checkDigit, setCheckDigit] = useState(document.getElementById("checkDigit-login")) |
|
|
const [checkDigit, setCheckDigit] = useState(document.getElementById("checkDigit-login")) |
|
|
const [checkCheckDigitBlur, setCheckCheckDigitBlur] = useState(false) |
|
|
const [checkCheckDigitBlur, setCheckCheckDigitBlur] = useState(false) |
|
|
const [checkHKIdDocWithCheckDigit, setCheckHKIdDocWithCheckDigit] = useState(false) |
|
|
const [checkHKIdDocWithCheckDigit, setCheckHKIdDocWithCheckDigit] = useState(false) |
|
|
|
|
|
|
|
|
const email = document.getElementById("email-login") |
|
|
const email = document.getElementById("email-login") |
|
|
const [checkEmail, setCheckEmail] = useState(false) |
|
|
const [checkEmail, setCheckEmail] = useState(false) |
|
|
const [checkEmailBlur, setCheckEmailBlur] = useState(false) |
|
|
const [checkEmailBlur, setCheckEmailBlur] = useState(false) |
|
|
|
|
|
|
|
|
|
|
|
const district = document.getElementById("address4-combo") |
|
|
|
|
|
const [checkDistrict, setCheckDistrict] = useState(false) |
|
|
|
|
|
const [checkDistrictBlur, setCheckDistrictBlur] = useState(false) |
|
|
const [districtErrStr, setDistrictErrStr] = useState("") |
|
|
const [districtErrStr, setDistrictErrStr] = useState("") |
|
|
|
|
|
|
|
|
const idDocTypeComboList = ComboData.idDocType; |
|
|
const idDocTypeComboList = ComboData.idDocType; |
|
@@ -151,7 +160,20 @@ const CustomFormWizard = (props) => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const handleCheckIdDocNumber = async () => { |
|
|
const handleCheckIdDocNumber = async () => { |
|
|
if (values?.idNo) { |
|
|
|
|
|
|
|
|
if (values?.idNo&&values?.checkDigit !="") { |
|
|
|
|
|
if (handleIdNo(values.idNo, selectedIdDocType.type, values.checkDigit)){ |
|
|
|
|
|
const response = await axios.post(`${POST_IDNO}`, { |
|
|
|
|
|
i1: values.idNo, |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(response.data.Vaild) |
|
|
|
|
|
setCheckIdDocNumber(response.data.Vaild === false) |
|
|
|
|
|
return response.data.Vaild === false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCheckIdDocNumberbyCheckDigit = async () => { |
|
|
|
|
|
if (values?.checkDigit) { |
|
|
if (handleIdNo(values.idNo, selectedIdDocType.type, values.checkDigit)){ |
|
|
if (handleIdNo(values.idNo, selectedIdDocType.type, values.checkDigit)){ |
|
|
const response = await axios.post(`${POST_IDNO}`, { |
|
|
const response = await axios.post(`${POST_IDNO}`, { |
|
|
i1: values.idNo, |
|
|
i1: values.idNo, |
|
@@ -169,11 +191,23 @@ const CustomFormWizard = (props) => { |
|
|
const response = await axios.post(`${POST_USER_EMAIL}`, { |
|
|
const response = await axios.post(`${POST_USER_EMAIL}`, { |
|
|
e1: values.email, |
|
|
e1: values.email, |
|
|
}) |
|
|
}) |
|
|
setCheckEmail((Number(response.data[0]) === 1)) |
|
|
|
|
|
|
|
|
setCheckEmail((Number(response.data[0]) === 1)) |
|
|
return Number(response.data[0]) === 1 |
|
|
return Number(response.data[0]) === 1 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCheckDistrict = async () => { |
|
|
|
|
|
setDistrictErrStr(""); |
|
|
|
|
|
if (selectedAddress5?.type === "hongKong") { |
|
|
|
|
|
if (selectedAddress4 == null || selectedAddress4 == "" || selectedAddress4 == {}){ |
|
|
|
|
|
setCheckDistrict(true) |
|
|
|
|
|
setDistrictErrStr(getRequiredErrStr("district")) |
|
|
|
|
|
}else { |
|
|
|
|
|
setCheckDistrict(false) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (username) { |
|
|
if (username) { |
|
@@ -230,7 +264,7 @@ const CustomFormWizard = (props) => { |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (checkCheckDigitBlur) { |
|
|
if (checkCheckDigitBlur) { |
|
|
handleCheckIdDocNumber() |
|
|
|
|
|
|
|
|
handleCheckIdDocNumberbyCheckDigit() |
|
|
setCheckCheckDigitBlur(false) |
|
|
setCheckCheckDigitBlur(false) |
|
|
} |
|
|
} |
|
|
}, [checkCheckDigitBlur]) |
|
|
}, [checkCheckDigitBlur]) |
|
@@ -249,6 +283,21 @@ const CustomFormWizard = (props) => { |
|
|
setCheckEmailBlur(false) |
|
|
setCheckEmailBlur(false) |
|
|
} |
|
|
} |
|
|
}, [checkEmailBlur]) |
|
|
}, [checkEmailBlur]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (district) { |
|
|
|
|
|
district.addEventListener("blur", function () { |
|
|
|
|
|
setCheckDistrictBlur(true) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, [district]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (checkDistrictBlur) { |
|
|
|
|
|
handleCheckDistrict() |
|
|
|
|
|
setCheckDistrictBlur(false) |
|
|
|
|
|
} |
|
|
|
|
|
}, [checkDistrictBlur]) |
|
|
|
|
|
|
|
|
const onCaptchaChange = () => { |
|
|
const onCaptchaChange = () => { |
|
|
HttpUtils.post({ |
|
|
HttpUtils.post({ |
|
@@ -290,9 +339,11 @@ const CustomFormWizard = (props) => { |
|
|
handleIdNo(data.idNo, selectedIdDocType.type, data.checkDigit) && |
|
|
handleIdNo(data.idNo, selectedIdDocType.type, data.checkDigit) && |
|
|
handlePhone(data.phone) && |
|
|
handlePhone(data.phone) && |
|
|
handleUsername(data.username) && |
|
|
handleUsername(data.username) && |
|
|
|
|
|
handleCheckDistrict()&& |
|
|
!checkUsername && |
|
|
!checkUsername && |
|
|
!checkEmail && |
|
|
!checkEmail && |
|
|
!checkIdDocNumber |
|
|
|
|
|
|
|
|
!checkIdDocNumber&& |
|
|
|
|
|
!checkDistrict |
|
|
) { |
|
|
) { |
|
|
setisValid(true) |
|
|
setisValid(true) |
|
|
return isValid |
|
|
return isValid |
|
@@ -389,13 +440,13 @@ const CustomFormWizard = (props) => { |
|
|
selectedAddress4, selectedAddress5, |
|
|
selectedAddress4, selectedAddress5, |
|
|
termsAndConAccept, termsAndConNotAccept, fileList]) |
|
|
termsAndConAccept, termsAndConNotAccept, fileList]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
setDistrictErrStr(""); |
|
|
|
|
|
if (selectedAddress5?.type === "hongKong") { |
|
|
|
|
|
if (selectedAddress4 == null || selectedAddress4 == "" || selectedAddress4 == {}) |
|
|
|
|
|
setDistrictErrStr(getRequiredErrStr("district")) |
|
|
|
|
|
} |
|
|
|
|
|
}, [selectedAddress4, selectedAddress5]) |
|
|
|
|
|
|
|
|
// useEffect(() => { |
|
|
|
|
|
// setDistrictErrStr(""); |
|
|
|
|
|
// if (selectedAddress5?.type === "hongKong") { |
|
|
|
|
|
// if (selectedAddress4 == null || selectedAddress4 == "" || selectedAddress4 == {}) |
|
|
|
|
|
// setDistrictErrStr(getRequiredErrStr("district")) |
|
|
|
|
|
// } |
|
|
|
|
|
// }, [selectedAddress4, selectedAddress5]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
props.step == 2 ? _onSubmit() : null; |
|
|
props.step == 2 ? _onSubmit() : null; |
|
@@ -1091,7 +1142,7 @@ const CustomFormWizard = (props) => { |
|
|
placeholder={intl.formatMessage({ id: 'idDocNumber' })} |
|
|
placeholder={intl.formatMessage({ id: 'idDocNumber' })} |
|
|
fullWidth |
|
|
fullWidth |
|
|
sx={{ mr: 1 }} |
|
|
sx={{ mr: 1 }} |
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo && checkIdDocNumber && checkHKIdDocWithCheckDigit)} |
|
|
|
|
|
|
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo || checkIdDocNumber)} |
|
|
onBlur={formik.handleBlur} |
|
|
onBlur={formik.handleBlur} |
|
|
inputProps={{ |
|
|
inputProps={{ |
|
|
maxLength: selectedIdDocType.type === 'HKID' ? 8 : 18, |
|
|
maxLength: selectedIdDocType.type === 'HKID' ? 8 : 18, |
|
@@ -1151,7 +1202,7 @@ const CustomFormWizard = (props) => { |
|
|
}, |
|
|
}, |
|
|
}} |
|
|
}} |
|
|
fullWidth |
|
|
fullWidth |
|
|
error={Boolean(formik.touched.checkDigit && formik.errors.checkDigit)} |
|
|
|
|
|
|
|
|
error={Boolean(formik.touched.checkDigit && formik.errors.checkDigit || checkIdDocNumber)} |
|
|
onBlur={formik.handleBlur} |
|
|
onBlur={formik.handleBlur} |
|
|
/> |
|
|
/> |
|
|
</Stack> |
|
|
</Stack> |
|
@@ -1181,7 +1232,7 @@ const CustomFormWizard = (props) => { |
|
|
placeholder={intl.formatMessage({ id: 'idDocNumber' })} |
|
|
placeholder={intl.formatMessage({ id: 'idDocNumber' })} |
|
|
fullWidth |
|
|
fullWidth |
|
|
sx={{ mr: 1 }} |
|
|
sx={{ mr: 1 }} |
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo && checkIdDocNumber)} |
|
|
|
|
|
|
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo || checkIdDocNumber)} |
|
|
onBlur={formik.handleBlur} |
|
|
onBlur={formik.handleBlur} |
|
|
inputProps={{ |
|
|
inputProps={{ |
|
|
maxLength: 18, |
|
|
maxLength: 18, |
|
@@ -1345,7 +1396,7 @@ const CustomFormWizard = (props) => { |
|
|
options={ComboData.district} |
|
|
options={ComboData.district} |
|
|
disabled={checkCountry} |
|
|
disabled={checkCountry} |
|
|
// error={Boolean(districtErrStr != "")} |
|
|
// error={Boolean(districtErrStr != "")} |
|
|
onBlur={formik.handleBlur} |
|
|
|
|
|
|
|
|
// onBlur={formik.handleBlur} |
|
|
getOptionLabel={(option) => option.type ? intl.formatMessage({ id: option.type }) : ""} |
|
|
getOptionLabel={(option) => option.type ? intl.formatMessage({ id: option.type }) : ""} |
|
|
onChange={(event, newValue) => { |
|
|
onChange={(event, newValue) => { |
|
|
setSelectedAddress4(newValue); |
|
|
setSelectedAddress4(newValue); |
|
@@ -1355,7 +1406,7 @@ const CustomFormWizard = (props) => { |
|
|
"#address4-combo": { padding: "0px 0px 0px 3px" }, |
|
|
"#address4-combo": { padding: "0px 0px 0px 3px" }, |
|
|
"& .MuiAutocomplete-endAdornment": { top: "auto" }, |
|
|
"& .MuiAutocomplete-endAdornment": { top: "auto" }, |
|
|
}} |
|
|
}} |
|
|
renderInput={(params) => <TextField error={Boolean(districtErrStr != "")} {...params} placeholder={intl.formatMessage({ id: 'region' })} |
|
|
|
|
|
|
|
|
renderInput={(params) => <TextField error={checkDistrict} {...params} placeholder={intl.formatMessage({ id: 'region' })} |
|
|
/>} |
|
|
/>} |
|
|
/> |
|
|
/> |
|
|
<Autocomplete |
|
|
<Autocomplete |
|
@@ -1420,7 +1471,7 @@ const CustomFormWizard = (props) => { |
|
|
{formik.errors.address3} |
|
|
{formik.errors.address3} |
|
|
</FormHelperText> |
|
|
</FormHelperText> |
|
|
)} |
|
|
)} |
|
|
{districtErrStr != "" && ( |
|
|
|
|
|
|
|
|
{checkDistrict && ( |
|
|
<FormHelperText error > |
|
|
<FormHelperText error > |
|
|
{districtErrStr} |
|
|
{districtErrStr} |
|
|
</FormHelperText> |
|
|
</FormHelperText> |
|
|