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

Default discontinued prescriptions to collapsed view #7780

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 32 additions & 0 deletions src/Components/Medicine/PrescriptionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@
? DISCHARGE_PRN_TKEYS
: DISCHARGE_NORMAL_TKEYS;

// Implementing collapsible view for each prescription entry
const [collapsedPrescriptions, setCollapsedPrescriptions] = useState<string[]>([]);

Check failure on line 59 in src/Components/Medicine/PrescriptionsTable.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `string[]` with `⏎····string[]⏎··`

const toggleCollapse = (id: string) => {
setCollapsedPrescriptions((prev) => {
if (prev.includes(id)) {
return prev.filter((prescriptionId) => prescriptionId !== id);
} else {
return [...prev, id];
}
});
};

// Default the view of discontinued prescriptions to collapsed
const discontinuedPrescriptions = data?.results.filter((prescription) => prescription.discontinued).map((prescription) => prescription.id) || [];

Check failure on line 72 in src/Components/Medicine/PrescriptionsTable.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·data?.results.filter((prescription)·=>·prescription.discontinued)` with `⏎····data?.results⏎······.filter((prescription)·=>·prescription.discontinued)⏎······`
useState(() => {
setCollapsedPrescriptions(discontinuedPrescriptions);
});

return (
<div>
{data?.results && (
Expand Down Expand Up @@ -205,6 +224,19 @@
) : (
"never"
),
// Adding a toggle button to expand/collapse the prescription details
actions: (
<button
onClick={() => toggleCollapse(obj.id)}
className="text-primary-600 hover:text-primary-900"
>
{collapsedPrescriptions.includes(obj.id) ? (
<CareIcon icon="l-angle-down" />
) : (
<CareIcon icon="l-angle-up" />
)}
</button>
),
})) || []
}
objectKeys={Object.values(tkeys)}
Expand Down
Loading