|
|
@@ -29,7 +29,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"; |
|
|
|
|
|
|
@@ -62,6 +62,7 @@ const CustomFormWizard = (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([]); |
|
|
@@ -109,6 +110,17 @@ const CustomFormWizard = (props) => { |
|
|
|
useEffect(() => { |
|
|
|
changePassword(''); |
|
|
|
onCaptchaChange(); |
|
|
|
axios.get(`${GET_USERNAME}`) |
|
|
|
.then((response) => { |
|
|
|
if (response.status === 200) { |
|
|
|
setUserNameList(response.data); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
console.log(error); |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const onCaptchaChange = ()=>{ |
|
|
@@ -441,7 +453,17 @@ const CustomFormWizard = (props) => { |
|
|
|
captchaField:'' |
|
|
|
}), |
|
|
|
validationSchema:yup.object().shape({ |
|
|
|
username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱') |
|
|
|
username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱').test( |
|
|
|
"checkUserNameUsed", |
|
|
|
"此用戶登入名稱已被注冊,請使用其他用戶登入名稱", |
|
|
|
function(value) { |
|
|
|
if (userNameList.some(item => item.username === value)) { |
|
|
|
return false |
|
|
|
} else { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
.matches(/^[aA-zZ0-9\s]+$/, "用戶名稱不包含特殊字符") |
|
|
|
.matches(/^\S*$/, '用戶名稱不包含空格'), |
|
|
|
password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') |
|
|
|