-
{props.message}
+
{props.message}
diff --git a/src/_containers/LoginPage/LoginPage.js b/src/_containers/LoginPage/LoginPage.js
index 5d7f028..c6a79bc 100644
--- a/src/_containers/LoginPage/LoginPage.js
+++ b/src/_containers/LoginPage/LoginPage.js
@@ -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;
}
diff --git a/src/_containers/LoginPage/components/Login.js b/src/_containers/LoginPage/components/Login.js
index ab4b130..3a3a025 100644
--- a/src/_containers/LoginPage/components/Login.js
+++ b/src/_containers/LoginPage/components/Login.js
@@ -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}
diff --git a/src/_containers/RegisterPage/CreateAccount/index.js b/src/_containers/RegisterPage/CreateAccount/index.js
index f62b7d6..ee06e5e 100644
--- a/src/_containers/RegisterPage/CreateAccount/index.js
+++ b/src/_containers/RegisterPage/CreateAccount/index.js
@@ -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}
>
@@ -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");
+ }}
>
{/*
Vai trò
diff --git a/src/_containers/RegisterPage/CreateAccount/index.scss b/src/_containers/RegisterPage/CreateAccount/index.scss
index 1e0aff3..029a007 100644
--- a/src/_containers/RegisterPage/CreateAccount/index.scss
+++ b/src/_containers/RegisterPage/CreateAccount/index.scss
@@ -138,4 +138,8 @@
.input_date_base_container {
flex: 1;
}
+}
+
+.login-form-container {
+ padding-bottom: 40px;
}
\ No newline at end of file