diff options
author | Dessalines <tyhou13@gmx.com> | 2019-10-18 17:20:27 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-10-18 17:20:27 -0700 |
commit | 4e5561283392d2ab1545cabb4455a8ffc490f86b (patch) | |
tree | a4ee9cc096826dc32faf3675212c7f95f1b3ea5e /ui/src/components/login.tsx | |
parent | 82ea5ae9186e5a8e631c87a61077e16713eb87a4 (diff) |
Running prettier on code.
- #305 , #309
Diffstat (limited to 'ui/src/components/login.tsx')
-rw-r--r-- | ui/src/components/login.tsx | 162 |
1 files changed, 123 insertions, 39 deletions
diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index 66962acc..87fa39fe 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -1,7 +1,12 @@ import { Component, linkEvent } from 'inferno'; -import { Subscription } from "rxjs"; +import { Subscription } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; -import { LoginForm, RegisterForm, LoginResponse, UserOperation } from '../interfaces'; +import { + LoginForm, + RegisterForm, + LoginResponse, + UserOperation, +} from '../interfaces'; import { WebSocketService, UserService } from '../services'; import { msgOp } from '../utils'; import { i18n } from '../i18next'; @@ -14,14 +19,13 @@ interface State { registerLoading: boolean; } - export class Login extends Component<any, State> { private subscription: Subscription; emptyState: State = { loginForm: { username_or_email: undefined, - password: undefined + password: undefined, }, registerForm: { username: undefined, @@ -32,7 +36,7 @@ export class Login extends Component<any, State> { }, loginLoading: false, registerLoading: false, - } + }; constructor(props: any, context: any) { super(props, context); @@ -40,12 +44,19 @@ export class Login extends Component<any, State> { this.state = this.emptyState; this.subscription = WebSocketService.Instance.subject - .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) - .subscribe( - (msg) => this.parseMessage(msg), - (err) => console.error(err), - () => console.log("complete") - ); + .pipe( + retryWhen(errors => + errors.pipe( + delay(3000), + take(10) + ) + ) + ) + .subscribe( + msg => this.parseMessage(msg), + err => console.error(err), + () => console.log('complete') + ); } componentWillUnmount() { @@ -53,22 +64,20 @@ export class Login extends Component<any, State> { } componentDidMount() { - document.title = `${i18n.t('login')} - ${WebSocketService.Instance.site.name}`; + document.title = `${i18n.t('login')} - ${ + WebSocketService.Instance.site.name + }`; } render() { return ( <div class="container"> <div class="row"> - <div class="col-12 col-lg-6 mb-4"> - {this.loginForm()} - </div> - <div class="col-12 col-lg-6"> - {this.registerForm()} - </div> + <div class="col-12 col-lg-6 mb-4">{this.loginForm()}</div> + <div class="col-12 col-lg-6">{this.registerForm()}</div> </div> </div> - ) + ); } loginForm() { @@ -77,21 +86,45 @@ export class Login extends Component<any, State> { <form onSubmit={linkEvent(this, this.handleLoginSubmit)}> <h5>Login</h5> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="email_or_username">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="email_or_username">#</T> + </label> <div class="col-sm-10"> - <input type="text" class="form-control" value={this.state.loginForm.username_or_email} onInput={linkEvent(this, this.handleLoginUsernameChange)} required minLength={3} /> + <input + type="text" + class="form-control" + value={this.state.loginForm.username_or_email} + onInput={linkEvent(this, this.handleLoginUsernameChange)} + required + minLength={3} + /> </div> </div> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="password">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="password">#</T> + </label> <div class="col-sm-10"> - <input type="password" value={this.state.loginForm.password} onInput={linkEvent(this, this.handleLoginPasswordChange)} class="form-control" required /> + <input + type="password" + value={this.state.loginForm.password} + onInput={linkEvent(this, this.handleLoginPasswordChange)} + class="form-control" + required + /> </div> </div> <div class="form-group row"> <div class="col-sm-10"> - <button type="submit" class="btn btn-secondary">{this.state.loginLoading ? - <svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg> : i18n.t('login')}</button> + <button type="submit" class="btn btn-secondary"> + {this.state.loginLoading ? ( + <svg class="icon icon-spinner spin"> + <use xlinkHref="#icon-spinner"></use> + </svg> + ) : ( + i18n.t('login') + )} + </button> </div> </div> </form> @@ -101,43 +134,95 @@ export class Login extends Component<any, State> { registerForm() { return ( <form onSubmit={linkEvent(this, this.handleRegisterSubmit)}> - <h5><T i18nKey="sign_up">#</T></h5> + <h5> + <T i18nKey="sign_up">#</T> + </h5> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="username">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="username">#</T> + </label> <div class="col-sm-10"> - <input type="text" class="form-control" value={this.state.registerForm.username} onInput={linkEvent(this, this.handleRegisterUsernameChange)} required minLength={3} maxLength={20} pattern="[a-zA-Z0-9_]+" /> + <input + type="text" + class="form-control" + value={this.state.registerForm.username} + onInput={linkEvent(this, this.handleRegisterUsernameChange)} + required + minLength={3} + maxLength={20} + pattern="[a-zA-Z0-9_]+" + /> </div> </div> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="email">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="email">#</T> + </label> <div class="col-sm-10"> - <input type="email" class="form-control" placeholder={i18n.t('optional')} value={this.state.registerForm.email} onInput={linkEvent(this, this.handleRegisterEmailChange)} minLength={3} /> + <input + type="email" + class="form-control" + placeholder={i18n.t('optional')} + value={this.state.registerForm.email} + onInput={linkEvent(this, this.handleRegisterEmailChange)} + minLength={3} + /> </div> </div> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="password">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="password">#</T> + </label> <div class="col-sm-10"> - <input type="password" value={this.state.registerForm.password} onInput={linkEvent(this, this.handleRegisterPasswordChange)} class="form-control" required /> + <input + type="password" + value={this.state.registerForm.password} + onInput={linkEvent(this, this.handleRegisterPasswordChange)} + class="form-control" + required + /> </div> </div> <div class="form-group row"> - <label class="col-sm-2 col-form-label"><T i18nKey="verify_password">#</T></label> + <label class="col-sm-2 col-form-label"> + <T i18nKey="verify_password">#</T> + </label> <div class="col-sm-10"> - <input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required /> + <input + type="password" + value={this.state.registerForm.password_verify} + onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} + class="form-control" + required + /> </div> </div> <div class="form-group row"> <div class="col-sm-10"> <div class="form-check"> - <input class="form-check-input" type="checkbox" checked={this.state.registerForm.show_nsfw} onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}/> - <label class="form-check-label"><T i18nKey="show_nsfw">#</T></label> + <input + class="form-check-input" + type="checkbox" + checked={this.state.registerForm.show_nsfw} + onChange={linkEvent(this, this.handleRegisterShowNsfwChange)} + /> + <label class="form-check-label"> + <T i18nKey="show_nsfw">#</T> + </label> </div> </div> </div> <div class="form-group row"> <div class="col-sm-10"> - <button type="submit" class="btn btn-secondary">{this.state.registerLoading ? - <svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg> : i18n.t('sign_up')}</button> + <button type="submit" class="btn btn-secondary"> + {this.state.registerLoading ? ( + <svg class="icon icon-spinner spin"> + <use xlinkHref="#icon-spinner"></use> + </svg> + ) : ( + i18n.t('sign_up') + )} + </button> </div> </div> </form> @@ -217,5 +302,4 @@ export class Login extends Component<any, State> { } } } - } |