@nivaro/react 0.3.95 → 0.3.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { jsxs as m, jsx as t, Fragment as E } from "react/jsx-runtime";
1
+ import { jsxs as h, jsx as t, Fragment as E } from "react/jsx-runtime";
2
2
  import { useQueryClient as T, useQuery as j, useMutation as O } from "@tanstack/react-query";
3
3
  import { Settings2 as W } from "lucide-react";
4
4
  import { useState as w, useEffect as q } from "react";
@@ -20,18 +20,18 @@ const S = [
20
20
  "model",
21
21
  "token_cap"
22
22
  ];
23
- function Q(d) {
24
- var x, g, o, b, y, p;
25
- const r = d, l = ((x = r == null ? void 0 : r.response) == null ? void 0 : x.fields) ?? ((g = r == null ? void 0 : r.body) == null ? void 0 : g.fields);
26
- if (l && typeof l == "object") {
23
+ function Q(c) {
24
+ var x, b, o, g, y, p;
25
+ const r = c, d = ((x = r == null ? void 0 : r.response) == null ? void 0 : x.fields) ?? ((b = r == null ? void 0 : r.body) == null ? void 0 : b.fields);
26
+ if (d && typeof d == "object") {
27
27
  const a = {}, n = [];
28
- for (const [e, c] of Object.entries(l))
29
- S.includes(e) ? a[e] = String(c) : n.push(String(c));
28
+ for (const [e, l] of Object.entries(d))
29
+ S.includes(e) ? a[e] = String(l) : n.push(String(l));
30
30
  return { byField: a, rest: n };
31
31
  }
32
32
  const i = [
33
33
  (o = r == null ? void 0 : r.response) == null ? void 0 : o.message,
34
- (b = r == null ? void 0 : r.body) == null ? void 0 : b.message,
34
+ (g = r == null ? void 0 : r.body) == null ? void 0 : g.message,
35
35
  (y = r == null ? void 0 : r.response) == null ? void 0 : y.error,
36
36
  (p = r == null ? void 0 : r.body) == null ? void 0 : p.error,
37
37
  r == null ? void 0 : r.message
@@ -42,7 +42,7 @@ function Q(d) {
42
42
  }
43
43
  return { byField: s, rest: f };
44
44
  }
45
- function R(d) {
45
+ function R(c) {
46
46
  return {
47
47
  enabled: "The nightly report",
48
48
  window_start_hour: "Window start",
@@ -51,46 +51,46 @@ function R(d) {
51
51
  notify: "Notification",
52
52
  model: "Model",
53
53
  token_cap: "Token cap"
54
- }[d];
54
+ }[c];
55
55
  }
56
- function h({
57
- label: d,
56
+ function m({
57
+ label: c,
58
58
  hint: r,
59
- error: l,
59
+ error: d,
60
60
  children: u
61
61
  }) {
62
- return /* @__PURE__ */ m("div", { className: "space-y-1", children: [
63
- /* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-3", children: [
64
- /* @__PURE__ */ m("div", { className: "min-w-0", children: [
65
- /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: d }),
62
+ return /* @__PURE__ */ h("div", { className: "space-y-1", children: [
63
+ /* @__PURE__ */ h("div", { className: "flex items-center justify-between gap-3", children: [
64
+ /* @__PURE__ */ h("div", { className: "min-w-0", children: [
65
+ /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: c }),
66
66
  r && /* @__PURE__ */ t("div", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: r })
67
67
  ] }),
68
68
  u
69
69
  ] }),
70
- l && /* @__PURE__ */ t("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: l })
70
+ d && /* @__PURE__ */ t("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: d })
71
71
  ] });
72
72
  }
73
73
  function re() {
74
- const d = P(), r = T(), [l, u] = w(!1), i = j({
74
+ const c = P(), r = T(), [d, u] = w(!1), i = j({
75
75
  queryKey: ["ops-report-settings"],
76
- enabled: l,
77
- queryFn: () => d.request(M("/ops-reports/settings")).then((e) => e.data)
78
- }), [s, f] = w(null), [x, g] = w(""), [o, b] = w({ byField: {}, rest: [] }), [y, p] = w(null);
76
+ enabled: d,
77
+ queryFn: () => c.request(M("/ops-reports/settings")).then((e) => e.data)
78
+ }), [s, f] = w(null), [x, b] = w(""), [o, g] = w({ byField: {}, rest: [] }), [y, p] = w(null);
79
79
  q(() => {
80
- i.data && (f(i.data), g(String(i.data.token_cap)));
80
+ i.data && (f(i.data), b(String(i.data.token_cap)));
81
81
  }, [i.data]);
82
82
  const a = O({
83
- mutationFn: (e) => d.request(B("/ops-reports/settings", e)),
83
+ mutationFn: (e) => c.request(B("/ops-reports/settings", e)),
84
84
  onSuccess: (e) => {
85
- b({ byField: {}, rest: [] }), p(null), r.setQueryData(["ops-report-settings"], e.data), u(!1);
85
+ g({ byField: {}, rest: [] }), p(null), r.setQueryData(["ops-report-settings"], e.data), u(!1);
86
86
  },
87
87
  onError: (e) => {
88
- const c = Q(e);
89
- b(c), e.status === 400 && (Object.keys(c.byField).length || c.rest.length) ? p(null) : (p(e), z(e, "Could not save the settings"));
88
+ const l = Q(e);
89
+ g(l), e.status === 400 && (Object.keys(l.byField).length || l.rest.length) ? p(null) : (p(e), z(e, "Could not save the settings"));
90
90
  }
91
- }), n = (e, c) => f((_) => _ && { ..._, [e]: c });
92
- return /* @__PURE__ */ m(D, { open: l, onOpenChange: u, children: [
93
- /* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ m(
91
+ }), n = (e, l) => f((_) => _ && { ..._, [e]: l });
92
+ return /* @__PURE__ */ h(D, { open: d, onOpenChange: u, children: [
93
+ /* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ h(
94
94
  k,
95
95
  {
96
96
  variant: "outline",
@@ -104,8 +104,8 @@ function re() {
104
104
  ]
105
105
  }
106
106
  ) }),
107
- /* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */ m(E, { children: [
108
- /* @__PURE__ */ t(h, { label: "Nightly report", hint: "Run now always works.", error: o.byField.enabled, children: /* @__PURE__ */ t(
107
+ /* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */ h(E, { children: [
108
+ /* @__PURE__ */ t(m, { label: "Nightly report", hint: "Run now always works.", error: o.byField.enabled, children: /* @__PURE__ */ t(
109
109
  F,
110
110
  {
111
111
  checked: s.enabled,
@@ -114,7 +114,7 @@ function re() {
114
114
  }
115
115
  ) }),
116
116
  /* @__PURE__ */ t(
117
- h,
117
+ m,
118
118
  {
119
119
  label: "Window starts (hour)",
120
120
  hint: "0 to 23, instance time",
@@ -137,7 +137,7 @@ function re() {
137
137
  }
138
138
  ),
139
139
  /* @__PURE__ */ t(
140
- h,
140
+ m,
141
141
  {
142
142
  label: "Window ends (hour)",
143
143
  hint: "1 to 24, after the start",
@@ -159,7 +159,7 @@ function re() {
159
159
  )
160
160
  }
161
161
  ),
162
- /* @__PURE__ */ t(h, { label: "Email administrators", error: o.byField.email, children: /* @__PURE__ */ t(
162
+ /* @__PURE__ */ t(m, { label: "Email administrators", error: o.byField.email, children: /* @__PURE__ */ t(
163
163
  F,
164
164
  {
165
165
  checked: s.email,
@@ -168,7 +168,7 @@ function re() {
168
168
  }
169
169
  ) }),
170
170
  /* @__PURE__ */ t(
171
- h,
171
+ m,
172
172
  {
173
173
  label: "Notify administrators",
174
174
  hint: "Off = this page only",
@@ -184,7 +184,7 @@ function re() {
184
184
  }
185
185
  ),
186
186
  /* @__PURE__ */ t(
187
- h,
187
+ m,
188
188
  {
189
189
  label: "Model",
190
190
  hint: "Blank = the AI settings’ chat model",
@@ -202,7 +202,7 @@ function re() {
202
202
  }
203
203
  ),
204
204
  /* @__PURE__ */ t(
205
- h,
205
+ m,
206
206
  {
207
207
  label: "Token cap",
208
208
  hint: "20,000 to 5,000,000 per run",
@@ -213,7 +213,7 @@ function re() {
213
213
  inputMode: "numeric",
214
214
  value: x,
215
215
  onChange: (e) => {
216
- g(e.target.value), n("token_cap", Number(e.target.value.replace(/[^\d]/g, "")));
216
+ b(e.target.value), n("token_cap", Number(e.target.value.replace(/[^\d]/g, "")));
217
217
  },
218
218
  "aria-label": "Token cap",
219
219
  className: v(
@@ -226,7 +226,7 @@ function re() {
226
226
  ),
227
227
  o.rest.length > 0 && /* @__PURE__ */ t("ul", { role: "alert", className: "space-y-0.5 text-[11.5px] text-red-600 dark:text-red-400", children: o.rest.map((e) => /* @__PURE__ */ t("li", { children: e }, e)) }),
228
228
  y != null && /* @__PURE__ */ t(C, { error: y, fallback: "Could not save" }),
229
- /* @__PURE__ */ m("div", { className: "flex justify-end gap-2 pt-1", children: [
229
+ /* @__PURE__ */ h("div", { className: "flex justify-end gap-2 pt-1", children: [
230
230
  /* @__PURE__ */ t(k, { variant: "ghost", size: "sm", className: "h-8", onClick: () => u(!1), children: "Cancel" }),
231
231
  /* @__PURE__ */ t(
232
232
  k,
@@ -234,7 +234,10 @@ function re() {
234
234
  size: "sm",
235
235
  className: "h-8",
236
236
  disabled: a.isPending,
237
- onClick: () => a.mutate(s),
237
+ onClick: () => {
238
+ const { email_me: e, ...l } = s;
239
+ a.mutate(l);
240
+ },
238
241
  children: a.isPending ? "Saving…" : "Save"
239
242
  }
240
243
  )