@variamosple/variamos-components 0.1.0 → 0.1.1

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,2 +1,5 @@
1
1
  import { FC } from 'react';
2
- export declare const HeaderOptions: FC<unknown>;
2
+ export interface HeaderOptionsProps {
3
+ adminApiUrl?: string;
4
+ }
5
+ export declare const HeaderOptions: FC<HeaderOptionsProps>;
@@ -1,15 +1,15 @@
1
- import { jsxs as S, Fragment as E, jsx as p } from "react/jsx-runtime";
2
- import { useState as h, useEffect as F, useMemo as T } from "react";
1
+ import { jsxs as S, Fragment as F, jsx as p } from "react/jsx-runtime";
2
+ import { useState as h, useEffect as T, useMemo as j } from "react";
3
3
  import { NavDropdown as g } from "react-bootstrap";
4
4
  import "../../Context/AnalyticsContext.js";
5
- import { useMenu as j } from "../../Context/MenuContext.js";
6
- import { useRouter as C } from "../../Context/RouterContext.js";
7
- import { useSession as b } from "../../Context/SessionContext.js";
8
- import { mapToWebTarget as x } from "../../Model/Router.js";
5
+ import { useMenu as C } from "../../Context/MenuContext.js";
6
+ import { useRouter as b } from "../../Context/RouterContext.js";
7
+ import { useSession as x } from "../../Context/SessionContext.js";
8
+ import { mapToWebTarget as L } from "../../Model/Router.js";
9
9
  import { Events as y } from "../../Common/Events.js";
