You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReact,{Component}from'react';import{Button,Container,Entry}from'../components';import{observer}from'mobx-react';importFormStore,{Validators}from'mobx-valite-form-store';exporttypeLoginEntries={username: string;password: string;};exporttypeLoginFormProps={passwordRecoveryURL: string;onLogin: (entries: LoginEntries)=>void;};constvalidators: Validators<LoginEntries>={username: [(value: string)=>!!value.trim()||'Nome de usuário vazio.',(value: string)=>value.length>18||'Nome de usuário maior que o permitido.'],password: [(value: string)=>!!value.trim()||'Senha vazia.',(value: string)=>value!=='123456'||'Senha de usuário muito fácil, use outra.']};
@observerexportclassLoginFormextendsComponent<LoginFormProps>{store: FormStore<LoginEntries>=newFormStore({},validators);onPress=async()=>{awaitthis.store.validateEntries();if(this.store.isValid&&!this.store.isLoading)return;this.props.onLogin(this.store.entries);};render(){return(<Container><Entrylabel="Nome de Usuário"value={this.store.entries.username}message={this.store.errors.username}onChange={(value)=>this.store.setEntry('username',value)}/><Entrylabel="Senha"value={this.store.entries.password}message={this.store.errors.password}onChange={(value)=>this.store.setEntry('password',value)}/><Linkto={this.props.passwordRecoveryURL}>Esqueceu sua senha?</Link><ButtononPress={this.onPress}isDisabled={!this.store.isValid||this.store.isLoading}>
Entrar
</Button></Container>);}}
Would be nice to have a file with usage examples, recipes and other approaches using this library.
The text was updated successfully, but these errors were encountered: