synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
142 lines (141 loc) • 4.18 kB
JavaScript
import { jsx as n, jsxs as o, Fragment as C } from "react/jsx-runtime";
import { getEvaluationPermissions as E, deleteEvaluation as D } from "../../synapse-client/SynapseClient.js";
import { useSynapseContext as g } from "../../utils/context/SynapseContext.js";
import { Card as b, CardContent as x, Box as I, Button as S, IconButton as k, Menu as w, MenuItem as p, Divider as v } from "@mui/material";
import { useState as d, useEffect as y } from "react";
import { ErrorBanner as B } from "../error/ErrorBanner.js";
import P from "../IconSvg/IconSvg.js";
import { CreatedOnByUserDiv as A } from "./CreatedOnByUserDiv.js";
import { DeleteEvaluationQueueConfirmationDialog as M } from "./DeleteEvaluationQueueConfirmationDialog.js";
function q({
evaluation: e,
onEdit: m,
onModifyAccess: h,
onSubmit: u,
onDeleteSuccess: s
}) {
const { accessToken: t } = g(), [i, r] = d(), [l, f] = d();
return y(() => {
r(void 0), E(e.id, t).then((a) => {
f(a);
}).catch((a) => r(a));
}, [e, t]), /* @__PURE__ */ n("div", { className: "evaluation-card", children: /* @__PURE__ */ n(b, { children: /* @__PURE__ */ o(x, { sx: { p: 3 }, children: [
i && /* @__PURE__ */ n(B, { error: i }),
l && /* @__PURE__ */ o(C, { children: [
/* @__PURE__ */ o(I, { sx: { display: "flex", justifyContent: "space-between" }, children: [
/* @__PURE__ */ n("label", { children: "EVALUATION QUEUE" }),
/* @__PURE__ */ n(
O,
{
permissions: l,
onDelete: () => {
r(void 0), D(e.id, t).then(s).catch(r);
},
onEdit: m,
onModifyAccess: h
}
)
] }),
/* @__PURE__ */ o("h4", { children: [
e.name,
" (",
e.id,
")"
] }),
/* @__PURE__ */ n("label", { children: "Description" }),
/* @__PURE__ */ n("p", { children: e.description }),
/* @__PURE__ */ n("label", { children: "Instructions" }),
/* @__PURE__ */ n("p", { children: e.submissionInstructionsMessage }),
/* @__PURE__ */ n(
A,
{
userId: e.ownerId,
date: new Date(e.createdOn)
}
),
l?.canSubmit && /* @__PURE__ */ n(
S,
{
className: "submit-button",
color: "primary",
variant: "contained",
onClick: u,
children: "Submit"
}
)
] })
] }) }) });
}
function O({
permissions: e,
onEdit: m,
onModifyAccess: h,
onDelete: u
}) {
const [s, t] = d(!1), [i, r] = d(null), l = !!i, f = (a) => {
r(a.currentTarget);
}, c = () => {
r(null);
};
return e.canEdit || e.canChangePermissions || e.canDelete ? /* @__PURE__ */ o(C, { children: [
e?.canDelete && /* @__PURE__ */ n(
M,
{
open: s,
onConfirm: () => {
u(), t(!1);
},
onCancel: () => t(!1)
},
String(s)
),
/* @__PURE__ */ n(k, { onClick: f, "aria-label": "Options", children: /* @__PURE__ */ n(P, { icon: "verticalEllipsis", wrap: !1 }) }),
/* @__PURE__ */ o(
w,
{
anchorEl: i,
open: l,
onClose: c,
slotProps: { paper: { sx: { minWidth: "120px" } } },
children: [
e.canEdit && /* @__PURE__ */ n(
p,
{
role: "menuitem",
onClick: () => {
c(), m();
},
children: "Edit"
}
),
e.canChangePermissions && /* @__PURE__ */ n(
p,
{
role: "menuitem",
onClick: () => {
c(), h();
},
children: "Modify Access"
}
),
e.canDelete && /* @__PURE__ */ n(v, {}),
e.canDelete && /* @__PURE__ */ n(
p,
{
role: "menuitem",
onClick: () => {
c(), t(!0);
},
children: "Delete"
}
)
]
}
)
] }) : null;
}
export {
q as EvaluationCard,
q as default
};
//# sourceMappingURL=EvaluationCard.js.map