From 46b9df3279f51479cfc607cbce8fb8b73bef69f7 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Wed, 6 Oct 2021 16:11:06 +0200 Subject: Initial commit --- src/components/SearchForm.js | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/components/SearchForm.js (limited to 'src/components/SearchForm.js') diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js new file mode 100644 index 0000000..0dc288c --- /dev/null +++ b/src/components/SearchForm.js @@ -0,0 +1,72 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { Button, Select, Input, Icon } from "semantic-ui-react"; + +class SearchForm extends React.Component { + static propTypes = { + filter: PropTypes.func.isRequired + }; + + constructor(props) { + super(props); + this.state = { + field: "default-field", + value: "" + }; + + this.clearSearch = this.clearSearch.bind(this); + this.handleInput = this.handleInput.bind(this); + this.submitSearch = this.submitSearch.bind(this); + } + + handleInput(e) { + this.setState({ + [e.target.name]: e.target.value + }); + } + + clearSearch(_) { + this.setState({ value: "" }); + this.props.filter(null, null); + } + + submitSearch(e) { + e.preventDefault(); + this.props.filter(this.state.field, this.state.value); + } + + render() { + const searchOptions = [ + { + key: "default-field", + value: "default-field", + text: "Default field" + } + ]; + return ( +
+ + + +