Skip to content

Instantly share code, notes, and snippets.

@marr
Created February 29, 2016 23:15
Show Gist options
  • Save marr/f03788045965a9957ae7 to your computer and use it in GitHub Desktop.
Save marr/f03788045965a9957ae7 to your computer and use it in GitHub Desktop.
import React from 'react'
import AccountDetail from 'components/AccountDetail'
import CustomerForm from 'components/CustomerForm'
import CustomerPanel from 'components/CustomerPanel'
import SecurityPanel from 'components/SecurityPanel'
class Account extends React.Component {
constructor(props) {
super(props)
this.state = {
isEditing: true
}
this.edit = this.edit.bind(this)
this.handleEdit = this.handleEdit.bind(this)
}
edit(e) {
this.setState({ isEditing: true })
}
handleEdit(e) {
debugger // never hit
}
render() {
const { guest } = this.props
const { account, centre } = guest
const isEditing = this.state.isEditing
const form = {
initialValues: account,
handleSubmit: this.handleEdit
}
return (
<div className="guest-detail">
<h2>Account</h2>
<div className="col">
{ (isEditing) ? <CustomerForm {...form} /> : (
<CustomerPanel {...account} onEditClick={this.edit} />
) }
<SecurityPanel {...account} />
</div>
<div className="col">
<AccountDetail {...account} centre={centre} />
</div>
</div>
)
}
}
export default Account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment