@burdenoff/microfe-healthybowl 2026.710.21 → 2026.710.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/healthybowl/HealthyBowlRoot.js +93 -85
- package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
- package/dist/healthybowl/HealthyBowlRoutes.js +98 -86
- package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
- package/dist/healthybowl/hooks/useHealthyBowlWithdrawal.js +237 -0
- package/dist/healthybowl/hooks/useHealthyBowlWithdrawal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/AnimalDetailsPage.js +532 -527
- package/dist/healthybowl/pages/livestock/AnimalDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/MedicationLibraryPage.js +387 -0
- package/dist/healthybowl/pages/livestock/MedicationLibraryPage.js.map +1 -0
- package/dist/healthybowl/pages/livestock/WithdrawalAlertsPage.js +286 -0
- package/dist/healthybowl/pages/livestock/WithdrawalAlertsPage.js.map +1 -0
- package/dist/healthybowl/pages/livestock/WithdrawalCalendarPage.js +182 -0
- package/dist/healthybowl/pages/livestock/WithdrawalCalendarPage.js.map +1 -0
- package/dist/healthybowl/pages/livestock/withdrawal/AnimalWithdrawalCard.js +166 -0
- package/dist/healthybowl/pages/livestock/withdrawal/AnimalWithdrawalCard.js.map +1 -0
- package/dist/healthybowl/pages/livestock/withdrawal/LogTreatmentModal.js +274 -0
- package/dist/healthybowl/pages/livestock/withdrawal/LogTreatmentModal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/withdrawal/WithdrawalNav.js +40 -0
- package/dist/healthybowl/pages/livestock/withdrawal/WithdrawalNav.js.map +1 -0
- package/dist/healthybowl/pages/livestock/withdrawal/status.js +53 -0
- package/dist/healthybowl/pages/livestock/withdrawal/status.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../../../context/HealthyBowlContext.js";
|
|
2
|
+
import { StatusBadge as t } from "../../../components/StatusBadge.js";
|
|
3
|
+
import "../../../components/index.js";
|
|
4
|
+
import { GET_ANIMAL_STATUS as n } from "../../../hooks/useHealthyBowlWithdrawal.js";
|
|
5
|
+
import { PRODUCE_LABEL as r, formatClearDate as i, statusMeta as a, statusPillLabel as o } from "./status.js";
|
|
6
|
+
import { useI18n as s } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
7
|
+
import { Ban as c, Lock as l, ShieldCheck as u } from "lucide-react";
|
|
8
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
|
+
import { useQuery as p } from "@apollo/client/react";
|
|
10
|
+
//#region src/healthybowl/pages/livestock/withdrawal/AnimalWithdrawalCard.tsx
|
|
11
|
+
var m = "00000000-0000-0000-0000-000000000001", h = ({ animalId: h }) => {
|
|
12
|
+
let { t: g } = s(), { workspaceId: _ } = e(), { data: v } = p(n, {
|
|
13
|
+
variables: {
|
|
14
|
+
context: { workspaceId: _ || m },
|
|
15
|
+
animalId: h
|
|
16
|
+
},
|
|
17
|
+
fetchPolicy: "cache-and-network",
|
|
18
|
+
skip: !h
|
|
19
|
+
}), y = v?.getHealthyBowlAnimalWithdrawalStatus;
|
|
20
|
+
if (!y || y.treatments.length === 0) return null;
|
|
21
|
+
let b = y.produceStatuses.filter((e) => e.status !== "NOT_APPLICABLE"), x = y.produceStatuses.filter((e) => e.blocked).map((e) => ({
|
|
22
|
+
produce: e.produceType,
|
|
23
|
+
label: r[e.produceType]
|
|
24
|
+
}));
|
|
25
|
+
return /* @__PURE__ */ f("div", {
|
|
26
|
+
className: "space-y-4",
|
|
27
|
+
children: [
|
|
28
|
+
y.blocked ? /* @__PURE__ */ f("div", {
|
|
29
|
+
className: "flex items-center gap-2 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-sm text-status-error-text",
|
|
30
|
+
children: [/* @__PURE__ */ d(c, { className: "h-4 w-4 shrink-0" }), /* @__PURE__ */ f("span", { children: [
|
|
31
|
+
/* @__PURE__ */ d("strong", {
|
|
32
|
+
className: "font-semibold",
|
|
33
|
+
children: g("healthybowl.withdrawal.animal.blocked", "BLOCKED")
|
|
34
|
+
}),
|
|
35
|
+
" —",
|
|
36
|
+
" ",
|
|
37
|
+
g("healthybowl.withdrawal.animal.blockedDetail", "Produce from this animal cannot be sold or harvested until its withdrawal period ends.")
|
|
38
|
+
] })]
|
|
39
|
+
}) : /* @__PURE__ */ f("div", {
|
|
40
|
+
className: "flex items-center gap-2 rounded-lg border border-status-success-border bg-status-success-bgSubtle px-4 py-3 text-sm text-status-success-text",
|
|
41
|
+
children: [/* @__PURE__ */ d(u, { className: "h-4 w-4 shrink-0" }), g("healthybowl.withdrawal.animal.clear", "All produce is clear — safe to sell and harvest.")]
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ f("div", {
|
|
44
|
+
className: "grid grid-cols-1 gap-4 md:grid-cols-3",
|
|
45
|
+
children: [/* @__PURE__ */ d("div", {
|
|
46
|
+
className: "md:col-span-2 grid grid-cols-1 gap-3 sm:grid-cols-2",
|
|
47
|
+
children: b.map((e) => {
|
|
48
|
+
let n = a(e.status);
|
|
49
|
+
return /* @__PURE__ */ f("div", {
|
|
50
|
+
className: `rounded-lg border border-l-4 border-border-subtle bg-bg-surface p-3 ${n.rail}`,
|
|
51
|
+
children: [/* @__PURE__ */ f("div", {
|
|
52
|
+
className: "flex items-center justify-between",
|
|
53
|
+
children: [/* @__PURE__ */ d("span", {
|
|
54
|
+
className: "font-medium text-text-primary",
|
|
55
|
+
children: r[e.produceType]
|
|
56
|
+
}), /* @__PURE__ */ d(t, {
|
|
57
|
+
variant: n.variant,
|
|
58
|
+
label: o(e.status, e.daysLeft),
|
|
59
|
+
dot: !0
|
|
60
|
+
})]
|
|
61
|
+
}), /* @__PURE__ */ d("div", {
|
|
62
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
63
|
+
children: e.blocked ? g("healthybowl.withdrawal.animal.clearsIn", "Clears in {{days}} days — {{date}}", {
|
|
64
|
+
days: e.daysLeft,
|
|
65
|
+
date: i(e.clearDate)
|
|
66
|
+
}) : g("healthybowl.withdrawal.animal.safe", "Safe to sell")
|
|
67
|
+
})]
|
|
68
|
+
}, e.produceType);
|
|
69
|
+
})
|
|
70
|
+
}), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("div", {
|
|
71
|
+
className: "mb-2 text-sm font-semibold text-text-primary",
|
|
72
|
+
children: g("healthybowl.withdrawal.animal.produceActions", "Produce Actions")
|
|
73
|
+
}), x.length === 0 ? /* @__PURE__ */ d("p", {
|
|
74
|
+
className: "text-xs text-text-secondary",
|
|
75
|
+
children: g("healthybowl.withdrawal.animal.noBlocked", "No produce is blocked.")
|
|
76
|
+
}) : /* @__PURE__ */ d("div", {
|
|
77
|
+
className: "space-y-2",
|
|
78
|
+
children: x.map((e) => /* @__PURE__ */ d("div", {
|
|
79
|
+
className: "space-y-1.5",
|
|
80
|
+
children: [
|
|
81
|
+
g("healthybowl.withdrawal.animal.actionList", "List {{p}} on Marketplace", { p: e.label }),
|
|
82
|
+
g("healthybowl.withdrawal.animal.actionHarvest", "Harvest {{p}}", { p: e.label }),
|
|
83
|
+
g("healthybowl.withdrawal.animal.actionTrace", "Add {{p}} to Trace Batch", { p: e.label })
|
|
84
|
+
].map((e) => /* @__PURE__ */ f("div", {
|
|
85
|
+
className: "flex items-center gap-2 rounded-md bg-bg-sunken px-3 py-2 text-xs text-text-secondary",
|
|
86
|
+
"aria-disabled": !0,
|
|
87
|
+
children: [/* @__PURE__ */ d(l, { className: "h-3.5 w-3.5 shrink-0 text-status-error-text" }), /* @__PURE__ */ f("span", { children: [
|
|
88
|
+
e,
|
|
89
|
+
" — ",
|
|
90
|
+
g("healthybowl.withdrawal.animal.blockedShort", "blocked")
|
|
91
|
+
] })]
|
|
92
|
+
}, e))
|
|
93
|
+
}, e.produce))
|
|
94
|
+
})] })]
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ f("div", {
|
|
97
|
+
className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
|
|
98
|
+
children: [/* @__PURE__ */ d("div", {
|
|
99
|
+
className: "mb-3 text-sm font-semibold text-text-primary",
|
|
100
|
+
children: g("healthybowl.withdrawal.animal.history", "Medication treatment history")
|
|
101
|
+
}), /* @__PURE__ */ d("div", {
|
|
102
|
+
className: "overflow-x-auto",
|
|
103
|
+
children: /* @__PURE__ */ f("table", {
|
|
104
|
+
className: "w-full text-sm",
|
|
105
|
+
children: [/* @__PURE__ */ d("thead", { children: /* @__PURE__ */ f("tr", {
|
|
106
|
+
className: "border-b border-border-subtle text-left text-xs text-text-secondary",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ d("th", {
|
|
109
|
+
className: "pb-2 pr-3 font-medium",
|
|
110
|
+
children: g("healthybowl.withdrawal.animal.date", "Date")
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ d("th", {
|
|
113
|
+
className: "pb-2 pr-3 font-medium",
|
|
114
|
+
children: g("healthybowl.withdrawal.animal.medication", "Medication")
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ d("th", {
|
|
117
|
+
className: "pb-2 pr-3 font-medium",
|
|
118
|
+
children: g("healthybowl.withdrawal.animal.doseRoute", "Dose / Route")
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ d("th", {
|
|
121
|
+
className: "pb-2 pr-3 font-medium",
|
|
122
|
+
children: g("healthybowl.withdrawal.animal.vet", "Vet")
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ d("th", {
|
|
125
|
+
className: "pb-2 font-medium",
|
|
126
|
+
children: g("healthybowl.withdrawal.animal.withdrawal", "Withdrawal")
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}) }), /* @__PURE__ */ d("tbody", { children: y.treatments.map((e) => {
|
|
130
|
+
let t = [];
|
|
131
|
+
return e.milkWithdrawalDays !== null && t.push(`milk ${e.milkWithdrawalDays}d`), e.meatWithdrawalDays !== null && t.push(`meat ${e.meatWithdrawalDays}d`), e.eggsWithdrawalDays !== null && t.push(`eggs ${e.eggsWithdrawalDays}d`), /* @__PURE__ */ f("tr", {
|
|
132
|
+
className: "border-b border-border-subtle/60 last:border-0",
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ d("td", {
|
|
135
|
+
className: "py-2 pr-3 text-text-secondary",
|
|
136
|
+
children: i(e.treatmentDate)
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ d("td", {
|
|
139
|
+
className: "py-2 pr-3 text-text-primary",
|
|
140
|
+
children: e.medicationName
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ d("td", {
|
|
143
|
+
className: "py-2 pr-3 text-text-secondary",
|
|
144
|
+
children: [e.dose, e.route].filter(Boolean).join(" · ") || "—"
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ d("td", {
|
|
147
|
+
className: "py-2 pr-3 text-text-secondary",
|
|
148
|
+
children: e.administeredBy || "—"
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ d("td", {
|
|
151
|
+
className: "py-2 text-text-secondary",
|
|
152
|
+
children: t.join(" · ") || "—"
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}, e.id);
|
|
156
|
+
}) })]
|
|
157
|
+
})
|
|
158
|
+
})]
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
export { h as AnimalWithdrawalCard };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=AnimalWithdrawalCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimalWithdrawalCard.js","names":[],"sources":["../../../../../src/healthybowl/pages/livestock/withdrawal/AnimalWithdrawalCard.tsx"],"sourcesContent":["/**\n * Per-animal withdrawal status card for the animal detail page (BOFF-2885, mock view 4).\n *\n * Shows the BLOCKED banner, per-produce status + countdown, gated produce actions (list /\n * harvest / trace are locked while under withdrawal) and the medication treatment history.\n * Self-contained: queries the animal's real withdrawal status; renders nothing when the animal\n * has no medication treatments, so it's a no-op on animals that were never treated.\n */\nimport { useQuery } from '@apollo/client/react';\nimport { Ban, Lock, ShieldCheck } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { StatusBadge } from '../../../components';\nimport {\n GET_ANIMAL_STATUS,\n type AnimalWithdrawalStatusData,\n type ProduceType,\n} from '../../../hooks/useHealthyBowlWithdrawal';\nimport { useHealthyBowl } from '../../../context/HealthyBowlContext';\nimport { PRODUCE_LABEL, formatClearDate, statusMeta, statusPillLabel } from './status';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\nexport const AnimalWithdrawalCard = ({ animalId }: { animalId: string }) => {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const ctx = { workspaceId: workspaceId || FALLBACK_WORKSPACE_ID };\n\n const { data } = useQuery<AnimalWithdrawalStatusData, { context: { workspaceId: string }; animalId: string }>(\n GET_ANIMAL_STATUS,\n {\n variables: { context: ctx, animalId },\n fetchPolicy: 'cache-and-network',\n skip: !animalId,\n }\n );\n\n const status = data?.getHealthyBowlAnimalWithdrawalStatus;\n // No treatments recorded → nothing to show (keeps clean animals uncluttered).\n if (!status || status.treatments.length === 0) return null;\n\n const applicable = status.produceStatuses.filter((p) => p.status !== 'NOT_APPLICABLE');\n const blockedProduce = status.produceStatuses.filter((p) => p.blocked);\n\n const produceActions: Array<{ produce: ProduceType; label: string }> = blockedProduce.map((p) => ({\n produce: p.produceType,\n label: PRODUCE_LABEL[p.produceType],\n }));\n\n return (\n <div className=\"space-y-4\">\n {/* BLOCKED / clear banner */}\n {status.blocked ? (\n <div className=\"flex items-center gap-2 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-sm text-status-error-text\">\n <Ban className=\"h-4 w-4 shrink-0\" />\n <span>\n <strong className=\"font-semibold\">{t('healthybowl.withdrawal.animal.blocked', 'BLOCKED')}</strong> —{' '}\n {t(\n 'healthybowl.withdrawal.animal.blockedDetail',\n 'Produce from this animal cannot be sold or harvested until its withdrawal period ends.'\n )}\n </span>\n </div>\n ) : (\n <div className=\"flex items-center gap-2 rounded-lg border border-status-success-border bg-status-success-bgSubtle px-4 py-3 text-sm text-status-success-text\">\n <ShieldCheck className=\"h-4 w-4 shrink-0\" />\n {t('healthybowl.withdrawal.animal.clear', 'All produce is clear — safe to sell and harvest.')}\n </div>\n )}\n\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-3\">\n {/* Per-produce status */}\n <div className=\"md:col-span-2 grid grid-cols-1 gap-3 sm:grid-cols-2\">\n {applicable.map((p) => {\n const meta = statusMeta(p.status);\n return (\n <div\n key={p.produceType}\n className={`rounded-lg border border-l-4 border-border-subtle bg-bg-surface p-3 ${meta.rail}`}\n >\n <div className=\"flex items-center justify-between\">\n <span className=\"font-medium text-text-primary\">{PRODUCE_LABEL[p.produceType]}</span>\n <StatusBadge variant={meta.variant} label={statusPillLabel(p.status, p.daysLeft)} dot />\n </div>\n <div className=\"mt-1 text-xs text-text-secondary\">\n {p.blocked\n ? t('healthybowl.withdrawal.animal.clearsIn', 'Clears in {{days}} days — {{date}}', {\n days: p.daysLeft,\n date: formatClearDate(p.clearDate),\n })\n : t('healthybowl.withdrawal.animal.safe', 'Safe to sell')}\n </div>\n </div>\n );\n })}\n </div>\n\n {/* Produce actions (gated) */}\n <div>\n <div className=\"mb-2 text-sm font-semibold text-text-primary\">\n {t('healthybowl.withdrawal.animal.produceActions', 'Produce Actions')}\n </div>\n {produceActions.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.withdrawal.animal.noBlocked', 'No produce is blocked.')}\n </p>\n ) : (\n <div className=\"space-y-2\">\n {produceActions.map((a) => (\n <div key={a.produce} className=\"space-y-1.5\">\n {[\n t('healthybowl.withdrawal.animal.actionList', 'List {{p}} on Marketplace', { p: a.label }),\n t('healthybowl.withdrawal.animal.actionHarvest', 'Harvest {{p}}', { p: a.label }),\n t('healthybowl.withdrawal.animal.actionTrace', 'Add {{p}} to Trace Batch', { p: a.label }),\n ].map((label) => (\n <div\n key={label}\n className=\"flex items-center gap-2 rounded-md bg-bg-sunken px-3 py-2 text-xs text-text-secondary\"\n aria-disabled\n >\n <Lock className=\"h-3.5 w-3.5 shrink-0 text-status-error-text\" />\n <span>\n {label} — {t('healthybowl.withdrawal.animal.blockedShort', 'blocked')}\n </span>\n </div>\n ))}\n </div>\n ))}\n </div>\n )}\n </div>\n </div>\n\n {/* Treatment history */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <div className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.withdrawal.animal.history', 'Medication treatment history')}\n </div>\n <div className=\"overflow-x-auto\">\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"pb-2 pr-3 font-medium\">{t('healthybowl.withdrawal.animal.date', 'Date')}</th>\n <th className=\"pb-2 pr-3 font-medium\">{t('healthybowl.withdrawal.animal.medication', 'Medication')}</th>\n <th className=\"pb-2 pr-3 font-medium\">\n {t('healthybowl.withdrawal.animal.doseRoute', 'Dose / Route')}\n </th>\n <th className=\"pb-2 pr-3 font-medium\">{t('healthybowl.withdrawal.animal.vet', 'Vet')}</th>\n <th className=\"pb-2 font-medium\">{t('healthybowl.withdrawal.animal.withdrawal', 'Withdrawal')}</th>\n </tr>\n </thead>\n <tbody>\n {status.treatments.map((tr) => {\n const parts: string[] = [];\n if (tr.milkWithdrawalDays !== null) parts.push(`milk ${tr.milkWithdrawalDays}d`);\n if (tr.meatWithdrawalDays !== null) parts.push(`meat ${tr.meatWithdrawalDays}d`);\n if (tr.eggsWithdrawalDays !== null) parts.push(`eggs ${tr.eggsWithdrawalDays}d`);\n return (\n <tr key={tr.id} className=\"border-b border-border-subtle/60 last:border-0\">\n <td className=\"py-2 pr-3 text-text-secondary\">{formatClearDate(tr.treatmentDate)}</td>\n <td className=\"py-2 pr-3 text-text-primary\">{tr.medicationName}</td>\n <td className=\"py-2 pr-3 text-text-secondary\">\n {[tr.dose, tr.route].filter(Boolean).join(' · ') || '—'}\n </td>\n <td className=\"py-2 pr-3 text-text-secondary\">{tr.administeredBy || '—'}</td>\n <td className=\"py-2 text-text-secondary\">{parts.join(' · ') || '—'}</td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;AAoBA,IAAM,IAAwB,wCAEjB,KAAwB,EAAE,kBAAqC;CAC1E,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,mBAAgB,GAAgB,EAGlC,EAAE,YAAS,EACf,GACA;EACE,WAAW;GAAE,SALL,EAAE,aAAa,KAAe,GAAuB;GAKlC;GAAU;EACrC,aAAa;EACb,MAAM,CAAC;EACR,CACF,EAEK,IAAS,GAAM;AAErB,KAAI,CAAC,KAAU,EAAO,WAAW,WAAW,EAAG,QAAO;CAEtD,IAAM,IAAa,EAAO,gBAAgB,QAAQ,MAAM,EAAE,WAAW,iBAAiB,EAGhF,IAFiB,EAAO,gBAAgB,QAAQ,MAAM,EAAE,QAAQ,CAEgB,KAAK,OAAO;EAChG,SAAS,EAAE;EACX,OAAO,EAAc,EAAE;EACxB,EAAE;AAEH,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GAEG,EAAO,UACN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAK,WAAU,oBAAqB,CAAA,EACpC,kBAAC,QAAD,EAAA,UAAA;KACE,kBAAC,UAAD;MAAQ,WAAU;gBAAiB,EAAE,yCAAyC,UAAU;MAAU,CAAA;;KAAG;KACpG,EACC,+CACA,yFACD;KACI,EAAA,CAAA,CACH;QAEN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAa,WAAU,oBAAqB,CAAA,E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SACpE,kBAAC,MAAD;UAAI,WAAU;oBACX,CAAC,EAAG,MAAM,EAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,KAAK,MAAM,IAAI;UACjD,CAAA;SACL,kBAAC,MAAD;UAAI,WAAU;oBAAiC,EAAG,kBAAkB;UAAS,CAAA;SAC7E,kBAAC,MAAD;UAAI,WAAU;oBAA4B,EAAM,KAAK,MAAM,IAAI;UAAS,CAAA;SACrE;UARI,EAAG,GAQP;QAEP,EACI,CAAA,CACF;;KACJ,CAAA,CACF;;GACF"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Modal as e } from "../../../components/Modal.js";
|
|
2
|
+
import "../../../components/index.js";
|
|
3
|
+
import { PRODUCE_LABEL as t, formatClearDate as n, previewClearDate as r } from "./status.js";
|
|
4
|
+
import { useEffect as ee, useMemo as te, useState as i } from "react";
|
|
5
|
+
import { useI18n as ne } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
6
|
+
import { CheckCircle2 as re, Info as ie, Syringe as a, XCircle as o } from "lucide-react";
|
|
7
|
+
import { Fragment as ae, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { Button as l, Input as u, Select as d, SelectContent as f, SelectItem as p, SelectTrigger as m, SelectValue as h, Textarea as oe } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
//#region src/healthybowl/pages/livestock/withdrawal/LogTreatmentModal.tsx
|
|
10
|
+
var se = [
|
|
11
|
+
"IM",
|
|
12
|
+
"IV",
|
|
13
|
+
"IM/IV",
|
|
14
|
+
"SC",
|
|
15
|
+
"Oral",
|
|
16
|
+
"Intramammary",
|
|
17
|
+
"Topical",
|
|
18
|
+
"Other"
|
|
19
|
+
], g = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), _ = ({ open: _, onClose: v, animals: ce, library: y, defaultAnimalId: b, onSubmit: le }) => {
|
|
20
|
+
let { t: x } = ne(), [S, C] = i(b ?? ""), [w, T] = i(""), [E, D] = i(""), [O, k] = i("IM"), [A, j] = i(""), [M, N] = i(g()), [P, F] = i(""), [I, L] = i(""), [R, z] = i(""), [B, V] = i(""), [H, U] = i(""), [W, G] = i(!1), [K, q] = i(null);
|
|
21
|
+
ee(() => {
|
|
22
|
+
_ && (C(b ?? ""), T(""), D(""), k("IM"), j(""), N(g()), F(""), L(""), z(""), V(""), U(""), q(null));
|
|
23
|
+
}, [_, b]);
|
|
24
|
+
let ue = te(() => y.find((e) => e.id === w) ?? null, [y, w]), de = (e) => {
|
|
25
|
+
T(e);
|
|
26
|
+
let t = y.find((t) => t.id === e);
|
|
27
|
+
t && (D(t.name), k(t.route || "Other"), z(t.milkWithdrawalDays === null ? "" : String(t.milkWithdrawalDays)), V(t.meatWithdrawalDays === null ? "" : String(t.meatWithdrawalDays)), U(t.eggsWithdrawalDays === null ? "" : String(t.eggsWithdrawalDays)));
|
|
28
|
+
}, J = (e) => {
|
|
29
|
+
let t = e.trim();
|
|
30
|
+
if (t === "") return null;
|
|
31
|
+
let n = Number(t);
|
|
32
|
+
return Number.isFinite(n) && n >= 0 ? Math.round(n) : null;
|
|
33
|
+
}, Y = J(R), X = J(B), Z = J(H), fe = [
|
|
34
|
+
{
|
|
35
|
+
produce: "MILK",
|
|
36
|
+
days: Y,
|
|
37
|
+
clear: r(M, Y)
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
produce: "MEAT",
|
|
41
|
+
days: X,
|
|
42
|
+
clear: r(M, X)
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
produce: "EGGS",
|
|
46
|
+
days: Z,
|
|
47
|
+
clear: r(M, Z)
|
|
48
|
+
}
|
|
49
|
+
], Q = S && E.trim() && M, pe = async () => {
|
|
50
|
+
if (!Q) {
|
|
51
|
+
q(x("healthybowl.withdrawal.log.validation", "Choose an animal, a medication and a treatment date."));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
G(!0), q(null);
|
|
55
|
+
try {
|
|
56
|
+
await le({
|
|
57
|
+
animalId: S,
|
|
58
|
+
medicationLibraryItemId: w || null,
|
|
59
|
+
medicationName: E.trim(),
|
|
60
|
+
route: O,
|
|
61
|
+
dose: A.trim() || null,
|
|
62
|
+
treatmentDate: M,
|
|
63
|
+
administeredBy: P.trim() || null,
|
|
64
|
+
notes: I.trim() || null,
|
|
65
|
+
milkWithdrawalDays: Y,
|
|
66
|
+
meatWithdrawalDays: X,
|
|
67
|
+
eggsWithdrawalDays: Z
|
|
68
|
+
}), v();
|
|
69
|
+
} catch (e) {
|
|
70
|
+
q(e instanceof Error ? e.message : String(e));
|
|
71
|
+
} finally {
|
|
72
|
+
G(!1);
|
|
73
|
+
}
|
|
74
|
+
}, $ = "mb-1 block text-sm font-medium text-text-primary";
|
|
75
|
+
return /* @__PURE__ */ s(e, {
|
|
76
|
+
open: _,
|
|
77
|
+
onClose: v,
|
|
78
|
+
title: x("healthybowl.withdrawal.log.title", "Log a Treatment"),
|
|
79
|
+
description: x("healthybowl.withdrawal.log.description", "Record a medication and we compute the safe-by date per produce."),
|
|
80
|
+
size: "lg",
|
|
81
|
+
footer: /* @__PURE__ */ c(ae, { children: [/* @__PURE__ */ s(l, {
|
|
82
|
+
variant: "outline",
|
|
83
|
+
onClick: v,
|
|
84
|
+
disabled: W,
|
|
85
|
+
children: x("healthybowl.common.cancel", "Cancel")
|
|
86
|
+
}), /* @__PURE__ */ c(l, {
|
|
87
|
+
onClick: pe,
|
|
88
|
+
disabled: W || !Q,
|
|
89
|
+
children: [/* @__PURE__ */ s(a, { className: "h-4 w-4" }), W ? x("healthybowl.withdrawal.log.saving", "Saving…") : x("healthybowl.withdrawal.log.save", "Save Treatment & Start Withdrawal")]
|
|
90
|
+
})] }),
|
|
91
|
+
children: /* @__PURE__ */ c("div", {
|
|
92
|
+
className: "grid gap-4 md:grid-cols-2",
|
|
93
|
+
children: [/* @__PURE__ */ c("div", {
|
|
94
|
+
className: "space-y-4",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
97
|
+
className: $,
|
|
98
|
+
children: x("healthybowl.withdrawal.log.animal", "Animal")
|
|
99
|
+
}), /* @__PURE__ */ c(d, {
|
|
100
|
+
value: S,
|
|
101
|
+
onValueChange: C,
|
|
102
|
+
children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, { placeholder: x("healthybowl.withdrawal.log.animalPlaceholder", "Select an animal") }) }), /* @__PURE__ */ s(f, { children: ce.map((e) => /* @__PURE__ */ c(p, {
|
|
103
|
+
value: e.id,
|
|
104
|
+
children: [
|
|
105
|
+
e.tagNumber,
|
|
106
|
+
" · ",
|
|
107
|
+
e.name
|
|
108
|
+
]
|
|
109
|
+
}, e.id)) })]
|
|
110
|
+
})] }),
|
|
111
|
+
/* @__PURE__ */ c("div", { children: [
|
|
112
|
+
/* @__PURE__ */ s("label", {
|
|
113
|
+
className: $,
|
|
114
|
+
children: x("healthybowl.withdrawal.log.medication", "Medication")
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ c(d, {
|
|
117
|
+
value: w,
|
|
118
|
+
onValueChange: de,
|
|
119
|
+
children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, { placeholder: x("healthybowl.withdrawal.log.medicationPlaceholder", "Pick from the library") }) }), /* @__PURE__ */ s(f, { children: y.map((e) => /* @__PURE__ */ c(p, {
|
|
120
|
+
value: e.id,
|
|
121
|
+
children: [
|
|
122
|
+
e.name,
|
|
123
|
+
" · ",
|
|
124
|
+
e.className
|
|
125
|
+
]
|
|
126
|
+
}, e.id)) })]
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ s(u, {
|
|
129
|
+
className: "mt-2",
|
|
130
|
+
value: E,
|
|
131
|
+
onChange: (e) => D(e.target.value),
|
|
132
|
+
placeholder: x("healthybowl.withdrawal.log.medicationNamePlaceholder", "or type a medication name")
|
|
133
|
+
}),
|
|
134
|
+
ue ? /* @__PURE__ */ c("div", {
|
|
135
|
+
className: "mt-2 flex flex-wrap items-center gap-1.5 rounded-md border border-status-success-border bg-status-success-bgSubtle px-3 py-2 text-xs text-status-success-text",
|
|
136
|
+
children: [/* @__PURE__ */ s(ie, { className: "h-3.5 w-3.5" }), x("healthybowl.withdrawal.log.autofill", "Auto-filled from the medication library — you can override.")]
|
|
137
|
+
}) : null
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ c("div", {
|
|
140
|
+
className: "grid grid-cols-2 gap-3",
|
|
141
|
+
children: [/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
142
|
+
className: $,
|
|
143
|
+
children: x("healthybowl.withdrawal.log.dose", "Dose")
|
|
144
|
+
}), /* @__PURE__ */ s(u, {
|
|
145
|
+
value: A,
|
|
146
|
+
onChange: (e) => j(e.target.value),
|
|
147
|
+
placeholder: "20 mg/kg"
|
|
148
|
+
})] }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
149
|
+
className: $,
|
|
150
|
+
children: x("healthybowl.withdrawal.log.route", "Route")
|
|
151
|
+
}), /* @__PURE__ */ c(d, {
|
|
152
|
+
value: O,
|
|
153
|
+
onValueChange: k,
|
|
154
|
+
children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, {}) }), /* @__PURE__ */ s(f, { children: se.map((e) => /* @__PURE__ */ s(p, {
|
|
155
|
+
value: e,
|
|
156
|
+
children: e
|
|
157
|
+
}, e)) })]
|
|
158
|
+
})] })]
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ c("div", {
|
|
161
|
+
className: "grid grid-cols-2 gap-3",
|
|
162
|
+
children: [/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
163
|
+
className: $,
|
|
164
|
+
htmlFor: "treatment-date",
|
|
165
|
+
children: x("healthybowl.withdrawal.log.treatmentDate", "Treatment date")
|
|
166
|
+
}), /* @__PURE__ */ s("input", {
|
|
167
|
+
id: "treatment-date",
|
|
168
|
+
type: "date",
|
|
169
|
+
value: M,
|
|
170
|
+
onChange: (e) => N(e.target.value),
|
|
171
|
+
className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
|
|
172
|
+
})] }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
173
|
+
className: $,
|
|
174
|
+
children: x("healthybowl.withdrawal.log.administeredBy", "Administered by")
|
|
175
|
+
}), /* @__PURE__ */ s(u, {
|
|
176
|
+
value: P,
|
|
177
|
+
onChange: (e) => F(e.target.value),
|
|
178
|
+
placeholder: "Dr. …"
|
|
179
|
+
})] })]
|
|
180
|
+
}),
|
|
181
|
+
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
182
|
+
className: $,
|
|
183
|
+
children: x("healthybowl.withdrawal.log.withdrawalDays", "Withdrawal period (days)")
|
|
184
|
+
}), /* @__PURE__ */ s("div", {
|
|
185
|
+
className: "grid grid-cols-3 gap-3",
|
|
186
|
+
children: [
|
|
187
|
+
[
|
|
188
|
+
"Milk",
|
|
189
|
+
R,
|
|
190
|
+
z
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
"Meat",
|
|
194
|
+
B,
|
|
195
|
+
V
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"Eggs",
|
|
199
|
+
H,
|
|
200
|
+
U
|
|
201
|
+
]
|
|
202
|
+
].map(([e, t, n]) => /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("span", {
|
|
203
|
+
className: "mb-1 block text-xs text-text-secondary",
|
|
204
|
+
children: e
|
|
205
|
+
}), /* @__PURE__ */ s(u, {
|
|
206
|
+
type: "number",
|
|
207
|
+
min: 0,
|
|
208
|
+
value: t,
|
|
209
|
+
onChange: (e) => n(e.target.value),
|
|
210
|
+
placeholder: "—"
|
|
211
|
+
})] }, e))
|
|
212
|
+
})] }),
|
|
213
|
+
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
|
|
214
|
+
className: $,
|
|
215
|
+
children: x("healthybowl.withdrawal.log.notes", "Notes")
|
|
216
|
+
}), /* @__PURE__ */ s(oe, {
|
|
217
|
+
rows: 2,
|
|
218
|
+
value: I,
|
|
219
|
+
onChange: (e) => L(e.target.value),
|
|
220
|
+
placeholder: x("healthybowl.withdrawal.log.notesPlaceholder", "Reason for treatment…")
|
|
221
|
+
})] })
|
|
222
|
+
]
|
|
223
|
+
}), /* @__PURE__ */ c("div", {
|
|
224
|
+
className: "space-y-3",
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ c("div", {
|
|
227
|
+
className: "rounded-lg border border-border-subtle bg-bg-sunken p-4",
|
|
228
|
+
children: [/* @__PURE__ */ s("div", {
|
|
229
|
+
className: "mb-3 text-sm font-semibold text-text-primary",
|
|
230
|
+
children: x("healthybowl.withdrawal.log.computed", "Computed clear dates")
|
|
231
|
+
}), /* @__PURE__ */ s("ul", {
|
|
232
|
+
className: "space-y-2.5",
|
|
233
|
+
children: fe.map((e) => /* @__PURE__ */ c("li", {
|
|
234
|
+
className: "flex items-center gap-2 text-sm",
|
|
235
|
+
children: [
|
|
236
|
+
e.clear ? /* @__PURE__ */ s(re, { className: "h-4 w-4 shrink-0 text-status-success-text" }) : /* @__PURE__ */ s(o, { className: "h-4 w-4 shrink-0 text-text-tertiary" }),
|
|
237
|
+
/* @__PURE__ */ s("span", {
|
|
238
|
+
className: "font-medium text-text-primary",
|
|
239
|
+
children: t[e.produce]
|
|
240
|
+
}),
|
|
241
|
+
e.clear ? /* @__PURE__ */ c("span", {
|
|
242
|
+
className: "text-text-secondary",
|
|
243
|
+
children: [
|
|
244
|
+
x("healthybowl.withdrawal.log.clears", "clears"),
|
|
245
|
+
" ",
|
|
246
|
+
n(e.clear),
|
|
247
|
+
" ",
|
|
248
|
+
e.days === null ? "" : `(${e.days}d)`
|
|
249
|
+
]
|
|
250
|
+
}) : /* @__PURE__ */ s("span", {
|
|
251
|
+
className: "text-text-tertiary",
|
|
252
|
+
children: x("healthybowl.withdrawal.log.notApplicable", "Not applicable")
|
|
253
|
+
})
|
|
254
|
+
]
|
|
255
|
+
}, e.produce))
|
|
256
|
+
})]
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ s("p", {
|
|
259
|
+
className: "text-xs text-text-tertiary",
|
|
260
|
+
children: x("healthybowl.withdrawal.log.hint", "Milk, meat or eggs from this animal can't be sold, harvested or trace-batched until the clear date. We'll notify you when each clears.")
|
|
261
|
+
}),
|
|
262
|
+
K ? /* @__PURE__ */ s("div", {
|
|
263
|
+
className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
|
|
264
|
+
children: K
|
|
265
|
+
}) : null
|
|
266
|
+
]
|
|
267
|
+
})]
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
//#endregion
|
|
272
|
+
export { _ as LogTreatmentModal };
|
|
273
|
+
|
|
274
|
+
//# sourceMappingURL=LogTreatmentModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogTreatmentModal.js","names":[],"sources":["../../../../../src/healthybowl/pages/livestock/withdrawal/LogTreatmentModal.tsx"],"sourcesContent":["/**\n * Log a Treatment — records a medication administration and starts the withdrawal countdown.\n * Roadmap 13 · BOFF-2885 (mock views 1 & 2).\n *\n * Selecting a medication from the library auto-fills the per-produce withdrawal days (the\n * farmer can override), and the computed clear dates preview updates live. No fabricated data:\n * every option comes from the animals list and the real medication library.\n */\nimport { useEffect, useMemo, useState } from 'react';\nimport { CheckCircle2, Info, Syringe, XCircle } from 'lucide-react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../../components';\nimport type { MedicationLibraryItem } from '../../../hooks/useHealthyBowlWithdrawal';\nimport { PRODUCE_LABEL, formatClearDate, previewClearDate } from './status';\n\ninterface AnimalOption {\n id: string;\n tagNumber: string;\n name: string;\n type: string;\n}\n\ninterface LogTreatmentModalProps {\n open: boolean;\n onClose: () => void;\n animals: AnimalOption[];\n library: MedicationLibraryItem[];\n defaultAnimalId?: string;\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst ROUTES = ['IM', 'IV', 'IM/IV', 'SC', 'Oral', 'Intramammary', 'Topical', 'Other'];\n\nconst todayIso = () => new Date().toISOString().slice(0, 10);\n\nexport const LogTreatmentModal = ({\n open,\n onClose,\n animals,\n library,\n defaultAnimalId,\n onSubmit,\n}: LogTreatmentModalProps) => {\n const { t } = useI18n();\n\n const [animalId, setAnimalId] = useState(defaultAnimalId ?? '');\n const [medicationId, setMedicationId] = useState('');\n const [medicationName, setMedicationName] = useState('');\n const [route, setRoute] = useState('IM');\n const [dose, setDose] = useState('');\n const [treatmentDate, setTreatmentDate] = useState(todayIso());\n const [administeredBy, setAdministeredBy] = useState('');\n const [notes, setNotes] = useState('');\n const [milkDays, setMilkDays] = useState<string>('');\n const [meatDays, setMeatDays] = useState<string>('');\n const [eggsDays, setEggsDays] = useState<string>('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Reset form each time the modal opens.\n useEffect(() => {\n if (open) {\n setAnimalId(defaultAnimalId ?? '');\n setMedicationId('');\n setMedicationName('');\n setRoute('IM');\n setDose('');\n setTreatmentDate(todayIso());\n setAdministeredBy('');\n setNotes('');\n setMilkDays('');\n setMeatDays('');\n setEggsDays('');\n setError(null);\n }\n }, [open, defaultAnimalId]);\n\n const selectedMedication = useMemo(() => library.find((m) => m.id === medicationId) ?? null, [library, medicationId]);\n\n const applyMedication = (id: string) => {\n setMedicationId(id);\n const med = library.find((m) => m.id === id);\n if (med) {\n setMedicationName(med.name);\n setRoute(med.route || 'Other');\n setMilkDays(med.milkWithdrawalDays === null ? '' : String(med.milkWithdrawalDays));\n setMeatDays(med.meatWithdrawalDays === null ? '' : String(med.meatWithdrawalDays));\n setEggsDays(med.eggsWithdrawalDays === null ? '' : String(med.eggsWithdrawalDays));\n }\n };\n\n const parseDays = (v: string): number | null => {\n const s = v.trim();\n if (s === '') return null;\n const n = Number(s);\n return Number.isFinite(n) && n >= 0 ? Math.round(n) : null;\n };\n\n const milk = parseDays(milkDays);\n const meat = parseDays(meatDays);\n const eggs = parseDays(eggsDays);\n\n const previews: Array<{ produce: keyof typeof PRODUCE_LABEL; days: number | null; clear: string | null }> = [\n { produce: 'MILK', days: milk, clear: previewClearDate(treatmentDate, milk) },\n { produce: 'MEAT', days: meat, clear: previewClearDate(treatmentDate, meat) },\n { produce: 'EGGS', days: eggs, clear: previewClearDate(treatmentDate, eggs) },\n ];\n\n const canSubmit = animalId && medicationName.trim() && treatmentDate;\n\n const handleSubmit = async () => {\n if (!canSubmit) {\n setError(t('healthybowl.withdrawal.log.validation', 'Choose an animal, a medication and a treatment date.'));\n return;\n }\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n animalId,\n medicationLibraryItemId: medicationId || null,\n medicationName: medicationName.trim(),\n route,\n dose: dose.trim() || null,\n treatmentDate,\n administeredBy: administeredBy.trim() || null,\n notes: notes.trim() || null,\n milkWithdrawalDays: milk,\n meatWithdrawalDays: meat,\n eggsWithdrawalDays: eggs,\n });\n onClose();\n } catch (err) {\n setError(err instanceof Error ? err.message : String(err));\n } finally {\n setSubmitting(false);\n }\n };\n\n const fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\n const dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.withdrawal.log.title', 'Log a Treatment')}\n description={t(\n 'healthybowl.withdrawal.log.description',\n 'Record a medication and we compute the safe-by date per produce.'\n )}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSubmit} disabled={submitting || !canSubmit}>\n <Syringe className=\"h-4 w-4\" />\n {submitting\n ? t('healthybowl.withdrawal.log.saving', 'Saving…')\n : t('healthybowl.withdrawal.log.save', 'Save Treatment & Start Withdrawal')}\n </Button>\n </>\n }\n >\n <div className=\"grid gap-4 md:grid-cols-2\">\n <div className=\"space-y-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.animal', 'Animal')}</label>\n <Select value={animalId} onValueChange={setAnimalId}>\n <SelectTrigger>\n <SelectValue placeholder={t('healthybowl.withdrawal.log.animalPlaceholder', 'Select an animal')} />\n </SelectTrigger>\n <SelectContent>\n {animals.map((a) => (\n <SelectItem key={a.id} value={a.id}>\n {a.tagNumber} · {a.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.medication', 'Medication')}</label>\n <Select value={medicationId} onValueChange={applyMedication}>\n <SelectTrigger>\n <SelectValue\n placeholder={t('healthybowl.withdrawal.log.medicationPlaceholder', 'Pick from the library')}\n />\n </SelectTrigger>\n <SelectContent>\n {library.map((m) => (\n <SelectItem key={m.id} value={m.id}>\n {m.name} · {m.className}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n <Input\n className=\"mt-2\"\n value={medicationName}\n onChange={(e) => setMedicationName(e.target.value)}\n placeholder={t('healthybowl.withdrawal.log.medicationNamePlaceholder', 'or type a medication name')}\n />\n {selectedMedication ? (\n <div className=\"mt-2 flex flex-wrap items-center gap-1.5 rounded-md border border-status-success-border bg-status-success-bgSubtle px-3 py-2 text-xs text-status-success-text\">\n <Info className=\"h-3.5 w-3.5\" />\n {t(\n 'healthybowl.withdrawal.log.autofill',\n 'Auto-filled from the medication library — you can override.'\n )}\n </div>\n ) : null}\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.dose', 'Dose')}</label>\n <Input value={dose} onChange={(e) => setDose(e.target.value)} placeholder=\"20 mg/kg\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.route', 'Route')}</label>\n <Select value={route} onValueChange={setRoute}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {ROUTES.map((r) => (\n <SelectItem key={r} value={r}>\n {r}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel} htmlFor=\"treatment-date\">\n {t('healthybowl.withdrawal.log.treatmentDate', 'Treatment date')}\n </label>\n <input\n id=\"treatment-date\"\n type=\"date\"\n value={treatmentDate}\n onChange={(e) => setTreatmentDate(e.target.value)}\n className={dateInput}\n />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.administeredBy', 'Administered by')}</label>\n <Input value={administeredBy} onChange={(e) => setAdministeredBy(e.target.value)} placeholder=\"Dr. …\" />\n </div>\n </div>\n\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.withdrawal.log.withdrawalDays', 'Withdrawal period (days)')}\n </label>\n <div className=\"grid grid-cols-3 gap-3\">\n {(\n [\n ['Milk', milkDays, setMilkDays],\n ['Meat', meatDays, setMeatDays],\n ['Eggs', eggsDays, setEggsDays],\n ] as const\n ).map(([lbl, val, setter]) => (\n <div key={lbl}>\n <span className=\"mb-1 block text-xs text-text-secondary\">{lbl}</span>\n <Input type=\"number\" min={0} value={val} onChange={(e) => setter(e.target.value)} placeholder=\"—\" />\n </div>\n ))}\n </div>\n </div>\n\n <div>\n <label className={fieldLabel}>{t('healthybowl.withdrawal.log.notes', 'Notes')}</label>\n <Textarea\n rows={2}\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder={t('healthybowl.withdrawal.log.notesPlaceholder', 'Reason for treatment…')}\n />\n </div>\n </div>\n\n {/* Computed clear dates */}\n <div className=\"space-y-3\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken p-4\">\n <div className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.withdrawal.log.computed', 'Computed clear dates')}\n </div>\n <ul className=\"space-y-2.5\">\n {previews.map((p) => (\n <li key={p.produce} className=\"flex items-center gap-2 text-sm\">\n {p.clear ? (\n <CheckCircle2 className=\"h-4 w-4 shrink-0 text-status-success-text\" />\n ) : (\n <XCircle className=\"h-4 w-4 shrink-0 text-text-tertiary\" />\n )}\n <span className=\"font-medium text-text-primary\">{PRODUCE_LABEL[p.produce]}</span>\n {p.clear ? (\n <span className=\"text-text-secondary\">\n {t('healthybowl.withdrawal.log.clears', 'clears')} {formatClearDate(p.clear)}{' '}\n {p.days !== null ? `(${p.days}d)` : ''}\n </span>\n ) : (\n <span className=\"text-text-tertiary\">\n {t('healthybowl.withdrawal.log.notApplicable', 'Not applicable')}\n </span>\n )}\n </li>\n ))}\n </ul>\n </div>\n <p className=\"text-xs text-text-tertiary\">\n {t(\n 'healthybowl.withdrawal.log.hint',\n \"Milk, meat or eggs from this animal can't be sold, harvested or trace-batched until the clear date. We'll notify you when each clears.\"\n )}\n </p>\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;;AAyCA,IAAM,KAAS;CAAC;CAAM;CAAM;CAAS;CAAM;CAAQ;CAAgB;CAAW;CAAQ,EAEhF,2BAAiB,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG,EAE/C,KAAqB,EAChC,SACA,YACA,aACA,YACA,oBACA,mBAC4B;CAC5B,IAAM,EAAE,SAAM,IAAS,EAEjB,CAAC,GAAU,KAAe,EAAS,KAAmB,GAAG,EACzD,CAAC,GAAc,KAAmB,EAAS,GAAG,EAC9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AAU;oBAAhB;WACG,EAAE,qCAAqC,SAAS;WAAC;WAAE,EAAgB,EAAE,MAAM;WAAE;WAC7E,EAAE,SAAS,OAAwB,KAAjB,IAAI,EAAE,KAAK;WACzB;cAEP,kBAAC,QAAD;UAAM,WAAU;oBACb,EAAE,4CAA4C,iBAAiB;UAC3D,CAAA;SAEN;UAjBI,EAAE,QAiBN,CACL;OACC,CAAA,CACD;;KACN,kBAAC,KAAD;MAAG,WAAU;gBACV,EACC,mCACA,yIACD;MACC,CAAA;KACH,IACC,kBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA,GACJ;KACA;MACF;;EACA,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { cn as e } from "../../../utils/helpers.js";
|
|
2
|
+
import { useBasePath as t } from "../../../hooks/useBasePath.js";
|
|
3
|
+
import { useI18n as n } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
4
|
+
import { Link as r, useLocation as i } from "react-router-dom";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/healthybowl/pages/livestock/withdrawal/WithdrawalNav.tsx
|
|
7
|
+
var o = () => {
|
|
8
|
+
let { t: o } = n(), { buildPath: s } = t(), { pathname: c } = i(), l = s("livestock/withdrawal-alerts");
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: "inline-flex flex-wrap gap-1 rounded-lg border border-border-subtle bg-bg-surface p-1",
|
|
11
|
+
children: [
|
|
12
|
+
{
|
|
13
|
+
to: l,
|
|
14
|
+
label: o("healthybowl.withdrawal.nav.alerts", "Active Alerts"),
|
|
15
|
+
exact: !0
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
to: `${l}/library`,
|
|
19
|
+
label: o("healthybowl.withdrawal.nav.library", "Medication Library"),
|
|
20
|
+
exact: !1
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
to: `${l}/calendar`,
|
|
24
|
+
label: o("healthybowl.withdrawal.nav.calendar", "Clear-Date Calendar"),
|
|
25
|
+
exact: !1
|
|
26
|
+
}
|
|
27
|
+
].map((t) => {
|
|
28
|
+
let n = t.exact ? c === t.to : c.startsWith(t.to);
|
|
29
|
+
return /* @__PURE__ */ a(r, {
|
|
30
|
+
to: t.to,
|
|
31
|
+
className: e("rounded-md px-3 py-1.5 text-sm transition-colors", n ? "bg-bg-sunken font-medium text-text-primary" : "text-text-secondary hover:text-text-primary"),
|
|
32
|
+
children: t.label
|
|
33
|
+
}, t.to);
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { o as WithdrawalNav };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=WithdrawalNav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithdrawalNav.js","names":[],"sources":["../../../../../src/healthybowl/pages/livestock/withdrawal/WithdrawalNav.tsx"],"sourcesContent":["/** Sub-navigation tabs shared by the three withdrawal views (BOFF-2885). */\nimport { Link, useLocation } from 'react-router-dom';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useBasePath } from '../../../hooks/useBasePath';\nimport { cn } from '../../../utils/helpers';\n\nexport const WithdrawalNav = () => {\n const { t } = useI18n();\n const { buildPath } = useBasePath();\n const { pathname } = useLocation();\n const root = buildPath('livestock/withdrawal-alerts');\n\n const tabs = [\n { to: root, label: t('healthybowl.withdrawal.nav.alerts', 'Active Alerts'), exact: true },\n { to: `${root}/library`, label: t('healthybowl.withdrawal.nav.library', 'Medication Library'), exact: false },\n { to: `${root}/calendar`, label: t('healthybowl.withdrawal.nav.calendar', 'Clear-Date Calendar'), exact: false },\n ];\n\n return (\n <div className=\"inline-flex flex-wrap gap-1 rounded-lg border border-border-subtle bg-bg-surface p-1\">\n {tabs.map((tab) => {\n const active = tab.exact ? pathname === tab.to : pathname.startsWith(tab.to);\n return (\n <Link\n key={tab.to}\n to={tab.to}\n className={cn(\n 'rounded-md px-3 py-1.5 text-sm transition-colors',\n active ? 'bg-bg-sunken font-medium text-text-primary' : 'text-text-secondary hover:text-text-primary'\n )}\n >\n {tab.label}\n </Link>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,UAAsB;CACjC,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,iBAAc,GAAa,EAC7B,EAAE,gBAAa,GAAa,EAC5B,IAAO,EAAU,8BAA8B;AAQrD,QACE,kBAAC,OAAD;EAAK,WAAU;YAPJ;GACX;IAAE,IAAI;IAAM,OAAO,EAAE,qCAAqC,gBAAgB;IAAE,OAAO;IAAM;GACzF;IAAE,IAAI,GAAG,EAAK;IAAW,OAAO,EAAE,sCAAsC,qBAAqB;IAAE,OAAO;IAAO;GAC7G;IAAE,IAAI,GAAG,EAAK;IAAY,OAAO,EAAE,uCAAuC,sBAAsB;IAAE,OAAO;IAAO;GACjH,CAIS,KAAK,MAAQ;GACjB,IAAM,IAAS,EAAI,QAAQ,MAAa,EAAI,KAAK,EAAS,WAAW,EAAI,GAAG;AAC5E,UACE,kBAAC,GAAD;IAEE,IAAI,EAAI;IACR,WAAW,EACT,oDACA,IAAS,+CAA+C,8CACzD;cAEA,EAAI;IACA,EARA,EAAI,GAQJ;IAET;EACE,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/healthybowl/pages/livestock/withdrawal/status.ts
|
|
2
|
+
var e = {
|
|
3
|
+
BLOCKED: {
|
|
4
|
+
variant: "error",
|
|
5
|
+
label: "Blocked — do not sell",
|
|
6
|
+
rail: "border-l-status-error-border"
|
|
7
|
+
},
|
|
8
|
+
UNDER_WITHDRAWAL: {
|
|
9
|
+
variant: "warning",
|
|
10
|
+
label: "Under withdrawal",
|
|
11
|
+
rail: "border-l-status-warning-border"
|
|
12
|
+
},
|
|
13
|
+
CLEARED: {
|
|
14
|
+
variant: "success",
|
|
15
|
+
label: "Cleared",
|
|
16
|
+
rail: "border-l-status-success-border"
|
|
17
|
+
},
|
|
18
|
+
NOT_APPLICABLE: {
|
|
19
|
+
variant: "muted",
|
|
20
|
+
label: "N/A",
|
|
21
|
+
rail: "border-l-border-subtle"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function t(t) {
|
|
25
|
+
return e[t] ?? e.NOT_APPLICABLE;
|
|
26
|
+
}
|
|
27
|
+
function n(e, t) {
|
|
28
|
+
return e === "CLEARED" ? "Cleared" : e === "NOT_APPLICABLE" ? "N/A" : e === "BLOCKED" ? t <= 0 ? "Blocked — do not sell" : `Blocked · ${t}d` : `Under withdrawal · ${t}d`;
|
|
29
|
+
}
|
|
30
|
+
var r = {
|
|
31
|
+
MILK: "Milk",
|
|
32
|
+
MEAT: "Meat",
|
|
33
|
+
EGGS: "Eggs"
|
|
34
|
+
};
|
|
35
|
+
function i(e) {
|
|
36
|
+
if (!e) return "—";
|
|
37
|
+
let t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
38
|
+
return Number.isNaN(t.getTime()) ? e : t.toLocaleDateString("en-GB", {
|
|
39
|
+
day: "2-digit",
|
|
40
|
+
month: "short",
|
|
41
|
+
year: "numeric",
|
|
42
|
+
timeZone: "UTC"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function a(e, t) {
|
|
46
|
+
if (t == null || !Number.isFinite(t) || t < 0) return null;
|
|
47
|
+
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
48
|
+
return Number.isNaN(n.getTime()) ? null : new Date(n.getTime() + t * 864e5).toISOString().slice(0, 10);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { r as PRODUCE_LABEL, i as formatClearDate, a as previewClearDate, t as statusMeta, n as statusPillLabel };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","names":[],"sources":["../../../../../src/healthybowl/pages/livestock/withdrawal/status.ts"],"sourcesContent":["/**\n * Shared presentation helpers for livestock withdrawal status (BOFF-2885).\n * Semantic tokens only — colour comes from the StatusBadge variant, never raw hex.\n */\nimport type { ProduceType, WithdrawalStatus } from '../../../hooks/useHealthyBowlWithdrawal';\n\ntype BadgeVariant = 'success' | 'warning' | 'error' | 'info' | 'default' | 'muted';\n\nexport interface StatusMeta {\n variant: BadgeVariant;\n label: string;\n /** Left-rail / dot token class for card treatments. */\n rail: string;\n}\n\nconst META: Record<WithdrawalStatus, StatusMeta> = {\n BLOCKED: { variant: 'error', label: 'Blocked — do not sell', rail: 'border-l-status-error-border' },\n UNDER_WITHDRAWAL: { variant: 'warning', label: 'Under withdrawal', rail: 'border-l-status-warning-border' },\n CLEARED: { variant: 'success', label: 'Cleared', rail: 'border-l-status-success-border' },\n NOT_APPLICABLE: { variant: 'muted', label: 'N/A', rail: 'border-l-border-subtle' },\n};\n\nexport function statusMeta(status: WithdrawalStatus): StatusMeta {\n return META[status] ?? META.NOT_APPLICABLE;\n}\n\n/** Short pill label with the countdown, e.g. \"Blocked · 0 days\", \"Under withdrawal · 26 days\". */\nexport function statusPillLabel(status: WithdrawalStatus, daysLeft: number): string {\n if (status === 'CLEARED') return 'Cleared';\n if (status === 'NOT_APPLICABLE') return 'N/A';\n if (status === 'BLOCKED') return daysLeft <= 0 ? 'Blocked — do not sell' : `Blocked · ${daysLeft}d`;\n return `Under withdrawal · ${daysLeft}d`;\n}\n\nexport const PRODUCE_LABEL: Record<ProduceType, string> = { MILK: 'Milk', MEAT: 'Meat', EGGS: 'Eggs' };\n\n/** Format an ISO (YYYY-MM-DD) clear date as \"02 Jul 2026\"; em-dash for null. */\nexport function formatClearDate(iso: string | null): string {\n if (!iso) return '—';\n const d = new Date(`${iso}T00:00:00Z`);\n if (Number.isNaN(d.getTime())) return iso;\n return d.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'UTC' });\n}\n\n/** Compute a client-side clear date preview: treatmentDate (ISO) + days → \"02 Jul 2026\". */\nexport function previewClearDate(treatmentDate: string, days: number | null): string | null {\n if (days === null || days === undefined || !Number.isFinite(days) || days < 0) return null;\n const base = new Date(`${treatmentDate}T00:00:00Z`);\n if (Number.isNaN(base.getTime())) return null;\n const clear = new Date(base.getTime() + days * 86_400_000);\n return clear.toISOString().slice(0, 10);\n}\n"],"mappings":";AAeA,IAAM,IAA6C;CACjD,SAAS;EAAE,SAAS;EAAS,OAAO;EAAyB,MAAM;EAAgC;CACnG,kBAAkB;EAAE,SAAS;EAAW,OAAO;EAAoB,MAAM;EAAkC;CAC3G,SAAS;EAAE,SAAS;EAAW,OAAO;EAAW,MAAM;EAAkC;CACzF,gBAAgB;EAAE,SAAS;EAAS,OAAO;EAAO,MAAM;EAA0B;CACnF;AAED,SAAgB,EAAW,GAAsC;AAC/D,QAAO,EAAK,MAAW,EAAK;;AAI9B,SAAgB,EAAgB,GAA0B,GAA0B;AAIlF,QAHI,MAAW,YAAkB,YAC7B,MAAW,mBAAyB,QACpC,MAAW,YAAkB,KAAY,IAAI,0BAA0B,aAAa,EAAS,KAC1F,sBAAsB,EAAS;;AAGxC,IAAa,IAA6C;CAAE,MAAM;CAAQ,MAAM;CAAQ,MAAM;CAAQ;AAGtG,SAAgB,EAAgB,GAA4B;AAC1D,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,oBAAI,IAAI,KAAK,GAAG,EAAI,YAAY;AAEtC,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,IAC/B,EAAE,mBAAmB,SAAS;EAAE,KAAK;EAAW,OAAO;EAAS,MAAM;EAAW,UAAU;EAAO,CAAC;;AAI5G,SAAgB,EAAiB,GAAuB,GAAoC;AAC1F,KAAI,KAAS,QAA8B,CAAC,OAAO,SAAS,EAAK,IAAI,IAAO,EAAG,QAAO;CACtF,IAAM,oBAAO,IAAI,KAAK,GAAG,EAAc,YAAY;AAGnD,QAFI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,OAC3B,IAAI,KAAK,EAAK,SAAS,GAAG,IAAO,MAAW,CAC7C,aAAa,CAAC,MAAM,GAAG,GAAG"}
|
package/package.json
CHANGED