Browse Source

Update table when saving.

feature/bike-tracking
Drew Larson 8 years ago
parent
commit
3d9df8c97b
  1. 2
      bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx
  2. 5
      bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx
  3. 5
      bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx

2
bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx

@ -95,6 +95,8 @@ class BikeForm extends React.Component {
throw new Error('Bad response from server');
}
console.log(response.json());
}).then(() => {
this.props.getBikes();
});
}

5
bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx

@ -65,7 +65,10 @@ export default class BikeModal extends React.Component {
open={this.state.open}
autoScrollBodyContent
>
{ this.state.bike ? <BikeForm bike={this.state.bike} editing={this.state.editing} /> : <div>Unable to edit bike.</div>}
{ this.state.bike ?
<BikeForm bike={this.state.bike} editing={this.state.editing} getBikes={this.props.getBikes} /> :
<div>Unable to edit bike.</div>
}
</Dialog>
</div>);
}

5
bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx

@ -38,6 +38,10 @@ export default class BikeTable extends React.Component {
}
componentDidMount() {
this.getBikes();
}
getBikes = () => {
fetch('/api/v1/bikes/', {
credentials: 'same-origin',
})
@ -119,6 +123,7 @@ export default class BikeTable extends React.Component {
bike={this.state.bikeModal.bike}
open={this.state.bikeModal.open}
editing={this.state.bikeModal.editing}
getBikes={this.getBikes}
/>
</div>
</div>

Loading…
Cancel
Save