synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
119 lines (118 loc) • 3.93 kB
JavaScript
import { jsx as r, jsxs as S } 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 "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { useEffect as v } from "react";
import { useSynapseContext as L } from "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { Box as w } 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 { useGetEntityChallenge as E } from "../../synapse-queries/entity/useGetEntityChallenge.js";
import { useGetIsUserMemberOfTeam as B } from "../../synapse-queries/team/useTeamMembers.js";
import { useGetUserSubmissionTeams as I } from "../../synapse-queries/user/useGetUserTeams.js";
import { useGetCurrentUserProfile as M } from "../../synapse-queries/user/useUserBundle.js";
import k from "@mui/icons-material/ExitToApp";
import n from "../SpinnerButton/SpinnerButton.js";
const ho = ({
projectId: l,
onError: i,
onJoinClick: s,
onLeaveClick: m
}) => {
const { isAuthenticated: o } = L(), { data: a } = M({
enabled: o
}), {
data: e,
isLoading: c,
error: g
} = E(l, {
enabled: o
}), {
data: h,
isLoading: u,
error: f
} = B(
e?.participantTeamId,
a?.ownerId,
{
enabled: !!e && !!a
}
), b = !!h, {
data: p,
error: x,
isLoading: C
} = I(e?.id, 20, 0, {
enabled: !!e && o
}), T = p && p.results.length > 0, d = b && T, t = g || f || x;
return v(() => {
t && i && i(t);
}, [t, i]), c || u || C ? /* @__PURE__ */ r(n, { showSpinner: !0, children: "Loading..." }) : /* @__PURE__ */ S(w, { children: [
!d && /* @__PURE__ */ r(
n,
{
disableElevation: !0,
variant: "contained",
onClick: () => o && s ? s() : void 0,
sx: {
color: "white",
backgroundColor: "#109488",
fontSize: "1.12em",
textTransform: "none",
padding: "4px 18px",
fontWeight: 400,
":hover": { color: "white", backgroundColor: "#109488" },
":active": { color: "white", backgroundColor: "#109488" },
":visited": { color: "white", backgroundColor: "#109488" }
},
children: "Register for this Challenge"
}
),
d && /* @__PURE__ */ r(
n,
{
disableElevation: !0,
variant: "outlined",
endIcon: /* @__PURE__ */ r(k, {}),
onClick: () => m ? m() : void 0,
sx: {
borderColor: "white",
color: "white",
fontSize: "1.12em",
textTransform: "none",
padding: "4px 18px",
fontWeight: 400,
":hover": {
color: "#172430",
borderColor: "#172430"
}
},
children: "Leave Challenge"
}
)
] });
};
export {
ho as default
};
//# sourceMappingURL=ChallengeRegisterButton.js.map