-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) O3-3589: Enable data table to search based on all table columns (…
…#76) * revamped search bar * cleanup
- Loading branch information
Showing
8 changed files
with
85 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Order } from "@openmrs/esm-patient-common-lib"; | ||
import { useMemo } from "react"; | ||
|
||
interface CustomOrder extends Omit<Order, "orderer" | "patient"> { | ||
patient: string; | ||
patientUuid: string; | ||
orderer: string; | ||
} | ||
|
||
export default function useSearchResults( | ||
tableEntries: CustomOrder[], | ||
searchString | ||
): CustomOrder[] { | ||
const searchResults = useMemo(() => { | ||
if (searchString && searchString.trim() !== "") { | ||
const search = searchString.toLowerCase(); | ||
return tableEntries.filter((eachDataRow) => | ||
Object.entries(eachDataRow).some(([header, value]) => { | ||
return `${value}`.toLowerCase().includes(search); | ||
}) | ||
); | ||
} | ||
|
||
return tableEntries; | ||
}, [searchString, tableEntries]); | ||
|
||
return searchResults; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters