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

397 lines (396 loc) 16.9 kB
import { jsx as e, jsxs as r, Fragment as y } from "react/jsx-runtime"; import G from "../../AccessRequirementList/AccessRequirementList.js"; import { CancelDataAccessRequestConfirmationModal as W } from "./CancelDataAccessRequestConfirmationModal.js"; import { ApproveSubmissionConfirmationModal as _ } from "./ApproveSubmissionConfirmationModal.js"; import { displayToast as $ } from "../../ToastMessage/ToastMessage.js"; import { useGetAccessRequirements as z, useGetAccessRequirementACL as Y, useGetAccessRequirementWikiPageKey as J } from "../../../synapse-queries/dataaccess/useAccessRequirements.js"; import Q from "../../../synapse-queries/dataaccess/useDataAccessSubmission.js"; 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 { SubmissionState as m, ACCESS_TYPE as X, FileHandleAssociateType as Z } from "@sage-bionetworks/synapse-types"; import "../../../utils/functions/EntityTypeUtils.js"; import { ACT_TEAM_ID as ee } from "../../../utils/SynapseConstants.js"; import { isEmpty as T, upperFirst as te, toLower as ie } from "lodash-es"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import "../../../utils/context/SynapseContext.js"; import "@tanstack/react-query"; import "../../../utils/PermissionLevelToAccessType.js"; import { useState as p, useMemo as j, Fragment as U } from "react"; import "use-deep-compare-effect"; import "@tanstack/query-core"; import "lodash-es/isEmpty"; import "lodash-es/isEqual"; import "lodash-es/xorWith"; import { useGetUserAccessApproval as re } from "../../../synapse-queries/dataaccess/useAccessApprovals.js"; import "@sage-bionetworks/synapse-client"; import "../../../utils/types/IsType.js"; import { Skeleton as o, Grid as g, Typography as i, Button as h, Stack as R } 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 { useNavigate as ae } from "react-router"; import { useGetCurrentUserProfile as se } from "../../../synapse-queries/user/useUserBundle.js"; import { formatDate as F } from "../../../utils/functions/DateFormatter.js"; import l from "dayjs"; import ne from "dayjs/plugin/duration"; import { SynapseErrorBoundary as oe } from "../../error/ErrorBanner.js"; import { Markdown as de } from "../../Markdown/MarkdownSynapse.js"; import { UserBadge as S } from "../../UserCard/UserBadge.js"; import P from "../../UserOrTeamBadge/UserOrTeamBadge.js"; import { FileHandleLink as ce } from "../../widgets/FileHandleLink.js"; import le from "../RejectDataAccessRequestModal.js"; l.extend(ne); function w(c) { const { submissionId: s, fileHandleId: d } = c, u = j( () => ({ fileHandleId: d, associateObjectId: s, associateObjectType: Z.DataAccessSubmissionAttachment }), [d, s] ); return /* @__PURE__ */ e( ce, { showDownloadIcon: !0, fileHandleAssociation: u }, d ); } function me(c) { const { data: s } = J( c.accessRequirementId, { throwOnError: !0 } ); return s ? /* @__PURE__ */ e("div", { className: "AccessRequirementWikiContainer", children: /* @__PURE__ */ r("div", { className: "AccessRequirementWikiContent", children: [ /* @__PURE__ */ e(i, { variant: "headline1", children: "Access Requirement" }), /* @__PURE__ */ e("hr", {}), /* @__PURE__ */ e( de, { wikiId: s?.wikiPageId, ownerId: s?.ownerObjectId, objectType: s?.ownerObjectType } ) ] }) }) : /* @__PURE__ */ e(o, { width: "100%", height: "600px" }); } function ue(c, s) { return s.submittedBy === c || !!s.accessorChanges.find((d) => d.userId === c); } function nt(c) { const { submissionId: s, isReviewer: d } = c, [u, A] = p(!1), { data: f } = se(), { data: t, isLoading: O } = Q(s, { throwOnError: !0 }), k = !!(t && f && ue(f.ownerId, t)), { data: q, isLoading: B } = re(String(s), { enabled: k && t && t.state === m.APPROVED }), C = !!(q && l(q.expiredOn).isBefore(l())), E = t && t.submittedBy === f?.ownerId, { data: n } = z( parseInt(t?.accessRequirementId), { enabled: !!t } ), { data: K, isLoading: v } = Y( t?.accessRequirementId, { enabled: !!t, throwOnError: !0 } ), [N, I] = p(!1), [ L, D ] = p(!1), [M, x] = p(!1), H = ae(), b = K?.resourceAccess.filter((a) => a.accessType.includes(X.REVIEW_SUBMISSIONS)).map((a) => a.principalId), V = j(() => t && !B ? C ? "Expired" : t.state : /* @__PURE__ */ e(o, { width: 100 }), [C, B, t]); return /* @__PURE__ */ r(g, { container: !0, spacing: 4, className: "SubmissionPage", children: [ N && n && /* @__PURE__ */ e( G, { renderAsModal: !0, accessRequirementFromProps: [n], onHide: () => I(!1), onSubmissionCreated: (a) => { I(!1), $("Data access request submitted", "success", { primaryButtonConfig: { text: "View Request", onClick: () => { H("/submissions/" + a); } } }); } } ), /* @__PURE__ */ e( _, { open: M, onClose: () => { x(!1); }, submissionId: String(s) } ), u && /* @__PURE__ */ e( le, { submissionId: s, open: u, onClose: () => A(!1) } ), /* @__PURE__ */ r( g, { className: "SubmissionSummary", size: { xs: 12, sm: 4, lg: 3 }, children: [ /* @__PURE__ */ e(i, { variant: "dataFieldKey", gutterBottom: !0, children: "Status" }), /* @__PURE__ */ e( i, { variant: "headline3", sx: { textTransform: "uppercase" }, gutterBottom: !0, children: V } ), /* @__PURE__ */ e("br", {}), O && /* @__PURE__ */ e(o, { width: 200 }), t && d && t.state === m.SUBMITTED && /* @__PURE__ */ r("div", { className: "ButtonContainer", children: [ /* @__PURE__ */ e( h, { onClick: () => { x(!0); }, color: "success", variant: "contained", children: "Approve" } ), /* @__PURE__ */ e( h, { onClick: () => { A(!0); }, color: "error", variant: "contained", children: "Reject" } ) ] }), t && E && /* @__PURE__ */ r("div", { className: "ButtonContainer", children: [ /* @__PURE__ */ e( W, { open: L, submissionId: String(s), accessRequirementId: t?.accessRequirementId || "", onClose: () => D(!1) } ), t.state === m.SUBMITTED && /* @__PURE__ */ e( h, { onClick: () => { D(!0); }, color: "primary", variant: "outlined", children: "Cancel Request" } ), t.state !== m.SUBMITTED && /* @__PURE__ */ r( h, { onClick: () => { I(!0); }, color: "primary", variant: "outlined", children: [ t.state === m.APPROVED ? "Update" : "Modify", " ", "Request" ] } ) ] }), /* @__PURE__ */ e(i, { variant: "dataFieldKey", gutterBottom: !0, children: "Access Requirement Name" }), /* @__PURE__ */ e(i, { variant: "smallText1", gutterBottom: !0, children: n?.name ?? /* @__PURE__ */ e(o, { width: 100 }) }), /* @__PURE__ */ e("br", {}), d && /* @__PURE__ */ r(y, { children: [ /* @__PURE__ */ e(i, { variant: "dataFieldKey", gutterBottom: !0, children: "Assigned Reviewer" }), /* @__PURE__ */ r(R, { children: [ v && /* @__PURE__ */ e(o, { width: 100 }), !v && !T(b) && b.map((a) => /* @__PURE__ */ e(P, { principalId: a }, a)), !v && T(b) && /* @__PURE__ */ e(P, { principalId: ee }) ] }), /* @__PURE__ */ e("br", {}) ] }), /* @__PURE__ */ e(i, { variant: "dataFieldKey", gutterBottom: !0, children: "Conditions" }), n ? /* @__PURE__ */ e(i, { variant: "smallText1", component: "div", gutterBottom: !0, children: /* @__PURE__ */ r("ul", { children: [ /* @__PURE__ */ r("li", { children: [ "Expiration period:", " ", l.duration({ milliseconds: n.expirationPeriod }).asDays(), " ", "day(s)", n.expirationPeriod === 0 && " (no expiration)" ] }), n.isCertifiedUserRequired && /* @__PURE__ */ e("li", { children: "User must be Certified" }), n.isValidatedProfileRequired && /* @__PURE__ */ e("li", { children: "User Profile must be Validated" }), n.isDUCRequired && /* @__PURE__ */ e("li", { children: "DUC is required" }), n.isIDURequired && /* @__PURE__ */ e("li", { children: "IDU is required" }), n.isIDUPublic && /* @__PURE__ */ e("li", { children: "IDU will be made public" }), n.isIRBApprovalRequired && /* @__PURE__ */ e("li", { children: "IRB Approval is required" }), n.areOtherAttachmentsRequired && /* @__PURE__ */ e("li", { children: "Other attachments are required" }) ] }) }) : /* @__PURE__ */ e(o, { width: 100 }), /* @__PURE__ */ e("br", {}), /* @__PURE__ */ r("div", { className: "SubmissionSummaryGrid", children: [ /* @__PURE__ */ e(i, { variant: "dataFieldKey", children: "Submitted By" }), /* @__PURE__ */ e(i, { variant: "smallText1", children: t ? /* @__PURE__ */ e(S, { userId: t.submittedBy }) : /* @__PURE__ */ e(o, { width: 100 }) }), /* @__PURE__ */ e(i, { variant: "dataFieldKey", children: "Submitted On" }), /* @__PURE__ */ e(i, { variant: "smallText1", children: t ? F(l(t.submittedOn)) : /* @__PURE__ */ e(o, { width: 100 }) }), d && /* @__PURE__ */ r(y, { children: [ /* @__PURE__ */ e(i, { variant: "dataFieldKey", children: "Modified By" }), /* @__PURE__ */ e(i, { variant: "smallText1", children: t ? /* @__PURE__ */ e(S, { userId: t.modifiedBy }) : /* @__PURE__ */ e(o, { width: 100 }) }) ] }), /* @__PURE__ */ e(i, { variant: "dataFieldKey", children: "Modified On" }), /* @__PURE__ */ e(i, { variant: "smallText1", children: t ? F(l(t.modifiedOn)) : /* @__PURE__ */ e(o, { width: 100 }) }), /* @__PURE__ */ r(i, { className: "Key", variant: "dataFieldKey", children: [ "Data Requesters", `${t ? ` (${t.accessorChanges.length})` : ""}` ] }), t ? t.accessorChanges.map((a) => /* @__PURE__ */ r(U, { children: [ /* @__PURE__ */ e(i, { className: "Key DataAccessor", variant: "smallText1", children: /* @__PURE__ */ e("span", { style: { whiteSpace: "nowrap" }, children: /* @__PURE__ */ e( S, { userId: a.userId }, a.userId ) }) }), /* @__PURE__ */ e(i, { className: "Value DataAccessor", variant: "smallText1", children: te( ie( a.type.substring( 0, a.type.indexOf("_") ) ) ) }) ] }, a.userId)) : /* @__PURE__ */ e(o, { width: 100 }), /* @__PURE__ */ e(i, { className: "Key", variant: "dataFieldKey", children: "Institution" }), /* @__PURE__ */ e(i, { className: "Value", variant: "smallText1", children: t ? t.researchProjectSnapshot.institution : /* @__PURE__ */ e(o, { width: 100 }) }), /* @__PURE__ */ e(i, { className: "Key", variant: "dataFieldKey", children: "Project Lead" }), /* @__PURE__ */ e(i, { className: "Value", variant: "smallText1", children: t ? t.researchProjectSnapshot.projectLead : /* @__PURE__ */ e(o, { width: 100 }) }) ] }) ] } ), /* @__PURE__ */ e( g, { size: { xs: 12, sm: 8, lg: 9 }, children: /* @__PURE__ */ r(R, { sx: { gap: 2 }, children: [ /* @__PURE__ */ e(oe, { children: t ? /* @__PURE__ */ e( me, { accessRequirementId: t.accessRequirementId } ) : /* @__PURE__ */ e(y, {}) }), t?.rejectedReason && /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ e(i, { variant: "headline1", gutterBottom: !0, children: "Reason for rejection given by reviewer" }), /* @__PURE__ */ e("hr", {}), /* @__PURE__ */ e( i, { variant: "body1", style: { whiteSpace: "pre-line" }, gutterBottom: !0, children: t.rejectedReason } ) ] }), /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ r(i, { variant: "headline1", children: [ "Contents of the Access Request", /* @__PURE__ */ e("hr", {}) ] }), /* @__PURE__ */ r( R, { sx: { gap: 2 }, children: [ t?.researchProjectSnapshot?.intendedDataUseStatement && /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ e(i, { variant: "headline2", gutterBottom: !0, children: "Intended Data Use Statement" }), /* @__PURE__ */ e( i, { variant: "body1", style: { whiteSpace: "pre-line" }, gutterBottom: !0, children: t.researchProjectSnapshot.intendedDataUseStatement } ) ] }), /* @__PURE__ */ e(i, { variant: "headline2", gutterBottom: !0, children: "Documents" }), t?.ducFileHandleId && /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ e(i, { variant: "smallText2", children: "Data Use Certificate (DUC)" }), /* @__PURE__ */ e( w, { submissionId: t.id, fileHandleId: t.ducFileHandleId } ) ] }), t?.irbFileHandleId && /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ e(i, { variant: "smallText2", gutterBottom: !0, children: "IRB Approval Letter" }), /* @__PURE__ */ e( w, { submissionId: t.id, fileHandleId: t.irbFileHandleId } ) ] }), t?.attachments && /* @__PURE__ */ r("section", { children: [ /* @__PURE__ */ e(i, { variant: "smallText2", gutterBottom: !0, children: "Other Attachments" }), t.attachments.map((a) => /* @__PURE__ */ r(U, { children: [ /* @__PURE__ */ e( w, { submissionId: t.id, fileHandleId: a } ), /* @__PURE__ */ e("br", {}) ] }, a)) ] }) ] } ) ] }) ] }) } ) ] }); } export { nt as default }; //# sourceMappingURL=SubmissionPage.js.map