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

99 lines (98 loc) 3.74 kB
import { jsx as t, jsxs as c } 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 "../../utils/SynapseConstants.js"; import { noop as h } from "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import { useCallback as I } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Button as v, Alert as l, Stack as g, Typography as d } 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 { SynapseSpinner as u } from "../LoadingScreen/LoadingScreen.js"; 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 { useGetTeam as b } from "../../synapse-queries/team/useTeam.js"; import { useAddMemberToTeam as y, useGetAllOpenMembershipInvitations as w } from "../../synapse-queries/team/useTeamMembers.js"; import { useGetCurrentUserProfile as f } from "../../synapse-queries/user/useUserBundle.js"; import { UserBadge as B } from "../UserCard/UserBadge.js"; import A from "../UserOrTeamBadge/UserOrTeamBadge.js"; function nt(a) { const { teamId: r, onSuccess: n = h, ...s } = a, { data: o } = f(), { mutate: m, isPending: i } = y({ onSuccess: () => { n(); } }), e = !o || i, p = I(() => { o?.ownerId && m({ teamId: r, userId: o.ownerId }); }, [o?.ownerId, m, r]); return /* @__PURE__ */ t( v, { variant: "contained", disabled: e, startIcon: i ? /* @__PURE__ */ t(u, {}) : void 0, ...s, onClick: p, children: "Accept Invitation" } ); } function mt(a) { const { teamId: r } = a, { data: n } = f(), { data: s, status: o, error: m } = w(n?.ownerId, { enabled: !!n?.ownerId }), { data: i } = b(r, { enabled: !!r }); if (o === "pending") return /* @__PURE__ */ t(u, {}); if (o === "error") return /* @__PURE__ */ t(l, { severity: "error", children: m.message }); const e = s.find( (p) => p.teamId === r ); return e == null ? /* @__PURE__ */ c(l, { severity: "error", children: [ "No matching invitation for team ", i ? i.name : `ID: ${r}` ] }) : /* @__PURE__ */ c( g, { sx: { gap: 2 }, children: [ /* @__PURE__ */ c(d, { variant: "body1", children: [ /* @__PURE__ */ t(B, { userId: e.createdBy }), " has invited you to join", " ", /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(A, { principalId: r }) }), e.message ? " with the following message:" : "." ] }), e.message && /* @__PURE__ */ t(d, { variant: "body1", component: "blockquote", children: e.message }), /* @__PURE__ */ t(d, { variant: "body1", children: "Do you want to accept this invitation?" }) ] } ); } export { nt as AcceptMembershipInvitationButton, mt as OpenMembershipInvitation }; //# sourceMappingURL=OpenMembershipInvitation.js.map