Skip to content
This repository was archived by the owner on Oct 9, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export const pickAddress = (address) => {
return { type: 'PICK_ADDRESS', address };
}

export const completeAddress = address => {
return { type: 'COMPLETE_ADDRESS', address }
}

export const toggleAddressForm = () => {
return { type: 'TOGGLE_ADDRESS_FORM' };
}
Expand Down
46 changes: 33 additions & 13 deletions src/components/Address.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
import React, { Component } from 'react';
import { Panel } from 'react-bootstrap';
import React, { Component } from 'react'
import { ControlLabel,
FormControl,
FormGroup,
Panel
} from 'react-bootstrap'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'

import { completeAddress } from '../actions'

class Address extends Component {
constructor () {
super ()
this.handleChange = this._handleChange.bind(this)
}

_handleChange (event) {
this.props.completeAddress({ [ event.target.name ]: event.target.value })
}

render() {
const { cartAddress } = this.props
const title = (
<h3>Livraison</h3>
);

)
return (
<Panel header={ title }>
{ this.props.cartAddress ? this.props.cartAddress.streetAddress : '' }
{ cartAddress ? cartAddress.streetAddress : '' }
<hr />
<FormGroup>
<ControlLabel>Additional Information (digicode, etc...)</ControlLabel>
<FormControl name="description" type="description"
onChange={ this.handleChange.bind(this) } />
</FormGroup>
<FormGroup>
<ControlLabel>Floor</ControlLabel>
<FormControl name="floor" type="floor"
onChange={ this.handleChange } />
</FormGroup>
</Panel>
)
}
}

function mapStateToProps(state, props) {
return {
cartAddress: state.cartAddress,
};
}

export default withRouter(connect(mapStateToProps)(Address))
export default connect(({ cartAddress }) => ({ cartAddress }),
{ completeAddress })(Address)
2 changes: 2 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const cartAddress = (state = null, action) => {
return action.address['@id'];
case 'RESET_CHECKOUT':
return null;
case 'COMPLETE_ADDRESS':
return Object.assign({}, state, action.address)
case 'DISCONNECT':
if (state) {
const isNewAddress = !state.hasOwnProperty('@id')
Expand Down