From 3d9df8c97b79b65e28427dd4504baad982664aaa Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 1 Feb 2017 22:32:43 -0600 Subject: [PATCH] Update table when saving. --- .../assets/js/bikes/components/BikeForm/index.jsx | 2 ++ .../assets/js/bikes/components/BikeModal/index.jsx | 5 ++++- .../assets/js/bikes/components/BikeTable/index.jsx | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx index 513bd8a..ea65bbf 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx +++ b/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(); }); } diff --git a/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx index b7c49a6..349c25e 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx +++ b/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 ? :
Unable to edit bike.
} + { this.state.bike ? + : +
Unable to edit bike.
+ } ); } diff --git a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx index 6c812e6..5eba1c2 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx +++ b/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} />