1 import React from "react";
2 import PropTypes from "prop-types";
3 import SearchTerm from "./SearchTerm";
5 const SearchTermsInput = ({
11 const handleAddTerm = (event) => {
12 event.preventDefault();
16 const handleRemoveTerm = (id) => {
20 const handleTermChange = (id, value) => {
21 onTermChange(id, value);
24 const createSearchTerms = () => {
25 const searchTerms = [];
26 for (const entry of terms.entries()) {
28 const value = entry[1];
33 onTermChange={handleTermChange}
34 onAddTerm={handleAddTerm}
35 onRemoveTerm={handleRemoveTerm}/>
37 searchTerms.push(searchTerm);
43 <div className="search-terms-input">
45 <button onClick={handleAddTerm}>Add term</button>
50 SearchTermsInput.propTypes = {
51 terms: PropTypes.object.isRequired,
52 onTermChange: PropTypes.func.isRequired,
53 onAddTerm: PropTypes.func.isRequired,
54 onRemoveTerm: PropTypes.func.isRequired,
57 export default SearchTermsInput;