@genai-fi/base 4.3.0 → 4.3.2

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,10 +1,11 @@
1
1
  import { CSSProperties } from 'react';
2
2
  interface Props {
3
3
  application: string;
4
+ apiUrl: string;
4
5
  delay?: number;
5
6
  className?: string;
6
7
  style?: CSSProperties;
7
8
  variant?: 'contained' | 'outlined' | 'text';
8
9
  }
9
- export default function Feedback({ application, delay, className, style, variant }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export default function Feedback({ application, apiUrl, delay, className, style, variant }: Props): import("react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,9 +1,9 @@
1
- import { jsx as t, jsxs as b, Fragment as h } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as S, Fragment as T } from "react/jsx-runtime";
2
2
  import "../../state/webrtcState.js";
3
- import { useState as o, useEffect as k } from "react";
4
- import { useTranslation as S } from "react-i18next";
3
+ import { useState as r, useEffect as g } from "react";
4
+ import { useTranslation as w } from "react-i18next";
5
5
  import "../../hooks/peer.js";
6
- import { Button as T } from "../Button/Button.js";
6
+ import { Button as F } from "../Button/Button.js";
7
7
  import "../../index-SOhdqzHq.js";
8
8
  import "../../style/theme.js";
9
9
  import "../../util/canvas.js";
@@ -16,48 +16,54 @@ import "../WorkflowLayout/svgContext.js";
16
16
  import "../WorkflowLayout/Widget.js";
17
17
  import "../IconMenu/context.js";
18
18
  import "@emotion/react";
19
- import g from "./FeedbackForm.js";
20
- import { c as I } from "../../createSvgIcon-BM4dw4Lw.js";
21
- const v = I(/* @__PURE__ */ t("path", {
19
+ import I from "./FeedbackForm.js";
20
+ import { c as v } from "../../createSvgIcon-BM4dw4Lw.js";
21
+ const j = v(/* @__PURE__ */ o("path", {
22
22
  d: "M12 6c0-.55-.45-1-1-1H5.82l.66-3.18.02-.23c0-.31-.13-.59-.33-.8L5.38 0 .44 4.94C.17 5.21 0 5.59 0 6v6.5c0 .83.67 1.5 1.5 1.5h6.75c.62 0 1.15-.38 1.38-.91l2.26-5.29c.07-.17.11-.36.11-.55zm10.5 4h-6.75c-.62 0-1.15.38-1.38.91l-2.26 5.29c-.07.17-.11.36-.11.55V18c0 .55.45 1 1 1h5.18l-.66 3.18-.02.24c0 .31.13.59.33.8l.79.78 4.94-4.94c.27-.27.44-.65.44-1.06v-6.5c0-.83-.67-1.5-1.5-1.5"
23
23
  }), "ThumbsUpDown");
24
- function P({ application: c, delay: e, className: n, style: i, variant: s }) {
25
- const { t: a } = S(), [p, u] = o(!1), [l, w] = o(""), [f, r] = o(!1), m = localStorage.getItem("feedbackSubmitted") === "true";
26
- return k(() => {
27
- if (!m) {
28
- const d = setTimeout(
24
+ function R({ application: s, apiUrl: t, delay: n, className: a, style: p, variant: u }) {
25
+ const { t: f } = w(), [l, c] = r(!1), [d, h] = r(""), [b, m] = r(!1), i = localStorage.getItem("feedbackSubmitted") === "true";
26
+ return g(() => {
27
+ if (!i) {
28
+ const k = setTimeout(
29
29
  () => {
30
+ t && fetch(`${t}`).then((e) => e.json()).then((e) => {
31
+ h(e.token), c(!0);
32
+ }).catch(() => {
33
+ console.warn("Feedback denied");
34
+ });
30
35
  },
31
- e ?? 3e5
36
+ n ?? 3e5
32
37
  );
33
- return () => clearTimeout(d);
38
+ return () => clearTimeout(k);
34
39
  }
35
- }, [m, e]), /* @__PURE__ */ b(h, { children: [
36
- p && /* @__PURE__ */ t(
37
- T,
40
+ }, [i, n, t]), /* @__PURE__ */ S(T, { children: [
41
+ l && /* @__PURE__ */ o(
42
+ F,
38
43
  {
39
- variant: s ?? "contained",
40
- onClick: () => r(!0),
41
- className: n,
42
- style: i,
43
- startIcon: /* @__PURE__ */ t(v, {}),
44
- children: a("feedback.button")
44
+ variant: u ?? "contained",
45
+ onClick: () => m(!0),
46
+ className: a,
47
+ style: p,
48
+ startIcon: /* @__PURE__ */ o(j, {}),
49
+ children: f("feedback.button")
45
50
  }
46
51
  ),
47
- /* @__PURE__ */ t(
48
- g,
52
+ /* @__PURE__ */ o(
53
+ I,
49
54
  {
50
- open: f,
51
- onClose: () => r(!1),
55
+ open: b,
56
+ apiUrl: t,
57
+ onClose: () => m(!1),
52
58
  onDone: () => {
53
- localStorage.setItem("feedbackSubmitted", "true"), u(!1);
59
+ localStorage.setItem("feedbackSubmitted", "true"), c(!1);
54
60
  },
55
- token: l,
56
- application: c
61
+ token: d,
62
+ application: s
57
63
  }
58
64
  )
59
65
  ] });
60
66
  }
61
67
  export {
62
- P as default
68
+ R as default
63
69
  };
@@ -2,8 +2,9 @@ interface Props {
2
2
  token: string;
3
3
  application: string;
4
4
  open?: boolean;
5
+ apiUrl: string;
5
6
  onClose?: () => void;
6
7
  onDone?: () => void;
7
8
  }
8
- export default function FeedbackForm({ application, open, onClose, token, onDone }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export default function FeedbackForm({ application, open, onClose, token, onDone, apiUrl }: Props): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -1,88 +1,107 @@
1
- import { jsxs as o, Fragment as N, jsx as e } from "react/jsx-runtime";
2
- import { Dialog as T, DialogContent as Y, DialogActions as _ } from "@mui/material";
3
- import { s as l } from "../../Feedback.module-C2gI6YmB.js";
4
- import { useState as r, useRef as j, useEffect as A } from "react";
5
- import { Button as b } from "../Button/Button.js";
6
- import B from "./Rating.js";
7
- import F from "./Recommend.js";
8
- import y from "./Experience.js";
9
- import { useTranslation as I } from "react-i18next";
10
- const x = "https://store.gen-ai.fi/common/thank_you_graphic.jpg";
11
- function M(c, n, a) {
12
- return !(c <= 0 || c > 5 || n <= 0 || n > 5 || a.length > 1e3);
1
+ import { jsxs as r, Fragment as F, jsx as e } from "react/jsx-runtime";
2
+ import { Dialog as S, DialogContent as Y, DialogActions as _ } from "@mui/material";
3
+ import { s as h } from "../../Feedback.module-C2gI6YmB.js";
4
+ import { useState as o, useRef as A, useEffect as B } from "react";
5
+ import { Button as T } from "../Button/Button.js";
6
+ import D from "./Rating.js";
7
+ import O from "./Recommend.js";
8
+ import I from "./Experience.js";
9
+ import { useTranslation as M } from "react-i18next";
10
+ const y = "https://store.gen-ai.fi/common/thank_you_graphic.jpg";
11
+ function P(a, t, s) {
12
+ return !(a <= 0 || a > 5 || t <= 0 || t > 5 || s.length > 1e3);
13
13
  }
14
- function L({ application: c, open: n, onClose: a, token: S, onDone: w }) {
15
- const { t } = I(), [d, f] = r(0), [m, u] = r(0), [h, g] = r(""), [i, C] = r(!1), [s, v] = r(!1), p = j(!1);
16
- A(() => {
17
- if (!n || p.current) return;
18
- const E = new Image();
19
- E.src = x, p.current = !0;
20
- }, [n]);
21
- const R = M(d, m, h), D = () => {
22
- }, k = () => {
23
- a && a(), setTimeout(() => {
24
- C(!1), v(!1), f(0), u(0), g("");
14
+ function Q({ application: a, open: t, onClose: s, token: E, onDone: g, apiUrl: p }) {
15
+ const { t: n } = M(), [l, k] = o(0), [f, b] = o(0), [d, x] = o(""), [i, C] = o(!1), [c, m] = o(!1), v = A(!1);
16
+ B(() => {
17
+ if (!t || v.current) return;
18
+ const u = new Image();
19
+ u.src = y, v.current = !0;
20
+ }, [t]);
21
+ const N = P(l, f, d), j = () => {
22
+ p && fetch(`${p}`, {
23
+ method: "POST",
24
+ headers: {
25
+ "Content-Type": "application/json"
26
+ },
27
+ body: JSON.stringify({
28
+ token: E,
29
+ application: a,
30
+ rating: l,
31
+ recommend: f,
32
+ describe: d,
33
+ valuableFeature: "",
34
+ suggestions: ""
35
+ })
36
+ }).then((u) => {
37
+ u.ok ? (C(!0), g && g()) : m(!0);
38
+ }).catch(() => {
39
+ m(!0);
40
+ });
41
+ }, R = () => {
42
+ s && s(), setTimeout(() => {
43
+ C(!1), m(!1), k(0), b(0), x("");
25
44
  }, 500);
26
45
  };
27
- return /* @__PURE__ */ o(
28
- T,
46
+ return /* @__PURE__ */ r(
47
+ S,
29
48
  {
30
- open: n ?? !1,
31
- onClose: k,
49
+ open: t ?? !1,
50
+ onClose: R,
32
51
  children: [
33
- /* @__PURE__ */ o(Y, { className: l.feedback, children: [
34
- !i && !s && /* @__PURE__ */ o(N, { children: [
35
- /* @__PURE__ */ e("h1", { children: t("feedback.title") }),
52
+ /* @__PURE__ */ r(Y, { className: h.feedback, children: [
53
+ !i && !c && /* @__PURE__ */ r(F, { children: [
54
+ /* @__PURE__ */ e("h1", { children: n("feedback.title") }),
36
55
  /* @__PURE__ */ e(
37
- B,
56
+ D,
38
57
  {
39
- rating: d,
40
- onChange: f
58
+ rating: l,
59
+ onChange: k
41
60
  }
42
61
  ),
43
62
  /* @__PURE__ */ e(
44
- F,
63
+ O,
45
64
  {
46
- rating: m,
47
- onChange: u
65
+ rating: f,
66
+ onChange: b
48
67
  }
49
68
  ),
50
69
  /* @__PURE__ */ e(
51
- y,
70
+ I,
52
71
  {
53
- experience: h,
54
- onChange: g
72
+ experience: d,
73
+ onChange: x
55
74
  }
56
75
  )
57
76
  ] }),
58
- i && /* @__PURE__ */ e("div", { className: l.thankYouBox, children: /* @__PURE__ */ e(
77
+ i && /* @__PURE__ */ e("div", { className: h.thankYouBox, children: /* @__PURE__ */ e(
59
78
  "img",
60
79
  {
61
- src: x,
62
- alt: t("feedback.thankYou")
80
+ src: y,
81
+ alt: n("feedback.thankYou")
63
82
  }
64
83
  ) }),
65
- s && /* @__PURE__ */ o("div", { className: l.messageBox, children: [
66
- /* @__PURE__ */ e("h1", { children: t("feedback.error") }),
67
- /* @__PURE__ */ e("p", { children: t("feedback.errorMessage") })
84
+ c && /* @__PURE__ */ r("div", { className: h.messageBox, children: [
85
+ /* @__PURE__ */ e("h1", { children: n("feedback.error") }),
86
+ /* @__PURE__ */ e("p", { children: n("feedback.errorMessage") })
68
87
  ] })
69
88
  ] }),
70
- /* @__PURE__ */ o(_, { children: [
89
+ /* @__PURE__ */ r(_, { children: [
71
90
  /* @__PURE__ */ e(
72
- b,
91
+ T,
73
92
  {
74
- variant: !i && !s ? "outlined" : "contained",
75
- onClick: k,
76
- children: t("feedback.close")
93
+ variant: !i && !c ? "outlined" : "contained",
94
+ onClick: R,
95
+ children: n("feedback.close")
77
96
  }
78
97
  ),
79
- !i && !s && /* @__PURE__ */ e(
80
- b,
98
+ !i && !c && /* @__PURE__ */ e(
99
+ T,
81
100
  {
82
101
  variant: "contained",
83
- onClick: D,
84
- disabled: !R,
85
- children: t("feedback.send")
102
+ onClick: j,
103
+ disabled: !N,
104
+ children: n("feedback.send")
86
105
  }
87
106
  )
88
107
  ] })
@@ -91,5 +110,5 @@ function L({ application: c, open: n, onClose: a, token: S, onDone: w }) {
91
110
  );
92
111
  }
93
112
  export {
94
- L as default
113
+ Q as default
95
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/base",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",