1import { o as __toESM } from "./chunk-6z4oVpB-.js"; 2import { t as require_react } from "./react-CCT1erMQ.js"; 3import "./prop-types-BP3O0vhg.js"; 4import { t as require_jsx_runtime } from "./jsx-runtime-6ToSbptA.js"; 5import "./clsx-BbsgvS4T.js"; 6import "./typeof-CtObx4yR.js"; 7import "./Amplify-ydFdTLPK.js"; 8import { n as _objectSpread2, r as init_objectSpread2, t as _objectWithoutProperties } from "./objectWithoutProperties-Cgp7QKOy.js"; 9import "./types-CQ-ki0qK.js"; 10import "./amplifyUrl-DhBXUoj8.js"; 11import "./tslib.es6-CGMJRn24.js"; 12import "./api-BN7R4l5b.js"; 13import "./createCognitoUserPoolEndpointResolver-DIsnsOMn.js"; 14import "./auth-D-8td4-a.js"; 15import { a as formatCurrency, d as formatPercent } from "./helpers-BQW8LNh3.js"; 16import "./getCurrentUser-CO2hH9tr.js"; 17import "./_baseGetTag-CcQT-b-8.js"; 18import "./errors-CJ9PkTii.js"; 19import "./isObjectLike-C0C335kY.js"; 20import "./shim-BLxGA08a.js"; 21import "./use-isomorphic-layout-effect.browser.esm-BDjLKVP-.js"; 22import "./isSymbol-BD-EcKMA.js"; 23import "./debounce-CIlO4Yzq.js"; 24import "./dist-Cz4mcmaa.js"; 25import "./dist-DaeMORX8.js"; 26import "./react-dom-Dddidh9b.js"; 27import "./dist-DetJSI7l.js"; 28import "./dist-Dsgwk-jH.js"; 29import "./classPrivateFieldGet2-D2HqlEEJ.js"; 30import "./dist-javwCbI7.js"; 31import "./dist-DjKy_3Dj.js"; 32import "./Combination-CE9BhVA8.js"; 33import "./dist-BHtPb5hX.js"; 34import "./dist-C5RjQM0F.js"; 35import "./dist-SbNcsVrs.js"; 36import "./dist-BnVQncHy.js"; 37import { i as DropdownMenuItem, o as DropdownMenuSeparator } from "./dropdown-menu-NIFzDEaK.js"; 38import { a as SelectLabel, c as SelectValue, i as SelectItem, n as SelectContent, r as SelectGroup, s as SelectTrigger, t as Select } from "./select-8FJ_dY_9.js"; 39import "./dist-BpwkAU0Q.js"; 40import { C as useFetcher, F as useSearchParams, P as useRouteLoaderData, T as useLoaderData } from "./chunk-62JRHF6Z-z8JX8DDB.js"; 41import "./exports-PpHA8CsK.js"; 42import "./extends-7lTa5GQE.js"; 43import "./notifyManager-Bch6NZ-h.js"; 44import "./useBaseQuery-1WImwwVq.js"; 45import "./useInfiniteQuery-CX5ozztk.js"; 46import "./useMutation-k2qXTuOE.js"; 47import "./QueryClientProvider-DBT_lM_H.js"; 48import "./useQuery-DLS21iiV.js"; 49import "./constants-TZTPDohO.js"; 50import "./session-BF1M_iJk.js"; 51import "./iconPropTypes-C5chbmyn-CpVo52O4.js"; 52import "./bucket-0-Uq1JG5fZ.js"; 53import "./bucket-1-COAg-Eqq.js"; 54import "./bucket-3-DKA1ROBB.js"; 55import "./bucket-6-B3kg9Htr.js"; 56import "./bucket-10-Ca5cox4R.js"; 57import "./bucket-13-DojbEaO8.js"; 58import { r as Renew } from "./bucket-14-IUg4qkXR.js"; 59import "./bucket-15-CpBPyEaO.js"; 60import { n as TrashCan } from "./bucket-18-BV3V-3UN.js"; 61import "./dist-W5s9RbHT.js"; 62import "./dist-DCv7IJcI.js"; 63import "./createLucideIcon-DENnxagg.js"; 64import "./check-BFnH1yl0.js"; 65import "./chevron-right-CEcbN75N.js"; 66import "./utils-DL_RvPHk.js"; 67import { t as toast } from "./use-toast-CIbRNZGg.js"; 68import "./mixpanel.module-D03As0KW.js"; 69import "./subDays-vez96V8M.js"; 70import "./addMonths-C0iKCEqw.js"; 71import "./endOfMonth-h_W7cRKV.js"; 72import "./roundingMethods-DuMrTbDg.js"; 73import "./differenceInWeeks-B00-N4lk.js"; 74import "./client.gen-B5RyugF5.js"; 75import "./constants-BTubQFbu.js"; 76import { t as Button } from "./button-BgUr9YaP.js"; 77import "./tooltip-BQPMLsOF.js"; 78import { n as LongText_default } from "./LongText-Chh0tzMc.js"; 79import { t as Badge } from "./badge-BfOudBXs.js"; 80import "./useSessionQuery-CydkiRrr.js"; 81import "./bootstrap-BQ86EXdW.js"; 82import "./dist-C_Pp4NuF.js"; 83import { a as DialogFooter, c as DialogTrigger, i as DialogDescription, o as DialogHeader, r as DialogContent, s as DialogTitle, t as Dialog } from "./dialog-odsl4nrF.js"; 84import { n as track_default } from "./track-BOLPaScP.js"; 85import "./utils-BFgzP0mr.js"; 86import "./comments-Z3QCdchs.js"; 87import "./base-path-CtfbOIOI.js"; 88import "./zod-McvqnZjg.js"; 89import { t as Input } from "./input-wPGsBI9X.js"; 90import "./skeleton-DlrxaJwT.js"; 91import { t as v4_default } from "./v4-WmvKwL3y.js"; 92import { t as invariant } from "./tiny-invariant-DGRZ75gT.js"; 93import "./useDebounceCallback-CpDQu6xV.js"; 94import { a as getExpandedRowModel, o as getFilteredRowModel, r as createColumnHelper } from "./lib-BmE5oXwC.js"; 95import { a as TableHead, c as TableRow, n as TableBody, o as TableHeader, r as TableCell, s as TableHeaderRow, t as Table$1 } from "./table-BhizvUWs.js"; 96import "./reset-to-first-page-Buz3wC4q.js"; 97import "./filter-search-params-CGhr97jh.js"; 98import "./use-table-context-DYyO1Fg2.js"; 99import { _n as updateProcedureCardItem, jn as zProcedureCardItemUpdateRequest, ut as getProcedureCardItems } from "./sdk.gen-Ck47bYkT.js"; 100import "./client-BqXsOWRb.js"; 101import "./api-DBmJIxr0.js"; 102import "./useMatchesData-DA2pgjYw.js"; 103import "./api-r4p_4VL4.js"; 104import "./queries-IBfwHsl2.js"; 105import "./dist-C2D8DSus.js"; 106import "./popover-SmfnFw8c.js"; 107import { a as TableLayoutHeader, n as TableLayoutBody, o as TableLayoutHeaderRow, s as TableLayoutRoot } from "./table-layout-BMU5VJgu.js"; 108import { r as DefaultTableCell, t as DefaultTableHead } from "./table-header-kEso2dsp.js"; 109import { t as Table } from "./table-rkatVwLH.js"; 110import "./textarea-HOzOod_m.js"; 111import "./DetailPopover-BgYp7AYL.js"; 112import { t as AsyncTableProvider } from "./async-table-provider-CdQTSu03.js"; 113import { a as SEARCH_PARAM_NAME, i as ItemSearchForm, n as useDropdownContext, r as ItemDetailCell, t as EllipsisMenu } from "./ellipsis-menu-Dfnnbdad.js"; 114import { n as DefaultTooltip, t as SortableHeader } from "./sortable-header-C-AMl5_M.js"; 115import { t as StandardItemToggle } from "./preference-cards-client-item-DvZWDkGK.js"; 116const v2_mock_ProcedureCardItemStatusesData = [ 117 { 118 id: v4_default(), 119 value: "Approved" 120 }, 121 { 122 id: v4_default(), 123 value: "NR rev'd" 124 }, 125 { 126 id: v4_default(), 127 value: "SCM rev'd" 128 }, 129 { 130 id: v4_default(), 131 value: "SGM rev'd" 132 }, 133 { 134 id: v4_default(), 135 value: "Pending" 136 } 137]; 138var import_react = /* @__PURE__ */ __toESM(require_react(), 1); 139var import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1); 140function ItemStatusSelect(item) { 141 var _defaultStatus$id, _updateStatusFetcher$7, _updateStatusFetcher$8, _updateStatusFetcher$9, _updateStatusFetcher$10; 142 const loaderData = useRouteLoaderData("procedure-detail-items"); 143 const statuses = loaderData === null || loaderData === void 0 ? void 0 : loaderData.statuses; 144 const updateStatusFetcher = useFetcher(); 145 const defaultStatus = statuses === null || statuses === void 0 ? void 0 : statuses.find((s) => s.value === item.status); 146 const [statusId, setStatusId] = import_react.useState((_defaultStatus$id = defaultStatus === null || defaultStatus === void 0 ? void 0 : defaultStatus.id) !== null && _defaultStatus$id !== void 0 ? _defaultStatus$id : null); 147 import_react.useEffect(() => { 148 var _currentStatus$id; 149 const currentStatus = statuses === null || statuses === void 0 ? void 0 : statuses.find((s) => s.value === item.status); 150 setStatusId((_currentStatus$id = currentStatus === null || currentStatus === void 0 ? void 0 : currentStatus.id) !== null && _currentStatus$id !== void 0 ? _currentStatus$id : null); 151 }, [item.status, statuses]); 152 import_react.useEffect(() => { 153 var _updateStatusFetcher$;
154 if (updateStatusFetcher.state === "idle" && (updateStatusFetcher === null || updateStatusFetcher === void 0 || (_updateStatusFetcher$ = updateStatusFetcher.data) === null || _updateStatusFetcher$ === void 0 ? void 0 : _updateStatusFetcher$.success) === false) { 155 var _ref, _updateStatusFetcher$2, _updateStatusFetcher$3, _updateStatusFetcher$4, _updateStatusFetcher$5, _updateStatusFetcher$6, _defaultStatus$id2; 156 toast({ 157 title: "Error updating status", 158 description: (_ref = (_updateStatusFetcher$2 = (_updateStatusFetcher$3 = updateStatusFetcher.data) === null || _updateStatusFetcher$3 === void 0 ? void 0 : _updateStatusFetcher$3.api) !== null && _updateStatusFetcher$2 !== void 0 ? _updateStatusFetcher$2 : (_updateStatusFetcher$4 = updateStatusFetcher.data) === null || _updateStatusFetcher$4 === void 0 ? void 0 : _updateStatusFetcher$4.message) !== null && _ref !== void 0 ? _ref : ((_updateStatusFetcher$5 = updateStatusFetcher.data) === null || _updateStatusFetcher$5 === void 0 || (_updateStatusFetcher$5 = _updateStatusFetcher$5.error) === null || _updateStatusFetcher$5 === void 0 ? void 0 : _updateStatusFetcher$5.formErrors) ? (_updateStatusFetcher$6 = updateStatusFetcher.data) === null || _updateStatusFetcher$6 === void 0 || (_updateStatusFetcher$6 = _updateStatusFetcher$6.error) === null || _updateStatusFetcher$6 === void 0 ? void 0 : _updateStatusFetcher$6.formErrors : "Unknown error", 159 variant: "destructive" 160 }); 161 const defaultStatus$1 = statuses === null || statuses === void 0 ? void 0 : statuses.find((s) => s.value === item.status); 162 setStatusId((_defaultStatus$id2 = defaultStatus$1 === null || defaultStatus$1 === void 0 ? void 0 : defaultStatus$1.id) !== null && _defaultStatus$id2 !== void 0 ? _defaultStatus$id2 : null); 163 } 164 }, [ 165 updateStatusFetcher.state, 166 (_updateStatusFetcher$7 = updateStatusFetcher.data) === null || _updateStatusFetcher$7 === void 0 ? void 0 : _updateStatusFetcher$7.success, 167 (_updateStatusFetcher$8 = updateStatusFetcher.data) === null || _updateStatusFetcher$8 === void 0 ? void 0 : _updateStatusFetcher$8.api, 168 (_updateStatusFetcher$9 = updateStatusFetcher.data) === null || _updateStatusFetcher$9 === void 0 ? void 0 : _updateStatusFetcher$9.message, 169 (_updateStatusFetcher$10 = updateStatusFetcher.data) === null || _updateStatusFetcher$10 === void 0 || (_updateStatusFetcher$10 = _updateStatusFetcher$10.error) === null || _updateStatusFetcher$10 === void 0 ? void 0 : _updateStatusFetcher$10.formErrors, 170 statuses, 171 item.status 172 ]); 173 const handleChangeStatus = (id) => { 174 if (!item.itemId) return; 175 const newStatusId = id === "null" ? null : id; 176 setStatusId(newStatusId); 177 track_default.pcmV2.procedureChangeItemStatus(); 178 updateStatusFetcher.submit({ 179 itemId: item.itemId, 180 procedure_card_item_status_id: newStatusId 181 }, { method: "PATCH" }); 182 }; 183 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, { 184 onValueChange: handleChangeStatus, 185 value: statusId !== null && statusId !== void 0 ? statusId : void 0, 186 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, { 187 className: "w-24 flex-row-reverse", 188 variant: "outline", 189 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, { placeholder: "â" }) 190 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroup, { children: statuses ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [statuses.map((status) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, { 191 value: status.id, 192 children: status.value 193 }, status.id)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, { 194 value: "null", 195 children: "â" 196 })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectLabel, { 197 className: "text-zinc-500", 198 children: "No options available" 199 }) }) })] 200 }); 201} 202function isInputValid(input) { 203 return input !== "" && !isNaN(parseInt(input)) && parseInt(input) >= 0; 204} 205function OpenHoldDetail({ item, onHoldCountChange, onOpenCountChange, openCount, holdCount }) { 206 var _item$client_item_id; 207 function handleOpenCountChange(event) { 208 const value = event.target.value; 209 if (isInputValid(value)) onOpenCountChange(parseInt(value)); 210 else onOpenCountChange(0); 211 } 212 function handleHoldCountChange(event) { 213 const value = event.target.value; 214 if (isInputValid(value)) onHoldCountChange(parseInt(value)); 215 else onHoldCountChange(0); 216 } 217 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 218 className: "flex w-full flex-col gap-2.5 border border-zinc-200 bg-card p-1", 219 children: [
220 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { 221 type: "hidden", 222 name: "itemId", 223 value: (_item$client_item_id = item.client_item_id) !== null && _item$client_item_id !== void 0 ? _item$client_item_id : void 0 224 }), 225 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { 226 className: "p-2", 227 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemDetailCell, { item }) 228 }), 229 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Table$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeaderRow, { 230 className: "no-wrap flex justify-around", 231 children: [ 232 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHead, { 233 align: "center", 234 className: "no-wrap flex w-1/3 items-center justify-center", 235 children: "Open" 236 }), 237 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHead, { 238 align: "center", 239 className: "no-wrap flex w-1/3 items-center justify-center", 240 children: "PRN" 241 }), 242 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHead, { 243 align: "center", 244 className: "no-wrap flex w-1/3 items-center justify-center", 245 children: "Unit Price" 246 }) 247 ] 248 }) }
248), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, { 249 className: "no-wrap flex h-20 items-center justify-around", 250 children: [ 251 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableCell, { 252 align: "center", 253 className: "no-wrap flex w-1/3 items-center justify-center", 254 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { 255 type: "hidden", 256 name: "unit_open", 257 value: openCount 258 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 259 type: "text", 260 className: "inline-flex max-w-9 items-center rounded border px-2 py-0.5 text-center text-detail leading-4 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", 261 value: openCount, 262 onInput: handleOpenCountChange 263 })] 264 }), 265 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableCell, { 266 align: "center", 267 className: "no-wrap flex w-1/3 items-center justify-center", 268 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { 269 type: "hidden", 270 name: "unit_hold", 271 value: holdCount 272 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 273 type: "text", 274 className: "inline-flex max-w-9 items-center rounded border px-2 py-0.5 text-center text-detail leading-4 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", 275 value: holdCount, 276 onInput: handleHoldCountChange 277 })] 278 }), 279 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { 280 align: "center", 281 className: "no-wrap flex w-1/3 items-center justify-center font-medium", 282 children: item.item_cost ? formatCurrency(item.item_cost, item.item_cost < 10 ? 2 : 0) : "â" 283 }) 284 ] 285 }) })] }) 286 ] 287 }); 288} 289function OpenHoldModal(props) { 290 var _fetcher$data5, _fetcher$data6; 291 const { item, unitValue } = props; 292 const fetcher = useFetcher(); 293 const [open, setOpen] = (0, import_react.useState)(false); 294 const [openCount, setOpenCount] = (0, import_react.useState)(item.unit_open || 0); 295 const [holdCount, setHoldCount] = (0, import_react.useState)(item.unit_hold || 0); 296 const [error, setError] = (0, import_react.useState)(""); 297 (0, import_react.useEffect)(() => { 298 var _fetcher$data, _fetcher$data4; 299 if (fetcher.state === "idle" && (fetcher === null || fetcher === void 0 || (_fetcher$data = fetcher.data) === null || _fetcher$data === void 0 ? void 0 : _fetcher$data.success) === false) { 300 var _fetcher$data2, _fetcher$data3; 301 setError(((_fetcher$data2 = fetcher.data) === null || _fetcher$data2 === void 0 || (_fetcher$data2 = _fetcher$data2.error) === null || _fetcher$data2 === void 0 ? void 0 : _fetcher$data2.formErrors) ? (_fetcher$data3 = fetcher.data) === null || _fetcher$data3 === void 0 || (_fetcher$data3 = _fetcher$data3.error) === null || _fetcher$data3 === void 0 ? void 0 : _fetcher$data3.formErrors.join(". ") : "Unknown error"); 302 setOpenCount(item.unit_open || 0); 303 setHoldCount(item.unit_hold || 0); 304 } else if (fetcher.state === "idle" && (fetcher === null || fetcher === void 0 || (_fetcher$data4 = fetcher.data) === null || _fetcher$data4 === void 0 ? void 0 : _fetcher$data4.success) === true) setError(""); 305 }, [ 306 fetcher.state, 307 (_fetcher$data5 = fetcher.data) === null || _fetcher$data5 === void 0 ? void 0 : _fetcher$data5.success, 308 (_fetcher$data6 = fetcher.data) === null || _fetcher$data6 === void 0 || (_fetcher$data6 = _fetcher$data6.error) === null || _fetcher$data6 === void 0 ? void 0 : _fetcher$data6.formErrors, 309 item.unit_open, 310 item.unit_hold 311 ]); 312 (0, import_react.useEffect)(() => { 313 var _fetcher$data7; 314 if (fetcher.data && "ok" in fetcher.data && (fetcher === null || fetcher === void 0 || (_fetcher$data7 = fetcher.data) === null || _fetcher$data7 === void 0 ? void 0 : _fetcher$data7.success)) setOpen(false); 315 }, [fetcher.data]); 316 function handleDialogOpen(nextOpen) { 317 setOpenCount(item.unit_open || 0); 318 setHoldCount(item.unit_hold || 0); 319 setError(""); 320 setOpen(nextOpen); 321 } 322 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Dialog, { 323 onOpenChange: handleDialogOpen, 324 open, 325 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTrigger, { 326 asChild: true, 327 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { 328 variant: "outline", 329 size: "button", 330 className: "cursor-pointer hover:bg-zinc-100", 331 children: unitValue !== null && unitValue !== void 0 ? unitValue : "-" 332 }) 333 }
333), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, { 334 className: "max-h-96 w-[740px] max-w-[740px]", 335 children: [ 336 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogHeader, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, { children: "Picklist Amount" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: "Select an open and hold quantity for the selected item." })] }), 337 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(fetcher.Form, { 338 method: "PATCH", 339 className: "w-full min-w-0", 340 id: "update-item-open-hold-form", 341 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenHoldDetail, { 342 item, 343 onOpenCountChange: setOpenCount, 344 onHoldCountChange: setHoldCount, 345 openCount, 346 holdCount 347 }) 348 }), 349 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogFooter, { children: [error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { 350 className: "mt-2 font-m text-red-500", 351 children: error 352 }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { 353 variant: "solid", 354 disabled: !item || fetcher.state === "submitting", 355 className: "bg-indigo-500 text-white hover:bg-zinc-700", 356 type: "submit", 357 form: "update-item-open-hold-form", 358 children: "Save Amounts" 359 })] }) 360 ] 361 })] 362 }); 363} 364function RemoveItemFromPicklist(props) { 365 const fetcher = useFetcher(); 366 const { setOpen } = useDropdownContext(); 367 (0, import_react.useEffect)(() => { 368 if (fetcher.state === "idle" && fetcher.data) { 369 if (fetcher.data.success === true) setOpen(false); 370 else if (fetcher.data.success === false) { 371 var _fetcher$data; 372 toast({ 373 title: "Error removing item from Picklist", 374 description: ((_fetcher$data = fetcher.data) === null || _fetcher$data === void 0 || (_fetcher$data = _fetcher$data.error) === null || _fetcher$data === void 0 ? void 0 : _fetcher$data.formErrors) || "Unknown error", 375 variant: "destructive" 376 }); 377 } 378 } 379 }, [ 380 fetcher.state, 381 fetcher.data, 382 props.itemId, 383 setOpen 384 ]); 385 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(fetcher.Form, { 386 method: "PATCH", 387 children: [ 388 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { 389 type: "hidden", 390 name: "itemId", 391 value: props.itemId 392 }), 393 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { 394 type: "hidden", 395 name: "is_deleted", 396 value: "true" 397 }), 398 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { 399 type: "submit", 400 disabled: fetcher.state !== "idle", 401 className: "group", 402 children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 403 className: "flex flex-row items-center text-red-500", 404 children: ["Remove Item from Picklist ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrashCan, { className: "ml-2" })] 405 }) 406 }) 407 ] 408 }); 409} 410function getSubTableMeta(info) { 411 return info.table.options.meta; 412} 413var columnHelper = createColumnHelper(); 414const itemDetailsColumn = columnHelper.display({ 415 id: "item_details", 416 filterFn: (row, _columnId, filterValue) => { 417 var _row$original$categor, _row$original$client_, _row$original$client_2, _row$original$client_3; 418 return ((_row$original$categor = row.original.category_name) === null || _row$original$categor === void 0 ? void 0 : _row$original$categor.toLowerCase().includes(filterValue.toLowerCase())) || ((_row$original$client_ = row.original.client_item_description) === null || _row$original$client_ === void 0 ? void 0 : _row$original$client_.toLowerCase().includes(filterValue.toLowerCase())) || ((_row$original$client_2 = row.original.client_erp_item_id) === null || _row$original$client_2 === void 0 ? void 0 : _row$original$client_2.toLowerCase().includes(filterValue.toLowerCase())) || ((_row$original$client_3 = row.original.client_mfg_catalog_id) === null || _row$original$client_3 === void 0 ? void 0 : _row$original$client_3.toLowerCase().includes(filterValue.toLowerCase())) || false; 419 }, 420 meta: { label: "Item Details" }, 421 header(props) { 422 var _props$column$columnD; 423 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 424 header: props.header, 425 className: "h-10", 426 children: (_props$column$columnD = props.column.columnDef.meta) === null || _props$column$columnD === void 0 ? void 0 : _props$column$columnD.label 427 }); 428 }, 429 cell(props) { 430 if (props.row.getCanExpand()) { 431 var _props$row$original$c; 432 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 433 cell: props.cell, 434 className: "h-10", 435 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LongText_default, { text: (_props$row$original$c = props.row.original.category_name) !== null && _props$row$original$c !== void 0 ? _props$row$original$c : "" }) 436 }); 437 } 438 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 439 cell: props.cell, 440 className: "h-auto px-2 py-1.5", 441 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemDetailCell, { item: props.row.original }) 442 }); 443 } 444}); 445const columns = [ 446 itemDetailsColumn,
447 columnHelper.display({ 448 id: "status", 449 meta: { label: "Status" }, 450 header(props) { 451 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 452 header: props.header, 453 className: "h-10", 454 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 455 }); 456 }, 457 cell(props) { 458 var _props$row$original$c2; 459 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 460 cell: props.cell, 461 className: "h-10" 462 }); 463 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 464 cell: props.cell, 465 className: "h-auto", 466 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemStatusSelect, { 467 itemId: (_props$row$original$c2 = props.row.original.client_item_id) !== null && _props$row$original$c2 !== void 0 ? _props$row$original$c2 : null, 468 status: props.row.original.status 469 }) 470 }); 471 } 472 }), 473 columnHelper.display({ 474 id: "item_usage", 475 meta: { 476 label: "Usage", 477 info: "Percentage of cases in the past 12 months where this item was actually used, out of all cases associated with this procedure card's preference cards." 478 }, 479 header(props) { 480 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 481 header: props.header, 482 className: "h-10", 483 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 484 }); 485 }, 486 cell(props) { 487 var _props$row$original$i; 488 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 489 cell: props.cell, 490 className: "h-10" 491 }); 492 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 493 cell: props.cell, 494 className: "h-auto", 495 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { 496 variant: "outline", 497 className: "text-green-700", 498 children: formatPercent((_props$row$original$i = props.row.original.item_usage) !== null && _props$row$original$i !== void 0 ? _props$row$original$i : 0, 0) 499 }) 500 }); 501 } 502 }), 503 columnHelper.display({ 504 id: "item_presence", 505 meta: { 506 label: "Card Presence", 507 info: "Percentage of preference cards associated with this procedure that include this item weighted by number of cases." 508 }, 509 header(props) { 510 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 511 header: props.header, 512 className: "h-10", 513 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 514 }); 515 }, 516 cell(props) { 517 var _props$row$original$i2; 518 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 519 cell: props.cell, 520 className: "h-10" 521 }); 522 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 523 cell: props.cell, 524 className: "h-auto", 525 children: props.row.original.includes_completely_calculated_values ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { 526 className: "text-green-700", 527 children: formatPercent((_props$row$original$i2 = props.row.original.item_presence) !== null && _props$row$original$i2 !== void 0 ? _props$row$original$i2 : 0, 0) 528 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 529 className: "flex items-center justify-center gap-1", 530 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Renew, { className: "animate-spin text-zinc-600 direction-reverse" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTooltip, { 531 info: "Recalculating Card Presence", 532 className: "font-r" 533 })] 534 }) 535 }); 536 } 537 }), 538 columnHelper.display({ 539 id: "item_cost", 540 meta: { label: "Item Cost" }, 541 header(props) { 542 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 543 header: props.header, 544 className: "h-10", 545 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 546 }); 547 }, 548 cell(props) { 549 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 550 cell: props.cell, 551 className: "h-10" 552 }); 553 const itemCost = props.row.original.item_cost; 554 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 555 cell: props.cell, 556 className: "h-auto", 557 children: props.row.original.includes_completely_calculated_values ? /* @__P
557URE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: itemCost ? formatCurrency(itemCost, itemCost < 10 ? 2 : 0) : "â" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 558 className: "flex items-center justify-center gap-1", 559 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Renew, { className: "animate-spin text-zinc-600 direction-reverse" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTooltip, { 560 info: "Recalculating Item Cost", 561 className: "font-r" 562 })] 563 }) 564 }); 565 } 566 }), 567 columnHelper.display({ 568 id: "unit_open", 569 meta: { label: "Open" }, 570 header(props) { 571 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 572 header: props.header, 573 className: "h-10", 574 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 575 }); 576 }, 577 cell(props) { 578 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 579 cell: props.cell, 580 className: "h-10" 581 }); 582 const isProcedureCardAdmin = getSubTableMeta(props).isProcedureCardAdmin; 583 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 584 cell: props.cell, 585 className: "h-auto", 586 children: isProcedureCardAdmin ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenHoldModal, { 587 item: props.row.original, 588 unitValue: props.row.original.unit_open 589 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { 590 variant: "outline", 591 children: props.row.original.unit_open 592 }) 593 }); 594 } 595 }), 596 columnHelper.display({ 597 id: "unit_hold", 598 meta: { label: "PRN" }, 599 header(props) { 600 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 601 header: props.header, 602 className: "h-10", 603 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 604 }); 605 }, 606 cell(props) { 607 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 608 cell: props.cell, 609 className: "h-10" 610 }); 611 const isProcedureCardAdmin = getSubTableMeta(props).isProcedureCardAdmin; 612 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 613 cell: props.cell, 614 className: "h-auto", 615 children: isProcedureCardAdmin ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenHoldModal, { 616 item: props.row.original, 617 unitValue: props.row.original.unit_hold 618 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { 619 variant: "outline", 620 children: props.row.original.unit_hold 621 }) 622 }); 623 } 624 }), 625 columnHelper.display({ 626 id: "alternatives", 627 meta: { label: "Alternatives" }, 628 header(props) { 629 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 630 header: props.header, 631 className: "h-10", 632 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 633 }); 634 }, 635 cell(props) { 636 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 637 cell: props.cell, 638 className: "h-10" 639 }); 640 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 641 cell: props.cell, 642 className: "h-auto", 643 children: "TODO Alternatives" 644 }); 645 } 646 }), 647 columnHelper.display({ 648 id: "menu", 649 meta: {}, 650 header(props) { 651 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 652 header: props.header, 653 className: "h-10", 654 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 655 }); 656 }, 657 cell(props) { 658 var _props$row$original$i3; 659 if (props.row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 660 cell: props.cell, 661 className: "h-10" 662 }); 663 const meta = getSubTableMeta(props); 664 const isProcedureCardAdmin = meta.isProcedureCardAdmin; 665 const canSetAsStandard = meta.canSetAsStandard; 666 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 667 cell: props.cell, 668 className: "h-auto", 669 children: props.row.original.client_item_id && (isProcedureCardAdmin || canSetAsStandard) && /* @__P
669URE__ */ (0, import_jsx_runtime.jsxs)(EllipsisMenu, { children: [canSetAsStandard && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuItem, { 670 onSelect: (e) => e.preventDefault(), 671 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandardItemToggle, { 672 clientItemId: props.row.original.client_item_id, 673 currentValue: (_props$row$original$i3 = props.row.original.is_standard_item) !== null && _props$row$original$i3 !== void 0 ? _props$row$original$i3 : false 674 }) 675 }), isProcedureCardAdmin && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuSeparator, { className: "mx-auto min-h-[1px] w-full bg-zinc-200" })] }), isProcedureCardAdmin && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuItem, { 676 onSelect: (e) => e.preventDefault(), 677 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemoveItemFromPicklist, { itemId: props.row.original.client_item_id }) 678 })] }) 679 }); 680 } 681 }) 682]; 683init_objectSpread2(); 684var _excluded = [ 685 "DefaultTableRow", 686 "row", 687 "rowIndex" 688]; 689function groupByCategory(items) { 690 const categoryItems = /* @__PURE__ */ new Map(); 691 [...items].sort((a, b) => { 692 var _a$category_sequence, _b$category_sequence, _a$inner_category_seq, _b$inner_category_seq; 693 const categoryDiff = ((_a$category_sequence = a.category_sequence) !== null && _a$category_sequence !== void 0 ? _a$category_sequence : 0) - ((_b$category_sequence = b.category_sequence) !== null && _b$category_sequence !== void 0 ? _b$category_sequence : 0); 694 if (categoryDiff !== 0) return categoryDiff; 695 return ((_a$inner_category_seq = a.inner_category_sequence) !== null && _a$inner_category_seq !== void 0 ? _a$inner_category_seq : 0) - ((_b$inner_category_seq = b.inner_category_sequence) !== null && _b$inner_category_seq !== void 0 ? _b$inner_category_seq : 0); 696 }).forEach((i) => { 697 var _i$category_name; 698 const key = (_i$category_name = i.category_name) !== null && _i$category_name !== void 0 ? _i$category_name : "Uncategorized"; 699 if (!categoryItems.has(key)) categoryItems.set(key, []); 700 categoryItems.get(key).push(i); 701 }); 702 let rows = []; 703 categoryItems.forEach((value, key) => { 704 rows.push(createCategoryRow(key, value)); 705 }); 706 return rows; 707} 708function createCategoryRow(category, items) { 709 return { 710 client_id: "", 711 preference_card_client_item_id: "", 712 category_name: category, 713 subRows: items 714 }; 715} 716async function loader(args) { 717 var _results$data; 718 invariant(args.params.procedureId, "procedureId is required for picklist items"); 719 return { 720 items: groupByCategory((_results$data = (await getProcedureCardItems({ path: { procedure_card_id: args.params.procedureId } })).data) !== null && _results$data !== void 0 ? _results$data : []), 721 statuses: v2_mock_ProcedureCardItemStatusesData 722 }; 723} 724async function action(args) { 725 const formData = await args.request.formData(); 726 const itemId = formData.get("itemId"); 727 const procedureId = args.params.procedureId; 728 if (!itemId || !procedureId) return { 729 success: false, 730 error: { 731 formErrors: ["Invalid procedure item details"], 732 fieldErrors: {} 733 } 734 }; 735 const validated = {}; 736 for (const [key, value] of formData.entries()) if (key === "unit_open" || key === "unit_hold") { 737 const numValue = Number(value); 738 if (Number.isNaN(numValue)) return { 739 success: false, 740 error: { 741 formErrors: ["Invalid unit value"], 742 fieldErrors: {} 743 } 744 }; 745 validated[key] = numValue; 746 } else if (key === "is_deleted") validated[key] = value === "true"; 747 else if (!(value instanceof File)) validated[key] = value === "null" ? null : value; 748 const parsed = zProcedureCardItemUpdateRequest.safeParse(validated); 749 if (!parsed.success) return { 750 success: false, 751 error: { 752 formErrors: parsed.error.issues.map((issue) => issue.message), 753 fieldErrors: {} 754 } 755 }; 756 const updateRequest = parsed.data; 757 const result = await updateProcedureCardItem({ 758 body: updateRequest, 759 path: { 760 procedure_card_id: procedureId, 761 item_id: itemId 762 } 763 }); 764 if (result.error) { 765 const formErrors = []; 766 const detail = result.error.detail; 767 if (!detail || typeof detail === "string") formErrors.push(detail !== null && detail !== void 0 ? detail : "An unknown error occurred"); 768 else formErrors.push(...detail.map((e) => e.msg)); 769 return { 770 success: false, 771 error: { 772 formErrors, 773 fieldErrors: {} 774 } 775 }; 776 } 777 return { 778 success: true, 779 error: null 780 }; 781} 782function Component() { 783 var _searchParams$get, _itemDetailsColumn$id; 784 const loaderData = useLoaderData(); 785 const [searchParams] = useSearchParams(); 786 const searchTerm = (_searchParams$get = searchParams.get("search")) !== null && _searchParams$get !== void 0 ? _searchParams$get : ""; 787 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutRoot, { 788 className: "px-6", 789 children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AsyncTableProvider, { 790 data: loaderData.items, 791 columns, 792 options: { 793 getExpandedRowModel: getExpandedRowModel(), 794 getSubRows: (row) => row.subRows, 795 getFilteredRowModel: getFilteredRowModel(), 796 filterFromLeafRows: true, 797 maxLeafRowFilterDepth: 1, 798 state: { 799 expanded: true, 800 columnVisibility: { menu: true }, 801 columnFilters: [{ 802 id: (_itemDetailsColumn$id = itemDetailsColumn.id) !== null && _itemDetailsColumn$id !== void 0 ? _itemDetailsColumn$id : "", 803 value: searchTerm 804 }] 805 }, 806 meta: { 807 isProcedureCardAdmin: true, 808 canSetAsStandard: true 809 } 810 }, 811 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutHeaderRow, { 812 className: "gap-6", 813 children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 814 className: "mb-4 flex w-full gap-2", 815 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { 816 className: "flex-1", 817 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemSearchForm, { 818 placeholder: "Search picklist items", 819 defaultValue: searchTerm 820 }) 821 }
821), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { 822 disabled: true, 823 children: "CLI-18" 824 })] 825 }) 826 }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, { renderRow: (props) => { 827 const { DefaultTableRow, row, rowIndex } = props, tableRowProps = _objectWithoutProperties(props, _excluded); 828 if (row.getCanExpand()) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableRow, _objectSpread2(_objectSpread2({}, tableRowProps), {}, { className: "z-10 bg-indigo-50 hover:bg-indigo-50" }), rowIndex); 829 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableRow, _objectSpread2(_objectSpread2({}, tableRowProps), {}, { className: "bg-zinc-100" }), rowIndex); 830 } }) })] 831 }) 832 }); 833} 834export { Component, action, groupByCategory, loader }; 835 836//# sourceMappingURL=procedure-detail-items.route-DPJaZR3K.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.