synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
46 lines (45 loc) • 1.66 kB
JavaScript
import { jsxs as h, Fragment as p, jsx as r } from "react/jsx-runtime";
import { useGetUserChallengesInfinite as I } from "../../synapse-queries/user/useGetUserChallenges.js";
import { PRODUCTION_ENDPOINT_CONFIG as j } from "../../utils/functions/getEndpoint.js";
import { useEffect as d } from "react";
import { useErrorHandler as N } from "react-error-boundary";
import { useInView as w } from "react-intersection-observer";
import { SkeletonTable as x } from "../Skeleton/SkeletonTable.js";
function U({ userId: g }) {
const l = N(), { ref: m, inView: a } = w(), {
data: u,
status: i,
isFetching: n,
isLoading: E,
hasNextPage: c,
fetchNextPage: o,
isError: f,
error: s
} = I(g);
d(() => {
f && s && l(s);
}, [f, s, l]), d(() => {
i === "success" && !n && c && o && a && o();
}, [i, n, c, o, a]);
const t = u?.pages.flatMap((e) => e.results) ?? [];
return /* @__PURE__ */ h(p, { children: [
t.length > 0 && /* @__PURE__ */ h(p, { children: [
t.map((e) => e && e.challenge && e.projectHeader ? /* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
"a",
{
target: "_self",
rel: "noopener noreferrer",
href: `${j.PORTAL}Synapse:${e.challenge.projectId}/challenge`,
children: e.projectHeader.name
}
) }, `user-challenge-list-item-${e.challenge.projectId}`) : !1),
/* @__PURE__ */ r("div", { ref: m })
] }),
!n && t.length == 0 && /* @__PURE__ */ r("div", { children: "Empty" }),
E && /* @__PURE__ */ r(x, { numRows: 5, numCols: 1 })
] });
}
export {
U as default
};
//# sourceMappingURL=UserChallenges.js.map