Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ProfileSetupFirstStep = React.createClass({
  2. mixins: [ErrorsMixin],
  3. getInitialState() {
  4. return {
  5. gender: null, // default is no gender
  6. }
  7. },
  8. submit(event) {
  9. event.preventDefault();
  10. // make sure gender was set by user
  11. if (!this.state.gender){
  12. throwError("Please pick a gender for your baby");
  13. }
  14. if (this.refs.password.value === this.refs.confirmPassword.value) {
  15. if (this.refs.password.value.length >= 6) {
  16. Accounts.createUser({
  17. profile: {
  18. gender: this.state.gender,
  19. photo: this.insertImage(),
  20. user: this.refs.babyName.value
  21. },
  22. email: this.refs.email.value,
  23. password: this.refs.password.value
  24. }, this.handleErrors);
  25. } else {
  26. throwError("Password is too short");
  27. }
  28. } else {
  29. throwError("Password doesn`t match");
  30. }
  31. },
  32.  
  33. insertImage () {
  34. var fsImage = new FS.File(this.refs.photoInput.files[0]);
  35. return Images.insert(fsImage, this.handleErrors);
  36. },
  37. onGenderChange(e) {
  38. // prevent default stops radio button from changing position, don't use
  39. this.setState({gender: e.target.value});
  40. },
  41.  
  42. render() {
  43. return (
  44. <div className="page">
  45. <h1 className="page-title">Profile Setup</h1>
  46. <form name="profile" onSubmit={this.submit}>
  47. <div className="input-cont">
  48. <input type="text" name="babyName" ref="babyName" placeholder="Baby’s name" />
  49. </div>
  50.  
  51. <div className="input-cont" ref="gender ">
  52. <input type="radio" name="gender" value="male" onChange={this.onGenderChange} /> BOY
  53. <input type="radio" name="gender" value="female" onChange={this.onGenderChange} /> GIRL
  54. </div>
  55.  
  56. <div className="input-cont">
  57. <input type="email" name="email" ref="email" placeholder="Your email" />
  58. </div>
  59.  
  60. <div className="input-cont">
  61. <input type="password" name="password" ref="password" placeholder="Password" />
  62. </div>
  63.  
  64. <div className="input-cont">
  65. <input type="password" name="confirmPassword" ref="confirmPassword" placeholder="Confirm Password" />
  66. </div>
  67.  
  68. <div className="input-cont">
  69. <input type="file" ref="photoInput" required/>
  70. </div>
  71.  
  72. <p>
  73. By tapping “Next”, you accept our terms and cond- tions. We will only use your information
  74. to send to up- dates on the site and notifications for using the site. We will never share
  75. your information with anyone.
  76. </p>
  77.  
  78. <div className="actions">
  79. <button type="submit" className="btn btn-default">Next</button>
  80. </div>
  81. </form>
  82. </div>
  83. )
  84. }
  85. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement