| @@ -15,7 +15,7 @@ import { | |||||
| Button, | Button, | ||||
| } from '@mui/material'; | } from '@mui/material'; | ||||
| import VisibilityIcon from '@mui/icons-material/Visibility'; | import VisibilityIcon from '@mui/icons-material/Visibility'; | ||||
| import { GET_USERNAME } from "utils/ApiPathConst"; | |||||
| import { GET_ID } from "utils/ApiPathConst"; | |||||
| // project import | // project import | ||||
| import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
| @@ -55,7 +55,7 @@ const Register = () => { | |||||
| const [activeStep, setActiveStep] = useState(0); | const [activeStep, setActiveStep] = useState(0); | ||||
| const [completed, setCompleted] = useState([false]); | const [completed, setCompleted] = useState([false]); | ||||
| const [updateValid, setUpdateValid] = useState(false); | const [updateValid, setUpdateValid] = useState(false); | ||||
| const [username, setUsername] = useState(""); | |||||
| const [idNo, setIdNo] = useState(""); | |||||
| const totalSteps = () => { | const totalSteps = () => { | ||||
| return steps.length; | return steps.length; | ||||
| @@ -73,19 +73,19 @@ const Register = () => { | |||||
| return completedSteps() === totalSteps(); | return completedSteps() === totalSteps(); | ||||
| }; | }; | ||||
| const handleCheckUsername = async () => { | |||||
| const response = await axios.get(`${GET_USERNAME}`, { | |||||
| const handleCheckID = async () => { | |||||
| const response = await axios.get(`${GET_ID}`, { | |||||
| params: { | params: { | ||||
| username: username, | |||||
| idNo: idNo, | |||||
| } | } | ||||
| }) | }) | ||||
| return Number(response.data[0]) === 1 | return Number(response.data[0]) === 1 | ||||
| } | } | ||||
| const handleNext = async () => { | const handleNext = async () => { | ||||
| const test = await handleCheckUsername() | |||||
| const test = await handleCheckID() | |||||
| if (test) { | if (test) { | ||||
| notifyActionError("此用戶登入名稱已被注冊,請使用其他用戶登入名稱") | |||||
| notifyActionError("此用戶已注冊,請返回登入頁面並進行登入流程。") | |||||
| } else { | } else { | ||||
| const newActiveStep = | const newActiveStep = | ||||
| isLastStep() && !allStepsCompleted() | isLastStep() && !allStepsCompleted() | ||||
| @@ -150,7 +150,7 @@ const Register = () => { | |||||
| ) : ( | ) : ( | ||||
| <React.Fragment> | <React.Fragment> | ||||
| <AuthWrapper> | <AuthWrapper> | ||||
| <CustomFormWizard setUpdateValid={setUpdateValid} step={activeStep} setUsername={setUsername}/> | |||||
| <CustomFormWizard setUpdateValid={setUpdateValid} step={activeStep} setIdNo={setIdNo}/> | |||||
| {/* <CustomFormWizard step={activeStep} /> */} | {/* <CustomFormWizard step={activeStep} /> */} | ||||
| </AuthWrapper> | </AuthWrapper> | ||||
| <Stack direction="row" sx={{ pb: 2 }}> | <Stack direction="row" sx={{ pb: 2 }}> | ||||
| @@ -21,7 +21,7 @@ import { useFormik, FormikProvider } from 'formik'; | |||||
| import * as yup from 'yup'; | import * as yup from 'yup'; | ||||
| import axios from "axios"; | import axios from "axios"; | ||||
| import { POST_PUBLIC_USER_REGISTER, POST_CAPTCHA, GET_USER_EMAIL } from "utils/ApiPathConst"; | |||||
| import { POST_IAMSMART_USER_REGISTER, POST_CAPTCHA, GET_USER_EMAIL } from "utils/ApiPathConst"; | |||||
| import * as ComboData from "utils/ComboData"; | import * as ComboData from "utils/ComboData"; | ||||
| @@ -177,6 +177,20 @@ const CustomFormWizard = (props) => { | |||||
| } | } | ||||
| }, [checkEmailBlur]) | }, [checkEmailBlur]) | ||||
| useEffect(() => { | |||||
| if (iAmSmartData) { | |||||
| formik.setFieldValue("enName", iAmSmartData.enName??""); | |||||
| formik.setFieldValue("cnName", iAmSmartData.cnName??""); | |||||
| formik.setFieldValue("idNo", iAmSmartData.idNo??""); | |||||
| formik.setFieldValue("checkDigit", iAmSmartData.checkDigit??""); | |||||
| formik.setFieldValue("email", iAmSmartData.email??""); | |||||
| formik.setFieldValue("phone", iAmSmartData.phone??""); | |||||
| formik.setFieldValue("phoneCountryCode", iAmSmartData.phoneCountryCode??""); | |||||
| formik.setFieldValue("address1", iAmSmartData.address1??""); | |||||
| props.setIdNo(iAmSmartData.idNo??""); | |||||
| } | |||||
| }, [iAmSmartData]) | |||||
| const onCaptchaChange = () => { | const onCaptchaChange = () => { | ||||
| HttpUtils.post({ | HttpUtils.post({ | ||||
| url: POST_CAPTCHA, | url: POST_CAPTCHA, | ||||
| @@ -274,12 +288,12 @@ const CustomFormWizard = (props) => { | |||||
| } | } | ||||
| const user = { | const user = { | ||||
| enName: values.enName, | |||||
| chName: values.chName, | |||||
| enName: iAmSmartData.enName, | |||||
| chName: iAmSmartData.chName, | |||||
| emailAddress: values.email, | emailAddress: values.email, | ||||
| idDocType: values.idDocType, | |||||
| identification: values.idNo, | |||||
| checkDigit: values.checkDigit, | |||||
| idDocType: "HKID", | |||||
| identification: iAmSmartData.idNo, | |||||
| checkDigit: iAmSmartData.checkDigit, | |||||
| tncFlag: tncFlag, | tncFlag: tncFlag, | ||||
| type: "IND", | type: "IND", | ||||
| }; | }; | ||||
| @@ -293,7 +307,7 @@ const CustomFormWizard = (props) => { | |||||
| formData.append("userAddress", JSON.stringify(userAddress)); | formData.append("userAddress", JSON.stringify(userAddress)); | ||||
| if (isValid) { | if (isValid) { | ||||
| axios.post(POST_PUBLIC_USER_REGISTER, formData, { | |||||
| axios.post(POST_IAMSMART_USER_REGISTER, formData, { | |||||
| headers: { | headers: { | ||||
| "Content-Type": "multipart/form-data" | "Content-Type": "multipart/form-data" | ||||
| } | } | ||||
| @@ -339,13 +353,13 @@ const CustomFormWizard = (props) => { | |||||
| const formik = useFormik({ | const formik = useFormik({ | ||||
| initialValues: ({ | initialValues: ({ | ||||
| email: '', | |||||
| emailConfirm: '', | |||||
| address1: '', | |||||
| email: iAmSmartData.email??"", | |||||
| emailConfirm: iAmSmartData.email??"", | |||||
| address1: iAmSmartData.address1??"", | |||||
| address2: '', | address2: '', | ||||
| address3: '', | address3: '', | ||||
| phone: '', | |||||
| phoneCountryCode: '852', | |||||
| phone: iAmSmartData.phone??"", | |||||
| phoneCountryCode: iAmSmartData.phoneCountryCode??"852", | |||||
| submit: null, | submit: null, | ||||
| fax: '', | fax: '', | ||||
| faxCountryCode: '852', | faxCountryCode: '852', | ||||
| @@ -43,10 +43,13 @@ export const POST_CAPTCHA = apiPath+'/captcha'; | |||||
| //register | //register | ||||
| export const POST_PUBLIC_USER_REGISTER = apiPath+'/user/register'; | export const POST_PUBLIC_USER_REGISTER = apiPath+'/user/register'; | ||||
| export const POST_IAMSMART_USER_REGISTER = apiPath+'/user/smart/register'; | |||||
| export const GET_USERNAME = apiPath+'/user/username'; | export const GET_USERNAME = apiPath+'/user/username'; | ||||
| export const GET_USER_EMAIL = apiPath+'/user/email'; | export const GET_USER_EMAIL = apiPath+'/user/email'; | ||||
| export const GET_ID = apiPath+'/user/verifyID'; | |||||
| export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail'; | export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail'; | ||||
| //Public | //Public | ||||
| export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg'; | export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg'; | ||||
| export const GET_SET_PRIMARY_USER = apiPath+'/user/primary'; | export const GET_SET_PRIMARY_USER = apiPath+'/user/primary'; | ||||