UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

93 lines (92 loc) 2.64 kB
import { jsxs as l, Fragment as S, jsx as t } from "react/jsx-runtime"; import { useGetAllSubscriptions as h } from "../../synapse-queries/subscription/useSubscription.js"; import { Box as y, Tabs as v, Tab as p, Stack as P, Button as T } from "@mui/material"; import { SubscriptionObjectType as r, SortByType as D } from "@sage-bionetworks/synapse-types"; import { useState as d, useId as C } from "react"; import F from "../DropdownSelect/DropdownSelect.js"; import I from "./SubscriptionItem.js"; const o = [ { value: "ASC", label: "Date Posted" }, { value: "DESC", label: "Most Recent" } ]; function N() { const [s, u] = d( r.FORUM ), [i, m] = d(o[0]), b = C(), n = { objectType: s, sortBy: D.CREATED_ON, sortDirection: i.value }, { data: g, hasNextPage: f, isFetchingNextPage: c, fetchNextPage: x } = h( n, // Since the user may edit their subscriptions on this page, set staleTime to infinity to prevent re-fetching while editing { staleTime: 1 / 0, select: (e) => ({ pages: e.pages.flatMap((a) => a.results), pageParams: e.pageParams }) }, // Override the query key with a unique ID, because we don't want changes to invalidate this list while it's being used [`subscriptionPageFetch_${b}`, n] ); return /* @__PURE__ */ l(S, { children: [ /* @__PURE__ */ t(y, { sx: { float: "right" }, children: /* @__PURE__ */ t( F, { variant: "outlined", options: o.map((e) => e.label), selectedIndex: o.findIndex( (e) => e.value === i.value ), setSelectedIndex: (e) => m(o[e]) } ) }), /* @__PURE__ */ l( v, { sx: { mb: 3 }, value: s, onChange: (e, a) => { e.stopPropagation(), u(a); }, textColor: "secondary", indicatorColor: "secondary", children: [ /* @__PURE__ */ t(p, { value: r.FORUM, label: "Project Forums" }), /* @__PURE__ */ t(p, { value: r.THREAD, label: "Threads" }) ] } ), /* @__PURE__ */ t( P, { sx: { gap: 0.5 }, children: g?.pages.map((e) => /* @__PURE__ */ t( I, { subscription: e }, e.subscriptionId )) } ), f && /* @__PURE__ */ t( T, { variant: "contained", onClick: () => { x(); }, disabled: c, sx: { mt: 6 }, children: c ? "Loading..." : "Load More" } ) ] }); } export { N as default }; //# sourceMappingURL=SubscriptionPage.js.map