diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js
index 2fbc26f..58f66ad 100644
--- a/src/layout/MainLayout/Header/index.js
+++ b/src/layout/MainLayout/Header/index.js
@@ -74,62 +74,62 @@ function Header(props) {
isGLDLoggedIn() ?
- Dashboard
+ Dashboard
- Application
+ Application
- Proof
+ Proof
- Payment
+ Payment
- Client
+ Client
-
- Users (GLD)
+ Users (GLD)
-
- Users (Individual)
+ Users (Individual)
-
- Users (Organization)
+ Users (Organization)
-
- Organization
+ Organization
-
- User Group
+ User Group
- Logout
+ Logout
:
- 主頁
+ 主頁
- 我的公共啟事
+ 我的公共啟事
- 校對記錄
+ 校對記錄
- 付款記錄
+ 付款記錄
- 設定
+ 設定
{isPrimaryLoggedIn() ?
:
@@ -137,7 +137,7 @@ function Header(props) {
}
- 登出
+ 登出
);
@@ -145,10 +145,10 @@ function Header(props) {
const logoutContent = (
- 登入
+ 登入
- 申請
+ 申請
);
diff --git a/src/pages/authentication/AuthWrapper.js b/src/pages/authentication/AuthWrapper.js
index c96d079..fe37dd3 100644
--- a/src/pages/authentication/AuthWrapper.js
+++ b/src/pages/authentication/AuthWrapper.js
@@ -44,8 +44,8 @@ const AuthWrapper = ({ children }) => (
alignItems="center"
spacing={2}>
- 香港特別行政區政府
- 憲報
+ 香港特別行政區政府
+ 憲報
import('./auth-forms/BusCustomFormWizard')));
- const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom')));
- // import CustomFormWizard from './auth-forms/BusCustomFormWizard';
- // import AuthWrapper from './AuthWrapperCustom';
-
- // ================================|| REGISTER ||================================ //
- const stepStyle = {
- width:"40%",
- boxShadow: 2,
- backgroundColor: "#FFFFFF",
- padding: 2,
- "& .Mui-active": {
- "&.MuiStepIcon-root": {
- color: "warning.main",
- fontSize: "2rem",
- },
- "& .MuiStepConnector-line": {
- borderColor: "warning.main"
- }
+// import { Link } from 'react-router-dom';
+import React, { useState } from 'react';
+
+// material-ui
+import {
+ Stepper,
+ Step,
+ StepButton,
+ // Grid,
+ Stack,
+ Typography,
+ Button,
+
+} from '@mui/material';
+import VisibilityIcon from '@mui/icons-material/Visibility';
+
+// project import
+import Loadable from 'components/Loadable';
+import { lazy } from 'react';
+const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/BusCustomFormWizard')));
+const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom')));
+// import CustomFormWizard from './auth-forms/BusCustomFormWizard';
+// import AuthWrapper from './AuthWrapperCustom';
+
+// ================================|| REGISTER ||================================ //
+const stepStyle = {
+ width: "40%",
+ boxShadow: 2,
+ backgroundColor: "#FFFFFF",
+ padding: 2,
+ "& .Mui-active": {
+ "&.MuiStepIcon-root": {
+ color: "warning.main",
+ fontSize: "2rem",
},
- "& .Mui-completed": {
- "&.MuiStepIcon-root": {
- color: "secondary.main",
- fontSize: "2rem",
- },
- "& .MuiStepConnector-line": {
- borderColor: "secondary.main"
- }
+ "& .MuiStepConnector-line": {
+ borderColor: "warning.main"
+ }
+ },
+ "& .Mui-completed": {
+ "&.MuiStepIcon-root": {
+ color: "secondary.main",
+ fontSize: "2rem",
+ },
+ "& .MuiStepConnector-line": {
+ borderColor: "secondary.main"
}
}
- const steps = ['個人資料', '預覽', '完成提交'];
+}
+const steps = ['個人資料', '預覽', '完成提交'];
- const BusRegister = () => {
- const [activeStep, setActiveStep] = useState(0);
- const [completed, setCompleted] = useState([false]);
- const [updateValid, setUpdateValid] = useState(false);
+const BusRegister = () => {
+ const [activeStep, setActiveStep] = useState(0);
+ const [completed, setCompleted] = useState([false]);
+ const [updateValid, setUpdateValid] = useState(false);
- const totalSteps = () => {
- return steps.length;
- };
+ const totalSteps = () => {
+ return steps.length;
+ };
- const completedSteps = () => {
- return Object.keys(completed).length;
- };
+ const completedSteps = () => {
+ return Object.keys(completed).length;
+ };
- const isLastStep = () => {
- return activeStep === totalSteps() - 1;
- };
+ const isLastStep = () => {
+ return activeStep === totalSteps() - 1;
+ };
- const allStepsCompleted = () => {
- return completedSteps() === totalSteps();
- };
+ const allStepsCompleted = () => {
+ return completedSteps() === totalSteps();
+ };
- const handleNext = () => {
- const newActiveStep =
+ const handleNext = () => {
+ const newActiveStep =
isLastStep() && !allStepsCompleted()
- ? // It's the last step, but not all steps have been completed,
- // find the first step that has been completed
- steps.findIndex((step, i) => !(i in completed))
- : activeStep + 1;
- setActiveStep(newActiveStep);
- scrollToTop();
- };
-
- const handleBack = () => {
- scrollToTop();
- setActiveStep((prevActiveStep) => prevActiveStep - 1);
- };
-
- const scrollToTop = () => {
- window.scrollTo(0,0);
- };
-
- const handleReset = () => {
- setActiveStep(0);
- setCompleted({});
- };
-
- return(
- //
-
-
- {steps.map((label, index) => (
-
- {
- index < 2 ?
- (
- {label}
- ) :
- (}
- // onClick={handleStep(index)}
- >
- {label}
- )
- }
-
-
- ))}
-
- {allStepsCompleted() ? (
-
-
- All steps completed - you're finished
-
-
-
-
-
-
- ) : (
-
-
-
- {/* */}
-
-
- { activeStep === totalSteps() - 1 ? (
-
- ):(
-
- //
- );
- };
-
- export default BusRegister;
+
+
+ )}
+
+ //
+ );
+};
+
+export default BusRegister;
diff --git a/src/pages/authentication/Register.js b/src/pages/authentication/Register.js
index 1f5f133..1d1efa8 100644
--- a/src/pages/authentication/Register.js
+++ b/src/pages/authentication/Register.js
@@ -1,182 +1,182 @@
- // import { Link } from 'react-router-dom';
- import React,{useState
- // ,useEffect
- } from 'react';
+// import { Link } from 'react-router-dom';
+import React, {
+ useState
+ // ,useEffect
+} from 'react';
- // material-ui
- import {
- Stepper,
- Step,
- StepButton,
- // Grid,
- Stack,
- Typography,
- Button,
+// material-ui
+import {
+ Stepper,
+ Step,
+ StepButton,
+ // Grid,
+ Stack,
+ Typography,
+ Button,
+} from '@mui/material';
+import VisibilityIcon from '@mui/icons-material/Visibility';
- } from '@mui/material';
- import VisibilityIcon from '@mui/icons-material/Visibility';
-
- // project import
- import Loadable from 'components/Loadable';
- import { lazy } from 'react';
- const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/CustomFormWizard')));
- const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom')));
- // ================================|| REGISTER ||================================ //
- const stepStyle = {
- width:"40%",
- boxShadow: 1,
- backgroundColor: "#FFFFFF",
- padding: 2,
- "& .Mui-active": {
- "&.MuiStepIcon-root": {
- color: "warning.main",
- fontSize: "2rem",
- },
- "& .MuiStepConnector-line": {
- borderColor: "warning.main"
- }
+// project import
+import Loadable from 'components/Loadable';
+import { lazy } from 'react';
+const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/CustomFormWizard')));
+const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom')));
+// ================================|| REGISTER ||================================ //
+const stepStyle = {
+ width: "40%",
+ boxShadow: 1,
+ backgroundColor: "#FFFFFF",
+ padding: 2,
+ "& .Mui-active": {
+ "&.MuiStepIcon-root": {
+ color: "warning.main",
+ fontSize: "2rem",
+ },
+ "& .MuiStepConnector-line": {
+ borderColor: "warning.main"
+ }
+ },
+ "& .Mui-completed": {
+ "&.MuiStepIcon-root": {
+ color: "secondary.main",
+ fontSize: "2rem",
},
- "& .Mui-completed": {
- "&.MuiStepIcon-root": {
- color: "secondary.main",
- fontSize: "2rem",
- },
- "& .MuiStepConnector-line": {
- borderColor: "secondary.main"
- }
+ "& .MuiStepConnector-line": {
+ borderColor: "secondary.main"
}
}
- const steps = ['個人資料', '預覽', '完成提交'];
+}
+const steps = ['個人資料', '預覽', '完成提交'];
- const Register = () => {
- const [activeStep, setActiveStep] = useState(0);
- const [completed, setCompleted] = useState([false]);
- const [updateValid, setUpdateValid] = useState(false);
+const Register = () => {
+ const [activeStep, setActiveStep] = useState(0);
+ const [completed, setCompleted] = useState([false]);
+ const [updateValid, setUpdateValid] = useState(false);
- const totalSteps = () => {
- return steps.length;
- };
+ const totalSteps = () => {
+ return steps.length;
+ };
- const completedSteps = () => {
- return Object.keys(completed).length;
- };
+ const completedSteps = () => {
+ return Object.keys(completed).length;
+ };
- const isLastStep = () => {
- return activeStep === totalSteps() - 1;
- };
+ const isLastStep = () => {
+ return activeStep === totalSteps() - 1;
+ };
- const allStepsCompleted = () => {
- return completedSteps() === totalSteps();
- };
+ const allStepsCompleted = () => {
+ return completedSteps() === totalSteps();
+ };
- const handleNext = () => {
- const newActiveStep =
+ const handleNext = () => {
+ const newActiveStep =
isLastStep() && !allStepsCompleted()
- ? // It's the last step, but not all steps have been completed,
- // find the first step that has been completed
- steps.findIndex((step, i) => !(i in completed))
- : activeStep + 1;
- setActiveStep(newActiveStep);
- scrollToTop();
- };
-
- const handleBack = () => {
- scrollToTop();
- setActiveStep((prevActiveStep) => prevActiveStep - 1);
- };
+ ? // It's the last step, but not all steps have been completed,
+ // find the first step that has been completed
+ steps.findIndex((step, i) => !(i in completed))
+ : activeStep + 1;
+ setActiveStep(newActiveStep);
+ scrollToTop();
+ };
- const scrollToTop = () => {
- window.scrollTo(0,0);
- };
+ const handleBack = () => {
+ scrollToTop();
+ setActiveStep((prevActiveStep) => prevActiveStep - 1);
+ };
- const handleReset = () => {
- setActiveStep(0);
- setCompleted({});
- };
+ const scrollToTop = () => {
+ window.scrollTo(0, 0);
+ };
- return(
- //
-
-
- {steps.map((label, index) => (
-
- {
- index < 2 ?
- (
- {label}
- ) :
- (}
- // onClick={handleStep(index)}
- >
- {label}
- )
- }
+ const handleReset = () => {
+ setActiveStep(0);
+ setCompleted({});
+ };
-
- ))}
-
- {allStepsCompleted() ? (
-
-
- All steps completed - you're finished
-
-
-
- Reset
-
-
- ) : (
-
-
-
- {/* */}
-
-
- { activeStep === 2|| activeStep === 0? (
-
+
+
+ {steps.map((label, index) => (
+
+ {
+ index < 2 ?
+ (
- 返回
-
- ):(
- {label}
+ ) :
+ (}
+ // onClick={handleStep(index)}
>
- 返回
+ {label}
+ )
+ }
+
+
+ ))}
+
+ {allStepsCompleted() ? (
+
+
+ All steps completed - you're finished
+
+
+
+ Reset
+
+
+ ) : (
+
+
+
+ {/* */}
+
+
+ {activeStep === 2 || activeStep === 0 ? (
+
+ 返回
+
+ ) : (
+
+ 返回
+
+ )
+ }
+
+ {activeStep === totalSteps() - 2 ?
+ (
+
+ 提交
- )
- }
-
- {activeStep === totalSteps() - 2 ?
+ ) : (activeStep === totalSteps() - 1 ?
+ (
+
+ 提交
+
+ ) :
(
-
- 提交
+ //
+
+ 繼續
- ) : ( activeStep === totalSteps() - 1 ?
- (
-
- 提交
-
- ):
- (
- //
-
- 繼續
-
- )
+ )
)}
- {/* {activeStep !== steps.length &&
+ {/* {activeStep !== steps.length &&
(completed[activeStep] ? (
Step {activeStep + 1} already completed
@@ -188,12 +188,12 @@
: 'Complete Step'}
))} */}
-
-
- )}
-
- //
- );
- };
+
+
+ )}
+
+ //
+ );
+};
- export default Register;
+export default Register;
diff --git a/src/pages/authentication/RegisterCustom.js b/src/pages/authentication/RegisterCustom.js
index afed143..b478d0c 100644
--- a/src/pages/authentication/RegisterCustom.js
+++ b/src/pages/authentication/RegisterCustom.js
@@ -7,14 +7,11 @@ import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png';
import banner from 'assets/images/bg_ml.jpg';
import { Stack } from '../../../node_modules/@mui/material/index';
-
// ================================|| LOGIN ||================================ //
-
-
const RegisterCustom = () => (
-
-
+
+
(
'& > *': {
flexGrow: 1,
flexBasis: '50%'
- }
+ },
+ backgroundColor: "secondary"
}}
+
>
@@ -38,7 +37,7 @@ const RegisterCustom = () => (
個人用戶
- }>以「智方便」繼續
+ }>以「智方便」繼續
@@ -50,7 +49,7 @@ const RegisterCustom = () => (
或
- 申請個人用戶
+ 申請個人用戶
需上載身份證明文件數碼檔案以進行網上申請。
@@ -59,7 +58,7 @@ const RegisterCustom = () => (
機構/公司用戶
- 申請機構/公司用戶
+ 申請機構/公司用戶
需上載以下任何一份證明文件以進行網上申請。
如:商業登記證;專業執業證書
diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js
index 637f9e0..ff1400e 100644
--- a/src/pages/authentication/auth-forms/AuthLoginCustom.js
+++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js
@@ -4,8 +4,8 @@ import React, {
lazy
} from 'react';
import { Link as RouterLink } from 'react-router-dom';
-import {useNavigate} from 'react-router-dom';
-import {useForm,} from 'react-hook-form'
+import { useNavigate } from 'react-router-dom';
+import { useForm, } from 'react-hook-form'
// material-ui
import {
@@ -26,7 +26,7 @@ import {
// third party
import * as yup from 'yup';
-import { useFormik,FormikProvider } from 'formik';
+import { useFormik, FormikProvider } from 'formik';
// project import
//import FirebaseSocial from './FirebaseSocial';
@@ -38,8 +38,8 @@ const PasswordAlertDialog = Loadable(lazy(() => import('./PasswordAlertDialog'))
import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons';
// import axios from "axios";
import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png';
-import {useDispatch} from "react-redux";
-import {handleLogin} from "auth/index";
+import { useDispatch } from "react-redux";
+import { handleLogin } from "auth/index";
import useJwt from "../../../auth/jwt/useJwt";
import { handleLogoutFunction } from 'auth/index';
// ============================|| FIREBASE - LOGIN ||============================ //
@@ -64,11 +64,11 @@ const AuthLoginCustom = () => {
};
const tryLogin = () => {
- if(isValid){
- dispatch(handleLogoutFunction());
+ if (isValid) {
+ dispatch(handleLogoutFunction());
// setSumitting(true)
useJwt
- .login({username: values.username, password: values.password})
+ .login({ username: values.username, password: values.password })
.then((response) => {
console.log(response)
const userData = {
@@ -82,7 +82,7 @@ const AuthLoginCustom = () => {
creditor: response.data.creditor,
//avatar: require('src/assets/images/users/avatar-3.png').default,
}
- const data = {...userData, accessToken: response.data.accessToken, refreshToken: response.data.refreshToken}
+ const data = { ...userData, accessToken: response.data.accessToken, refreshToken: response.data.refreshToken }
// setSuccess(true)
dispatch(handleLogin(data))
navigate('/dashboard');
@@ -96,42 +96,41 @@ const AuthLoginCustom = () => {
setErrorMassage(error.response.data.error)
setOpen(true)
});
- }else{
+ } else {
setOpen(true)
}
}
const formik = useFormik({
- initialValues:({
- username: '',
- password: '',
- submit: null
+ initialValues: ({
+ username: '',
+ password: '',
+ submit: null
}),
- validationSchema:yup.object().shape({
- // username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'),
- username: yup.string().required('請輸入用戶名稱'),
- password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼')
- .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母')
- .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母')
- .matches(/^(?=.*[0-9])/, '請包括最少1個數字')
- .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'),
+ validationSchema: yup.object().shape({
+ // username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'),
+ username: yup.string().required('請輸入用戶名稱'),
+ password: yup.string().min(8, '請輸入最少8位密碼').required('請輸入密碼')
+ .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母')
+ .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母')
+ .matches(/^(?=.*[0-9])/, '請包括最少1個數字')
+ .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'),
}),
});
- const checkDataField = (data)=> {
- if (data.username !==""&&
- data.password !==""&&
- handlePassword(data.password)
- // &&handle6Digi(data.username)
- )
- {
- setisValid(true)
- setIsButtonDisabled(false);
- return isValid
- }else{
- setisValid(false)
- setIsButtonDisabled(true);
- return isValid
+ const checkDataField = (data) => {
+ if (data.username !== "" &&
+ data.password !== "" &&
+ handlePassword(data.password)
+ // &&handle6Digi(data.username)
+ ) {
+ setisValid(true)
+ setIsButtonDisabled(false);
+ return isValid
+ } else {
+ setisValid(false)
+ setIsButtonDisabled(true);
+ return isValid
}
};
@@ -143,17 +142,17 @@ const AuthLoginCustom = () => {
var numbers = /[0-9]/g;
var symbol = /^(?=.*[!@#%&])/;
if (!new_pass.match(lowerCase)) {
- return false;
+ return false;
} else if (!new_pass.match(upperCase)) {
- return false;
+ return false;
} else if (!new_pass.match(numbers)) {
- return false;
+ return false;
} else if (!new_pass.match(symbol)) {
- return false;
+ return false;
} else if (new_pass.length < 8) {
return false;
} else {
- return true;
+ return true;
}
}
@@ -162,123 +161,123 @@ const AuthLoginCustom = () => {
};
const { values } = formik
- useEffect(() => {
- checkDataField(values)
- }, [values])
+ useEffect(() => {
+ checkDataField(values)
+ }, [values])
- const {handleSubmit} = useForm({})
+ const { handleSubmit } = useForm({})
return (
-
-
-
+
+
+
+
);
};
diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js
index 907ae7d..9a3e264 100644
--- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js
+++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js
@@ -1,26 +1,26 @@
-import { useEffect, useState, } from 'react';
+import { useEffect, useState, } from 'react';
// material-ui
import {
- Box,
- Button,
- FormControl,
- FormHelperText,
- Grid, IconButton,
- InputAdornment,
- InputLabel, OutlinedInput,
- Stack,
- Typography,
- FormGroup,
- TextField,
- Checkbox
- // MenuItem
+ Box,
+ Button,
+ FormControl,
+ FormHelperText,
+ Grid, IconButton,
+ InputAdornment,
+ InputLabel, OutlinedInput,
+ Stack,
+ Typography,
+ FormGroup,
+ TextField,
+ Checkbox
+ // MenuItem
} from '@mui/material';
-import {useForm,} from 'react-hook-form'
+import { useForm, } from 'react-hook-form'
import Autocomplete from "@mui/material/Autocomplete";
// third party
-import { useFormik,FormikProvider } from 'formik';
+import { useFormik, FormikProvider } from 'formik';
import * as yup from 'yup';
// import axios from "axios";
@@ -30,7 +30,7 @@ import * as yup from 'yup';
import { strengthColorChi, strengthIndicator } from 'utils/password-strength';
// import {apiPath} from "auth/utils";
import axios from "axios";
-import {POST_PUBLIC_USER_REGISTER, POST_CAPTCHA} from "utils/ApiPathConst";
+import { POST_PUBLIC_USER_REGISTER, POST_CAPTCHA, GET_USERNAME } from "utils/ApiPathConst";
// import * as HttpUtils from 'utils/HttpUtils';
import * as ComboData from "utils/ComboData";
@@ -50,11 +50,13 @@ import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined';
import { Link } from 'react-router-dom';
import * as HttpUtils from "../../../utils/HttpUtils"
import LoopIcon from '@mui/icons-material/Loop';
+import { useTheme } from '@mui/material/styles';
//import { Invaild } from 'utils/IconUtils';
// ============================|| FIREBASE - REGISTER ||============================ //
const BusCustomFormWizard = (props) => {
-
+
+ const theme = useTheme()
const [level, setLevel] = useState();
const [showPassword, setShowPassword] = useState(false);
const [showConfirmPassword, setshowConfirmPassword] = useState(false);
@@ -63,6 +65,7 @@ const BusCustomFormWizard = (props) => {
const [checkUpload, setCheckUpload] = useState(false);
const [isLoading, setLoding] = useState(true);
const [updateRows, setUpdateRows] = useState([]);
+ const [userNameList, setUserNameList] = useState([]);
const [captcha, setCaptcha] = useState([]);
const [captchaImg, setCaptchaImage] = useState([]);
@@ -89,17 +92,17 @@ const BusCustomFormWizard = (props) => {
const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false);
const [isValid, setisValid] = useState(false);
const [checkCountry, setCheckCountry] = useState(false);
-
+
const address4ComboList = ComboData.district;
const address5ComboList = ComboData.country;
const termsAndCon = "此網址由香港特別行政區政府物流服務署製作及管理。本署會盡力確保網址上的資料無誤,\n"
- + "但有絕對酌情權隨時刪除、暫停登載或編輯各項資料而無須給予任何理由。\n由於任何與網址"
- + "內資料有關的理由或原因,而導致出現申索、損失或損害,本署概不負責。\n使用者須自行評"
- + "估本網址所載或與本網址有關連的各項資料,並應在根據該等資料行事前,參照印行的香港"
- + "特別行政區憲報以核實該等資料,以及徵詢獨立意見。\n版權公告本網頁的內容,包括但不限"
- + "於所有文本、平面圖像、圖畫、圖片、照片以及數據或其他資料的匯編,均受版權保障。\n香"
- + "港特別行政區政府是本網頁內所有版權作品的擁有人,除非預先得到政府物流服務署的書面"
- + "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。"
+ + "但有絕對酌情權隨時刪除、暫停登載或編輯各項資料而無須給予任何理由。\n由於任何與網址"
+ + "內資料有關的理由或原因,而導致出現申索、損失或損害,本署概不負責。\n使用者須自行評"
+ + "估本網址所載或與本網址有關連的各項資料,並應在根據該等資料行事前,參照印行的香港"
+ + "特別行政區憲報以核實該等資料,以及徵詢獨立意見。\n版權公告本網頁的內容,包括但不限"
+ + "於所有文本、平面圖像、圖畫、圖片、照片以及數據或其他資料的匯編,均受版權保障。\n香"
+ + "港特別行政區政府是本網頁內所有版權作品的擁有人,除非預先得到政府物流服務署的書面"
+ + "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。"
const refType = "identification";
useEffect(() => {
@@ -111,68 +114,76 @@ const BusCustomFormWizard = (props) => {
// localStorage.setItem("checkCode",null);
// localStorage.setItem("base64Url",null);
// }else{
- onCaptchaChange();
+ onCaptchaChange();
// }
-
-
+ axios.get(`${GET_USERNAME}`)
+ .then((response) => {
+ if (response.status === 200) {
+ setUserNameList(response.data);
+ }
+
+ })
+ .catch(error => {
+ console.log(error);
+ return false;
+ });
}, []);
- const onCaptchaChange = ()=>{
+ const onCaptchaChange = () => {
HttpUtils.post({
url: POST_CAPTCHA,
- params:{width: 130, height: 40},
- onSuccess:(responseData)=>{
- localStorage.setItem("checkCode",responseData.checkCode);
- localStorage.setItem("base64Url",responseData.base64Url);
+ params: { width: 130, height: 40 },
+ onSuccess: (responseData) => {
+ localStorage.setItem("checkCode", responseData.checkCode);
+ localStorage.setItem("base64Url", responseData.base64Url);
setCaptcha(localStorage.getItem('checkCode'));
setCaptchaImage(localStorage.getItem('base64Url'));
}
});
}
- const checkDataField = (data)=> {
+ const checkDataField = (data) => {
// console.log(data.brExpiryDate)
- if (data.username !==""&&
- data.password !==""&&
- data.confirmPassword !==""&&
- data.password == data.confirmPassword&&
+ if (data.username !== "" &&
+ data.password !== "" &&
+ data.confirmPassword !== "" &&
+ data.password == data.confirmPassword &&
// (data.enCompanyName !=="" || selectedAddress5 ==="內地")&&
- (data.chCompanyName !=="" || data.enCompanyName !== "")&&
- data.enName !==""&&
- data.chName !==""&&
- data.address1 !==""&&
- data.email !==""&&
- data.emailConfirm !==""&&
- data.email == data.emailConfirm&&
- data.phone !==""&&
- data.phoneCountryCode !==""&&
- termsAndConAccept == true&&
- fileList.length!==0&&
- data.captchaField&&
- data.brNo!==""&&
- data.brExpiryDate!==""&&
- handlePassword(data.password)&&
- handleEmail(data.email)&&
- handlePhone(data.phone)&&
- handleUserName(data.username)&&
+ (data.chCompanyName !== "" || data.enCompanyName !== "") &&
+ data.enName !== "" &&
+ data.chName !== "" &&
+ data.address1 !== "" &&
+ data.email !== "" &&
+ data.emailConfirm !== "" &&
+ data.email == data.emailConfirm &&
+ data.phone !== "" &&
+ data.phoneCountryCode !== "" &&
+ termsAndConAccept == true &&
+ fileList.length !== 0 &&
+ data.captchaField &&
+ data.brNo !== "" &&
+ data.brExpiryDate !== "" &&
+ handlePassword(data.password) &&
+ handleEmail(data.email) &&
+ handlePhone(data.phone) &&
+ handleUserName(data.username) &&
handleCaptcha(data.captchaField)
- )
- {
+ ) {
setisValid(true)
return isValid
- }else{
+ } else {
setisValid(false)
return isValid
}
};
const handleCheckBoxChange = (event) => {
- console.log (event.target)
- if(event.target.name == 'termsAndConAccept'){
+ console.log(event.target)
+ if (event.target.name == 'termsAndConAccept') {
setTermsAndConAccept(event.target.checked)
setTermsAndConNotAccept(!event.target.checked)
}
- if(event.target.name == 'termsAndConNotAccept'){
+ if (event.target.name == 'termsAndConNotAccept') {
setTermsAndConNotAccept(event.target.checked)
setTermsAndConAccept(!event.target.checked)
}
@@ -183,8 +194,8 @@ const BusCustomFormWizard = (props) => {
var updateRowsIndex = updateRows.length;
const saveFileList = [];
- if (updateRowsIndex!=null){
- for (let i = 0; i < updateRowsIndex; i++){
+ if (updateRowsIndex != null) {
+ for (let i = 0; i < updateRowsIndex; i++) {
const file = updateRows[i]
file.id = i;
updateRowList.items.add(file);
@@ -193,21 +204,21 @@ const BusCustomFormWizard = (props) => {
let updatedFileList = updateRowList.files;
setFileList(updatedFileList);
setFileListData(saveFileList)
-
+
}
}, [updateRows]);
- const handleFileUpload = (event)=>{
+ const handleFileUpload = (event) => {
let updateList = new DataTransfer();
let currentFileList = fileListData;
const uploadFileList = event.target.files;
const saveFileList = [];
var currentIndex = 0;
- if (currentFileList.length!=null){
+ if (currentFileList.length != null) {
currentIndex = currentFileList.length;
- for (let i = 0; i < currentIndex; i++){
+ for (let i = 0; i < currentIndex; i++) {
const file = currentFileList[i]
// file.id = currentIndex;
updateList.items.add(file);
@@ -215,7 +226,7 @@ const BusCustomFormWizard = (props) => {
}
}
- for (let i = 0; i < uploadFileList.length && currentIndex<5; i++){
+ for (let i = 0; i < uploadFileList.length && currentIndex < 5; i++) {
const file = event.target.files[i]
let isDuplicate = false;
@@ -226,8 +237,8 @@ const BusCustomFormWizard = (props) => {
break;
}
}
- if (!isDuplicate && i+currentIndex<5) {
- file.id = currentIndex+i
+ if (!isDuplicate && i + currentIndex < 5) {
+ file.id = currentIndex + i
saveFileList.push(file)
updateList.items.add(file);
}
@@ -246,27 +257,27 @@ const BusCustomFormWizard = (props) => {
useEffect(() => {
checkDataField(values)
- }, [selectedAddress4,selectedAddress5,
- termsAndConAccept,termsAndConNotAccept,fileList])
+ }, [selectedAddress4, selectedAddress5,
+ termsAndConAccept, termsAndConNotAccept, fileList])
useEffect(() => {
- props.step ==2?_onSubmit():null;
+ props.step == 2 ? _onSubmit() : null;
onCaptchaChange();
checkDataField(values)
}, [props.step])
- const {handleSubmit} = useForm({})
+ const { handleSubmit } = useForm({})
const _onSubmit = () => {
setLoding(true);
values.address4 = selectedAddress4
values.address5 = selectedAddress5
// console.log(values)
- const busUserAddress = {
- "addressLine1":"",
- "addressLine2":"",
- "addressLine3":"",
- "district":"",
- "country":""
+ const busUserAddress = {
+ "addressLine1": "",
+ "addressLine2": "",
+ "addressLine3": "",
+ "district": "",
+ "country": ""
};
busUserAddress.addressLine1 = values.address1
busUserAddress.addressLine2 = values.address2
@@ -275,66 +286,66 @@ const BusCustomFormWizard = (props) => {
busUserAddress.country = values.address5
const userFaxNo = {
- "countryCode":values.faxCountryCode,
- "faxNumber":values.fax,
+ "countryCode": values.faxCountryCode,
+ "faxNumber": values.fax,
};
const busUserContactTel = {
- "countryCode":values.phoneCountryCode,
- "phoneNumber":values.phone,
+ "countryCode": values.phoneCountryCode,
+ "phoneNumber": values.phone,
};
let tncFlag = false;
- if (termsAndConAccept){
+ if (termsAndConAccept) {
tncFlag = true
}
- if (termsAndConNotAccept){
+ if (termsAndConNotAccept) {
tncFlag = false
}
const user = {
username: values.username,
- password: values.password,
- name: values.username,
- enCompanyName: values.enCompanyName,
- chCompanyName: values.chCompanyName,
- emailBus: values.email,
- brNo:values.brNo,
- brExpiryDate:values.brExpiryDate,
- contactPerson: values.enName,
- tncFlag:tncFlag,
- type:"ORG"
+ password: values.password,
+ name: values.username,
+ enCompanyName: values.enCompanyName,
+ chCompanyName: values.chCompanyName,
+ emailBus: values.email,
+ brNo: values.brNo,
+ brExpiryDate: values.brExpiryDate,
+ contactPerson: values.enName,
+ tncFlag: tncFlag,
+ type: "ORG"
};
var formData = new FormData();
- for (let i = 0; i < fileListData.length; i++){
+ for (let i = 0; i < fileListData.length; i++) {
const file = fileListData[i]
formData.append("multipartFileList", file);
}
formData.append("refType", refType);
-
+
for (const [key, value] of Object.entries(user)) {
formData.append(key, value);
}
-
+
formData.append("userFaxNo", JSON.stringify(userFaxNo));
formData.append("busUserContactTel", JSON.stringify(busUserContactTel));
formData.append("busUserAddress", JSON.stringify(busUserAddress));
- if (isValid){
- axios.post(POST_PUBLIC_USER_REGISTER, formData,{
+ if (isValid) {
+ axios.post(POST_PUBLIC_USER_REGISTER, formData, {
headers: {
- "Content-Type":"multipart/form-data"
+ "Content-Type": "multipart/form-data"
}
})
- .then((response) => {
- console.log(response)
- setCheckUpload(true)
- setLoding(false);
- })
- .catch(error => {
- console.error(error);
- setLoding(false);
- });
- }else{
+ .then((response) => {
+ console.log(response)
+ setCheckUpload(true)
+ setLoding(false);
+ })
+ .catch(error => {
+ console.error(error);
+ setLoding(false);
+ });
+ } else {
setLoding(false);
}
}
@@ -354,7 +365,7 @@ const BusCustomFormWizard = (props) => {
return false;
} else if (username.match(symbol)) {
return false;
- }else if (username.match(space)) {
+ } else if (username.match(space)) {
return false;
} else {
return true;
@@ -383,10 +394,10 @@ const BusCustomFormWizard = (props) => {
return false;
} else if (new_pass.length < 8) {
return false;
- }
+ }
else if (new_pass.match(space)) {
return false;
- }else {
+ } else {
// console.log("password true")
return true;
}
@@ -396,15 +407,18 @@ const BusCustomFormWizard = (props) => {
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (!email.match(validRegex)) {
return false;
- }else{
+ } else {
return true;
}
}
-
+
+ function displayErrorMsg(errorMsg) {
+ return {errorMsg}
+ }
const formik = useFormik({
- initialValues:({
- username:'',
+ initialValues: ({
+ username: '',
enName: '',
enCompanyName: '',
chCompanyName: '',
@@ -414,52 +428,62 @@ const BusCustomFormWizard = (props) => {
address3: '',
password: '',
confirmPassword: '',
- phone:'',
- phoneCountryCode:'852',
+ phone: '',
+ phoneCountryCode: '852',
submit: null,
- fax:'',
- faxCountryCode:'852',
- brExpiryDate:'',
- brNo:'',
- emailConfirm:'',
- captchaField:''
+ fax: '',
+ faxCountryCode: '852',
+ brExpiryDate: '',
+ brNo: '',
+ emailConfirm: '',
+ captchaField: ''
}),
-
- validationSchema:yup.object().shape({
- username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱')
- .matches(/^[aA-zZ0-9\s]+$/, "用戶名稱不包含特殊字符")
- .matches(/^\S*$/, '用戶名稱不包含空格'),
- password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼')
- .matches(/^\S*$/, '密碼不包含空格')
- .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母')
- .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母')
- .matches(/^(?=.*[0-9])/, '請包括最少1個數字')
- .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'),
- confirmPassword: yup.string().min(8,'請最少輸入8位密碼').required('請確認密碼').oneOf([yup.ref('password'), null], '請輸入相同密碼'),
- enName: yup.string().max(255).required('請輸入英文姓名'),
- enCompanyName: yup.string().matches(/^[^$^*()]+$/, 'No special characters $/^/*/(/)').when('chCompanyName', {
+
+ validationSchema: yup.object().shape({
+ username: yup.string().min(6, displayErrorMsg('用戶名稱最少6位')).required(displayErrorMsg('請輸入用戶名稱')).test(
+ "checkUserNameUsed",
+ displayErrorMsg("此用戶登入名稱已被注冊,請使用其他用戶登入名稱"),
+ function (value) {
+ if (userNameList.some(item => item.username === value)) {
+ return false
+ } else {
+ return true
+ }
+ }
+ )
+ .matches(/^[aA-zZ0-9\s]+$/, {message: displayErrorMsg("用戶名稱不包含特殊字符")})
+ .matches(/^\S*$/, {message: displayErrorMsg('用戶名稱不包含空格')}),
+ password: yup.string().min(8, displayErrorMsg('請輸入最少8位密碼')).required(displayErrorMsg('請輸入密碼'))
+ .matches(/^\S*$/, {message: displayErrorMsg('密碼不包含空格')})
+ .matches(/^(?=.*[a-z])/, {message: displayErrorMsg('請包括最少1個小寫字母')})
+ .matches(/^(?=.*[A-Z])/, {message: displayErrorMsg('請包括最少1個大寫字母')})
+ .matches(/^(?=.*[0-9])/, {message: displayErrorMsg('請包括最少1個數字')})
+ .matches(/^(?=.*[!@#%&])/, {message: displayErrorMsg('請包括最少1個特殊字符')}),
+ confirmPassword: yup.string().min(8, displayErrorMsg('請最少輸入8位密碼')).required(displayErrorMsg('請確認密碼')).oneOf([yup.ref('password'), null], displayErrorMsg('請輸入相同密碼')),
+ enName: yup.string().max(255).required(displayErrorMsg('請輸入英文姓名')),
+ enCompanyName: yup.string().matches(/^[^$^*()]+$/, {message: displayErrorMsg('No special characters $/^/*/(/)')}).when('chCompanyName', {
is: (chCompanyName) => !chCompanyName || chCompanyName.length === 0,
- then: yup.string().required('Please enter either English or Chinese name'),
- }),
- chCompanyName: yup.string().matches(/^[^$^*()]+$/, '不包含特殊字符 $/^/*/(/)').when('enCompanyName', {
- is: (enCompanyName) => !enCompanyName || enCompanyName.length === 0,
- then: yup.string().required('請輸入英文或中文名稱'),
+ then: yup.string().required(displayErrorMsg('Please enter either English or Chinese name')),
+ }),
+ chCompanyName: yup.string().matches(/^[^$^*()]+$/, {message: displayErrorMsg('不包含特殊字符 $/^/*/(/)')}).when('enCompanyName', {
+ is: (enCompanyName) => !enCompanyName || enCompanyName.length === 0,
+ then: yup.string().required(displayErrorMsg('請輸入英文或中文名稱')),
}),
- chName: yup.string().max(255).required('請輸入中文姓名'),
- address1: yup.string().max(255).required('請輸入第一行地址'),
- address2: yup.string().max(255).required('請輸入第二行地址'),
- address3: yup.string().max(255).required('請輸入第三行地址'),
- email: yup.string().email('請輸入電郵格式').max(255).required('請輸入電郵'),
- emailConfirm: yup.string().email('請輸入電郵格式').max(255).required('請輸入電郵').oneOf([yup.ref('email'), null], '請輸入相同電郵'),
- phoneCountryCode: yup.string().min(2,'請輸入最少2位數字').required('請輸入國際區號'),
- faxCountryCode: yup.string().min(2,'請輸入最少2位數字'),
- phone: yup.string().min(8,'請輸入最少8位數字').required('請輸入聯絡電話'),
- fax: yup.string().min(8,'請輸入最少8位數字'),
- brExpiryDate: yup.date().min(new Date().toISOString().split("T")[0], '請輸入商業登記證有效日期').max("2099-12-31", '請輸入商業登記證有效日期').required('請輸入商業登記證有效日期'),
- brNo: yup.string().min(8,'請輸入商業登記證號碼').required('請輸入商業登記證號碼'),
- captchaField: yup.string().required('請輸入驗證').oneOf([captcha], '請輸入有效驗證'),
+ chName: yup.string().max(255).required(displayErrorMsg('請輸入中文姓名')),
+ address1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')),
+ address2: yup.string().max(255).required(displayErrorMsg('請輸入第二行地址')),
+ address3: yup.string().max(255).required(displayErrorMsg('請輸入第三行地址')),
+ email: yup.string().email(displayErrorMsg('請輸入電郵格式')).max(255).required(displayErrorMsg('請輸入電郵')),
+ emailConfirm: yup.string().email(displayErrorMsg('請輸入電郵格式')).max(255).required(displayErrorMsg('請輸入電郵')).oneOf([yup.ref('email'), null], displayErrorMsg('請輸入相同電郵')),
+ phoneCountryCode: yup.string().min(2, displayErrorMsg('請輸入最少2位數字')).required(displayErrorMsg('請輸入國際區號')),
+ faxCountryCode: yup.string().min(2, displayErrorMsg('請輸入最少2位數字')),
+ phone: yup.string().min(8, displayErrorMsg('請輸入最少8位數字')).required(displayErrorMsg('請輸入聯絡電話')),
+ fax: yup.string().min(8, displayErrorMsg('請輸入最少8位數字')),
+ brExpiryDate: yup.date().min(new Date().toISOString().split("T")[0], displayErrorMsg('請輸入商業登記證有效日期')).max("2099-12-31", displayErrorMsg('請輸入商業登記證有效日期')).required(displayErrorMsg('請輸入商業登記證有效日期')),
+ brNo: yup.string().min(8, displayErrorMsg('請輸入商業登記證號碼')).required(displayErrorMsg('請輸入商業登記證號碼')),
+ captchaField: yup.string().required(displayErrorMsg('請輸入驗證')).oneOf([captcha], displayErrorMsg('請輸入有效驗證')),
}, ['enCompanyName', 'chCompanyName']),
-
+
});
const handleReset = (resetForm) => {
@@ -475,22 +499,22 @@ const BusCustomFormWizard = (props) => {
const { values } = formik
useEffect(() => {
checkDataField(values)
- }, [values])
+ }, [values])
return (