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 "./objectWithoutProperties-Cgp7QKOy.js"; 9import "./amplifyUrl-DhBXUoj8.js"; 10import "./tslib.es6-CGMJRn24.js"; 11import { o as formatDate } from "./helpers-BQW8LNh3.js"; 12import "./shim-BLxGA08a.js"; 13import "./use-isomorphic-layout-effect.browser.esm-BDjLKVP-.js"; 14import "./dist-Cz4mcmaa.js"; 15import "./dist-DaeMORX8.js"; 16import "./react-dom-Dddidh9b.js"; 17import "./dist-DetJSI7l.js"; 18import "./dist-Dsgwk-jH.js"; 19import "./classPrivateFieldGet2-D2HqlEEJ.js"; 20import "./dist-javwCbI7.js"; 21import "./dist-DjKy_3Dj.js"; 22import "./Combination-CE9BhVA8.js"; 23import "./dist-BHtPb5hX.js"; 24import "./dist-C5RjQM0F.js"; 25import "./dist-SbNcsVrs.js"; 26import "./select-8FJ_dY_9.js"; 27import "./dist-BpwkAU0Q.js"; 28import { F as useSearchParams, T as useLoaderData, r as Link, t as Await } from "./chunk-62JRHF6Z-z8JX8DDB.js"; 29import "./iconPropTypes-C5chbmyn-CpVo52O4.js"; 30import "./bucket-0-Uq1JG5fZ.js"; 31import { i as ChevronDown } from "./bucket-3-DKA1ROBB.js"; 32import "./bucket-10-Ca5cox4R.js"; 33import "./dist-W5s9RbHT.js"; 34import "./dist-DCv7IJcI.js"; 35import "./createLucideIcon-DENnxagg.js"; 36import "./loader-2-BkUAzF6M.js"; 37import "./search-BZG3c53g.js"; 38import "./utils-DL_RvPHk.js"; 39import "./subDays-vez96V8M.js"; 40import "./client.gen-B5RyugF5.js"; 41import { r as constants_default } from "./constants-BTubQFbu.js"; 42import { t as Button } from "./button-BgUr9YaP.js"; 43import "./tooltip-BQPMLsOF.js"; 44import { n as LongText_default } from "./LongText-Chh0tzMc.js"; 45import { t as Badge } from "./badge-BfOudBXs.js"; 46import "./xstate-react.esm-DX2qQh45.js"; 47import "./command-Bs-4k7Pe.js"; 48import "./dist-C_Pp4NuF.js"; 49import "./dialog-odsl4nrF.js"; 50import "./zod-McvqnZjg.js"; 51import "./input-wPGsBI9X.js"; 52import "./separator-BIFfjU4z.js"; 53import "./skeleton-DlrxaJwT.js"; 54import { t as invariant } from "./tiny-invariant-DGRZ75gT.js"; 55import "./spinner-CSg9X65E.js"; 56import { r as createColumnHelper } from "./lib-BmE5oXwC.js"; 57import "./controlled-pagination-B2SWmftf.js"; 58import "./table-BhizvUWs.js"; 59import "./reset-to-first-page-Buz3wC4q.js"; 60import "./filter-search-params-CGhr97jh.js"; 61import { c as getFilterParamKeys, i as useFilterPillItems, s as getFilterParamKey } from "./use-table-context-DYyO1Fg2.js"; 62import { t as Label } from "./label-DQ77xjEK.js"; 63import { On as zPreferenceCardChangeRequestStatus, Pn as zSearchPreferenceCardChangeRequestsData, in as searchPreferenceCardChangeRequests } from "./sdk.gen-Ck47bYkT.js"; 64import "./client-BqXsOWRb.js"; 65import "./dist-C2D8DSus.js"; 66import { a as TableLayoutHeader, i as TableLayoutFooter, n as TableLayoutBody, o as TableLayoutHeaderRow, s as TableLayoutRoot } from "./table-layout-BMU5VJgu.js"; 67import { c as FilterForm, i as PillButton, s as PreservedNonTableFilterParams } from "./default-multi-select-filter-U6Vui7yH.js"; 68import { r as DefaultTableCell, t as DefaultTableHead } from "./table-header-kEso2dsp.js"; 69import { t as Table } from "./table-rkatVwLH.js"; 70import "./combobox-BwL7K7gN.js"; 71import "./plural-DMgepuxz.js"; 72import "./dist-S6WxGKtS.js"; 73import { t as UrlPagination } from "./url-pagination-RGzzGCXU.js"; 74import { t as AsyncTableProvider } from "./async-table-provider-CdQTSu03.js"; 75import { t as SortableHeader } from "./sortable-header-C-AMl5_M.js"; 76import { t as looseParsePayload } from "./loose-parse-payload-BYuZOOUE.js"; 77import { t as SelectFilterBase } from "./select-filter-base-DQCjQa91.js"; 78var import_react = /* @__PURE__ */ __toESM(require_react()); 79var import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1); 80function TableLink({ to, children }) { 81 if (!children) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "â" }); 82 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { 83 variant: "link", 84 asChild: true, 85 size: "text", 86 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, { 87 className: "max-w-full font-m", 88 to, 89 children 90 }) 91 }); 92} 93function getColorClasses(status) { 94 switch (status) { 95 case "Pending": return "bg-yellow-100 text-yellow-900 border border-yellow-300"; 96 case "Complete": return "bg-green-100 text-green-900 border border-green-300"; 97 case "Cancelled": return "bg-white text-zinc-700 border border-zinc-300"; 98 case "Automation Error": return "bg-red-100 text-red-900 border border-red-300"; 99 case "Approved": return "bg-indigo-100 text-indigo-900 border border-indigo-300"; 100 default: return "bg-zinc-100 text-zinc-500"; 101 } 102} 103function RequestStatusPill({ status }) { 104 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { 105 variant: "custom", 106 className: getColorClasses(status), 107 children: status 108 }); 109} 110var options = zPreferenceCardChangeRequestStatus.options.map((option) => ({ 111 label: option, 112 value: option 113})); 114function StatusFilterPill(props) { 115 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectFilterBase, { 116 meta: props.meta, 117 options, 118 onOpenChange: (open) => { 119 if (!open) { 120 var _props$formRef; 121 (_props$formRef = props.formRef) === null || _props$formRef === void 0 || (_props$formRef = _props$formRef.current) === null || _props$formRef === void 0 || _props$formRef.requestSubmit(); 122 } 123 }, 124 children: ({ selectedOptions }) => { 125 var _props$meta$label, _props$meta, _props$meta$filter, _props$meta$filter2; 126 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PillButton, { 127 label: (_props$meta$label = (_props$meta = props.meta) === null || _props$meta === void 0 ? void 0 : _props$meta.label) !== null && _props$meta$label !== void 0 ? _props$meta$label : "", 128 selectedOptions, 129 pinned: (_props$meta$filter = props.meta.filter) === null || _props$meta$filter === void 0 ? void 0 : _props$meta$filter.pinned, 130 param: getFilterParamKey((_props$meta$filter2 = props.meta.filter) === null || _props$meta$filter2 === void 0 ? void 0 : _props$meta$filter2.param) 131 }); 132 } 133 }); 134} 135function StatusFilter(props) { 136 var _props$meta2; 137 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 138 className: "flex flex-col gap-1", 139 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: (_props$meta2 = props.meta) === null || _props$meta2 === void 0 ? void 0 : _props$meta2.label }
139), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectFilterBase, { 140 meta: props.meta, 141 options, 142 children: ({ selectedOptions }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, { 143 variant: "outline", 144 className: "w-full justify-between overflow-hidden", 145 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: selectedOptions.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LongText_default, { text: selectedOptions.map((option) => option.label).join(", ") }) : "All" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronDown, {})] 146 }) 147 })] 148 }); 149} 150async function loader(args) { 151 var _searchParams$get, _searchParams$get2, _searchParams$get3; 152 invariant(args.params.cardId, "cardId is required"); 153 const searchParams = new URL(args.request.url).searchParams; 154 const results = searchPreferenceCardChangeRequests(looseParsePayload(zSearchPreferenceCardChangeRequestsData, { 155 body: { 156 preference_card_id: args.params.cardId, 157 statuses: searchParams.getAll("status"), 158 assignee_ids: searchParams.getAll("assignee_id"), 159 location_ids: searchParams.getAll("location_id"), 160 service_line_ids: searchParams.getAll("service_line_id") 161 }, 162 query: { 163 page: (_searchParams$get = searchParams.get("page")) !== null && _searchParams$get !== void 0 ? _searchParams$get : void 0, 164 page_size: (_searchParams$get2 = searchParams.get("page_size")) !== null && _searchParams$get2 !== void 0 ? _searchParams$get2 : void 0, 165 sort: (_searchParams$get3 = searchParams.get("sort")) !== null && _searchParams$get3 !== void 0 ? _searchParams$get3 : "created_date|DESC" 166 } 167 })); 168 return { 169 items: results.then((res) => { 170 var _res$data$items, _res$data; 171 return (_res$data$items = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.items) !== null && _res$data$items !== void 0 ? _res$data$items : []; 172 }), 173 error: results.then((res) => res.error), 174 pagination: results.then((res) => { 175 var _res$data2, _res$data3, _res$data4, _res$data5; 176 return { 177 page: (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.page, 178 page_size: (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.page_size, 179 total: (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.total, 180 total_pages: (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.total_pages 181 }; 182 }) 183 }; 184} 185function Component() { 186 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutRoot, { 187 className: "px-6", 188 children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AsyncTableProvider, { 189 data: useLoaderData().items, 190 columns, 191 children: [
192 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutHeaderRow, { 193 className: "gap-6", 194 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { 195 className: "grow", 196 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterPills, {}) 197 }) 198 }) }), 199 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, {}) }), 200 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLayoutFooter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination, {}) }) 201 ] 202 }) 203 }); 204} 205function Pagination() { 206 const loaderData = useLoaderData(); 207 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Await, { 208 resolve: loaderData.pagination, 209 children: (data) => { 210 var _data$page, _data$page_size, _data$total, _data$total_pages; 211 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UrlPagination, { 212 page: (_data$page = data.page) !== null && _data$page !== void 0 ? _data$page : 1, 213 pageSize: (_data$page_size = data.page_size) !== null && _data$page_size !== void 0 ? _data$page_size : 20, 214 total: (_data$total = data.total) !== null && _data$total !== void 0 ? _data$total : 0, 215 totalPages: (_data$total_pages = data.total_pages) !== null && _data$total_pages !== void 0 ? _data$total_pages : 0, 216 resetPageOnPageSizeChange: false 217 }); 218 } 219 }) }); 220} 221function FilterPills() { 222 const formRef = import_react.useRef(null); 223 const [searchParams] = useSearchParams(); 224 const visibleItems = useFilterPillItems().filter((item) => { 225 var _item$meta$filter, _item$meta$filter2; 226 if ((_item$meta$filter = item.meta.filter) === null || _item$meta$filter === void 0 ? void 0 : _item$meta$filter.pinned) return true; 227 return getFilterParamKeys((_item$meta$filter2 = item.meta.filter) === null || _item$meta$filter2 === void 0 ? void 0 : _item$meta$filter2.param).some((param) => searchParams.has(param)); 228 }); 229 if (visibleItems.length === 0) return null; 230 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FilterForm, { 231 ref: formRef, 232 method: "GET", 233 className: "flex gap-2", 234 children: [visibleItems.map((item, index) => { 235 var _item$meta$filter3; 236 const { Pill } = item.components; 237 if (!Pill) return null; 238 const paramKeys = getFilterParamKeys((_item$meta$filter3 = item.meta.filter) === null || _item$meta$filter3 === void 0 ? void 0 : _item$meta$filter3.param); 239 const paramKey = paramKeys.join("|"); 240 const paramValueKey = paramKeys.map((param) => searchParams.getAll(param).join(",")).join("|"); 241 const baseKey = paramKey || item.meta.label || String(index); 242 const key = paramValueKey ? `${baseKey}:${paramValueKey}` : baseKey; 243 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { 244 formRef, 245 meta: item.meta 246 }, key); 247 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreservedNonTableFilterParams, {})] 248 }); 249} 250var columnHelper = createColumnHelper(); 251var columns = [ 252 columnHelper.accessor("client_card_id", { 253 id: "client_card_id", 254 size: 110, 255 meta: { 256 label: "Request ID", 257 sort: { param: "sequence" } 258 }, 259 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 260 header: props.header, 261 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 262 }), 263 cell: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 264 cell: props.cell, 265 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableLink, { 266 to: `${constants_default}/${props.row.original.preference_card_id}/requests/${props.row.original.id}`, 267 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LongText_default, { text: `${props.row.original.client_card_id}-${props.row.original.sequence}` }) 268 }) 269 }) 270 }), 271 columnHelper.accessor("status", { 272 id: "status", 273 size: 149, 274 meta: { 275 label: "Status", 276 sort: { param: "status" }, 277 filter: { 278 param: "status", 279 pinned: true, 280 components: { 281 Filter: StatusFilter, 282 Pill: StatusFilterPill 283 } 284 } 285 }, 286 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 287 header: props.header, 288 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { c
288olumn: props.column }) 289 }), 290 cell: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 291 cell: props.cell, 292 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RequestStatusPill, { status: props.row.original.status }) 293 }) 294 }), 295 columnHelper.accessor("procedure_name", { 296 id: "procedure_name", 297 meta: { 298 label: "Description", 299 sort: { param: "procedure_name" } 300 }, 301 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 302 header: props.header, 303 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 304 }), 305 cell: (props) => { 306 var _props$row$original$p; 307 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 308 cell: props.cell, 309 className: "max-w-[280px]", 310 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LongText_default, { text: (_props$row$original$p = props.row.original.procedure_name) !== null && _props$row$original$p !== void 0 ? _props$row$original$p : "â" }) 311 }); 312 } 313 }), 314 columnHelper.accessor("assignee.name", { 315 id: "assignee_name", 316 size: 149, 317 meta: { 318 label: "Assignee", 319 sort: { param: "assignee_name" } 320 }, 321 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 322 header: props.header, 323 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 324 }), 325 cell: (props) => { 326 var _props$row$original$a, _props$row$original$a2; 327 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 328 cell: props.cell, 329 children: (_props$row$original$a = (_props$row$original$a2 = props.row.original.assignee) === null || _props$row$original$a2 === void 0 ? void 0 : _props$row$original$a2.name) !== null && _props$row$original$a !== void 0 ? _props$row$original$a : "â" 330 }); 331 } 332 }), 333 columnHelper.accessor("requestor.name", { 334 id: "requestor_name", 335 size: 149, 336 meta: { label: "Requestor" }, 337 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 338 header: props.header, 339 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 340 }), 341 cell: (props) => { 342 var _props$row$original$r, _props$row$original$r2; 343 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 344 cell: props.cell, 345 children: (_props$row$original$r = (_props$row$original$r2 = props.row.original.requestor) === null || _props$row$original$r2 === void 0 ? void 0 : _props$row$original$r2.name) !== null && _props$row$original$r !== void 0 ? _props$row$original$r : "â" 346 }); 347 } 348 }), 349 columnHelper.accessor("created_date", { 350 id: "created_date", 351 size: 100, 352 meta: { 353 label: "Created", 354 sort: { param: "created_date" } 355 }, 356 header: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableHead, { 357 header: props.header, 358 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SortableHeader, { column: props.column }) 359 }), 360 cell: (props) => { 361 var _props$row$original$c; 362 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultTableCell, { 363 cell: props.cell, 364 children: props.row.original.created_date ? formatDate((_props$row$original$c = props.row.original.created_date) === null || _props$row$original$c === void 0 ? void 0 : _props$row$original$c.toString(), "2-digit", "2-digit", "2-digit") : "â" 365 }); 366 } 367 }) 368]; 369export { Component, loader }; 370 371//# sourceMappingURL=preference-card-detail-requests.route-DFI70Rga.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.