@ludo.ninja/components 2.3.72 → 2.3.73

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.
@@ -4,7 +4,7 @@ interface IImageInterceptor {
4
4
  title: string;
5
5
  fallbackSvg: ReactNode;
6
6
  }
7
- export declare const ImageInterceptor: ({ src, title, fallbackSvg, }: IImageInterceptor) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const ImageInterceptor: ({ src, title, fallbackSvg }: IImageInterceptor) => import("react/jsx-runtime").JSX.Element;
8
8
  export declare const Subscription: ({ routerPush }: {
9
9
  routerPush?: (a: string) => void;
10
10
  }) => null;
@@ -5,19 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Subscription = exports.ImageInterceptor = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = require("react");
9
- const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
10
- const styled_components_1 = __importDefault(require("styled-components"));
11
- const api_1 = require("@ludo.ninja/api");
12
- const ui_1 = require("../../store/ui");
13
- const env_1 = require("../../store/env");
8
+ const noContent_1 = require("./noContent");
14
9
  const store_1 = require("../../modules/user/store");
10
+ const env_1 = require("../../store/env");
11
+ const ui_1 = require("../../store/ui");
15
12
  const client_1 = require("@apollo/client");
16
- const OpportunitySvg_1 = require("@ludo.ninja/ui/build/modules/notifications/variants/OpportunitySvg");
13
+ const api_1 = require("@ludo.ninja/api");
14
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
17
15
  const InviteCodeSvg_1 = require("@ludo.ninja/ui/build/modules/notifications/variants/InviteCodeSvg");
16
+ const OpportunitySvg_1 = require("@ludo.ninja/ui/build/modules/notifications/variants/OpportunitySvg");
17
+ const ProjectSvg_1 = require("@ludo.ninja/ui/build/modules/notifications/variants/ProjectSvg");
18
18
  const XPIconSvg_1 = require("@ludo.ninja/ui/build/modules/notifications/variants/XPIconSvg");
19
- const noContent_1 = require("./noContent");
20
- const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
19
+ const react_1 = require("react");
20
+ const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
21
+ const styled_components_1 = __importDefault(require("styled-components"));
21
22
  const SImage = styled_components_1.default.div `
22
23
  position: relative;
23
24
  width: 62px;
@@ -38,28 +39,37 @@ const SImage = styled_components_1.default.div `
38
39
  height: 100%;
39
40
  }
