synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
80 lines (79 loc) • 3.19 kB
JavaScript
import { jsx as e, jsxs as c, Fragment as U } from "react/jsx-runtime";
import { getThread as v, getReply as N, getReplyMessageUrl as O, getUserProfileById as y, getThreadMessageUrl as S } from "../../synapse-client/SynapseClient.js";
import { useSynapseContext as C } from "../../utils/context/SynapseContext.js";
import { formatDate as A } from "../../utils/functions/DateFormatter.js";
import { PRODUCTION_ENDPOINT_CONFIG as M } from "../../utils/functions/getEndpoint.js";
import { Box as P, Skeleton as j, Typography as f } from "@mui/material";
import k from "dayjs";
import { useState as n, useEffect as D } from "react";
import T from "../IconSvg/IconSvg.js";
import { SkeletonParagraph as $ } from "../Skeleton/SkeletonParagraph.js";
import { UserBadge as E } from "../UserCard/UserBadge.js";
const L = async (i) => (await fetch(i, {
method: "GET",
headers: {
Accept: "*/*",
"Access-Control-Request-Headers": "authorization",
"Content-Type": "text/plain; charset=utf-8"
}
})).text(), X = (i) => {
const { threadId: l, replyId: s } = i, { accessToken: a } = C(), [d, w] = n(), [I, R] = n(""), [p, x] = n(), [B, h] = n(), [m, u] = n(!1);
return D(() => {
(async () => {
let o;
u(!0);
const t = await v(l, a);
if (s) {
const r = await N(s, a);
o = await O(r.messageKey, a), h(await y(r.createdBy)), x(r);
} else
h(await y(t.createdBy)), o = await S(
t.messageKey,
a
);
R(await L(o.messageUrl)), w(t), u(!1);
})();
}, [a, s, l]), /* @__PURE__ */ e("div", { className: "search-result-container", children: /* @__PURE__ */ c(
P,
{
sx: {
display: "grid",
gridTemplateColumns: "40px auto"
},
children: [
/* @__PURE__ */ e("div", { children: m ? /* @__PURE__ */ e(j, { variant: "circular", width: "30px", height: "30px" }) : s ? /* @__PURE__ */ e(T, { icon: "replyTwoTone" }) : /* @__PURE__ */ e(T, { icon: "chatTwoTone" }) }),
/* @__PURE__ */ e("div", { children: m ? /* @__PURE__ */ e($, { numRows: 4 }) : /* @__PURE__ */ c(U, { children: [
/* @__PURE__ */ e(f, { variant: "headline3", gutterBottom: !0, children: /* @__PURE__ */ e(
"a",
{
className: "link",
href: ((g, o, t) => {
let r = `${M.PORTAL}Synapse:${o}/discussion/threadId=${g}`;
return t && (r += `&replyId=${t}`), r;
})(
d?.id,
d?.projectId,
p?.id
),
children: d?.title
}
) }),
/* @__PURE__ */ e("div", { className: "truncated", children: /* @__PURE__ */ e(f, { variant: "body1", gutterBottom: !0, children: I }) }),
/* @__PURE__ */ c("div", { className: "search-result-footer", children: [
s ? "Reply" : "Thread",
" by",
" ",
/* @__PURE__ */ e(E, { userId: B?.ownerId }),
" ",
A(k(p?.createdOn))
] })
] }) })
]
}
) });
};
export {
X as default,
L as getMessage
};
//# sourceMappingURL=DiscussionSearchResult.js.map