HM-131. Доработки ошибок на странице Логина
This commit is contained in:
@ -101,10 +101,6 @@
|
|||||||
<div class="Login__title h3"></div>
|
<div class="Login__title h3"></div>
|
||||||
<form class="Login__form needs-validation" novalidate>
|
<form class="Login__form needs-validation" novalidate>
|
||||||
<div class="Login__inputContainer"></div>
|
<div class="Login__inputContainer"></div>
|
||||||
<div class="form-group form-check Login__check">
|
|
||||||
<input type="checkbox" class="form-check-input" id="check">
|
|
||||||
<label class="form-check-label" for="check">Оставаться в системе</label>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary Login__submit">Войти</button>
|
<button type="submit" class="btn btn-primary Login__submit">Войти</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -11,7 +11,6 @@ class LoginForm extends Component {
|
|||||||
this.form = this.mainNode.querySelector('.Login__form');
|
this.form = this.mainNode.querySelector('.Login__form');
|
||||||
this.inputContainer = this.mainNode.querySelector('.Login__inputContainer');
|
this.inputContainer = this.mainNode.querySelector('.Login__inputContainer');
|
||||||
this.submitButton = this.mainNode.querySelector('.Login__submit');
|
this.submitButton = this.mainNode.querySelector('.Login__submit');
|
||||||
this.checkboxSystem = this.mainNode.querySelector('.form-check-input');
|
|
||||||
this.logoImage = this.mainNode.querySelector('.Login__logo');
|
this.logoImage = this.mainNode.querySelector('.Login__logo');
|
||||||
this.logoImage.src = Image;
|
this.logoImage.src = Image;
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ class LoginForm extends Component {
|
|||||||
this.loginControl.input,
|
this.loginControl.input,
|
||||||
this.passwordControl.input,
|
this.passwordControl.input,
|
||||||
this.submitButton,
|
this.submitButton,
|
||||||
this.checkboxSystem,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
elements.forEach((element) => {
|
elements.forEach((element) => {
|
||||||
@ -61,6 +59,11 @@ class LoginForm extends Component {
|
|||||||
return this.form.checkValidity();
|
return this.form.checkValidity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setError = (message) => {
|
||||||
|
this.loginControl.setError(message);
|
||||||
|
this.passwordControl.setError(message);
|
||||||
|
}
|
||||||
|
|
||||||
submit = (event) => {
|
submit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (this.validateInputs()) {
|
if (this.validateInputs()) {
|
||||||
|
|||||||
@ -6,6 +6,11 @@ import routeService from '../../../../services/RouteService';
|
|||||||
import notify from '../../../../services/NotifyService';
|
import notify from '../../../../services/NotifyService';
|
||||||
import {ROUTES, EVENTS} from '../../../../core/consts';
|
import {ROUTES, EVENTS} from '../../../../core/consts';
|
||||||
|
|
||||||
|
const ERRORS = {
|
||||||
|
NOT_CORRECT: 'Неверный логин или пароль',
|
||||||
|
UNKNOWN_ERROR: 'Неизвестная ошибка',
|
||||||
|
};
|
||||||
|
|
||||||
class LoginPage extends Component {
|
class LoginPage extends Component {
|
||||||
constructor (mainNodeSelector, parentNode) {
|
constructor (mainNodeSelector, parentNode) {
|
||||||
super(mainNodeSelector, parentNode);
|
super(mainNodeSelector, parentNode);
|
||||||
@ -21,8 +26,12 @@ class LoginPage extends Component {
|
|||||||
routeService.goTo(ROUTES.MAIN);
|
routeService.goTo(ROUTES.MAIN);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
const message = e?.response?.data?.message || 'Неизвестная ошибка';
|
const message = e?.response?.data?.message || ERRORS.UNKNOWN_ERROR;
|
||||||
notify.warn(message);
|
if (message === ERRORS.NOT_CORRECT) {
|
||||||
|
this.form.setError(ERRORS.NOT_CORRECT);
|
||||||
|
} else {
|
||||||
|
notify.warn(message);
|
||||||
|
}
|
||||||
this.form.disabled(false);
|
this.form.disabled(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,5 +19,5 @@ export const ERRORS = {
|
|||||||
TYPED_NEW_PASSWORD: 'Заполните новый пароль',
|
TYPED_NEW_PASSWORD: 'Заполните новый пароль',
|
||||||
PASSWORD_NOT_EQUAL: 'Пароли не совпадают',
|
PASSWORD_NOT_EQUAL: 'Пароли не совпадают',
|
||||||
REPEAT_PASSWORD: 'Повторите новый пароль',
|
REPEAT_PASSWORD: 'Повторите новый пароль',
|
||||||
NOT_CORRECT_PASSWORD: 'Не верный старый пароль',
|
NOT_CORRECT_PASSWORD: 'Неверный старый пароль',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user