diff --git a/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx b/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx index 3e8816db..9236ceac 100644 --- a/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx +++ b/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx @@ -1,19 +1,31 @@ -import { useRef, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { ComboBox } from '@carbon/react'; import HttpService from '../../../services/HttpService'; +interface typeaheadArgs { + id: string; + onChange: any; + options: any; + value: any; +} + export default function TypeaheadWidget({ id, onChange, options: { category, itemFormat }, -}: { - id: string; - onChange: any; - options: any; -}) { + value, + ...args +}: typeaheadArgs) { const pathForCategory = (inputText: string) => { return `/connector-proxy/typeahead/${category}?prefix=${inputText}&limit=100`; }; + console.log('args', args); + console.log('value', value); + console.log('itemFormat', itemFormat); + + // if (value) { + // + // } const lastSearchTerm = useRef(''); const [items, setItems] = useState([]); @@ -21,6 +33,13 @@ export default function TypeaheadWidget({ const itemFormatRegex = /[^{}]+(?=})/g; const itemFormatSubstitutions = itemFormat.match(itemFormatRegex); + useEffect(() => { + if (value) { + setSelectedItem(JSON.parse(value)); + } + typeaheadSearch(value); + }, [value]); + const itemToString = (item: any) => { if (!item) { return null; @@ -51,12 +70,16 @@ export default function TypeaheadWidget({ } }; + console.log('selectedItem', selectedItem); + return ( { + console.log('event.selectedItem', event.selectedItem); setSelectedItem(event.selectedItem); - onChange(itemToString(event.selectedItem)); + // onChange(itemToString(event.selectedItem)); + onChange(JSON.stringify(event.selectedItem)); }} id={id} items={items} diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index 15d9c2d6..bd5c0e00 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -84,6 +84,7 @@ export default function TaskShow() { }, [params]); const processSubmitResult = (result: any) => { + return null; removeError(); if (result.ok) { navigate(`/tasks`);