diff --git a/src/billing-form/billing-form.component.tsx b/src/billing-form/billing-form.component.tsx index 8a110b4..108bbdc 100644 --- a/src/billing-form/billing-form.component.tsx +++ b/src/billing-form/billing-form.component.tsx @@ -26,6 +26,7 @@ import { TrashCan } from '@carbon/react/icons'; import fuzzy from 'fuzzy'; import { type BillabeItem } from '../types'; import { apiBasePath } from '../constants'; +import isEmpty from 'lodash-es/isEmpty'; type BillingFormProps = { patientUuid: string; @@ -47,9 +48,12 @@ const BillingForm: React.FC = ({ patientUuid, closeWorkspace } const [addedItems, setAddedItems] = useState([]); const [searchTerm, setSearchTerm] = useState(''); const debouncedSearchTerm = useDebounce(searchTerm); + const [disableSearch, setDisableSearch] = useState(true); const toggleSearch = (choiceSelected) => { - (document.getElementById('searchField') as HTMLInputElement).disabled = false; + if (!isEmpty(choiceSelected)) { + setDisableSearch(false); + } setCategory(choiceSelected === 'Stock Item' ? 'Stock Item' : 'Service'); }; @@ -82,7 +86,7 @@ const BillingForm: React.FC = ({ patientUuid, closeWorkspace } const anyInvalidQuantity = updatedItems.some((item) => item.Qnty <= 0); - setBillItems(updatedItems); + // setBillItems(updatedItems); setSaveDisabled(!isValid || anyInvalidQuantity); const updatedGrandTotal = updatedItems.reduce((acc, item) => acc + item.Total, 0); @@ -120,7 +124,7 @@ const BillingForm: React.FC = ({ patientUuid, closeWorkspace } } setBillItems(updatedItems); - setSearchOptions([]); + // setSearchOptions([]); calculateTotalAfterAddBillItem(updatedItems); (document.getElementById('searchField') as HTMLInputElement).value = ''; }; @@ -226,6 +230,10 @@ const BillingForm: React.FC = ({ patientUuid, closeWorkspace } ); }; + const handleClearSearchTerm = () => { + setSearchOptions([]); + }; + return (
@@ -244,15 +252,16 @@ const BillingForm: React.FC = ({ patientUuid, closeWorkspace } - +
    {searchOptions?.length > 0 && searchOptions?.map((row) => (