synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
275 lines (272 loc) • 10.6 kB
JavaScript
import { jsxs as i, Fragment as v, jsx as e } 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 { useState as l, useEffect as _ } from "react";
import "../../../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import { DialogTitle as F, Stack as N, Box as s, IconButton as M, DialogContent as A, TextField as U, Alert as O, DialogActions as G, Button as y, Typography as a } 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 b from "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 { useGetResearchProject as H, useUpdateResearchProject as Y } from "../../../../synapse-queries/dataaccess/useAccessRequirements.js";
import { InfoTwoTone as C } from "@mui/icons-material";
import { HelpPopover as q } from "../../../HelpPopover/HelpPopover.js";
import J from "../../../IconSvg/IconSvg.js";
import V, { getWordCount as R } from "../../../TextField/TextFieldWithWordLimit.js";
import X from "../ManagedACTAccessRequirementFormWikiWrapper.js";
const k = 50, w = 750;
function Ae(h) {
const { onSave: c, managedACTAccessRequirement: r, onHide: I } = h, [u, D] = l(""), [m, x] = l(""), [n, S] = l(""), [f, P] = l(), [p, g] = l(!1), { data: o, isLoading: W } = H(String(r.id), {
// Infinite staleTime ensures this won't be refetched unless explicitly invalidated by the mutation
staleTime: 1 / 0
});
_(() => {
b(u) && o?.projectLead && D(o?.projectLead), b(m) && o?.institution && x(o?.institution), b(n) && o?.intendedDataUseStatement && S(
o?.intendedDataUseStatement
);
}, [
o?.institution,
o?.intendedDataUseStatement,
o?.projectLead
// PORTALS-3774: initialize from existingResearchProject, but do not reset institution,
// projectLead, or intendedDataUseStatement if they have been modified
]);
const { mutate: B, isPending: T } = Y({
onSuccess: (t) => {
c && c(t);
},
onError: (t) => {
console.log(
"RequestDataAccessStep1: Error updating research project data: ",
t
), P({
key: "error",
message: E(t.reason)
});
}
}), d = W || T, E = (t = "") => /* @__PURE__ */ i(v, { children: [
/* @__PURE__ */ e("strong", { children: "Unable to update research project data." }),
/* @__PURE__ */ e("br", {}),
t
] }), j = (t) => {
t.preventDefault(), p ? (B({
...o,
accessRequirementId: String(r.id),
institution: m,
projectLead: u,
intendedDataUseStatement: n || void 0
}), g(!1)) : g(!0);
}, L = u && m && (!r.isIDURequired || n && R(n) >= k && R(n) <= w);
return /* @__PURE__ */ i(v, { children: [
/* @__PURE__ */ e(F, { children: /* @__PURE__ */ i(
N,
{
direction: "row",
sx: {
alignItems: "center",
gap: "5px"
},
children: [
"Request Access",
/* @__PURE__ */ e(s, { sx: { flexGrow: 1 } }),
/* @__PURE__ */ e(M, { onClick: I, children: /* @__PURE__ */ e(J, { icon: "close", wrap: !1, sx: { color: "grey.700" } }) })
]
}
) }),
p && /* @__PURE__ */ e(
z,
{
isIDURequired: r.isIDURequired
}
),
!p && /* @__PURE__ */ i(A, { children: [
/* @__PURE__ */ e(
X,
{
managedACTAccessRequirementId: String(
r.id
),
children: /* @__PURE__ */ i(
s,
{
component: "form",
onSubmit: j,
sx: {
"& .MuiTextField-root": {
marginBottom: "20px"
}
},
children: [
/* @__PURE__ */ e(
U,
{
id: "project-lead",
label: /* @__PURE__ */ i(s, { sx: { display: "inline" }, children: [
/* @__PURE__ */ e("span", { children: "First and last names of your project lead or PI" }),
/* @__PURE__ */ e(
q,
{
Icon: C,
containerSx: { float: "right" },
markdownText: `This field is required.
Provide the name of one person who serves as the project leader or PI.`
}
)
] }),
placeholder: "First and last name of individual leading the project, ex: Jane Smith",
fullWidth: !0,
disabled: d,
type: "text",
value: u,
required: !0,
onChange: (t) => D(t.target.value),
slotProps: {
inputLabel: {
// allows floating the help popover all the way to the right
sx: { width: "100%" }
}
}
}
),
/* @__PURE__ */ e(
U,
{
id: "institution",
label: "Your Institution",
placeholder: "Full, unabbreviated name of the institution you are affiliated with",
fullWidth: !0,
type: "text",
disabled: d,
value: m,
required: !0,
onChange: (t) => x(t.target.value)
}
),
r.isIDURequired && /* @__PURE__ */ e(
V,
{
id: "data-use",
minWords: k,
maxWords: w,
label: /* @__PURE__ */ i(s, { sx: { display: "inline" }, children: [
/* @__PURE__ */ e("span", { children: "Intended Data Use (IDU)" }),
/* @__PURE__ */ e(
q,
{
Icon: C,
containerSx: { float: "right" },
markdownText: `This field is required.
Check the instructions for data access for information on completing the IDU statement.`
}
)
] }),
helperText: r.isIDUPublic ? "This will be visible to the public" : void 0,
placeholder: "Outline the objectives of your proposed research involving this data, and your study design and analysis plan.",
fullWidth: !0,
required: !0,
multiline: !0,
rows: 9,
disabled: d,
value: n,
onChange: (t) => S(t.target.value)
}
)
]
}
)
}
),
f && /* @__PURE__ */ e(O, { severity: f.key, children: f.message })
] }),
/* @__PURE__ */ i(G, { children: [
p && /* @__PURE__ */ i(v, { children: [
/* @__PURE__ */ e(
y,
{
variant: "outlined",
onClick: () => {
g(!1);
},
children: "Back"
}
),
/* @__PURE__ */ e(s, { sx: { flexGrow: 1 } })
] }),
/* @__PURE__ */ e(y, { variant: "outlined", disabled: d, onClick: I, children: "Cancel" }),
/* @__PURE__ */ e(
y,
{
variant: "contained",
type: "submit",
disabled: d || !L,
onClick: j,
children: T ? "Saving..." : "Save and Continue"
}
)
] })
] });
}
function z(h) {
const { isIDURequired: c } = h;
return /* @__PURE__ */ i(A, { children: [
/* @__PURE__ */ e(
a,
{
variant: "body1",
gutterBottom: !0,
sx: {
fontWeight: 700
},
children: "Double-check your submission before continuing!"
}
),
/* @__PURE__ */ e(a, { variant: "body1", gutterBottom: !0, children: "Here are some common reasons a request is rejected:" }),
/* @__PURE__ */ i(s, { component: "ul", children: [
/* @__PURE__ */ i(a, { component: "li", variant: "body1", gutterBottom: !0, children: [
"Is your ",
/* @__PURE__ */ e("i", { children: "Project Lead" }),
" a full name (first and last)?"
] }),
/* @__PURE__ */ i(a, { component: "li", variant: "body1", gutterBottom: !0, children: [
"Is the ",
/* @__PURE__ */ e("i", { children: "Institution" }),
" name you provided unabbreviated and verifiable? You must give the full name of your institution, so we can look it up."
] }),
c && /* @__PURE__ */ i(a, { component: "li", variant: "body1", gutterBottom: !0, children: [
"Did you provide clear ",
/* @__PURE__ */ e("i", { children: "study objectives" }),
" and your",
" ",
/* @__PURE__ */ e("i", { children: "study design" }),
" and ",
/* @__PURE__ */ e("i", { children: "analysis plan" }),
" in the IDU section?"
] })
] }),
/* @__PURE__ */ e(a, { variant: "body1", gutterBottom: !0, children: "Please take a minute to make sure your submission is correct. If your submission is rejected, you’ll have to resubmit after a few days!" })
] });
}
export {
Ae as default
};
//# sourceMappingURL=ResearchProjectForm.js.map