Skip to content

Commit

Permalink
Added handleOnDelete function and props for customerData component
Browse files Browse the repository at this point in the history
  • Loading branch information
CesarRivasP committed Feb 8, 2019
1 parent f1804bc commit f3550bf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/containers/customer-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ class CustomerContainer extends Component {
this.props.history.goBack(); //Para indicar a que ruta se debe devolver
};

renderCustomerControl = (isEdit, isDelete) => {
const { customer } = this.props;
if(customer){ //cuando no venga en nulo
handleOnDelete = () => {
console.log('handleOnDelete');
};

renderCustomerControl = (isEdit, isDelete) => { //El match es un objeto, y eso es lo que viene como parametro
// const { customer } = this.props;

if(this.props.customer){ //cuando no venga en nulo
const CustomerControl = isEdit ? CustomerEdit : CustomerData;
return <CustomerControl
{...this.props.customer}
onSubmit={this.handleSubmit}
onBack={this.handleOnBack}
onSubmitSuccess={this.handleOnSubmitSuccess}
isDeleteAllow={!!isDelete} //isDeleteAllow debe ser un booleano, y para lograr que lo sea
// se usa la doble negacion. Si viene un valor thuthy, se transforma en true
onDelete={this.handleOnDelete}
/>
}
return null;
Expand All @@ -75,7 +83,7 @@ class CustomerContainer extends Component {
//Se puede definir rutas dinamicamente, y que estan esten anidadas
children={({ match: isEdit }) => (
<Route
path="/customers/:ci/del"
path="/customers/:ci/delete"
children={
({ match: isDelete }) => ( //--> alias
// this.renderCustomerControl(match)
Expand Down

0 comments on commit f3550bf

Please sign in to comment.