From 5e8fb126a33f23e543a6c2f7c5bf951fb3ee8a41 Mon Sep 17 00:00:00 2001
From: haritowa <6107211+haritowa@users.noreply.github.com>
Date: Sat, 24 Oct 2026 17:53:18 +0000
Subject: [PATCH] refactor(medications): hand the lifecycle controls the
medication
LifecycleManageBody takes the medication (id, name, active, course
status) instead of one prop per field. The call site in
medication-detail-tabs.tsx shrinks to one line, so the course status
reaches the controls without growing a file the size ratchet holds.
---
.../detail/medication-detail-tabs.tsx | 7 +-----
.../destructive-zone-section.test.tsx | 10 ++++----
.../sections/destructive-zone-section.tsx | 24 +++++++++----------
3 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/src/components/medications/detail/medication-detail-tabs.tsx b/src/components/medications/detail/medication-detail-tabs.tsx
index ba0e5da5d..9cefc459a 100644
--- a/src/components/medications/detail/medication-detail-tabs.tsx
+++ b/src/components/medications/detail/medication-detail-tabs.tsx
@@ -923,12 +923,7 @@ export function MedicationDetailTabs({
defaultOpen={false}
>
-
+
{/* v1.40 (#1024) — the courses: when it was taken, and a new
course once the last one has ended. */}
diff --git a/src/components/medications/sections/__tests__/destructive-zone-section.test.tsx b/src/components/medications/sections/__tests__/destructive-zone-section.test.tsx
index 3e71ba1da..5992803ea 100644
--- a/src/components/medications/sections/__tests__/destructive-zone-section.test.tsx
+++ b/src/components/medications/sections/__tests__/destructive-zone-section.test.tsx
@@ -66,10 +66,12 @@ describe("End is offered only for a running course", () => {
,
diff --git a/src/components/medications/sections/destructive-zone-section.tsx b/src/components/medications/sections/destructive-zone-section.tsx
index 541d4ad8e..ae1c193c2 100644
--- a/src/components/medications/sections/destructive-zone-section.tsx
+++ b/src/components/medications/sections/destructive-zone-section.tsx
@@ -83,23 +83,23 @@ const PAUSE_HELPER_ID = "medication-detail-pause-helper";
* Bare (no section / card chrome); the caller supplies its own grouping.
*/
export function LifecycleManageBody({
- medicationId,
- medicationName,
- active,
- courseStatus,
+ medication,
onAfterAction,
}: {
- medicationId: string;
- medicationName: string;
- active: boolean;
- /** Where today sits in the course (server-resolved). */
- courseStatus?: CourseStatus;
+ medication: {
+ id: string;
+ name: string;
+ active: boolean;
+ /** Where today sits in the course (server-resolved). */
+ courseStatus?: CourseStatus;
+ };
onAfterAction?: () => void;
}) {
const { t } = useTranslations();
const queryClient = useQueryClient();
+ const medicationId = medication.id;
- const [paused, setPaused] = useState(!active);
+ const [paused, setPaused] = useState(!medication.active);
const [tier1Busy, setTier1Busy] = useState(false);
async function tier1Toggle(pauseNext: boolean) {
@@ -158,10 +158,10 @@ export function LifecycleManageBody({
/>
- {canEndCourse(courseStatus) && (
+ {canEndCourse(medication.courseStatus) && (
)}