Browse Source

combo fix

master
Alex Cheung 2 years ago
parent
commit
0b3512a907
4 changed files with 38 additions and 33 deletions
  1. +23
    -18
      src/pages/authentication/auth-forms/CustomFormWizard.js
  2. +6
    -6
      src/pages/authentication/auth-forms/UploadFileTable.js
  3. +1
    -1
      src/pages/extra-pages/LoadingComponent.js
  4. +8
    -8
      src/utils/ComboData.js

+ 23
- 18
src/pages/authentication/auth-forms/CustomFormWizard.js View File

@@ -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 ?


+ 6
- 6
src/pages/authentication/auth-forms/UploadFileTable.js View File

@@ -72,12 +72,12 @@ export default function UploadFileTable({recordList}) {
sx={{border:1}} sx={{border:1}}
rowModesModel={rowModesModel} rowModesModel={rowModesModel}
disablePagination disablePagination
// initialState={{
// pagination: {
// paginationModel: {page: 0, pageSize: 5},
// },
// }}
// pageSizeOptions={[5, 10]}
initialState={{
pagination: {
paginationModel: {},
},
}}
hideFooterPagination={true}
autoHeight = {true} autoHeight = {true}
/> />
</Box> </Box>


+ 1
- 1
src/pages/extra-pages/LoadingComponent.js View File

@@ -7,7 +7,7 @@ const LoadingComponent = () => {
display="flex" display="flex"
justifyContent="center" justifyContent="center"
alignItems="center" alignItems="center"
autoHeight={true}
// autoHeight={true}
> >
<CircularProgress /> <CircularProgress />
</Box> </Box>


+ 8
- 8
src/utils/ComboData.js View File

@@ -1,12 +1,12 @@
export const idDocType = [ export const idDocType = [
{label:"護照", type:"passport"},
{label:"香港身份證", type:"HKID"},
{label:"內地身份證", type:"CNID"},
{label:"專業執業證書", type:"otherCert"}
{ key: 1, label: '護照', type: 'passport' },
{ key: 2, label: '香港身份證', type: 'HKID' },
{ key: 3, label: '內地身份證', type: 'CNID' },
{ key: 4, label: '專業執業證書', type: 'otherCert' }
]; ];
export const district = ["北區","長洲區","大埔區","大嶼山區","東區","觀塘區","黃大仙區","九龍城區","葵青區","南區","南丫島區",
"坪洲區","荃灣區","沙田區","深水埗區","屯門區","灣仔區","西貢區","油尖旺區","元朗區","中西區"];
export const country = ["中國香港","中國","中國澳門"];
export const district = ['北區', '長洲區', '大埔區', '大嶼山區', '東區', '觀塘區', '黃大仙區', '九龍城區', '葵青區', '南區', '南丫島區',
'坪洲區', '荃灣區', '沙田區', '深水埗區', '屯門區', '灣仔區', '西貢區', '油尖旺區', '元朗區', '中西區'];
export const country = ['中國香港', '中國', '中國澳門'];


export const accountFilter = [{id:1,label:"Active", key:"active"},{id:2,label:"Locked", key:"locked"},{id:3,label:"Not verified", key:"notVerified"}];
export const accountFilter = [{ id: 1, key: 1, label: 'Active', type: 'active' }, { id: 2, key: 2, label: 'Locked', type: 'locked' }, { id: 3, key: 3, label: 'Not verified', type: 'notVerified' }];

Loading…
Cancel
Save