Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. import React from 'react';
  2. import Formsy from 'formsy-react'
  3. import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
  4. import Formsytext from 'formsy-material-ui/lib/FormsyText';
  5. import RaisedButton from 'material-ui/RaisedButton';
  6. import {blueA400} from 'material-ui/styles/colors'
  7. import {redA400} from 'material-ui/styles/colors'
  8. import {Base,styles} from './base';
  9. import reqwest from 'reqwest';
  10. export class SignUp extends Base{
  11. submit(){
  12. reqwest ({
  13. url: '/users',
  14. metod: 'POST',
  15. data: {
  16. user:{
  17. email: this.state.email,
  18. password: this.state.password,
  19. passwordConfirmation: this.state.passwordConfirmation
  20. }
  21. },
  22. headers:{
  23. 'X-CSRF-Token':window.memoriaTokenReal.token
  24. }
  25. }).then(data =>{
  26. console.log(data);
  27. }).catch(err => console.log(err));
  28. }
  29. render(){
  30. return(
  31. <MuiThemeProvider>
  32. <Formsy.Form onValid={ ()=>this.enableSubmitBtn() }
  33. onInvalid={ ()=>this.disableSubmitBtn() }
  34. onValidSubmit={ () => this.submit() } >
  35. <div>
  36. <Formsytext
  37. onChange = {(e) => this.syncField(e,"email")}
  38. name = "email"
  39. required
  40. floatingLabelFocusStyle = {styles.floatingLabelFocusStyle}
  41. underlineFocusStyle = {styles.underlineStyle}
  42. validations = "isEmail"
  43. validationError = "Asegúrate de introducir el correo electrónico válido"
  44. floatingLabelText= "Correo electrónico" />
  45. </div>
  46. <div>
  47. <Formsytext
  48. onChange = {(e) => this.syncField(e,"password")}
  49. name = "password"
  50. required
  51. floatingLabelFocusStyle = {styles.floatingLabelFocusStyle}
  52. underlineFocusStyle = {styles.underlineStyle}
  53. type = "password"
  54. floatingLabelText= "Contraseña" />
  55. </div>
  56. <div>
  57. <Formsytext
  58. onChange = {(e) => this.syncField(e,"passwordConfirmation")}
  59. name = "password"
  60. required
  61. floatingLabelFocusStyle = {styles.floatingLabelFocusStyle}
  62. underlineFocusStyle = {styles.underlineStyle}
  63. type = "password"
  64. floatingLabelText= "Confirmar contraseña" />
  65. </div>
  66. <div>
  67. <RaisedButton
  68. style = {styles.buttonTop}
  69. backgroundColor = {styles.red}
  70. labelColor = '#ffffff'
  71. disabled = {!this.state.canSubmit}
  72. type = "submit"
  73. label = "Crear Cuenta" />
  74. <a href="#" onClick={this.props.toggle} style={styles.leftSpace}> Ya tengo una cuenta </a>
  75. </div>
  76. </Formsy.Form>
  77. </MuiThemeProvider>
  78. );
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement