Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/u4 x 356 fix lab results data table #40

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@
"@carbon/react": "1.14.0"
},
"packageManager": "[email protected]"
}
}
77 changes: 38 additions & 39 deletions src/patient-chart/laboratory-order.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,31 @@
];

const [searchTerm, setSearchTerm] = useState("");
const [items, setItems] = useState(sortedLabRequests);
const [initialTests] = useState(sortedLabRequests);

const handleChange = useCallback(
(val) => {
const searchText = val?.target?.value;
setSearchTerm(searchText);
if (searchText?.trim() == "") {
setItems(initialTests);
} else {
let filteredItems = [];
items.map((item) => {
const newArray = item?.orders?.filter(
(order) =>
order?.concept?.display
.toLowerCase()
.startsWith(searchText?.toLowerCase()) == true
);
if (newArray.length >= 1) {
filteredItems.push(item);
}
});

setItems(filteredItems);
}
},
[items, initialTests]
);
const [items, setItems] = useState(paginatedLabEntries);
const [initialTests, setInitialTests] = useState(paginatedLabEntries);


Check failure on line 119 in src/patient-chart/laboratory-order.component.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `⏎`
const handleChange = useCallback((event) => {
const searchText = event?.target?.value?.trim().toLowerCase();
setSearchTerm(searchText);
}, []);

useEffect(() => {
if (!searchTerm) {
setItems(initialTests);
} else {
const filteredItems = initialTests.filter((item) =>
item?.orders?.some((order) =>
order?.concept?.display.toLowerCase().includes(searchTerm)
)
);
setItems(filteredItems);
}
}, [searchTerm, initialTests]);

useEffect(() => {
setInitialTests(paginatedLabEntries);
}, [paginatedLabEntries]);

const EmailButtonAction: React.FC = () => {
const launchSendEmailModal = useCallback(() => {
Expand Down Expand Up @@ -227,7 +224,9 @@
};

const tableRows = useMemo(() => {
return paginatedLabEntries?.map((entry, index) => ({

Check failure on line 227 in src/patient-chart/laboratory-order.component.tsx

View workflow job for this annotation

GitHub Actions / build

Replace `⏎····return·items?.map((entry,·index)·=>·({⏎` with `····return·items?.map((entry,·index)·=>·({`
return items?.map((entry, index) => ({

...entry,
id: entry.uuid,
orderDate: {
Expand Down Expand Up @@ -278,7 +277,7 @@
),
},
}));
}, [paginatedLabEntries]);
}, [items]);

if (loading) {
return <DataTableSkeleton role="progressbar" />;
Expand All @@ -299,7 +298,14 @@
size={isTablet ? "lg" : "sm"}
experimentalAutoAlign={true}
>
{({ rows, headers, getHeaderProps, getTableProps, getRowProps }) => (
{({
rows,
headers,
getHeaderProps,
getTableProps,
getRowProps,
onInputChange,
}) => (
<TableContainer className={styles.tableContainer}>
<TableToolbar
style={{
Expand Down Expand Up @@ -429,7 +435,7 @@
page={currentPage}
pageSize={currentPageSize}
pageSizes={pageSizes}
totalItems={paginatedLabEntries?.length}
totalItems={sortedLabRequests?.length}
className={styles.pagination}
onChange={({ pageSize, page }) => {
if (pageSize !== currentPageSize) {
Expand All @@ -446,13 +452,6 @@
</div>
);
}

// return (
// <div>
// {/* <div className={styles.headerBtnContainer}></div> */}
// <EmptyState displayText={"Tests Ordered"} headerTitle={"Tests Ordered"} />
// </div>
// );
};

export default LaboratoryOrder;
Loading