UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

114 lines (113 loc) 3.9 kB
import { jsx as r, Fragment as b } from "react/jsx-runtime"; import { getSortApiRequestFromTableSortState as h } from "./SubmissionSortStateTranslator.js"; import A from "../../layout/InfiniteTableLayout.js"; import { Typography as C } from "@mui/material"; import "@mui/material/Skeleton"; import { SkeletonTable as R } from "../../Skeleton/SkeletonTable.js"; import { useState as w, useMemo as F } from "react"; import { upperFirst as T } from "lodash-es"; import x from "../../UserOrTeamBadge/UserOrTeamBadge.js"; import { useSearchAccessSubmissionUserRequestsInfinite as y } from "../../../synapse-queries/dataaccess/useDataAccessSubmission.js"; import { formatDate as n } from "../../../utils/functions/DateFormatter.js"; import { useReactTable as v, getCoreRowModel as O, createColumnHelper as q } from "@tanstack/react-table"; import a from "dayjs"; import { Link as I } from "react-router"; import t from "../../TanStackTable/ColumnHeader.js"; import M from "../../TanStackTable/StyledTanStackTable.js"; import { USER_ACCESS_HISTORY_SUBMISSION_SUBPATH as N } from "./RouteConstants.js"; const o = q(), c = [ o.accessor("accessRequirementName", { header: (e) => /* @__PURE__ */ r(t, { ...e, title: "Access Requirement Name" }), enableSorting: !1, enableColumnFilter: !1 }), o.accessor("state", { header: (e) => /* @__PURE__ */ r(t, { ...e, title: "Status" }), enableSorting: !1, cell: (e) => e.row.original.userAccessApproval && e.row.original.userAccessApproval.expiredOn && a(e.row.original.userAccessApproval.expiredOn).isBefore(a()) ? "Expired" : T(e.getValue().toLocaleLowerCase()), enableColumnFilter: !1, size: 75 }), o.accessor("createdOn", { header: (e) => /* @__PURE__ */ r(t, { ...e, title: "Date Submitted" }), enableSorting: !0, cell: (e) => n(a(e.getValue())), sortDescFirst: !0, enableColumnFilter: !1 }), o.display({ id: "expires", header: (e) => /* @__PURE__ */ r(t, { ...e, title: "Expires" }), enableSorting: !1, cell: (e) => e.row.original.userAccessApproval && e.row.original.userAccessApproval.expiredOn ? n(a(e.row.original.userAccessApproval.expiredOn)) : null, size: 75, enableColumnFilter: !1 }), o.accessor("submitterId", { header: (e) => /* @__PURE__ */ r(t, { ...e, title: "Submitter" }), enableSorting: !1, cell: (e) => /* @__PURE__ */ r(x, { principalId: e.getValue() }), enableColumnFilter: !1 }), o.accessor("id", { header: (e) => /* @__PURE__ */ r(t, { ...e, title: "" }), enableSorting: !1, cell: (e) => /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r( I, { to: `/${N}/${e.getValue()}`, children: "View Request" } ) }), size: 95, enableColumnFilter: !1 }) ]; function K() { const [e, m] = w([ { desc: !0, id: "createdOn" } ]), { data: l, isLoading: s, hasNextPage: u, isFetchingNextPage: p, fetchNextPage: d } = y({ sort: h(e) }), f = F( () => l?.pages.flatMap((S) => S.results || []) || [], [l] ), i = v({ data: f, columns: c, getCoreRowModel: O(), manualSorting: !0, columnResizeMode: "onChange", state: { sorting: e }, onSortingChange: m }), g = !s && i.getRowModel().rows.length === 0; return /* @__PURE__ */ r( A, { table: /* @__PURE__ */ r(M, { table: i, fullWidth: !0 }), isLoading: s, loader: /* @__PURE__ */ r(R, { numCols: c.length, fullWidthCells: !0 }), isEmpty: g, noResults: /* @__PURE__ */ r(C, { variant: "body1", sx: { textAlign: "center", my: 2 }, children: "You have no access requests" }), hasNextPage: u, onFetchNextPageClicked: () => { d(); }, isFetchingNextPage: p } ); } export { K as UserAccessRequestHistoryTable }; //# sourceMappingURL=UserAccessRequestHistoryTable.js.map