Guest User

Untitled

a guest
Oct 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import React, { Component } from 'react'
  2.  
  3. import Luhn from './luhn.js'
  4.  
  5. class Input extends Component {
  6.  
  7. constructor(props, context) {
  8. super(props, context);
  9.  
  10. this.state = {
  11. labelClassName : 'position-relative pr-1 pl-1',
  12. libelClassName : 'position-fixed row ml-1',
  13. value : '',
  14. validSiren : false,
  15. validIcon : 'invisible',
  16. errorIcon : 'invisible',
  17. }
  18.  
  19. this.valid = this.valid.bind(this)
  20. this.error = this.error.bind(this)
  21. }
  22.  
  23. handleChange(e) {
  24. this.setState({value : e.target.value })
  25. }
  26.  
  27. valid() {
  28. (!this.state.validSiren)
  29. ? this.setState({ validSiren : true })
  30. : true
  31. }
  32.  
  33. error() {
  34. (this.state.validSiren)
  35. ? this.setState({ validSiren : false })
  36. : true
  37. }
  38.  
  39. render() {
  40. return (
  41. <div>
  42.  
  43. <input type="number"
  44. id={input.id}
  45. onChange={this.handleChange.bind(this)}/>
  46.  
  47. {(this.state.value.length === 9)
  48. ? <Luhn siren={this.state.value}
  49. valid={this.valid}
  50. error={this.error} />
  51. : true }
  52.  
  53. <i id='errorCheck' className={`fa fa-exclamation-triangle checked ${this.state.errorIcon}` } aria-hidden="true"></i>
  54. <i id='validCheck' className={`fa fa-check-circle checked ${this.state.validIcon}` } aria-hidden="true"></i>
  55.  
  56. </div>
  57. )
  58. }
  59. }
  60.  
  61. export default Input
Add Comment
Please, Sign In to add comment