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

86 lines (85 loc) 2.45 kB
import { jsx as n, jsxs as c } from "react/jsx-runtime"; import { getEvaluationRoundsList as p } from "../../synapse-client/SynapseClient.js"; import { useSynapseContext as v } from "../../utils/context/SynapseContext.js"; import { useListState as L } from "../../utils/hooks/useListState.js"; import { Button as E } from "@mui/material"; import { useState as f, useEffect as h } from "react"; import R from "shortid"; import { ErrorBanner as g } from "../error/ErrorBanner.js"; import { EvaluationRoundEditor as T } from "./EvaluationRoundEditor.js"; import { convertEvaluationRoundToInput as S } from "./input_models/models.js"; const x = (o, i, e, a) => { const r = [], s = (d) => { p( o, { nextPageToken: d }, i ).then((t) => { const m = t.page.map( (u) => S(u) ); r.push(...m), a(void 0), t.nextPageToken ? s(t.nextPageToken) : e(r); }).catch((t) => { a(t); }); }; s(void 0); }; function A({ evaluationId: o }) { const { accessToken: i } = v(), [e, a] = f(), { list: r, appendToList: s, handleListChange: d, handleListRemove: t, setList: m } = L([]); return h( () => { x( o, i, m, a ); }, // we explicitly dont want to list setEvaluationRoundInputList nor setError as a dependency // if we do, the fetchEvaluationList will re-fetch from the backend on every new render // eslint-disable-next-line react-hooks/exhaustive-deps [i, o] ), e ? /* @__PURE__ */ n(g, { error: e }) : /* @__PURE__ */ c("div", { className: "evaluation-round-editor-list", children: [ /* @__PURE__ */ n("div", { className: "evaluation-rounds", children: r.map((u, l) => /* @__PURE__ */ n( T, { evaluationRoundInput: u, onSave: d(l), onDelete: t(l) }, u.reactListKey )) }), /* @__PURE__ */ n("div", { children: /* @__PURE__ */ n( E, { className: "add-round-button", variant: "contained", color: "primary", onClick: () => { s({ reactListKey: R(), evaluationId: o, roundStart: "", roundEnd: "", totalSubmissionLimit: "", otherLimits: [] }); }, children: "Add Round" } ) }) ] }); } export { A as EvaluationRoundEditorList }; //# sourceMappingURL=EvaluationRoundEditorList.js.map