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

149 lines (148 loc) 5.63 kB
import { jsxs as n, jsx as r } 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 { BUNDLE_MASK_QUERY_RESULTS as M, URL_TERMS_CONDITIONS_AGREEMENT as U } from "../../utils/SynapseConstants.js"; import "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "@tanstack/react-query"; import "../../utils/PermissionLevelToAccessType.js"; import { useState as f, useEffect as S } from "react"; import "../../utils/context/SynapseContext.js"; import "use-deep-compare-effect"; import { Link as g, Alert as F, AlertTitle as P, Typography as Q, Button as $ } 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 { useGetFullTableQueryResults as j } from "../../synapse-queries/entity/useGetQueryResultBundle.js"; import G, { LoadingItem as Y } from "./TermsAndConditionsItem.js"; function Se({ termsAndConditionsTableID: c, termsAndConditionsTableVersion: E, onFormChange: b, hideLinkToFullTC: R = !1 }) { const [m, I] = f([]), { data: a, isLoading: v, error: w, isError: L } = j( { entityId: c, query: { sql: `SELECT * FROM ${c}.${E} ORDER BY order asc` }, partMask: M, concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest" }, { staleTime: 1 / 0 }, !0 // force this query to be run as the anonymous user (without an access token) ), y = L && w.status == 404; y && b(!0), S(() => { if (a && a.queryResult && a.queryResult.queryResults) { const { rows: e, headers: t } = a.queryResult.queryResults, l = t.findIndex((o) => o.name === "icon"), q = t.findIndex((o) => o.name === "label"), O = t.findIndex( (o) => o.name === "description" ), p = []; e.forEach((o) => { const { values: h } = o, B = { iconFileHandleId: h[l] ?? "", label: h[q] ?? "", description: h[O] ?? "" }; p.push(B); }), I(p); const x = p.length; d(i(x)), u( i(x).fill(!0, 0, 1) ); } }, [a]); const C = "https://www.synapse.org/TrustCenter:TermsOfService", _ = "https://sagebionetworks.org/trust-center", i = (e) => Array.from(Array(e).fill(!1)); let k = !0; const [s, d] = f([]), [T, u] = f([]); S(() => (k && A(), () => { k = !1; }), [T, s]); const A = () => { const e = s.length > 0 && !s.includes(!1); b(e); }, N = (e) => { const t = !s[e], l = s.length; t ? (d( i(l).fill(!0, 0, e + 1) ), e + 2 <= m.length && u( i(l).fill(!0, 0, e + 2) )) : (d( i(l).fill(!0, 0, e) ), u( i(l).fill(!0, 0, e + 1) )); }; return /* @__PURE__ */ n("section", { className: "terms-conditions", children: [ /* @__PURE__ */ r("h3", { className: "page-header", children: "Pledge" }), /* @__PURE__ */ n("form", { children: [ /* @__PURE__ */ n("label", { children: [ "I affirm my commitment to Sage's", " ", /* @__PURE__ */ r(g, { target: "_blank", href: C, children: "Terms of Service" }), " ", "and policies for responsible research and data handling (", /* @__PURE__ */ r(g, { target: "_blank", href: _, children: "Trust Center" }), "), including:" ] }), y && /* @__PURE__ */ n(F, { severity: "warning", children: [ /* @__PURE__ */ r(P, { children: "Source data unavailable" }), /* @__PURE__ */ n(Q, { variant: "body1", children: [ "We are unable to display the source table content for the Synapse Pledge at this time. Please review the full", " ", /* @__PURE__ */ n(g, { target: "_blank", href: C, children: [ " ", "Terms of Service", " " ] }), " ", 'carefully before proceeding. By clicking "Agree And Continue," you confirm that you have read and understood the Terms and Conditions for use.' ] }) ] }), /* @__PURE__ */ n("ul", { className: "term-list", children: [ v && /* @__PURE__ */ r(Y, { numLoadingItems: 6 }), m.length > 0 && m.map((e, t) => /* @__PURE__ */ r( G, { item: e, id: t, checked: s[t], enabled: T[t], termsAndConditionsTableID: c, onChange: N }, `tc-item-${t}` )) ] }), !R && /* @__PURE__ */ r("div", { className: "view-terms", children: /* @__PURE__ */ r( $, { variant: "contained", href: U, target: "_blank", children: "View Complete Terms and Conditions for Use" } ) }) ] }) ] }); } export { Se as default }; //# sourceMappingURL=TermsAndConditions.js.map