40
41
  `;
41
- const ImageInterceptor = ({ src, title, fallbackSvg, }) => {
42
+ const ImageInterceptor = ({ src, title, fallbackSvg }) => {
42
43
  const [isLoading, setIsLoading] = (0, react_1.useState)(true);
43
44
  const [isError, setIsError] = (0, react_1.useState)(false);
44
- return ((0, jsx_runtime_1.jsxs)(SImage, { children: [isError && fallbackSvg, !isError && (0, jsx_runtime_1.jsx)("img", { width: "62", height: "62", src: src, alt: title, onLoad: () => {
45
+ return ((0, jsx_runtime_1.jsxs)(SImage, { children: [isError && fallbackSvg, !isError && ((0, jsx_runtime_1.jsx)("img", { width: "62", height: "62", src: src, alt: title, onLoad: () => {
45
46
  setIsLoading(false);
46
47
  }, onError: () => {
47
48
  setIsError(true);
48
49
  setIsLoading(false);
49
- } }), isLoading && ((0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { className: "skeleton", width: 62, height: 62, borderRadius: 4 }))] }));
50
+ } })), isLoading && (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { className: "skeleton", width: 62, height: 62, borderRadius: 4 })] }));
50
51
  };
51
52
  exports.ImageInterceptor = ImageInterceptor;
52
- const ImageNotification = ({ src, title, fallbackSvg, }) => {
53
+ const ImageNotification = ({ src, title, fallbackSvg }) => {
53
54
  if (!src) {
54
55
  return fallbackSvg;
55
56
  }
56
57
  return (0, jsx_runtime_1.jsx)(exports.ImageInterceptor, { fallbackSvg: fallbackSvg, title: title, src: src });
57
58
  };
59
+ const ProjectAlertMessage = ({ text }) => {
60
+ const dotIndex = text.indexOf(".");
61
+ if (dotIndex === -1) {
62
+ return text;
63
+ }
64
+ const token = text.slice(0, dotIndex);
65
+ const rest = text.slice(dotIndex);
66
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { style: { fontWeight: 700 }, children: token }), rest] }));
67
+ };
58
68
  const Subscription = ({ routerPush }) => {
59
69
  const { authToken } = api_1.authCookies.getCookies();
60
70
  const addNotification = (0, ui_1.useUiStore)((state) => state.addNotification);
61
- const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)(state => state.NEXT_PUBLIC_ENV_VALUE);
62
- const { user, } = (0, store_1.useUserStore)((state) => ({
71
+ const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
72
+ const { user } = (0, store_1.useUserStore)((state) => ({
63
73
  user: state.user,
64
74
  }));
65
75
  const userId = user?.userId || "";
@@ -78,7 +88,7 @@ const Subscription = ({ routerPush }) => {
78
88
  case api_1.notificationsSchema.IEventType.CommonOpportunity:
79
89
  case api_1.notificationsSchema.IEventType.UserOpportunity:
80
90
  addNotification({
81
- icon: (0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Opportunity updated", fallbackSvg: (0, jsx_runtime_1.jsx)(OpportunitySvg_1.OpportunitySvg, {}) }),
91
+ icon: ((0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Opportunity updated", fallbackSvg: (0, jsx_runtime_1.jsx)(OpportunitySvg_1.OpportunitySvg, {}) })),
82
92
  title: notification.name || "Opportunity updated",
83
93
  description: notification.description || "",
84
94
  onClick: () => {
@@ -88,9 +98,21 @@ const Subscription = ({ routerPush }) => {
88
98
  },
89
99
  });
90
100
  break;
101
+ case api_1.notificationsSchema.IEventType.ProjectAlert:
102
+ addNotification({
103
+ icon: ((0, jsx_runtime_1.jsx)(ImageNotification, { src: "", title: notification.name || "Project alert", fallbackSvg: (0, jsx_runtime_1.jsx)(ProjectSvg_1.ProjectSvg, {}) })),
104
+ title: notification.name || "Project alert",
105
+ description: (0, jsx_runtime_1.jsx)(ProjectAlertMessage, { text: notification.description || "" }),
106
+ onClick: () => {
107
+ if (notification.link) {
108
+ window.open(notification.link, "_blank");
109
+ }
110
+ },
111
+ });
112
+ break;
91
113
  case api_1.notificationsSchema.IEventType.UserInvitee:
92
114
  addNotification({
93
- icon: (0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Invite code used", fallbackSvg: (0, jsx_runtime_1.jsx)(InviteCodeSvg_1.InviteCodeSvg, {}) }),
115
+ icon: ((0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Invite code used", fallbackSvg: (0, jsx_runtime_1.jsx)(InviteCodeSvg_1.InviteCodeSvg, {}) })),
94
116
  title: notification.name || "Invite code used",
95
117
  description: notification.description || "",
96
118
  onClick: () => {
@@ -107,7 +129,7 @@ const Subscription = ({ routerPush }) => {
107
129
  case api_1.notificationsSchema.IEventType.UserXpIncrement:
108
130
  case api_1.notificationsSchema.IEventType.UserXps:
109
131
  addNotification({
110
- icon: (0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "XP updated", fallbackSvg: (0, jsx_runtime_1.jsx)(XPIconSvg_1.XpIconSvg, {}) }),
132
+ icon: ((0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "XP updated", fallbackSvg: (0, jsx_runtime_1.jsx)(XPIconSvg_1.XpIconSvg, {}) })),
111
133
  title: notification.name || "XP updated",
112
134
  description: notification.description || "",
113
135
  onClick: () => {
@@ -123,7 +145,7 @@ const Subscription = ({ routerPush }) => {
123
145
  break;
124
146
  default:
125
147
  addNotification({
126
- icon: (0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Ludo updated", fallbackSvg: (0, jsx_runtime_1.jsx)(noContent_1.NoContentSvg, {}) }),
148
+ icon: ((0, jsx_runtime_1.jsx)(ImageNotification, { src: notification.media || "", title: notification.name || "Ludo updated", fallbackSvg: (0, jsx_runtime_1.jsx)(noContent_1.NoContentSvg, {}) })),
127
149
  title: notification.name || "",
128
150
  description: notification.description || "",
129
151
  onClick: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.3.72",
3
+ "version": "2.3.73",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",