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

88 lines (87 loc) 3.46 kB
import { jsx as r, jsxs as c, Fragment as f } from "react/jsx-runtime"; import { useGetEvaluationsInfinite as P } from "../../synapse-queries/evaluation/useEvaluation.js"; import { LinearProgress as g, Alert as v, TextField as E, Box as n, FormControl as S, FormGroup as w, FormControlLabel as y, Checkbox as L } from "@mui/material"; import { useState as M, useEffect as T, useMemo as C } from "react"; import { HelpPopover as k } from "../HelpPopover/HelpPopover.js"; import A from "../IconSvg/IconSvg.js"; import { IconSvgButton as G } from "../IconSvgButton.js"; import s from "./EvaluationFinder.module.scss.js"; function J(N) { const { accessType: x, activeOnly: b, selectedIds: o = [], onChange: m } = N, [t, d] = M(""), { data: a, isLoading: F, hasNextPage: u, fetchNextPage: h, isFetchingNextPage: l } = P( { accessType: x, activeOnly: b }, { placeholderData: (e) => e, throwOnError: !0 } ); T(() => { u && !l && h(); }, [u, l, h]); const i = C(() => a?.pages?.flatMap((e) => e.results) ?? [], [a]), p = C(() => t.trim() ? i.filter( (e) => e.name?.toLowerCase().includes(t.toLowerCase()) ) : i, [i, t]); return F ? /* @__PURE__ */ r(g, {}) : a?.pages ? /* @__PURE__ */ c(f, { children: [ /* @__PURE__ */ r( E, { fullWidth: !0, variant: "outlined", value: t, onChange: (e) => d(e.target.value), className: s.searchField, placeholder: "Search Evaluations", slotProps: { input: { startAdornment: /* @__PURE__ */ r( A, { icon: "search", wrap: !1, className: s.searchIcon } ), endAdornment: /* @__PURE__ */ r(f, { children: t.length > 0 && /* @__PURE__ */ r( G, { icon: "close", size: "small", onClick: () => { d(""); } } ) }) } } } ), /* @__PURE__ */ r(n, { className: s.scrollContainer, children: /* @__PURE__ */ r(S, { fullWidth: !0, children: /* @__PURE__ */ c(w, { className: s.formGroup, children: [ p.map((e) => /* @__PURE__ */ r( y, { control: /* @__PURE__ */ r(L, { inputProps: { "aria-label": e.name } }), label: /* @__PURE__ */ c(n, { className: s.labelContainer, children: [ e.name, e.submissionInstructionsMessage && e.submissionInstructionsMessage.length > 0 && /* @__PURE__ */ r(n, { className: s.helpPopoverWrapper, children: /* @__PURE__ */ r( k, { markdownText: e.submissionInstructionsMessage, placement: "right" } ) }) ] }), checked: o.includes(e.id), onChange: () => { o.includes(e.id) ? m(o.filter((I) => I !== e.id)) : m([...o, e.id]); } }, e.id )), p.length === 0 && /* @__PURE__ */ r(n, { className: s.emptyState, children: "No evaluations found" }) ] }) }) }), l && /* @__PURE__ */ r(n, { className: s.loadingContainer, children: /* @__PURE__ */ r(g, {}) }) ] }) : /* @__PURE__ */ r(v, { severity: "error", children: "An unexpected error occurred and evaluations could not be loaded" }); } export { J as default }; //# sourceMappingURL=EvaluationFinder.js.map