Advertisement
Guest User

Untitled

a guest
May 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. /* sample-checkbox.js */
  2.  
  3. /** External Module Dependencies **/
  4. import React, {Component} from 'react'
  5. import cn from 'classnames'
  6. import Divider from 'material-ui/Divider'
  7. import TextField from 'material-ui/TextField'
  8. import Checkbox from 'material-ui/Checkbox';
  9.  
  10. /** Internal Module Dependencies **/
  11. import * as style from '../styles/style.css'
  12.  
  13. export default class SampleCheckbox extends Component {
  14. constructor(props) {
  15. super(props)
  16.  
  17. this.state = {
  18. selectedIndex: 0,
  19. paymentMethods: {},
  20. }
  21.  
  22. this.updateSelectedPaymentMethods = this.updateSelectedPaymentMethods.bind(this)
  23. }
  24.  
  25. componentWillMount() {
  26. this.props.getAppliedPayments(this.props.invoiceOrder)
  27. }
  28.  
  29. componentWillUpdate(nextProps, nextState) {
  30. this.props.getAppliedPayments(this.props.invoiceOrder)
  31. }
  32.  
  33. shouldComponentUpdate(nextProps, nextState) {
  34. if (JSON.stringify(nextProps) == JSON.stringify(this.props) &&
  35. JSON.stringify(nextState) == JSON.stringify(this.state)) {
  36. return false
  37. }
  38. else {
  39. return true
  40. }
  41. }
  42.  
  43. updateSelectedPaymentMethods(event, isInputChecked) {
  44. var paymentMethods = this.state.paymentMethods
  45.  
  46. paymentMethods[event.target.value] = isInputChecked
  47. this.setState({ paymentMethods: paymentMethods })
  48. }
  49.  
  50. select = (index) => this.setState({selectedIndex: index})
  51.  
  52. render() {
  53. return (
  54. <div className={cn(style.reviewPanel)}>
  55. <div className={cn(style.paymentTotalRow)}>
  56. <div className={cn(style.selectPaymentMethodContainer)}>
  57. <label style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: '12px', lineHeight: '22px', marginTop: '14px' }}>Payment Methods</label>
  58. <div className={cn(style.paymentMethods)}>
  59. <Checkbox
  60. className={cn(style.paymentMethod)}
  61. value='bank_transfer'
  62. iconStyle={{marginRight: '8px'}}
  63. label='Bank Transfer'
  64. labelStyle={{width: 'auto'}}
  65. style={{padding: '5px 2px', margin: '0 20px 0 0', width: 'auto'}}
  66. onCheck={this.updateSelectedPaymentMethods} />
  67. <Checkbox
  68. className={cn(style.paymentMethod)}
  69. value='debit_payment'
  70. iconStyle={{marginRight: '8px'}}
  71. label='Debit Card'
  72. labelStyle={{width: 'auto'}}
  73. style={{padding: '5px 2px', margin: '0 20px 0 0', width: 'auto'}}
  74. onCheck={this.updateSelectedPaymentMethods} />
  75. </div>
  76. </div>
  77. <div className={cn(style.paymentMethodContainer)}>
  78. {(this.state.paymentMethods['bank_transfer'] && (
  79. <div>
  80. <label style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: '12px', lineHeight: '22px', marginTop: '14px' }}>Bank Transfer</label>
  81. <div className={cn(style.paymentMethods)}>
  82. <TextField
  83. disabled={true}
  84. floatingLabelText='Payment Method Details'/>
  85. </div>
  86. </div>
  87. ))}
  88.  
  89. {(this.state.paymentMethods['debit_payment'] && (
  90. <div>
  91. <label style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: '12px', lineHeight: '22px', marginTop: '14px' }}>Debit Card</label>
  92. <div className={cn(style.paymentMethods)}>
  93. <TextField
  94. disabled={true}
  95. floatingLabelText='Payment Method Details' />
  96. </div>
  97. </div>
  98. ))}
  99. </div>
  100. </div>
  101. </div>
  102. )
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement