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 ( return (
<div id="modal-center" className="uk-flex-top uk-modal uk-flex uk-open" uk-modal=""> <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"> <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"> <div className="form-sunE-button">
{hasBtnClosePopup && <button className="btn-default mr-20" style={{width: 'unset', padding: '0 24px'}} onClick={handleClosePopup}>{textClose || 'Đóng'}</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> <button className="btn-line-blue" onClick={complete}>{textComplete || 'Đóng'}</button>

@ -21,7 +21,7 @@ function AlertSuccess(props) {
return ( return (
<div id="modal-center" className="uk-flex-top uk-modal uk-flex uk-open" uk-modal=""> <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"> <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"> <div className="form-sunE-button">
<button className="btn-line-blue" onClick={close}>Đóng</button> <button className="btn-line-blue" onClick={close}>Đóng</button>
</div> </div>

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

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

@ -9,7 +9,7 @@ import { roleRegister } from "../../../_constants/register";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Alert } from "../../../_components/Alert"; import { Alert } from "../../../_components/Alert";
import { userConstants } from "../../../_constants"; import { configConstants, userConstants } from "../../../_constants";
import { alertActions } from "../../../_actions"; import { alertActions } from "../../../_actions";
import { isEmail } from "../../../_helpers/validateEmail"; import { isEmail } from "../../../_helpers/validateEmail";
@ -29,6 +29,7 @@ const CreateAccount = () => {
const [phoneWarning, setPhoneWarning] = useState(""); const [phoneWarning, setPhoneWarning] = useState("");
const [nameWarning, setNameWarning] = useState(""); const [nameWarning, setNameWarning] = useState("");
const [addressWarning, setAddressWarning] = useState("");
const [birthdayWarning, setBirthdayWarning] = useState(""); const [birthdayWarning, setBirthdayWarning] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [rePassword, setRePassword] = useState(""); const [rePassword, setRePassword] = useState("");
@ -47,7 +48,7 @@ const CreateAccount = () => {
agents_code, agents_code,
password, password,
address, address,
birthday, birthday: dayjs(birthday).format('YYYY-MM-DD'),
email, email,
fullname, fullname,
gender, gender,
@ -55,9 +56,11 @@ const CreateAccount = () => {
role role
} }
try { 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) { if (res.status) {
dispatch(alertActions.success({ 'message': res?.msg, 'screen': userConstants.SCREEN_REGISTER })); 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) { } catch (err) {
dispatch(alertActions.error({ 'message': err, 'screen': userConstants.SCREEN_REGISTER, isShowPopup: true })); dispatch(alertActions.error({ 'message': err, 'screen': userConstants.SCREEN_REGISTER, isShowPopup: true }));
@ -74,6 +77,9 @@ const CreateAccount = () => {
if (password.length < 6 || password.trim() === "") { 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"); 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 = () => { const checkRePw = () => {
@ -164,6 +170,18 @@ const CreateAccount = () => {
} }
return; 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: { default: {
if (rePassword && !rePwError) { if (rePassword && !rePwError) {
checkRePw(); checkRePw();
@ -189,6 +207,8 @@ const CreateAccount = () => {
password.trim() !== "" && password.trim() !== "" &&
!!fullname.trim() && !!fullname.trim() &&
!!gender && !!gender &&
!nameWarning &&
!addressWarning &&
!disabledBtn !disabledBtn
) { ) {
if (emailError) { if (emailError) {
@ -375,12 +395,9 @@ const CreateAccount = () => {
removeWarningOnType={true} removeWarningOnType={true}
errorText={nameWarning} errorText={nameWarning}
setErrorText={setNameWarning} setErrorText={setNameWarning}
onBlur={() => {
onBlur={() => onBlurField("fullname");
fullname.trim() === "" }}
? setFullname("")
: setFullname(fullname.trim())
}
autoFocus={true} autoFocus={true}
></InputText> ></InputText>
<div className="flex-m field_item"> <div className="flex-m field_item">
@ -449,9 +466,14 @@ const CreateAccount = () => {
type="text" type="text"
name="name" name="name"
placeholder="Địa chỉ" placeholder="Địa chỉ"
required={true} removeWarningOnType={true}
errorText={addressWarning}
setErrorText={setAddressWarning}
renderLabelIcon={renderLocationIcon} renderLabelIcon={renderLocationIcon}
autoFocus={true} autoFocus={true}
onBlur={() => {
onBlurField("address");
}}
></InputText> ></InputText>
{/* <div> {/* <div>
<p style={{fontWeight: 600}}>Vai trò</p> <p style={{fontWeight: 600}}>Vai trò</p>

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