import React, { useEffect } from 'react'; import { useSelector } from 'react-redux'; import { FormGroup, TextInput, TextArea } from '@patternfly/react-core'; import PropTypes from 'prop-types'; import SearchBar from 'foremanReact/components/SearchBar'; import { helpLabel } from './FormHelpers'; import { SelectField } from './SelectField'; const TemplateSearchField = ({ name, controller, labelText, required, defaultValue, setValue, values, }) => { const searchQuery = useSelector( state => state.autocomplete?.[name]?.searchQuery ); useEffect(() => { setValue({ ...values, [name]: searchQuery }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [searchQuery]); const id = name.replace(/ /g, '-'); return ( null} /> ); }; export const formatter = (input, values, setValue) => { const isSelectType = !!input?.options; const inputType = input.value_type; const isTextType = inputType === 'plain' || !inputType; // null defaults to plain const { name, required, hidden_value: hidden } = input; const labelText = input.description; const value = values[name]; const id = name.replace(/ /g, '-'); if (isSelectType) { const options = input.options.split(/\r?\n/).map(option => option.trim()); return ( setValue({ ...values, [name]: newValue })} /> ); } if (isTextType) { return (