@variamosple/variamos-components 0.1.2 → 0.2.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.
- package/dist/Components/AuthWrapper/index.js +8 -7
- package/dist/Components/Header/HeaderOptions.js +3 -2
- package/dist/Components/Header/MenuItem.js +3 -2
- package/dist/Components/Header/SubHeader.js +7 -6
- package/dist/Components/Header/index.js +34 -26
- package/dist/Components/NotAuthorized/index.js +3 -2
- package/dist/Components/Notifications/NotificationBell.d.ts +6 -0
- package/dist/Components/Notifications/NotificationBell.js +36 -0
- package/dist/Components/Notifications/NotificationDrawer.d.ts +6 -0
- package/dist/Components/Notifications/NotificationDrawer.js +202 -0
- package/dist/Components/Notifications/NotificationSettings.d.ts +2 -0
- package/dist/Components/Notifications/NotificationSettings.js +68 -0
- package/dist/Components/Notifications/index.d.ts +3 -0
- package/dist/Components/Notifications/index.js +8 -0
- package/dist/Components/ProtectedRoute/index.js +13 -12
- package/dist/Components/index.d.ts +1 -0
- package/dist/Components/index.js +18 -12
- package/dist/Context/NotificationContext.d.ts +34 -0
- package/dist/Context/NotificationContext.js +2457 -0
- package/dist/Context/index.d.ts +1 -0
- package/dist/Context/index.js +15 -12
- package/dist/main.js +55 -46
- package/package.json +3 -2
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx as o, Fragment as u } from "react/jsx-runtime";
|
|
2
|
-
import d, { useEffect as
|
|
2
|
+
import d, { useEffect as m } from "react";
|
|
3
3
|
import { Spinner as f } from "react-bootstrap";
|
|
4
4
|
import "../../Context/AnalyticsContext.js";
|
|
5
5
|
import "../../Context/MenuContext.js";
|
|
6
6
|
import { useRouter as p } from "../../Context/RouterContext.js";
|
|
7
7
|
import { useSession as l } from "../../Context/SessionContext.js";
|
|
8
|
-
|
|
8
|
+
import "../../Context/NotificationContext.js";
|
|
9
|
+
const v = ({
|
|
9
10
|
redirectPath: i,
|
|
10
|
-
children:
|
|
11
|
+
children: c
|
|
11
12
|
}) => {
|
|
12
13
|
const [a, h] = d.useState(!1), { isAuthenticated: t, isLoading: r } = l(), { navigate: n } = p();
|
|
13
|
-
return
|
|
14
|
+
return m(() => {
|
|
14
15
|
if (!r && !t && !a) {
|
|
15
16
|
const e = window.location.href, s = new URLSearchParams();
|
|
16
17
|
s.set("redirectTo", encodeURIComponent(e)), h(!0), setTimeout(
|
|
@@ -18,7 +19,7 @@ const P = ({
|
|
|
18
19
|
300
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
|
-
}, [t, r, i, n, a]),
|
|
22
|
+
}, [t, r, i, n, a]), m(() => {
|
|
22
23
|
const e = new URL(window.location.href);
|
|
23
24
|
e.searchParams.has("authToken") && (localStorage.setItem("authToken", e.searchParams.get("authToken")), e.searchParams.delete("authToken"), window.history.replaceState({}, "", e));
|
|
24
25
|
}, []), r || !t ? /* @__PURE__ */ o("div", { className: "d-flex justify-content-center align-items-center w-100 h-100", children: /* @__PURE__ */ o(
|
|
@@ -28,8 +29,8 @@ const P = ({
|
|
|
28
29
|
variant: "primary",
|
|
29
30
|
style: { width: "3rem", height: "3rem", borderWidth: "0.5rem" }
|
|
30
31
|
}
|
|
31
|
-
) }) : /* @__PURE__ */ o(u, { children:
|
|
32
|
+
) }) : /* @__PURE__ */ o(u, { children: c });
|
|
32
33
|
};
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
+
v as AuthWrapper
|
|
35
36
|
};
|
|
@@ -5,10 +5,11 @@ import "../../Context/AnalyticsContext.js";
|
|
|
5
5
|
import { useMenu as C } from "../../Context/MenuContext.js";
|
|
6
6
|
import { useRouter as b } from "../../Context/RouterContext.js";
|
|
7
7
|
import { useSession as x } from "../../Context/SessionContext.js";
|
|
8
|
+
import "../../Context/NotificationContext.js";
|
|
8
9
|
import { mapToWebTarget as L } from "../../Model/Router.js";
|
|
9
10
|
import { Events as y } from "../../Common/Events.js";
|
|
10
11
|
import { BugFormModal as U } from "./BugFormModal.js";
|
|
11
|
-
const u = {},
|
|
12
|
+
const u = {}, Q = ({ adminApiUrl: B }) => {
|
|
12
13
|
const { user: o, isAuthenticated: m, logout: P } = x(), { options: l } = C(), { navigate: A } = b(), [R, c] = h(!1), [k] = h([
|
|
13
14
|
"Editor",
|
|
14
15
|
"Model",
|
|
@@ -91,5 +92,5 @@ const u = {}, O = ({ adminApiUrl: B }) => {
|
|
|
91
92
|
] });
|
|
92
93
|
};
|
|
93
94
|
export {
|
|
94
|
-
|
|
95
|
+
Q as HeaderOptions
|
|
95
96
|
};
|
|
@@ -5,8 +5,9 @@ import "../../Context/AnalyticsContext.js";
|
|
|
5
5
|
import "../../Context/MenuContext.js";
|
|
6
6
|
import { useRouter as C } from "../../Context/RouterContext.js";
|
|
7
7
|
import { useSession as N } from "../../Context/SessionContext.js";
|
|
8
|
+
import "../../Context/NotificationContext.js";
|
|
8
9
|
import { mapToWebTarget as m } from "../../Model/Router.js";
|
|
9
|
-
const
|
|
10
|
+
const z = ({
|
|
10
11
|
title: e,
|
|
11
12
|
type: w,
|
|
12
13
|
location: g,
|
|
@@ -46,5 +47,5 @@ const y = ({
|
|
|
46
47
|
)) });
|
|
47
48
|
};
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
+
z as MenuItemComponent
|
|
50
51
|
};
|
|
@@ -5,8 +5,9 @@ import "../../Context/AnalyticsContext.js";
|
|
|
5
5
|
import { useMenu as N } from "../../Context/MenuContext.js";
|
|
6
6
|
import { useRouter as v } from "../../Context/RouterContext.js";
|
|
7
7
|
import { useSession as R } from "../../Context/SessionContext.js";
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import "../../Context/NotificationContext.js";
|
|
9
|
+
const L = () => {
|
|
10
|
+
const { navigate: p } = v(), { subMenu: n } = N(), { user: r } = R(), t = w(() => {
|
|
10
11
|
const l = (r == null ? void 0 : r.roles) || [], m = (r == null ? void 0 : r.permissions) || [];
|
|
11
12
|
return n ? n.filter((o) => {
|
|
12
13
|
var a, c;
|
|
@@ -19,20 +20,20 @@ const H = () => {
|
|
|
19
20
|
(e) => m.includes(e)
|
|
20
21
|
)), i;
|
|
21
22
|
}) : [];
|
|
22
|
-
}, [n, r]),
|
|
23
|
-
|
|
23
|
+
}, [n, r]), f = (l) => () => {
|
|
24
|
+
p(l);
|
|
24
25
|
};
|
|
25
26
|
return t.length ? /* @__PURE__ */ s(h, { className: "py-1 shadow-sm bg-white", children: /* @__PURE__ */ s(g, { children: /* @__PURE__ */ s(d, { className: "d-flex justify-content-center w-100 gap-3", children: t.map((l) => /* @__PURE__ */ s(
|
|
26
27
|
d.Link,
|
|
27
28
|
{
|
|
28
29
|
as: "button",
|
|
29
30
|
className: "btn btn-link p-0",
|
|
30
|
-
onClick:
|
|
31
|
+
onClick: f(l.location),
|
|
31
32
|
children: l.title
|
|
32
33
|
},
|
|
33
34
|
l.location
|
|
34
35
|
)) }) }) }) : null;
|
|
35
36
|
};
|
|
36
37
|
export {
|
|
37
|
-
|
|
38
|
+
L as SubHeader
|
|
38
39
|
};
|
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N } from "react";
|
|
3
|
+
import { Navbar as a, Container as k, Nav as n } from "react-bootstrap";
|
|
3
4
|
import "../../Context/AnalyticsContext.js";
|
|
4
|
-
import { useMenu as
|
|
5
|
-
import { useRouter as
|
|
6
|
-
import { useSession as
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
import { useMenu as w } from "../../Context/MenuContext.js";
|
|
6
|
+
import { useRouter as C } from "../../Context/RouterContext.js";
|
|
7
|
+
import { useSession as S } from "../../Context/SessionContext.js";
|
|
8
|
+
import "../../Context/NotificationContext.js";
|
|
9
|
+
import { HeaderOptions as b } from "./HeaderOptions.js";
|
|
10
|
+
import { MenuItemComponent as m } from "./MenuItem.js";
|
|
11
|
+
import { SubHeader as v } from "./SubHeader.js";
|
|
12
|
+
import { NotificationBell as x } from "../Notifications/NotificationBell.js";
|
|
13
|
+
import { NotificationDrawer as D } from "../Notifications/NotificationDrawer.js";
|
|
14
|
+
const E = ({
|
|
15
|
+
logoUrl: s,
|
|
16
|
+
logoAlt: l = "App logo",
|
|
17
|
+
signInUrl: c,
|
|
18
|
+
adminApiUrl: p
|
|
15
19
|
}) => {
|
|
16
|
-
const { items:
|
|
20
|
+
const { items: d } = w(), { navigate: f } = C(), { isAuthenticated: r, isLoading: h } = S(), [u, t] = N(!1);
|
|
17
21
|
return /* @__PURE__ */ o("header", { className: "sticky-top", children: [
|
|
18
|
-
/* @__PURE__ */ e(
|
|
19
|
-
/* @__PURE__ */ e(
|
|
22
|
+
/* @__PURE__ */ e(a, { bg: "dark", variant: "dark", children: /* @__PURE__ */ o(k, { fluid: !0, children: [
|
|
23
|
+
/* @__PURE__ */ e(a.Brand, { onClick: () => f("/"), children: /* @__PURE__ */ e(
|
|
20
24
|
"img",
|
|
21
25
|
{
|
|
22
|
-
src:
|
|
26
|
+
src: s,
|
|
23
27
|
height: "30",
|
|
24
28
|
className: "d-inline-block align-top",
|
|
25
|
-
alt:
|
|
29
|
+
alt: l
|
|
26
30
|
}
|
|
27
31
|
) }),
|
|
28
|
-
/* @__PURE__ */ e(
|
|
29
|
-
/* @__PURE__ */ o(
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
/* @__PURE__ */ e(n, { className: "me-auto", children: d.map((i) => /* @__PURE__ */ e(m, { ...i }, i.title)) }),
|
|
33
|
+
/* @__PURE__ */ o(n, { className: "me-5 pe-5 align-items-center", children: [
|
|
34
|
+
r && /* @__PURE__ */ o(g, { children: [
|
|
35
|
+
/* @__PURE__ */ e(x, { onClick: () => t(!0), className: "me-2" }),
|
|
36
|
+
/* @__PURE__ */ e(D, { show: u, onClose: () => t(!1) })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ e(b, { adminApiUrl: p }),
|
|
39
|
+
!h && !r && /* @__PURE__ */ e(
|
|
40
|
+
m,
|
|
33
41
|
{
|
|
34
42
|
title: "Sign In",
|
|
35
43
|
type: "location",
|
|
36
|
-
location:
|
|
44
|
+
location: c
|
|
37
45
|
}
|
|
38
46
|
)
|
|
39
47
|
] })
|
|
40
48
|
] }) }),
|
|
41
|
-
/* @__PURE__ */ e(
|
|
49
|
+
/* @__PURE__ */ e(v, {})
|
|
42
50
|
] });
|
|
43
51
|
};
|
|
44
52
|
export {
|
|
45
|
-
|
|
53
|
+
E as Header
|
|
46
54
|
};
|
|
@@ -4,7 +4,8 @@ import "../../Context/AnalyticsContext.js";
|
|
|
4
4
|
import "../../Context/MenuContext.js";
|
|
5
5
|
import { useRouter as a } from "../../Context/RouterContext.js";
|
|
6
6
|
import "../../Context/SessionContext.js";
|
|
7
|
-
|
|
7
|
+
import "../../Context/NotificationContext.js";
|
|
8
|
+
const h = ({ homePath: e }) => {
|
|
8
9
|
const { navigate: r } = a();
|
|
9
10
|
return /* @__PURE__ */ o(i, { className: "d-flex flex-column justify-content-center align-items-center vh-100 text-center", children: [
|
|
10
11
|
/* @__PURE__ */ t("h1", { className: "display-1 fw-bold text-danger", children: "403" }),
|
|
@@ -13,5 +14,5 @@ const u = ({ homePath: e }) => {
|
|
|
13
14
|
] });
|
|
14
15
|
};
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
h as NotAuthorized
|
|
17
18
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Button as a, Badge as n } from "react-bootstrap";
|
|
3
|
+
import { Bell as l } from "react-bootstrap-icons";
|
|
4
|
+
import { useNotifications as s } from "../../Context/NotificationContext.js";
|
|
5
|
+
const f = ({
|
|
6
|
+
onClick: o,
|
|
7
|
+
className: i = ""
|
|
8
|
+
}) => {
|
|
9
|
+
const { unreadCount: t } = s();
|
|
10
|
+
return /* @__PURE__ */ r(
|
|
11
|
+
a,
|
|
12
|
+
{
|
|
13
|
+
variant: "link",
|
|
14
|
+
onClick: o,
|
|
15
|
+
className: `position-relative p-2 text-light ${i}`,
|
|
16
|
+
"aria-label": "Notifications",
|
|
17
|
+
style: { boxShadow: "none" },
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ e(l, { size: 22 }),
|
|
20
|
+
t > 0 && /* @__PURE__ */ e(
|
|
21
|
+
n,
|
|
22
|
+
{
|
|
23
|
+
pill: !0,
|
|
24
|
+
bg: "danger",
|
|
25
|
+
className: "position-absolute translate-middle-y start-50 top-0 border border-white",
|
|
26
|
+
style: { fontSize: "0.65rem", padding: "0.25em 0.5em" },
|
|
27
|
+
children: t > 99 ? "99+" : t
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
f as NotificationBell
|
|
36
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsxs as i, jsx as e, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useEffect as L } from "react";
|
|
3
|
+
import { Offcanvas as d, Button as r, Nav as c, Spinner as E } from "react-bootstrap";
|
|
4
|
+
import { ArrowLeft as M, Gear as H, Inbox as I, Trash as b, CheckAll as K, CircleFill as R } from "react-bootstrap-icons";
|
|
5
|
+
import { useNotifications as _ } from "../../Context/NotificationContext.js";
|
|
6
|
+
import { NotificationSettings as B } from "./NotificationSettings.js";
|
|
7
|
+
const F = {
|
|
8
|
+
review_assigned: {
|
|
9
|
+
title: "Language Review Assigned",
|
|
10
|
+
body: "You have been assigned to review the translation for {{languageName}}."
|
|
11
|
+
},
|
|
12
|
+
project_created: {
|
|
13
|
+
title: "Project Created",
|
|
14
|
+
body: "The project '{{projectName}}' has been created successfully."
|
|
15
|
+
},
|
|
16
|
+
test_template: {
|
|
17
|
+
title: "Notification Test",
|
|
18
|
+
body: "Hello {{name}}, this is a real-time notification test."
|
|
19
|
+
},
|
|
20
|
+
admin_alert: {
|
|
21
|
+
title: "{{title}}",
|
|
22
|
+
body: "{{body}}"
|
|
23
|
+
}
|
|
24
|
+
}, G = ({
|
|
25
|
+
show: m,
|
|
26
|
+
onClose: u
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
notifications: f,
|
|
30
|
+
isLoading: v,
|
|
31
|
+
fetchNotifications: k,
|
|
32
|
+
markAsRead: w,
|
|
33
|
+
markAllAsRead: S,
|
|
34
|
+
emptyTrash: T,
|
|
35
|
+
deleteNotification: z
|
|
36
|
+
} = _(), [n, C] = y("inbox"), [p, x] = y(!1);
|
|
37
|
+
L(() => {
|
|
38
|
+
m && k(n);
|
|
39
|
+
}, [m, n]);
|
|
40
|
+
const g = (t, a) => {
|
|
41
|
+
let s = t;
|
|
42
|
+
for (const l of Object.keys(a))
|
|
43
|
+
s = s.replace(new RegExp(`{{${l}}}`, "g"), String(a[l]));
|
|
44
|
+
return s;
|
|
45
|
+
}, j = (t) => {
|
|
46
|
+
const a = F[t.templateKey] || {
|
|
47
|
+
title: "New Alert",
|
|
48
|
+
body: `Notification template: ${t.templateKey}`
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
title: g(a.title, t.variables),
|
|
52
|
+
body: g(a.body, t.variables)
|
|
53
|
+
};
|
|
54
|
+
}, A = (t) => new Date(t).toLocaleDateString(void 0, {
|
|
55
|
+
hour: "2-digit",
|
|
56
|
+
minute: "2-digit"
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ i(d, { show: m, onHide: u, placement: "end", className: "text-dark", children: [
|
|
59
|
+
/* @__PURE__ */ e(d.Header, { closeButton: !0, className: "border-bottom", children: /* @__PURE__ */ e(d.Title, { className: "d-flex align-items-center w-100", children: p ? /* @__PURE__ */ i(N, { children: [
|
|
60
|
+
/* @__PURE__ */ e(
|
|
61
|
+
r,
|
|
62
|
+
{
|
|
63
|
+
variant: "link",
|
|
64
|
+
className: "p-0 me-2 text-dark",
|
|
65
|
+
onClick: () => x(!1),
|
|
66
|
+
"aria-label": "Back",
|
|
67
|
+
children: /* @__PURE__ */ e(M, { size: 20 })
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ e("span", { children: "Settings" })
|
|
71
|
+
] }) : /* @__PURE__ */ i("div", { className: "d-flex justify-content-between align-items-center w-100 me-3", children: [
|
|
72
|
+
/* @__PURE__ */ e("span", { children: "Notifications" }),
|
|
73
|
+
/* @__PURE__ */ e(
|
|
74
|
+
r,
|
|
75
|
+
{
|
|
76
|
+
variant: "link",
|
|
77
|
+
className: "p-0 text-secondary",
|
|
78
|
+
onClick: () => x(!0),
|
|
79
|
+
"aria-label": "Notification Settings",
|
|
80
|
+
style: { boxShadow: "none" },
|
|
81
|
+
children: /* @__PURE__ */ e(H, { size: 20 })
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }) }) }),
|
|
85
|
+
/* @__PURE__ */ e(d.Body, { className: "p-0 d-flex flex-column h-100", children: p ? /* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(B, {}) }) : /* @__PURE__ */ i(N, { children: [
|
|
86
|
+
/* @__PURE__ */ i(
|
|
87
|
+
c,
|
|
88
|
+
{
|
|
89
|
+
variant: "tabs",
|
|
90
|
+
activeKey: n,
|
|
91
|
+
onSelect: (t) => C(t),
|
|
92
|
+
className: "px-3 pt-2 bg-light border-bottom",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ e(c.Item, { children: /* @__PURE__ */ i(c.Link, { eventKey: "inbox", className: "d-flex align-items-center", children: [
|
|
95
|
+
/* @__PURE__ */ e(I, { className: "me-2" }),
|
|
96
|
+
"Inbox"
|
|
97
|
+
] }) }),
|
|
98
|
+
/* @__PURE__ */ e(c.Item, { children: /* @__PURE__ */ i(c.Link, { eventKey: "trash", className: "d-flex align-items-center", children: [
|
|
99
|
+
/* @__PURE__ */ e(b, { className: "me-2" }),
|
|
100
|
+
"Trash"
|
|
101
|
+
] }) })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
f.length > 0 && /* @__PURE__ */ e("div", { className: "d-flex justify-content-end align-items-center p-2 bg-light border-bottom px-3", children: n === "inbox" ? /* @__PURE__ */ i(
|
|
106
|
+
r,
|
|
107
|
+
{
|
|
108
|
+
variant: "link",
|
|
109
|
+
size: "sm",
|
|
110
|
+
className: "p-0 text-primary text-decoration-none d-flex align-items-center",
|
|
111
|
+
onClick: S,
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ e(K, { className: "me-1", size: 18 }),
|
|
114
|
+
"Mark all as read"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
) : /* @__PURE__ */ i(
|
|
118
|
+
r,
|
|
119
|
+
{
|
|
120
|
+
variant: "link",
|
|
121
|
+
size: "sm",
|
|
122
|
+
className: "p-0 text-danger text-decoration-none d-flex align-items-center",
|
|
123
|
+
onClick: T,
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ e(b, { className: "me-1", size: 16 }),
|
|
126
|
+
"Empty Trash"
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
) }),
|
|
130
|
+
/* @__PURE__ */ e("div", { className: "flex-grow-1 overflow-auto bg-light pt-3", children: v ? /* @__PURE__ */ e("div", { className: "text-center py-5", children: /* @__PURE__ */ e(E, { animation: "border", variant: "primary" }) }) : f.length === 0 ? /* @__PURE__ */ e("div", { className: "text-center py-5 text-muted", children: /* @__PURE__ */ e("p", { className: "mb-0", children: n === "inbox" ? "Your inbox is empty!" : "No deleted notifications." }) }) : /* @__PURE__ */ e("div", { className: "px-3", children: f.map((t) => {
|
|
131
|
+
const { title: a, body: s } = j(t), l = n === "inbox" && !t.isRead;
|
|
132
|
+
return /* @__PURE__ */ e(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
className: `p-3 mb-2 rounded border shadow-sm ${l ? "bg-white border-primary-subtle" : "bg-white border-light"}`,
|
|
136
|
+
style: {
|
|
137
|
+
transition: "all 0.2s ease-in-out",
|
|
138
|
+
borderLeft: l ? "4px solid #0d6efd" : "1px solid #dee2e6"
|
|
139
|
+
},
|
|
140
|
+
children: /* @__PURE__ */ i("div", { className: "d-flex justify-content-between align-items-start", children: [
|
|
141
|
+
/* @__PURE__ */ i("div", { className: "pe-2 flex-grow-1", children: [
|
|
142
|
+
/* @__PURE__ */ e(
|
|
143
|
+
"h6",
|
|
144
|
+
{
|
|
145
|
+
className: `mb-1 ${l ? "fw-bold text-dark" : "text-secondary fw-semibold"}`,
|
|
146
|
+
style: { fontSize: "0.9rem", lineHeight: "1.25" },
|
|
147
|
+
children: a
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ e(
|
|
151
|
+
"p",
|
|
152
|
+
{
|
|
153
|
+
className: "mb-2 text-muted",
|
|
154
|
+
style: { fontSize: "0.8rem", color: "#6c757d", lineHeight: "1.3" },
|
|
155
|
+
children: s
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ e("span", { className: "text-muted d-block", style: { fontSize: "0.7rem" }, children: A(t.createdAt) })
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ i("div", { className: "d-flex align-items-center gap-2", children: [
|
|
161
|
+
l && /* @__PURE__ */ e(
|
|
162
|
+
r,
|
|
163
|
+
{
|
|
164
|
+
variant: "link",
|
|
165
|
+
className: "p-1 text-primary border-0 d-flex align-items-center",
|
|
166
|
+
onClick: () => w(t.id),
|
|
167
|
+
title: "Mark as read",
|
|
168
|
+
style: { boxShadow: "none" },
|
|
169
|
+
children: /* @__PURE__ */ e(R, { size: 8, className: "text-primary" })
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
n === "inbox" && /* @__PURE__ */ e(
|
|
173
|
+
r,
|
|
174
|
+
{
|
|
175
|
+
variant: "link",
|
|
176
|
+
className: "p-1 text-secondary border-0 d-flex align-items-center",
|
|
177
|
+
onClick: () => z(t.id),
|
|
178
|
+
title: "Move to trash",
|
|
179
|
+
style: { boxShadow: "none" },
|
|
180
|
+
onMouseEnter: (h) => {
|
|
181
|
+
const o = h.currentTarget.querySelector("svg");
|
|
182
|
+
o && (o.style.fill = "#dc3545");
|
|
183
|
+
},
|
|
184
|
+
onMouseLeave: (h) => {
|
|
185
|
+
const o = h.currentTarget.querySelector("svg");
|
|
186
|
+
o && (o.style.fill = "currentColor");
|
|
187
|
+
},
|
|
188
|
+
children: /* @__PURE__ */ e(b, { size: 14, style: { transition: "fill 0.2s" } })
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
] })
|
|
192
|
+
] })
|
|
193
|
+
},
|
|
194
|
+
t.id
|
|
195
|
+
);
|
|
196
|
+
}) }) })
|
|
197
|
+
] }) })
|
|
198
|
+
] });
|
|
199
|
+
};
|
|
200
|
+
export {
|
|
201
|
+
G as NotificationDrawer
|
|
202
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { Spinner as u, Alert as b, Card as c, Form as s } from "react-bootstrap";
|
|
3
|
+
import { useNotifications as y } from "../../Context/NotificationContext.js";
|
|
4
|
+
const N = () => {
|
|
5
|
+
const { preferences: n, updatePreferences: i, isLoading: o } = y(), a = (e) => {
|
|
6
|
+
n && i({ [e]: !n[e] });
|
|
7
|
+
}, d = (e) => {
|
|
8
|
+
if (!n) return;
|
|
9
|
+
const h = n.mutedEventTypes.includes(e) ? n.mutedEventTypes.filter((p) => p !== e) : [...n.mutedEventTypes, e];
|
|
10
|
+
i({ mutedEventTypes: h });
|
|
11
|
+
};
|
|
12
|
+
if (o && !n)
|
|
13
|
+
return /* @__PURE__ */ t("div", { className: "text-center py-4", children: /* @__PURE__ */ t(u, { animation: "border", size: "sm" }) });
|
|
14
|
+
if (!n)
|
|
15
|
+
return /* @__PURE__ */ t(b, { variant: "warning", children: "Unable to load notification preferences." });
|
|
16
|
+
const m = [
|
|
17
|
+
{ key: "review_assigned", label: "Review Assignments (Relectures)" },
|
|
18
|
+
{ key: "project_created", label: "Project Creations" },
|
|
19
|
+
{ key: "system_alert", label: "System Alerts" }
|
|
20
|
+
];
|
|
21
|
+
return /* @__PURE__ */ t(c, { className: "border-0 shadow-sm", children: /* @__PURE__ */ l(c.Body, { className: "p-3", children: [
|
|
22
|
+
/* @__PURE__ */ t("h6", { className: "mb-3 text-secondary font-weight-bold", children: "Notification Channels" }),
|
|
23
|
+
/* @__PURE__ */ l(s.Group, { className: "mb-3", children: [
|
|
24
|
+
/* @__PURE__ */ t(
|
|
25
|
+
s.Check,
|
|
26
|
+
{
|
|
27
|
+
type: "switch",
|
|
28
|
+
id: "channel-inapp",
|
|
29
|
+
label: "In-App Notifications (Real-Time)",
|
|
30
|
+
checked: n.inAppEnabled,
|
|
31
|
+
onChange: () => a("inAppEnabled"),
|
|
32
|
+
className: "mb-2"
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ t(
|
|
36
|
+
s.Check,
|
|
37
|
+
{
|
|
38
|
+
type: "switch",
|
|
39
|
+
id: "channel-email",
|
|
40
|
+
label: "Email Alerts",
|
|
41
|
+
checked: n.emailEnabled,
|
|
42
|
+
onChange: () => a("emailEnabled")
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ t("hr", {}),
|
|
47
|
+
/* @__PURE__ */ t("h6", { className: "mb-3 text-secondary font-weight-bold", children: "Mute Event Types" }),
|
|
48
|
+
/* @__PURE__ */ t("p", { className: "text-muted small mb-3", children: "Check events you do NOT want to receive notifications for." }),
|
|
49
|
+
/* @__PURE__ */ t(s.Group, { children: m.map((e) => {
|
|
50
|
+
const r = n.mutedEventTypes.includes(e.key);
|
|
51
|
+
return /* @__PURE__ */ t(
|
|
52
|
+
s.Check,
|
|
53
|
+
{
|
|
54
|
+
type: "checkbox",
|
|
55
|
+
id: `mute-${e.key}`,
|
|
56
|
+
label: e.label,
|
|
57
|
+
checked: r,
|
|
58
|
+
onChange: () => d(e.key),
|
|
59
|
+
className: "mb-2 text-dark"
|
|
60
|
+
},
|
|
61
|
+
e.key
|
|
62
|
+
);
|
|
63
|
+
}) })
|
|
64
|
+
] }) });
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
N as NotificationSettings
|
|
68
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NotificationBell as i } from "./NotificationBell.js";
|
|
2
|
+
import { NotificationDrawer as e } from "./NotificationDrawer.js";
|
|
3
|
+
import { NotificationSettings as a } from "./NotificationSettings.js";
|
|
4
|
+
export {
|
|
5
|
+
i as NotificationBell,
|
|
6
|
+
e as NotificationDrawer,
|
|
7
|
+
a as NotificationSettings
|
|
8
|
+
};
|
|
@@ -4,29 +4,30 @@ import "../../Context/AnalyticsContext.js";
|
|
|
4
4
|
import "../../Context/MenuContext.js";
|
|
5
5
|
import { useRouter as h } from "../../Context/RouterContext.js";
|
|
6
6
|
import { useSession as d } from "../../Context/SessionContext.js";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import "../../Context/NotificationContext.js";
|
|
8
|
+
const L = ({
|
|
9
|
+
notAuthorizedPath: r,
|
|
9
10
|
allowedPermissions: i = [],
|
|
10
|
-
children:
|
|
11
|
+
children: p
|
|
11
12
|
}) => {
|
|
12
|
-
var
|
|
13
|
-
const { isAuthenticated:
|
|
13
|
+
var s;
|
|
14
|
+
const { isAuthenticated: e, isLoading: n, user: t } = d(), { navigate: m } = h();
|
|
14
15
|
return g(() => {
|
|
15
|
-
if (!
|
|
16
|
+
if (!n && e) {
|
|
16
17
|
const o = (t == null ? void 0 : t.permissions) || [];
|
|
17
|
-
!i.length || o.some((
|
|
18
|
+
!i.length || o.some((c) => i.includes(c)) || m(r);
|
|
18
19
|
}
|
|
19
20
|
}, [
|
|
20
|
-
r,
|
|
21
21
|
n,
|
|
22
22
|
e,
|
|
23
|
-
|
|
23
|
+
r,
|
|
24
|
+
m,
|
|
24
25
|
t,
|
|
25
26
|
i
|
|
26
|
-
]), i.length > 0 && !((
|
|
27
|
+
]), i.length > 0 && !((s = t == null ? void 0 : t.permissions) != null && s.some(
|
|
27
28
|
(o) => i.includes(o)
|
|
28
|
-
)) ? null : /* @__PURE__ */ f(u, { children:
|
|
29
|
+
)) ? null : /* @__PURE__ */ f(u, { children: p });
|
|
29
30
|
};
|
|
30
31
|
export {
|
|
31
|
-
|
|
32
|
+
L as ProtectedRoute
|
|
32
33
|
};
|
package/dist/Components/index.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { AuthWrapper as t } from "./AuthWrapper/index.js";
|
|
2
|
-
import { confirmationModalDefaultProps as
|
|
3
|
-
import { Footer as
|
|
4
|
-
import { Header as
|
|
5
|
-
import { NotAuthorized as
|
|
6
|
-
import { Paginator as
|
|
7
|
-
import { ProtectedRoute as
|
|
2
|
+
import { confirmationModalDefaultProps as f } from "./ConfirmationModal/index.js";
|
|
3
|
+
import { Footer as p } from "./Footer/index.js";
|
|
4
|
+
import { Header as m } from "./Header/index.js";
|
|
5
|
+
import { NotAuthorized as n } from "./NotAuthorized/index.js";
|
|
6
|
+
import { Paginator as d } from "./Paginator/index.js";
|
|
7
|
+
import { ProtectedRoute as u } from "./ProtectedRoute/index.js";
|
|
8
|
+
import { NotificationBell as P } from "./Notifications/NotificationBell.js";
|
|
9
|
+
import { NotificationDrawer as h } from "./Notifications/NotificationDrawer.js";
|
|
10
|
+
import { NotificationSettings as A } from "./Notifications/NotificationSettings.js";
|
|
8
11
|
export {
|
|
9
12
|
t as AuthWrapper,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
p as Footer,
|
|
14
|
+
m as Header,
|
|
15
|
+
n as NotAuthorized,
|
|
16
|
+
P as NotificationBell,
|
|
17
|
+
h as NotificationDrawer,
|
|
18
|
+
A as NotificationSettings,
|
|
19
|
+
d as Paginator,
|
|
20
|
+
u as ProtectedRoute,
|
|
21
|
+
f as confirmationModalDefaultProps
|
|
16
22
|
};
|