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

186 lines (185 loc) 6.09 kB
import { jsx as i, jsxs as v } from "react/jsx-runtime"; import "../../synapse-client/SynapseClient.js"; import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode"; import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse"; import "@sage-bionetworks/synapse-client/util/SynapseClientError"; import "@sage-bionetworks/synapse-types"; import "../../utils/functions/EntityTypeUtils.js"; import { getEndpoint as w, BackendDestinationEnum as x } from "../../utils/functions/getEndpoint.js"; import "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import "../../utils/SynapseConstants.js"; import { useState as D, useMemo as h } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Radio as N, Link as S, Tooltip as k, Box as B } from "@mui/material"; import "../../utils/hooks/useCookiePreferences.js"; import "../../utils/hooks/useSourceAppConfigs.js"; import "universal-cookie"; import "../../utils/AppUtils/session/ApplicationSessionContext.js"; import "../../utils/context/FullContextProvider.js"; import "../../utils/context/DocumentMetadataContext.js"; import '../../style/components/_spinner.css';/* empty css */ import "@tanstack/query-core"; import "lodash-es/isEmpty"; import "lodash-es/isEqual"; import "lodash-es/xorWith"; import "react-router"; import "@sage-bionetworks/synapse-client"; import "../../utils/types/IsType.js"; import { useGetChallengeTeamList as F, useGetTeamList as G } from "../../synapse-queries/team/useTeamList.js"; import { useGetAllOpenMembershipInvitations as P } from "../../synapse-queries/team/useTeamMembers.js"; import { useGetCurrentUserProfile as R } from "../../synapse-queries/user/useUserBundle.js"; import { formatDate as j } from "../../utils/functions/DateFormatter.js"; import { EmailTwoTone as y } from "@mui/icons-material"; import { DataGrid as E } from "@mui/x-data-grid"; import O from "dayjs"; import { ChallengeTeamSearch as Y } from "./ChallengeTeamSearch.js"; function xe(g) { const { challengeId: b, onSelectTeam: n, selectedTeamId: l } = g, { data: C, isLoading: T } = F(b), { data: s } = R(), { data: o } = P(s?.ownerId, { enabled: !!s?.ownerId }), [a, M] = D(""), m = C?.map((e) => e.teamId) ?? [], { data: d, isLoading: I } = G( m, { enabled: !!m.length } ), u = h(() => { const e = a.toLowerCase(), f = d?.list.filter( (t) => t.canPublicJoin || // `canRequestMembership` is true by default if the property is not present t.canRequestMembership !== !1 || o?.some( (r) => r.teamId === t.id ) ) ?? []; let c = f; return e.length && (c = f.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e))), c.map( (t) => ({ ...t, hasInvitation: !!o?.some( (r) => r.teamId === t.id ) }) ); }, [o, a, d?.list]), p = T || I, L = h( () => [ { field: "radiobutton", headerName: "", width: 25, sortable: !1, filterable: !1, hideable: !1, disableColumnMenu: !0, renderCell: ({ row: e }) => /* @__PURE__ */ i( N, { value: e.id, checked: String(e.id) === l, onClick: () => { n(String(e.id)); }, inputProps: { "aria-label": `Select ${e.name}` } } ) }, { field: "name", headerName: "Team Name", flex: 1, filterable: !1, hideable: !1, disableColumnMenu: !0, renderCell: ({ row: e }) => /* @__PURE__ */ i( S, { href: `${w( x.PORTAL_ENDPOINT )}/Team:${e.id}`, target: "_blank", underline: "hover", children: e.name } ) }, { field: "hasInvitation", headerName: "", width: 15, filterable: !1, hideable: !1, disableColumnMenu: !0, align: "center", renderCell: ({ value: e }) => e ? /* @__PURE__ */ i(k, { title: "You have been invited to join this team", children: /* @__PURE__ */ i(y, { fontSize: "small", sx: { color: "grey.700" } }) }) : null }, { field: "created", headerName: "Created On", width: 100, filterable: !1, hideable: !1, disableColumnMenu: !0, renderCell: ({ value: e }) => j(O(e), "MM/DD/YY") }, { field: "description", headerName: "Description", flex: 1, filterable: !1, hideable: !1, disableColumnMenu: !0 } ], [n, l] ); return /* @__PURE__ */ v(B, { sx: { height: 220 }, children: [ !p && /* @__PURE__ */ i( Y, { value: a, onChange: (e) => M(e.target.value), rowCount: u.length } ), /* @__PURE__ */ i( E, { initialState: { sorting: { sortModel: [{ field: "hasInvitation", sort: "desc" }] } }, loading: p, rows: u, columns: L, rowCount: 5, hideFooter: !0, density: "compact", rowBufferPx: 500, sx: { border: "none", height: "100%", "& .MuiDataGrid-columnHeader": { backgroundColor: "#F1F3F5" }, "& .Mui-odd": { backgroundColor: "#FBFBFC" }, ".MuiDataGrid-columnHeaderTitleContainer": { justifyContent: "space-between" }, ".radio": { display: "flex", alignItems: "center", height: "100%" } }, getRowClassName: (e) => e.indexRelativeToCurrentPage % 2 === 0 ? "Mui-even" : "Mui-odd" } ) ] }); } export { xe as default }; //# sourceMappingURL=ChallengeTeamTable.js.map