Guest User

Untitled

a guest
Nov 4th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import HomepageNavigation from '../../components/navigation/HomepageNavigation';
  3. import InterestBox from '../../components/register/InterestBox';
  4.  
  5. export class RegisterVolunteer extends Component {
  6.  
  7. constructor(props) {
  8. super(props)
  9. this.state = {interests: []}
  10. this.handleChange = this.handleChange.bind(this);
  11. this.addInterest = this.addInterest.bind(this);
  12. }
  13.  
  14. addInterest(id, name) {
  15. var mid = 'm' + id;
  16. console.log(this.state.interests[mid] == undefined)
  17. if(this.state.interests[mid] == undefined) {
  18. this.setState((state) => {
  19. state.interests[mid] = name;
  20. return {interests: state.interests}
  21. })
  22. } else {
  23. var newInterest = this.state.interests;
  24. delete newInterest[mid]
  25. this.setState(newInterest)
  26. }
  27. console.log(this.state.interests)
  28. }
  29.  
  30. getInterests() {
  31. console.log(this.state.interests.map((item, key) => {
  32. return (<span>{item}</span>)
  33. }))
  34. }
  35.  
  36. checkInfoFilled() {
  37. if(this.state.firstname != undefined && this.state.lastname != undefined & this.state.dateofbirth != undefined && this.state.email != undefined && this.state.address != undefined) {
  38. return true;
  39. }
  40. else {
  41. return false;
  42. }
  43. }
  44.  
  45. handleChange(event) {
  46. const target = event.target;
  47. const value = target.type === 'checkbox' ? target.checked : target.value;
  48. const name = target.name;
  49.  
  50. this.setState({
  51. [name]: value
  52. });
  53. }
  54.  
  55. render() {
  56. return (
  57. <div className="container">
  58. <HomepageNavigation />
  59. <section className="section has-text-centered">
  60. <div className="column is-offset-1 is-10">
  61. <form className="register-form">
  62. <h1 className="title is-size-1 register-title">Je suis un bénévole</h1>
  63. <section className="section register-section">
  64. <p>Clique sur les lignes pour y ajouter tes informations.</p>
  65. <div className="has-text-left">
  66. <p className="is-size-4">Je m'appelle <input type="text" name="firstname" placeholder="prénom" value={this.state.firstname} onChange={this.handleChange}/> <input type="text" name="lastname" placeholder="nom de famille" value={this.state.lastname} onChange={this.handleChange}/></p>
  67. <p className="is-size-4">Je suis né le <input type="date" name="dateofbirth" value={this.state.dateofbirth} onChange={this.handleChange}></input> et mon adresse est <input type="text" name="address" placeholder="adresse" value={this.state.address} onChange={this.handleChange}/></p>
  68. <p className="is-size-4">Mon adresse email est le <input type="email" name="email" placeholder="adresse email" value={this.state.email} onChange={this.handleChange} /></p>
  69. </div>
  70. </section>
  71. <section className="section register-section">
  72. <h2 className="register-title subtitle is-size-3">Mes centres d'intérêts</h2>
  73. <p>Sélectionne tous tes intérêts en cliquant desuss.</p>
  74. <div className="columns interest-columns is-multiline column is-mobile">
  75. <InterestBox id="1" handleClick={this.addInterest} icon={require('../../img/interests/futbol.svg')} title="Sports" />
  76. <InterestBox id="2" handleClick={this.addInterest} icon={require('../../img/interests/paw.svg')} title="Animaux" />
  77. <InterestBox id="3" handleClick={this.addInterest} icon={require('../../img/interests/briefcase.svg')} title="Bureau" />
  78. <InterestBox id="4" handleClick={this.addInterest} icon={require('../../img/interests/child.svg')} title="Enfants" />
  79. <InterestBox id="5" handleClick={this.addInterest} icon={require('../../img/interests/carry.svg')} title="Manuel" />
  80. <InterestBox id="6" handleClick={this.addInterest} icon={require('../../img/interests/leaf.svg')} title="Écolo" />
  81. <InterestBox id="7" handleClick={this.addInterest} icon={require('../../img/interests/microchip.svg')} title="Techno" />
  82. <InterestBox id="8" handleClick={this.addInterest} icon={require('../../img/interests/seniors.svg')} title="Aînés" />
  83. <InterestBox id="9" handleClick={this.addInterest} icon={require('../../img/interests/theater.svg')} title="Culture" />
  84. </div>
  85. </section>
  86. <section className="section register-section">
  87. {(1==1) ?
  88. <div><h2 className="register-title subtitle is-size-3 has-text-centered">Vérifions vos informations</h2>
  89. <p className="has-text-centered">Si une information n'est pas correcte, remonte et rectifie-la.</p>
  90. <div className="has-text-left">
  91. <p className="is-size-4">Votre nom est <span className="underlined">{this.state.firstname}</span> <span className="underlined">{this.state.lastname}</span>, vous êtes né le <span className="underlined">{this.state.dateofbirth}</span>.</p>
  92. <p className="is-size-4">Votre adresse email est le <span className="underlined">{this.state.email}</span>.</p>
  93. <p className="is-size-4">Vous êtes interessé par : {this.getInterests()}</p>
  94. <p className="is-size-4">Veuillez entrer votre mot de passe pour confirmer votre inscription.</p>
  95. <input type="password" name="password" placeholder="Mot de passe"></input><br />
  96. <input type="password" name="c_password" placeholder="Confirmation de mot de passe"></input><br />
  97. <button className="button is-primary has-text-left">Confirmer</button>
  98. </div></div> : '' }
  99. </section>
  100. </form>
  101. </div>
  102. </section>
  103. </div>
  104. )
  105. }
  106. }
  107.  
  108. export default RegisterVolunteer
Advertisement
Add Comment
Please, Sign In to add comment