synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
213 lines (212 loc) • 6.4 kB
JavaScript
import { jsxs as u, jsx as t } from "react/jsx-runtime";
import v from "../../synapse-queries/entity/useGetQueryResultBundle.js";
import { formatDate as R } from "../../utils/functions/DateFormatter.js";
import { parseEntityIdFromSqlStatement as C } from "../../utils/functions/SqlFunctions.js";
import { convertDoiToLink as D } from "../../utils/functions/RegularExpressions.js";
import { BUNDLE_MASK_QUERY_SELECT_COLUMNS as L, BUNDLE_MASK_QUERY_RESULTS as b } from "../../utils/SynapseConstants.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 "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import "lodash-es";
import { getFieldIndex as n } from "../../utils/functions/queryUtils.js";
import { Box as r, Skeleton as k, Chip as B, Typography as x, Link as _ } from "@mui/material";
import q from "@mui/material/Grid";
import w from "dayjs";
import M from "../PortalSectionHeader/PortalSectionHeader.js";
const E = ({
pub: i,
isLoading: a,
categoryColIndex: m,
// PORTALS-3426 - category was dropped
titleColIndex: s,
journalColIndex: l,
publicationDateColIndex: d,
doiColIndex: p
}) => /* @__PURE__ */ t(
q,
{
sx: {
height: { xs: "auto", sm: "initial" },
minWidth: { xs: "280px", lg: "initial" },
maxWidth: { xs: "450px", lg: "initial" }
},
children: /* @__PURE__ */ t(r, { sx: { height: "100%" }, children: a ? /* @__PURE__ */ t(k, { variant: "rectangular", height: 275, width: "100%" }) : /* @__PURE__ */ u("div", { children: [
i.values[l] && /* @__PURE__ */ t(
B,
{
label: /* @__PURE__ */ t(
x,
{
variant: "overline",
sx: { fontSize: "14px", lineHeight: "initial" },
children: i.values[l]
}
),
sx: {
borderRadius: "3px",
height: "auto",
padding: "4px 8px",
"& .MuiChip-label": {
padding: "0",
display: "block",
whiteSpace: "normal"
}
}
}
),
/* @__PURE__ */ t(
x,
{
variant: "headline2",
sx: {
color: "grey.1000",
fontSize: "21px",
padding: "20px 0px"
},
children: /* @__PURE__ */ t(
_,
{
href: D(i.values[p] || ""),
target: "_blank",
sx: {
color: "inherit",
textDecoration: "none",
fontWeight: "inherit",
"&:hover": {
textDecoration: "none"
}
},
children: i.values[s]
}
)
}
),
/* @__PURE__ */ t(
r,
{
sx: {
display: "flex",
gap: "8px",
flexDirection: "column"
},
children: /* @__PURE__ */ t(
x,
{
variant: "body1",
sx: {
color: "grey.700",
fontSize: "14px",
lineHeight: 1.35,
paddingBottom: { xs: 0, md: "35px" }
},
children: i.values[d] && R(
w(Number(i.values[d])),
"MMMM, YYYY"
)
}
)
}
)
] }) })
},
i.rowId
);
function Z(i) {
const { sql: a, buttonLink: m, buttonLinkText: s, summaryText: l } = i, d = C(a), p = {
partMask: L | b,
concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest",
entityId: d,
query: {
sql: a
}
}, { data: o, isLoading: h } = v(p), g = o?.queryResult.queryResults.rows ?? [];
let c;
((e) => {
e.CATEGORY = "Category", e.JOURNAL = "Journal", e.TITLE = "Title", e.PUBLICATION_DATE = "publicationDate", e.DOI = "DOI";
})(c || (c = {}));
const f = n(
"Category",
o
), y = n(
"Journal",
o
), T = n("Title", o), I = n(
"publicationDate",
o
), S = n("DOI", o);
return /* @__PURE__ */ u(
r,
{
sx: {
display: "grid",
gridTemplateColumns: { xs: "1fr", md: "3fr 1fr" },
height: { xs: "auto", md: "initial" },
gap: { xs: "24px", md: "80px" },
padding: { xs: "40px", lg: "80px" }
},
children: [
/* @__PURE__ */ t(
r,
{
sx: {
order: { xs: 1, md: 0 }
},
children: /* @__PURE__ */ t(
r,
{
sx: (e) => ({
display: "grid",
gap: "32px",
gridTemplateColumns: {
xs: "1fr",
sm: "repeat(auto-fill, minmax(280px, 1fr))",
lg: "repeat(auto-fill, minmax(255px, 1fr))",
xl: "repeat(auto-fill, minmax(322px, 1fr))"
},
[e.breakpoints.down("sm")]: {
"& > :nth-of-type(n+4)": {
display: "none"
}
}
}),
children: g.map((e) => /* @__PURE__ */ t(
E,
{
pub: e,
isLoading: h,
categoryColIndex: f,
titleColIndex: T,
journalColIndex: y,
publicationDateColIndex: I,
doiColIndex: S
},
e.rowId
))
}
)
}
),
/* @__PURE__ */ t(r, { sx: { paddingBottom: "30px" }, children: /* @__PURE__ */ t(
M,
{
title: "Recently Published",
summaryText: l,
buttonText: s,
link: m,
reverseButtonAndText: !0,
sx: {
h2: { fontSize: "24px", paddingTop: "30px", width: "100%" },
"& p": { fontSize: "16px", lineHeight: "24px" }
}
}
) })
]
}
);
}
export {
Z as default
};
//# sourceMappingURL=RecentPublicationsGrid.js.map