Skip to content

Commit

Permalink
Add reset button
Browse files Browse the repository at this point in the history
  • Loading branch information
medhatdawoud committed Feb 25, 2019
1 parent 6032bab commit 93f365a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/buy-car-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class BuyCarForm extends Component {
models = [];

onBrandChange = (brand) => {
this.setState({selectedBrand:brand,selectedModel:''});
this.setState({selectedBrand:brand,selectedModel:null});
this.models = this.models = API_Data.models[brand.value].map(brand => ({
value: brand.toLowerCase(),
label: brand
Expand All @@ -36,12 +36,18 @@ export default class BuyCarForm extends Component {
this.setState({selectedModel:model});
}

resetSearch = () => {
this.setState({selectedBrand:null,selectedModel:null});
this.models = [];
}

render() {
const {selectedBrand, selectedModel, keywords} = this.state;
return (
<div className="card BuyCarForm">
<div className="card-header">
<strong>Buy a car</strong>
<button class="btn btn-sm btn-info float-right" onClick={this.resetSearch}>reset</button>
</div>
<div className="card-body">
<Dropdown label="Brand"
Expand Down

0 comments on commit 93f365a

Please sign in to comment.