synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
151 lines (150 loc) • 4.55 kB
JavaScript
import { jsx as t, jsxs as A } from "react/jsx-runtime";
import M from "../layout/InfiniteTableLayout.js";
import { useSearchAccessSubmissionsInfinite as w } from "../../synapse-queries/dataaccess/useDataAccessSubmission.js";
import { formatDate as x } from "../../utils/functions/DateFormatter.js";
import { ACT_TEAM_ID as F } from "../../utils/SynapseConstants.js";
import { Stack as f } from "@mui/material";
import { useReactTable as L, getCoreRowModel as k, createColumnHelper as y } from "@tanstack/react-table";
import D from "dayjs";
import { upperFirst as P } from "lodash-es";
import { useState as j, useMemo as b } from "react";
import { Link as H } from "react-router";
import s from "../TanStackTable/ColumnHeader.js";
import O from "../TanStackTable/StyledTanStackTable.js";
import { UserBadge as B } from "../UserCard/UserBadge.js";
import o from "../UserOrTeamBadge/UserOrTeamBadge.js";
import { getSortApiRequestFromTableSortState as E } from "./UserAccessRequestHistory/SubmissionSortStateTranslator.js";
const r = y(), U = [
r.accessor("id", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Request" }),
enableSorting: !1,
cell: (e) => /* @__PURE__ */ t(H, { to: `/Submissions/${e.getValue()}`, children: e.getValue() })
}),
r.accessor("accessRequirementName", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Access Requirement Name" }),
enableSorting: !1
}),
r.accessor("submitterId", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Submitter" }),
enableSorting: !1,
cell: (e) => /* @__PURE__ */ t(o, { principalId: e.getValue() })
}),
r.accessor("state", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Status" }),
enableSorting: !1,
cell: (e) => P(e.getValue().toLocaleLowerCase())
}),
r.accessor("accessorChanges", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Requesters" }),
enableSorting: !1,
cell: (e) => /* @__PURE__ */ A(
f,
{
sx: {
gap: 1
},
children: [
/* @__PURE__ */ t(o, { principalId: e.row.original.submitterId }),
e.getValue().filter((a) => e.row.original.submitterId !== a.userId).map((a) => /* @__PURE__ */ t(
B,
{
userId: a.userId,
className: "requester"
},
a.userId
))
]
}
)
}),
r.accessor("accessRequirementReviewerIds", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Reviewer(s)" }),
enableSorting: !1,
cell: (e) => /* @__PURE__ */ t(
f,
{
sx: {
gap: 1
},
children: e.getValue().length === 0 ? /* @__PURE__ */ t(o, { principalId: F }) : e.getValue().map((a) => /* @__PURE__ */ t(o, { principalId: a }, a))
}
)
}),
r.accessor("createdOn", {
header: (e) => /* @__PURE__ */ t(s, { ...e, title: "Created Date" }),
enableSorting: !0,
cell: (e) => x(D(e.getValue())),
sortDescFirst: !0
})
];
function re({
showSubmitter: e = !1,
showStatus: a = !1,
showRequesters: S = !1,
accessorId: i,
accessRequirementId: n,
reviewerId: c,
submissionState: m,
reviewerFilterType: u
}) {
const [l, h] = j([
{
desc: !0,
id: "createdOn"
}
]), R = b(
() => ({
accessorId: i,
accessRequirementId: n,
submissionState: m,
reviewerId: c,
reviewerFilterType: u,
sort: E(l)
}),
[
i,
n,
m,
c,
u,
l
]
), { data: d, hasNextPage: C, fetchNextPage: I, isLoading: g, isFetchingNextPage: T } = w(R), V = b(
() => d?.pages.flatMap((q) => q.results) ?? [],
[d?.pages]
), p = L({
data: V,
columns: U,
getCoreRowModel: k(),
enableFilters: !1,
// filters are handled by separate controls
manualSorting: !0,
onSortingChange: h,
state: {
sorting: l,
columnVisibility: {
submitterId: e,
state: a,
accessorChanges: S
}
},
columnResizeMode: "onChange"
}), N = !g && p.getRowModel().rows.length === 0;
return /* @__PURE__ */ t("div", { className: "AccessSubmissionTable", children: /* @__PURE__ */ t(
M,
{
table: /* @__PURE__ */ t(O, { table: p, fullWidth: !0 }),
isLoading: g,
isEmpty: N,
hasNextPage: C,
onFetchNextPageClicked: () => {
I();
},
isFetchingNextPage: T
}
) });
}
export {
re as AccessRequestSubmissionTable
};
//# sourceMappingURL=AccessRequestSubmissionTable.js.map