synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
87 lines (86 loc) • 2.58 kB
JavaScript
import { jsxs as m, Fragment as p, jsx as t } from "react/jsx-runtime";
import * as C from "../../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 { useSynapseContext as j } from "../../utils/context/SynapseContext.js";
import { Alert as g } from "@mui/material";
import { useState as n } from "react";
import { ConfirmationDialog as S } from "../ConfirmationDialog/ConfirmationDialog.js";
import P from "../FullWidthAlert/FullWidthAlert.js";
import w from "../TextField/TextField.js";
function $({
isShowingModal: f = !1,
onClose: d
}) {
const { accessToken: u } = j(), [o, i] = n(""), [h, s] = n(!1), [a, r] = n(), c = () => {
i(""), r(void 0), d();
}, l = async () => {
try {
const e = await C.createProject(
o,
u
);
s(!0), c(), window.location.href = `/Synapse:${e.id}`;
} catch (e) {
e.reason ? r(e.reason) : r(e.toString());
}
};
return /* @__PURE__ */ m(p, { children: [
/* @__PURE__ */ t(
S,
{
open: f,
title: "Create a new Project",
content: /* @__PURE__ */ m(p, { children: [
/* @__PURE__ */ t(
w,
{
id: "projectInput",
label: "Project Name",
value: o,
fullWidth: !0,
onChange: (e) => {
i(e.target.value);
},
inputProps: {
onKeyDown: (e) => {
e.key === "Enter" && o !== "" && l();
}
}
}
),
a && /* @__PURE__ */ t(g, { severity: "error", children: a })
] }),
confirmButtonProps: { children: "Save" },
onConfirm: () => {
l();
},
onCancel: c,
maxWidth: "md"
}
),
/* @__PURE__ */ t(
P,
{
show: h,
variant: "info",
title: "Project created",
description: "",
autoCloseAfterDelayInSeconds: 10,
onClose: () => {
s(!1);
}
}
)
] });
}
export {
$ as CreateProjectModal
};
//# sourceMappingURL=CreateProjectModal.js.map