10
- import { BugFormModal as L } from "./BugFormModal.js";
11
- const u = {}, K = () => {
12
- const { user: o, isAuthenticated: m, logout: B } = b(), { options: l } = j(), { navigate: P } = C(), [R, c] = h(!1), [A] = h([
10
+ import { BugFormModal as U } from "./BugFormModal.js";
11
+ const u = {}, O = ({ adminApiUrl: B }) => {
12
+ const { user: o, isAuthenticated: m, logout: P } = x(), { options: l } = C(), { navigate: A } = b(), [R, c] = h(!1), [k] = h([
13
13
  "Editor",
14
14
  "Model",
15
15
  "Language",
@@ -17,8 +17,8 @@ const u = {}, K = () => {
17
17
  "Simulation",
18
18
  "Account/Security",
19
19
  "Other"
20
- ]), [k, f] = h(!1), v = (u == null ? void 0 : u.VITE_ADMIN_API_URL) || "http://localhost:4000/v1";
21
- F(() => {
20
+ ]), [v, f] = h(!1), D = B || (u == null ? void 0 : u.VITE_ADMIN_API_URL) || "/v1";
21
+ T(() => {
22
22
  const t = () => {
23
23
  c(!0);
24
24
  };
@@ -26,12 +26,12 @@ const u = {}, K = () => {
26
26
  y.unsubscribe("openReportBugModal", t);
27
27
  };
28
28
  }, []);
29
- const D = async (t, d) => {
29
+ const E = async (t, d) => {
30
30
  f(!0);
31
31
  try {
32
32
  const e = new FormData();
33
33
  e.append("title", t.title), e.append("description", t.description), e.append("priority", "medium"), e.append("category", t.category), o != null && o.email && e.append("reporterEmail", o.email), d && e.append("file", d);
34
- const i = v.replace(/\/v1$/, ""), s = {}, n = localStorage.getItem("authToken");
34
+ const i = D.replace(/\/v1$/, ""), s = {}, n = localStorage.getItem("authToken");
35
35
  n && (s.Authorization = `Bearer ${n}`);
36
36
  const a = await fetch(`${i}/bugs`, {
37
37
  method: "POST",
@@ -43,7 +43,7 @@ const u = {}, K = () => {
43
43
  } catch (e) {
44
44
  f(!1), alert("Failed to submit bug. Please try again."), console.error(e);
45
45
  }
46
- }, r = T(() => {
46
+ }, r = j(() => {
47
47
  const t = (o == null ? void 0 : o.permissions) || [], d = (o == null ? void 0 : o.roles) || [];
48
48
  return l != null && l.length ? l.filter((e) => {
49
49
  var s, n;
@@ -55,7 +55,7 @@ const u = {}, K = () => {
55
55
  )), i;
56
56
  }) : [];
57
57
  }, [l, o]);
58
- return !(r != null && r.length) && !m ? null : /* @__PURE__ */ S(E, { children: [
58
+ return !(r != null && r.length) && !m ? null : /* @__PURE__ */ S(F, { children: [
59
59
  /* @__PURE__ */ S(g, { title: (o == null ? void 0 : o.name) || "Options", id: "nav-dropdown", children: [
60
60
  r == null ? void 0 : r.map((t) => /* @__PURE__ */ p(
61
61
  g.Item,
@@ -65,8 +65,8 @@ const u = {}, K = () => {
65
65
  c(!0);
66
66
  return;
67
67
  }
68
- P(t.location, {
69
- target: x(t.target)
68
+ A(t.location, {
69
+ target: L(t.target)
70
70
  });
71
71
  },
72
72
  children: t.title
@@ -74,20 +74,20 @@ const u = {}, K = () => {
74
74
  t.title
75
75
  )),
76
76
  m && !!(r != null && r.length) && /* @__PURE__ */ p(g.Divider, {}),
77
- m && /* @__PURE__ */ p(g.Item, { onClick: B, children: "Logout" })
77
+ m && /* @__PURE__ */ p(g.Item, { onClick: P, children: "Logout" })
78
78
  ] }),
79
79
  /* @__PURE__ */ p(
80
- L,
80
+ U,
81
81
  {
82
82
  show: R,
83
83
  onHide: () => c(!1),
84
- onSubmit: D,
85
- categories: A,
86
- isSubmitting: k
84
+ onSubmit: E,
85
+ categories: k,
86
+ isSubmitting: v
87
87
  }
88
88
  )
89
89
  ] });
90
90
  };
91
91
  export {
92
- K as HeaderOptions
92
+ O as HeaderOptions
93
93
  };
@@ -3,5 +3,6 @@ export interface HeaderProps {
3
3
  logoUrl?: string;
4
4
  logoAlt?: string;
5
5
  signInUrl: string;
6
+ adminApiUrl?: string;
6
7
  }
7
8
  export declare const Header: FC<HeaderProps>;
@@ -1,21 +1,22 @@
1
1
  import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
- import { Navbar as t, Container as u, Nav as i } from "react-bootstrap";
2
+ import { Navbar as t, Container as h, Nav as i } from "react-bootstrap";
3
3
  import "../../Context/AnalyticsContext.js";
4
- import { useMenu as h } from "../../Context/MenuContext.js";
5
- import { useRouter as f } from "../../Context/RouterContext.js";
6
- import { useSession as g } from "../../Context/SessionContext.js";
7
- import { HeaderOptions as N } from "./HeaderOptions.js";
4
+ import { useMenu as f } from "../../Context/MenuContext.js";
5
+ import { useRouter as g } from "../../Context/RouterContext.js";
6
+ import { useSession as N } from "../../Context/SessionContext.js";
7
+ import { HeaderOptions as k } from "./HeaderOptions.js";
8
8
  import { MenuItemComponent as n } from "./MenuItem.js";
9
- import { SubHeader as k } from "./SubHeader.js";
10
- const I = ({
9
+ import { SubHeader as b } from "./SubHeader.js";
10
+ const M = ({
11
11
  logoUrl: a,
12
12
  logoAlt: m = "App logo",
13
- signInUrl: s
13
+ signInUrl: s,
14
+ adminApiUrl: c
14
15
  }) => {
15
- const { items: c } = h(), { navigate: l } = f(), { isAuthenticated: p, isLoading: d } = g();
16
+ const { items: l } = f(), { navigate: p } = g(), { isAuthenticated: d, isLoading: u } = N();
16
17
  return /* @__PURE__ */ o("header", { className: "sticky-top", children: [
17
- /* @__PURE__ */ e(t, { bg: "dark", variant: "dark", children: /* @__PURE__ */ o(u, { fluid: !0, children: [
18
- /* @__PURE__ */ e(t.Brand, { onClick: () => l("/"), children: /* @__PURE__ */ e(
18
+ /* @__PURE__ */ e(t, { bg: "dark", variant: "dark", children: /* @__PURE__ */ o(h, { fluid: !0, children: [
19
+ /* @__PURE__ */ e(t.Brand, { onClick: () => p("/"), children: /* @__PURE__ */ e(
19
20
  "img",
20
21
  {
21
22
  src: a,
@@ -24,10 +25,10 @@ const I = ({
24
25
  alt: m
25
26
  }
26
27
  ) }),
27
- /* @__PURE__ */ e(i, { className: "me-auto", children: c.map((r) => /* @__PURE__ */ e(n, { ...r }, r.title)) }),
28
+ /* @__PURE__ */ e(i, { className: "me-auto", children: l.map((r) => /* @__PURE__ */ e(n, { ...r }, r.title)) }),
28
29
  /* @__PURE__ */ o(i, { className: "me-5 pe-5", children: [
29
- /* @__PURE__ */ e(N, {}),
30
- !d && !p && /* @__PURE__ */ e(
30
+ /* @__PURE__ */ e(k, { adminApiUrl: c }),
31
+ !u && !d && /* @__PURE__ */ e(
31
32
  n,
32
33
  {
33
34
  title: "Sign In",
@@ -37,9 +38,9 @@ const I = ({
37
38
  )
38
39
  ] })
39
40
  ] }) }),
40
- /* @__PURE__ */ e(k, {})
41
+ /* @__PURE__ */ e(b, {})
41
42
  ] });
42
43
  };
43
44
  export {
44
- I as Header
45
+ M as Header
45
46
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@variamosple/variamos-components",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",