1
0
mirror of https://github.com/fspc/workstand.git synced 2025-02-23 01:13:22 -05:00

Update table when saving.

This commit is contained in:
Drew Larson 2017-02-01 22:32:43 -06:00
parent 846d07b894
commit 3d9df8c97b
3 changed files with 11 additions and 1 deletions

View File

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

View File

@ -65,7 +65,10 @@ export default class BikeModal extends React.Component {
open={this.state.open} open={this.state.open}
autoScrollBodyContent 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> </Dialog>
</div>); </div>);
} }

View File

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