fix bug 1207 v2

uat
HOANGLAOTA 1 year ago
parent 8aa3da75b3
commit cb2066aa92
  1. 2
      src/_components/Alert/error.js
  2. 2
      src/_components/Alert/success.js
  3. 2
      src/_containers/LoginPage/LoginPage.js
  4. 6
      src/_containers/LoginPage/components/Login.js
  5. 42
      src/_containers/RegisterPage/CreateAccount/index.js
  6. 4
      src/_containers/RegisterPage/CreateAccount/index.scss

@ -27,7 +27,7 @@ function AlertError(props) {
return (
<div id="modal-center" className="uk-flex-top uk-modal uk-flex uk-open" uk-modal="">
<div className="uk-modal-dialog uk-modal-body uk-margin-auto-vertical">
<p className="text-center">{props.message}</p>
<p className="text-center" style={{whiteSpace: 'pre-line'}}>{props.message}</p>
<div className="form-sunE-button">
{hasBtnClosePopup && <button className="btn-default mr-20" style={{width: 'unset', padding: '0 24px'}} onClick={handleClosePopup}>{textClose || 'Đóng'}</button>}
<button className="btn-line-blue" onClick={complete}>{textComplete || 'Đóng'}</button>

@ -21,7 +21,7 @@ function AlertSuccess(props) {
return (
<div id="modal-center" className="uk-flex-top uk-modal uk-flex uk-open" uk-modal="">
<div className="uk-modal-dialog uk-modal-body uk-margin-auto-vertical">
<p className="text-center">{props.message}</p>
<p className="text-center" style={{whiteSpace: 'pre-line'}}>{props.message}</p>
<div className="form-sunE-button">
<button className="btn-line-blue" onClick={close}>Đóng</button>
</div>

@ -204,7 +204,7 @@ function LoginPage() {
}
function validateParam() {
return isEmail(email) && password.length >= 6 && password.trim() !== ""
return !!email?.trim() && password.length >= 6 && password.trim() !== ""
? true
: false;
}

@ -247,9 +247,9 @@ function Login(props) {
required={true}
renderLabelIcon={renderEmailIcon}
errorText={emailError}
onBlur={() => {
onBlurField("email");
}}
// onBlur={() => {
// onBlurField("email");
// }}
setErrorText={setEmailError}
autoComplete={savePassword ? "on" : "new-password"}
autoFocus={true}

@ -9,7 +9,7 @@ import { roleRegister } from "../../../_constants/register";
import { useParams } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { Alert } from "../../../_components/Alert";
import { userConstants } from "../../../_constants";
import { configConstants, userConstants } from "../../../_constants";
import { alertActions } from "../../../_actions";
import { isEmail } from "../../../_helpers/validateEmail";
@ -29,6 +29,7 @@ const CreateAccount = () => {
const [phoneWarning, setPhoneWarning] = useState("");
const [nameWarning, setNameWarning] = useState("");
const [addressWarning, setAddressWarning] = useState("");
const [birthdayWarning, setBirthdayWarning] = useState("");
const [password, setPassword] = useState("");
const [rePassword, setRePassword] = useState("");
@ -47,7 +48,7 @@ const CreateAccount = () => {
agents_code,
password,
address,
birthday,
birthday: dayjs(birthday).format('YYYY-MM-DD'),
email,
fullname,
gender,
@ -55,9 +56,11 @@ const CreateAccount = () => {
role
}
try {
const res = await apiCaller(url, "POST", dataSubmit)
const res = await apiCaller(url, "POST", dataSubmit, null, true, configConstants.API_URL_SETEST, true, true)
if (res.status) {
dispatch(alertActions.success({ 'message': res?.msg, 'screen': userConstants.SCREEN_REGISTER }));
} else {
dispatch(alertActions.error({ 'message': Object.values(res?.msg)?.join('\n'), 'screen': userConstants.SCREEN_REGISTER, isShowPopup: true }));
}
} catch (err) {
dispatch(alertActions.error({ 'message': err, 'screen': userConstants.SCREEN_REGISTER, isShowPopup: true }));
@ -74,6 +77,9 @@ const CreateAccount = () => {
if (password.length < 6 || password.trim() === "") {
setPwError("Mật khẩu cần tối thiểu 6 kí tự và không gồm toàn dấu cách");
}
if(password?.trim()?.length > 50) {
setPwError("Mật khẩu không được quá 50 kí tự");
}
};
const checkRePw = () => {
@ -164,6 +170,18 @@ const CreateAccount = () => {
}
return;
}
case 'fullname': {
if (!!fullname && fullname?.trim()?.length > 50 && !nameWarning) {
setNameWarning("Họ tên không được quá 50 kí tự");
}
return;
}
case 'address': {
if (!!address && address?.trim()?.length > 80 && !addressWarning) {
setAddressWarning("Địa chỉ không được quá 80 kí tự");
}
return;
}
default: {
if (rePassword && !rePwError) {
checkRePw();
@ -189,6 +207,8 @@ const CreateAccount = () => {
password.trim() !== "" &&
!!fullname.trim() &&
!!gender &&
!nameWarning &&
!addressWarning &&
!disabledBtn
) {
if (emailError) {
@ -375,12 +395,9 @@ const CreateAccount = () => {
removeWarningOnType={true}
errorText={nameWarning}
setErrorText={setNameWarning}
onBlur={() =>
fullname.trim() === ""
? setFullname("")
: setFullname(fullname.trim())
}
onBlur={() => {
onBlurField("fullname");
}}
autoFocus={true}
></InputText>
<div className="flex-m field_item">
@ -449,9 +466,14 @@ const CreateAccount = () => {
type="text"
name="name"
placeholder="Địa chỉ"
required={true}
removeWarningOnType={true}
errorText={addressWarning}
setErrorText={setAddressWarning}
renderLabelIcon={renderLocationIcon}
autoFocus={true}
onBlur={() => {
onBlurField("address");
}}
></InputText>
{/* <div>
<p style={{fontWeight: 600}}>Vai trò</p>

@ -138,4 +138,8 @@
.input_date_base_container {
flex: 1;
}
}
.login-form-container {
padding-bottom: 40px;
}
Loading…
Cancel
Save