mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
added form validators
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { controller, target } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { TransactionsService } from 'services/';
|
||||
import { AppMainElement, AppPaginationElement } from 'components/';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { controller, target } from '@github/catalyst';
|
||||
import { html, TemplateResult, until } from 'lit-html';
|
||||
import { html, TemplateResult, until } from 'core/utils';
|
||||
import { WalletService } from 'services/';
|
||||
import { AppMainElement, WalletHeaderElement } from 'components/';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { targets, controller, target } from '@github/catalyst';
|
||||
//import { html, TemplateResult } from "lit-html";
|
||||
import { html, render, TemplateResult } from 'lit-html';
|
||||
//import { html, TemplateResult } from "core/utils";
|
||||
import { html, render, TemplateResult } from 'core/utils';
|
||||
import { AuthService } from 'services/';
|
||||
import { AppFormElement, InputFieldElement } from 'components/';
|
||||
import { RouterService } from 'core/services';
|
||||
@@ -58,10 +58,10 @@ class LoginPageElement extends BasePageElement {
|
||||
}
|
||||
} catch (err) {
|
||||
if (err?.errorCode == 400103) {
|
||||
this.emailInput.error = err?.message;
|
||||
this.emailInput.setError(err?.message);
|
||||
this.emailInput.update();
|
||||
} else if (err?.errorCode == 400104) {
|
||||
this.passwordInput.error = err?.message;
|
||||
this.passwordInput.setError(err?.message);
|
||||
this.passwordInput.update();
|
||||
} else {
|
||||
this.appForm?.setError('Unable to log in!');
|
||||
@@ -86,7 +86,7 @@ class LoginPageElement extends BasePageElement {
|
||||
data-name="email"
|
||||
data-label="E-mail"
|
||||
data-targets="login-page.inputs"
|
||||
data-rules="required|isEmail"
|
||||
data-rules="required|is_email"
|
||||
></input-field>
|
||||
<input-field
|
||||
data-type="password"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { controller } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
@controller
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { targets, controller } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { targets, controller, target } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { AuthService } from 'services/';
|
||||
import { InputFieldElement } from 'components/';
|
||||
import { AppFormElement, InputFieldElement } from 'components/';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
@controller
|
||||
class RegisterPageElement extends BasePageElement {
|
||||
@targets inputs: Array<InputFieldElement>;
|
||||
@target appForm: AppFormElement;
|
||||
authService: AuthService;
|
||||
constructor() {
|
||||
super({
|
||||
@@ -37,7 +38,17 @@ class RegisterPageElement extends BasePageElement {
|
||||
if (response?.id) {
|
||||
this.appMain.routerService.goTo('/login');
|
||||
}
|
||||
} catch (err) {}
|
||||
} catch (err) {
|
||||
if (err?.errorCode == 400103) {
|
||||
this.appForm?.getInput('email')?.setError(err?.message);
|
||||
this.appForm?.getInput('email')?.update();
|
||||
} else if (err?.errorCode == 400104) {
|
||||
this.appForm?.getInput('password')?.setError(err?.message);
|
||||
this.appForm?.getInput('password')?.update();
|
||||
} else {
|
||||
this.appForm?.setError('Unable to log in!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
validate(): boolean {
|
||||
@@ -51,7 +62,7 @@ class RegisterPageElement extends BasePageElement {
|
||||
|
||||
render = (): TemplateResult => {
|
||||
return html`
|
||||
<app-form data-custom="register-page#onSubmit" data-has-cancel="true">
|
||||
<app-form data-custom="register-page#onSubmit" data-has-cancel="true" data-target="register-page.appForm">
|
||||
<input-field
|
||||
data-type="text"
|
||||
data-name="username"
|
||||
@@ -64,7 +75,7 @@ class RegisterPageElement extends BasePageElement {
|
||||
data-name="email"
|
||||
data-label="E-mail"
|
||||
data-targets="register-page.inputs"
|
||||
data-rules="required|isEmail"
|
||||
data-rules="required|is_email"
|
||||
></input-field>
|
||||
<input-field
|
||||
data-type="password"
|
||||
@@ -74,6 +85,13 @@ class RegisterPageElement extends BasePageElement {
|
||||
data-rules="required"
|
||||
>
|
||||
</input-field>
|
||||
<input-field
|
||||
data-type="password"
|
||||
data-name="confirmpassword"
|
||||
data-label="Confirm Password"
|
||||
data-targets="register-page.inputs"
|
||||
data-rules="required|is_same[field(password)]"
|
||||
>
|
||||
</app-form>
|
||||
`;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { targets, controller } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { AuthService, TransactionsService, WalletService } from 'services/';
|
||||
import { InputFieldElement } from 'components/';
|
||||
import { RouterService } from 'core/services';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { targets, controller } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { AuthService, WalletService } from 'services/';
|
||||
import { InputFieldElement } from 'components/';
|
||||
import { RouterService } from 'core/services';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { targets, controller, target } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { AuthService, WalletService } from 'services/';
|
||||
import { AppPaginationElement, InputFieldElement } from 'components/';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { controller, target } from '@github/catalyst';
|
||||
import { html, TemplateResult } from 'lit-html';
|
||||
import { html, TemplateResult } from 'core/utils';
|
||||
import { TransactionsService, WalletService } from 'services/';
|
||||
import { AppMainElement, AppPaginationElement, WalletHeaderElement } from 'components/';
|
||||
import { BasePageElement } from 'common/';
|
||||
|
||||
Reference in New Issue
Block a user