|
@@ -75,7 +75,8 @@ const CustomFormWizard = (props) => { |
|
|
setLevel(strengthColorChi(temp)); |
|
|
setLevel(strengthColorChi(temp)); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const [selectedIdDocType, setSelectedIdDocType] = useState(null); |
|
|
|
|
|
|
|
|
const [selectedIdDocType, setSelectedIdDocType] = useState({}); |
|
|
|
|
|
// const [selectedIdDocLabel, setSelectedIdDocLabel] = useState(null); |
|
|
const [selectedAddress4, setSelectedAddress4] = useState(null); |
|
|
const [selectedAddress4, setSelectedAddress4] = useState(null); |
|
|
const [selectedAddress5, setSelectedAddress5] = useState(ComboData.country[0]); |
|
|
const [selectedAddress5, setSelectedAddress5] = useState(ComboData.country[0]); |
|
|
const [termsAndConAccept, setTermsAndConAccept] = useState(false); |
|
|
const [termsAndConAccept, setTermsAndConAccept] = useState(false); |
|
@@ -104,7 +105,7 @@ const CustomFormWizard = (props) => { |
|
|
data.password !==""&& |
|
|
data.password !==""&& |
|
|
data.confirmPassword !==""&& |
|
|
data.confirmPassword !==""&& |
|
|
data.password == data.confirmPassword&& |
|
|
data.password == data.confirmPassword&& |
|
|
selectedIdDocType !==""&& |
|
|
|
|
|
|
|
|
selectedIdDocType.type !==""&& |
|
|
data.idNo !==""&& |
|
|
data.idNo !==""&& |
|
|
data.enName !==""&& |
|
|
data.enName !==""&& |
|
|
data.address1 !==""&& |
|
|
data.address1 !==""&& |
|
@@ -116,7 +117,7 @@ const CustomFormWizard = (props) => { |
|
|
fileList.length!==0&& |
|
|
fileList.length!==0&& |
|
|
handlePassword(data.password)&& |
|
|
handlePassword(data.password)&& |
|
|
handleEmail(data.email)&& |
|
|
handleEmail(data.email)&& |
|
|
handleIdNo(data.idNo,selectedIdDocType)&& |
|
|
|
|
|
|
|
|
handleIdNo(data.idNo,selectedIdDocType.type)&& |
|
|
handle8Digi(data.phone)&& |
|
|
handle8Digi(data.phone)&& |
|
|
handle8Digi(data.username) |
|
|
handle8Digi(data.username) |
|
|
) |
|
|
) |
|
@@ -141,7 +142,7 @@ const CustomFormWizard = (props) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const handleFileUpload = (event)=>{ |
|
|
const handleFileUpload = (event)=>{ |
|
|
let list = new DataTransfer(); |
|
|
|
|
|
|
|
|
let updateList = new DataTransfer(); |
|
|
let currentFileList = fileListData; |
|
|
let currentFileList = fileListData; |
|
|
const uploadFileList = event.target.files; |
|
|
const uploadFileList = event.target.files; |
|
|
const saveFileList = []; |
|
|
const saveFileList = []; |
|
@@ -151,12 +152,12 @@ const CustomFormWizard = (props) => { |
|
|
currentIndex = currentFileList.length; |
|
|
currentIndex = currentFileList.length; |
|
|
for (let i = 0; i < currentIndex; i++){ |
|
|
for (let i = 0; i < currentIndex; i++){ |
|
|
const file = currentFileList[i] |
|
|
const file = currentFileList[i] |
|
|
list.items.add(file); |
|
|
|
|
|
|
|
|
updateList.items.add(file); |
|
|
saveFileList.push(file); |
|
|
saveFileList.push(file); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (let i = 0; i < uploadFileList.length; i++){ |
|
|
|
|
|
|
|
|
for (let i = 0; i < uploadFileList.length && currentIndex>5; i++){ |
|
|
const file = event.target.files[i] |
|
|
const file = event.target.files[i] |
|
|
let isDuplicate = false; |
|
|
let isDuplicate = false; |
|
|
// Check if the file name already exists in saveFileList |
|
|
// Check if the file name already exists in saveFileList |
|
@@ -166,18 +167,17 @@ const CustomFormWizard = (props) => { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!isDuplicate) { |
|
|
if (!isDuplicate) { |
|
|
file.id = currentIndex+i |
|
|
file.id = currentIndex+i |
|
|
saveFileList.push(file) |
|
|
saveFileList.push(file) |
|
|
list.items.add(file); |
|
|
|
|
|
|
|
|
updateList.items.add(file); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
let myFileList = list.files; |
|
|
|
|
|
|
|
|
let updatedFileList = updateList.files; |
|
|
|
|
|
|
|
|
setFileListData(saveFileList) |
|
|
setFileListData(saveFileList) |
|
|
setFileList(myFileList); |
|
|
|
|
|
|
|
|
setFileList(updatedFileList); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@@ -186,7 +186,9 @@ const CustomFormWizard = (props) => { |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
checkDataField(values) |
|
|
checkDataField(values) |
|
|
}, [selectedIdDocType,selectedAddress4,selectedAddress5, |
|
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
selectedIdDocType, |
|
|
|
|
|
selectedAddress4,selectedAddress5, |
|
|
termsAndConAccept,termsAndConNotAccept,fileList]) |
|
|
termsAndConAccept,termsAndConNotAccept,fileList]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@@ -196,7 +198,7 @@ const CustomFormWizard = (props) => { |
|
|
const {handleSubmit} = useForm({}) |
|
|
const {handleSubmit} = useForm({}) |
|
|
const _onSubmit = () => { |
|
|
const _onSubmit = () => { |
|
|
setLoding(true); |
|
|
setLoding(true); |
|
|
values.idDocType = selectedIdDocType |
|
|
|
|
|
|
|
|
values.idDocType = selectedIdDocType.type |
|
|
values.address4 = selectedAddress4 |
|
|
values.address4 = selectedAddress4 |
|
|
values.address5 = selectedAddress5 |
|
|
values.address5 = selectedAddress5 |
|
|
const userAddress = { |
|
|
const userAddress = { |
|
@@ -369,6 +371,7 @@ const CustomFormWizard = (props) => { |
|
|
resetForm(); |
|
|
resetForm(); |
|
|
setSelectedAddress4("") |
|
|
setSelectedAddress4("") |
|
|
setSelectedIdDocType("") |
|
|
setSelectedIdDocType("") |
|
|
|
|
|
// setSelectedIdDocLabel("") |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const { values } = formik |
|
|
const { values } = formik |
|
@@ -565,12 +568,14 @@ const CustomFormWizard = (props) => { |
|
|
id="idDocType" |
|
|
id="idDocType" |
|
|
// value={selectedIdDocType} |
|
|
// value={selectedIdDocType} |
|
|
options={idDocTypeComboList} |
|
|
options={idDocTypeComboList} |
|
|
getOptionLabel={(idDocTypeComboList) => idDocTypeComboList.label} |
|
|
|
|
|
|
|
|
// getOptionLabel={(idDocTypeComboList) => idDocTypeComboList.label} |
|
|
onBlur={formik.handleBlur} |
|
|
onBlur={formik.handleBlur} |
|
|
onChange={(event, newValue) => { |
|
|
onChange={(event, newValue) => { |
|
|
// console.log(newValue) |
|
|
// console.log(newValue) |
|
|
if (newValue!=null){ |
|
|
if (newValue!=null){ |
|
|
setSelectedIdDocType(newValue.type); |
|
|
|
|
|
|
|
|
console.log(newValue) |
|
|
|
|
|
setSelectedIdDocType(newValue); |
|
|
|
|
|
// setSelectedIdDocLabel(newValue.label); |
|
|
if (newValue.type!="HKID"){ |
|
|
if (newValue.type!="HKID"){ |
|
|
formik.setFieldValue("checkDigit","") |
|
|
formik.setFieldValue("checkDigit","") |
|
|
} |
|
|
} |
|
@@ -588,7 +593,7 @@ const CustomFormWizard = (props) => { |
|
|
)} |
|
|
)} |
|
|
</Stack> |
|
|
</Stack> |
|
|
</Grid> |
|
|
</Grid> |
|
|
{selectedIdDocType =="HKID"? |
|
|
|
|
|
|
|
|
{selectedIdDocType.type=="HKID"? |
|
|
<> |
|
|
<> |
|
|
<Grid item xs={10} md={5}> |
|
|
<Grid item xs={10} md={5}> |
|
|
<Stack spacing={1}> |
|
|
<Stack spacing={1}> |
|
@@ -604,7 +609,7 @@ const CustomFormWizard = (props) => { |
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo)} |
|
|
error={Boolean(formik.touched.idNo && formik.errors.idNo)} |
|
|
onBlur={formik.handleBlur} |
|
|
onBlur={formik.handleBlur} |
|
|
inputProps={{ |
|
|
inputProps={{ |
|
|
maxLength: selectedIdDocType =='HKID'?7:18, |
|
|
|
|
|
|
|
|
maxLength: selectedIdDocType.type =='HKID'?7:18, |
|
|
onKeyDown: (e) => { |
|
|
onKeyDown: (e) => { |
|
|
if (e.key === 'Enter') { |
|
|
if (e.key === 'Enter') { |
|
|
e.preventDefault(); |
|
|
e.preventDefault(); |
|
@@ -1147,7 +1152,7 @@ const CustomFormWizard = (props) => { |
|
|
證件類別: |
|
|
證件類別: |
|
|
</Typography> |
|
|
</Typography> |
|
|
<Typography name = "preview-idDocType"> |
|
|
<Typography name = "preview-idDocType"> |
|
|
{selectedIdDocType} |
|
|
|
|
|
|
|
|
{selectedIdDocType.label} |
|
|
</Typography> |
|
|
</Typography> |
|
|
</Stack> |
|
|
</Stack> |
|
|
</Grid> |
|
|
</Grid> |
|
@@ -1254,7 +1259,7 @@ const CustomFormWizard = (props) => { |
|
|
</Grid> |
|
|
</Grid> |
|
|
</Grid> |
|
|
</Grid> |
|
|
</FormGroup> |
|
|
</FormGroup> |
|
|
{/* Submit page */} |
|
|
|
|
|
|
|
|
{/* Submit page */} |
|
|
<FormGroup id={"submitForm"} sx={{ display: props.step === 2 ? "" : "none"}}> |
|
|
<FormGroup id={"submitForm"} sx={{ display: props.step === 2 ? "" : "none"}}> |
|
|
<Grid container spacing={3}> |
|
|
<Grid container spacing={3}> |
|
|
{isLoading ? |
|
|
{isLoading ? |
|
|