omninotice-notification-feed 0.0.0-stage → 0.2.0
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/README.md +266 -2
- package/dist/NotificationFeedPage-B7jnF1LL.js +971 -0
- package/dist/NotificationFeedPage-B7jnF1LL.js.map +1 -0
- package/dist/NotificationFeedPage-F2ht69hw.cjs +2 -0
- package/dist/NotificationFeedPage-F2ht69hw.cjs.map +1 -0
- package/dist/NotificationsFeedProvider-BApcYuJs.cjs +2 -0
- package/dist/NotificationsFeedProvider-BApcYuJs.cjs.map +1 -0
- package/dist/NotificationsFeedProvider-DTr1ulMN.js +35 -0
- package/dist/NotificationsFeedProvider-DTr1ulMN.js.map +1 -0
- package/dist/api/actions.d.ts +5 -0
- package/dist/api/apiFetch.d.ts +28 -0
- package/dist/api/envelope.d.ts +24 -0
- package/dist/api/notificationCounts.d.ts +24 -0
- package/dist/api/notificationDetails.d.ts +74 -0
- package/dist/api/notificationMapper.d.ts +11 -0
- package/dist/api/notifications.d.ts +102 -0
- package/dist/api/requests.d.ts +5 -0
- package/dist/api/schema.d.ts +17 -0
- package/dist/app/contexts/NotificationsContext.d.ts +10 -0
- package/dist/app/contexts/TabContext.d.ts +9 -0
- package/dist/app/providers/NotificationsFeedDataProvider.d.ts +19 -0
- package/dist/app/providers/NotificationsFeedProvider.d.ts +10 -0
- package/dist/app/providers/TabProvider.d.ts +11 -0
- package/dist/components/atoms/Button/Button.d.ts +3 -0
- package/dist/components/atoms/Container/Container.d.ts +4 -0
- package/dist/components/atoms/Loaders/SpinnerLoader/SpinnerLoader.d.ts +4 -0
- package/dist/components/atoms/NotificationIcon/NotificationIcon.d.ts +5 -0
- package/dist/components/atoms/Text/Text.d.ts +2 -0
- package/dist/components/atoms/icons/ArrowIcon.d.ts +2 -0
- package/dist/components/atoms/icons/BellRingIcon.d.ts +1 -0
- package/dist/components/atoms/icons/CheckIcon.d.ts +2 -0
- package/dist/components/atoms/icons/ChevronIcon.d.ts +2 -0
- package/dist/components/atoms/icons/CloseIcon.d.ts +2 -0
- package/dist/components/atoms/index.d.ts +8 -0
- package/dist/components/atoms/types.d.ts +33 -0
- package/dist/components/molecules/NotificationCard/NotificationCard.d.ts +2 -0
- package/dist/components/molecules/NotificationList/NotificationList.d.ts +6 -0
- package/dist/components/molecules/NotificationsState/NotificationsState.d.ts +2 -0
- package/dist/components/molecules/PageTitle/PageTitle.d.ts +1 -0
- package/dist/components/molecules/Tab/Tab.d.ts +1 -0
- package/dist/components/molecules/index.d.ts +3 -0
- package/dist/components/molecules/types.d.ts +60 -0
- package/dist/components/organisms/NotificationDetailsSidebar/NotificationDetailsSidebar.d.ts +8 -0
- package/dist/components/organisms/NotificationsRoot/NotificationsRoot.d.ts +4 -0
- package/dist/components/organisms/NotificationsSection/NotificationsSection.d.ts +1 -0
- package/dist/components/organisms/index.d.ts +1 -0
- package/dist/components/pages/NotificationFeedPage.d.ts +8 -0
- package/dist/config/SettingsContext.d.ts +3 -0
- package/dist/config/settings.config.d.ts +61 -0
- package/dist/helpers/classNames.d.ts +3 -0
- package/dist/helpers/decoder.d.ts +2 -0
- package/dist/helpers/isEmoji.d.ts +1 -0
- package/dist/helpers/renderButtonContent.d.ts +2 -0
- package/dist/helpers/renderIcon.d.ts +2 -0
- package/dist/helpers/resolvePicture.d.ts +18 -0
- package/dist/hooks/useNotificationDetails.d.ts +7 -0
- package/dist/hooks/useNotificationsFeed.d.ts +33 -0
- package/dist/hooks/useTab.d.ts +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/notificationDetails-BEOAyDdp.cjs +2 -0
- package/dist/notificationDetails-BEOAyDdp.cjs.map +1 -0
- package/dist/notificationDetails-CqA8ONhr.js +102 -0
- package/dist/notificationDetails-CqA8ONhr.js.map +1 -0
- package/dist/public.cjs +1 -0
- package/dist/public.d.ts +8 -0
- package/dist/public.js +4 -0
- package/dist/register-all.cjs +2 -0
- package/dist/register-all.cjs.map +1 -0
- package/dist/register-all.d.ts +1 -0
- package/dist/register-all.js +24 -0
- package/dist/register-all.js.map +1 -0
- package/dist/standalone.cjs +1 -0
- package/dist/standalone.d.ts +8 -0
- package/dist/standalone.js +3 -0
- package/dist/style.css +2 -0
- package/package.json +67 -4
|
@@ -0,0 +1,971 @@
|
|
|
1
|
+
import { createContext as e, createElement as t, forwardRef as n, isValidElement as r, memo as i, useCallback as a, useContext as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
2
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
3
|
+
//#region src/api/notificationMapper.ts
|
|
4
|
+
function m(e) {
|
|
5
|
+
let t = e.data[0];
|
|
6
|
+
if (!t) throw Error("Сервер не вернул количество уведомлений");
|
|
7
|
+
return {
|
|
8
|
+
all: t.total_count,
|
|
9
|
+
unread: t.unread_count
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function h(e, t) {
|
|
13
|
+
let n = e.data.find((e) => e.chit.message_id === t) ?? e.data[0];
|
|
14
|
+
if (!n) throw Error("Сервер не вернул уведомление");
|
|
15
|
+
let { chit: r } = n;
|
|
16
|
+
return {
|
|
17
|
+
messageId: r.message_id,
|
|
18
|
+
title: r.title,
|
|
19
|
+
description: r.description ?? "",
|
|
20
|
+
text: r.text ?? void 0,
|
|
21
|
+
action: r.action ? {
|
|
22
|
+
url: r.action.url,
|
|
23
|
+
title: r.action.title
|
|
24
|
+
} : void 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var g = new Intl.DateTimeFormat("ru-RU", {
|
|
28
|
+
hour: "2-digit",
|
|
29
|
+
minute: "2-digit"
|
|
30
|
+
});
|
|
31
|
+
function _(e) {
|
|
32
|
+
let { chit: t } = e, n = e.created_date, r = new Date(n);
|
|
33
|
+
return {
|
|
34
|
+
messageId: t.message_id,
|
|
35
|
+
status: e.status,
|
|
36
|
+
createdAt: n,
|
|
37
|
+
time: Number.isNaN(r.getTime()) ? "" : g.format(r),
|
|
38
|
+
title: t.title,
|
|
39
|
+
description: t.description ?? "",
|
|
40
|
+
picture: {
|
|
41
|
+
image: t.picture?.main ?? t.picture?.preview ?? t.picture?.cover ?? void 0,
|
|
42
|
+
icon: t.picture?.icon ?? void 0,
|
|
43
|
+
emoji: t.picture?.emoji ?? void 0
|
|
44
|
+
},
|
|
45
|
+
action: t.action ?? void 0,
|
|
46
|
+
isRead: e.is_read
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/components/atoms/icons/BellRingIcon.tsx
|
|
51
|
+
function v() {
|
|
52
|
+
return /* @__PURE__ */ p("svg", {
|
|
53
|
+
width: "15",
|
|
54
|
+
height: "16",
|
|
55
|
+
viewBox: "0 0 15 16",
|
|
56
|
+
fill: "none",
|
|
57
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ f("path", {
|
|
60
|
+
d: "M9.17984 12.6389C9.17984 13.8048 8.21022 14.75 7.01413 14.75C5.81805 14.75 4.84843 13.8048 4.84843 12.6389H9.17984Z",
|
|
61
|
+
stroke: "currentColor",
|
|
62
|
+
strokeLinecap: "round"
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ f("path", {
|
|
65
|
+
d: "M12.2746 12.6389H2.03205C1.40455 12.6389 1.09986 12.1265 1.16101 11.5427C1.17557 11.4037 1.233 11.2738 1.30271 11.1527L2.25481 9.4982C2.4649 9.13312 2.59576 8.7279 2.63886 8.3089L2.86865 6.07542C2.88905 5.87711 2.91809 5.6806 2.97586 5.48981C3.18223 4.8082 3.85189 3.10056 5.52905 2.39543V2.08333C5.52905 1.20888 6.25627 0.5 7.15333 0.5C8.05039 0.5 8.77761 1.20888 8.77761 2.08333V2.39544C10.3986 3.07696 11.0785 4.69501 11.3085 5.41799C11.3841 5.65567 11.4171 5.90248 11.4364 6.15115L11.5978 8.22926C11.6343 8.69942 11.7811 9.15435 12.0264 9.55715L12.9896 11.1392C13.0688 11.2692 13.1336 11.41 13.1475 11.5616C13.2002 12.1375 12.8953 12.6389 12.2746 12.6389Z",
|
|
66
|
+
stroke: "currentColor",
|
|
67
|
+
strokeLinecap: "round"
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ f("path", {
|
|
70
|
+
d: "M13.6534 5.375C14.1534 3.37498 12.9034 1.37499 11.1535 0.875M0.611081 5.375C0.111127 3.37498 1.36112 1.37499 3.11106 0.875",
|
|
71
|
+
stroke: "currentColor",
|
|
72
|
+
strokeLinecap: "round"
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/components/atoms/icons/ChevronIcon.tsx
|
|
79
|
+
function y({ width: e = 8, height: t = 15 }) {
|
|
80
|
+
return /* @__PURE__ */ f("svg", {
|
|
81
|
+
width: e,
|
|
82
|
+
height: t,
|
|
83
|
+
viewBox: "0 0 8 15",
|
|
84
|
+
fill: "none",
|
|
85
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
86
|
+
children: /* @__PURE__ */ f("path", {
|
|
87
|
+
d: "M0.5 0.5L7.25 7.25L0.5 14",
|
|
88
|
+
strokeLinecap: "round",
|
|
89
|
+
strokeLinejoin: "round",
|
|
90
|
+
stroke: "currentColor"
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/helpers/renderButtonContent.tsx
|
|
96
|
+
var b = (e, t, n) => /* @__PURE__ */ p(d, { children: [
|
|
97
|
+
t ? /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(t, {}) }) : null,
|
|
98
|
+
e,
|
|
99
|
+
n ? /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(n, {}) }) : null
|
|
100
|
+
] });
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/helpers/classNames.ts
|
|
103
|
+
function x(...e) {
|
|
104
|
+
return e.filter(Boolean).join(" ");
|
|
105
|
+
}
|
|
106
|
+
var S = {
|
|
107
|
+
button: "_button_1vx9h_1",
|
|
108
|
+
primary: "_primary_1vx9h_10",
|
|
109
|
+
secondary: "_secondary_1vx9h_21",
|
|
110
|
+
icon: "_icon_1vx9h_32",
|
|
111
|
+
link: "_link_1vx9h_50"
|
|
112
|
+
}, C = n(function(e, t) {
|
|
113
|
+
if (e.as === "a") {
|
|
114
|
+
let { as: n, variant: r = "primary", leftIcon: i, rightIcon: a, className: o, children: s, disabled: c, onClick: l, ...u } = e, d = (e) => {
|
|
115
|
+
c ? e.preventDefault() : l?.(e);
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ f("a", {
|
|
118
|
+
...u,
|
|
119
|
+
ref: t,
|
|
120
|
+
className: x(S.button, S[r], o),
|
|
121
|
+
"aria-disabled": c || void 0,
|
|
122
|
+
tabIndex: c ? -1 : u.tabIndex,
|
|
123
|
+
onClick: d,
|
|
124
|
+
children: b(s, i, a)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
let { as: n, variant: r = "primary", leftIcon: i, rightIcon: a, className: o, children: s, type: c = "button", ...l } = e;
|
|
128
|
+
return /* @__PURE__ */ f("button", {
|
|
129
|
+
...l,
|
|
130
|
+
ref: t,
|
|
131
|
+
type: c,
|
|
132
|
+
className: x(S.button, S[r], o),
|
|
133
|
+
children: b(s, i, a)
|
|
134
|
+
});
|
|
135
|
+
}), w = {
|
|
136
|
+
text: "_text_11w37_1",
|
|
137
|
+
primary: "_primary_11w37_9",
|
|
138
|
+
secondary: "_secondary_11w37_13",
|
|
139
|
+
paper: "_paper_11w37_17",
|
|
140
|
+
sizeXs: "_sizeXs_11w37_22",
|
|
141
|
+
sizeSm: "_sizeSm_11w37_27",
|
|
142
|
+
sizeMd: "_sizeMd_11w37_32",
|
|
143
|
+
sizeLg: "_sizeLg_11w37_37",
|
|
144
|
+
sizeXl: "_sizeXl_11w37_42",
|
|
145
|
+
sizeXxl: "_sizeXxl_11w37_47",
|
|
146
|
+
weightRegular: "_weightRegular_11w37_53",
|
|
147
|
+
weightMedium: "_weightMedium_11w37_57",
|
|
148
|
+
weightSemibold: "_weightSemibold_11w37_61",
|
|
149
|
+
weightBold: "_weightBold_11w37_65"
|
|
150
|
+
}, T = {
|
|
151
|
+
xs: w.sizeXs,
|
|
152
|
+
sm: w.sizeSm,
|
|
153
|
+
md: w.sizeMd,
|
|
154
|
+
lg: w.sizeLg,
|
|
155
|
+
xl: w.sizeXl,
|
|
156
|
+
xxl: w.sizeXxl
|
|
157
|
+
}, E = {
|
|
158
|
+
regular: w.weightRegular,
|
|
159
|
+
medium: w.weightMedium,
|
|
160
|
+
semibold: w.weightSemibold,
|
|
161
|
+
bold: w.weightBold
|
|
162
|
+
};
|
|
163
|
+
function D({ as: e = "p", variant: t = "primary", size: n = "md", weight: r = "regular", className: i, children: a, ...o }) {
|
|
164
|
+
let s = x(w.text, w[t], T[n], E[r], i);
|
|
165
|
+
return /* @__PURE__ */ f(e, {
|
|
166
|
+
...o,
|
|
167
|
+
className: s,
|
|
168
|
+
children: a
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
var O = { container: "_container_1eody_1" };
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/components/atoms/Container/Container.tsx
|
|
174
|
+
function k({ children: e }) {
|
|
175
|
+
return /* @__PURE__ */ f("div", {
|
|
176
|
+
className: O.container,
|
|
177
|
+
children: e
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/config/SettingsContext.ts
|
|
182
|
+
var A = e(z);
|
|
183
|
+
function j() {
|
|
184
|
+
return o(A);
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/helpers/renderIcon.tsx
|
|
188
|
+
function M(e) {
|
|
189
|
+
return r(e) ? e : typeof e == "function" ? /* @__PURE__ */ f(e, {}) : e;
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/helpers/isEmoji.ts
|
|
193
|
+
var ee = /^(?:\p{Extended_Pictographic}(?:\uFE0F|\u200D|\p{Emoji_Modifier})*|\p{Regional_Indicator}{2}|[0-9#*]\uFE0F?\u20E3)+$/u;
|
|
194
|
+
function te(e) {
|
|
195
|
+
return typeof e == "string" && ee.test(e.trim());
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/helpers/resolvePicture.ts
|
|
199
|
+
function ne(e) {
|
|
200
|
+
return typeof e == "function";
|
|
201
|
+
}
|
|
202
|
+
function N(e, t) {
|
|
203
|
+
let { image: n, icon: r, emoji: i } = e;
|
|
204
|
+
if (n && !t(n)) return {
|
|
205
|
+
kind: "image",
|
|
206
|
+
src: n
|
|
207
|
+
};
|
|
208
|
+
if (r) {
|
|
209
|
+
if (typeof r == "string") {
|
|
210
|
+
if (!t(r)) return {
|
|
211
|
+
kind: "image",
|
|
212
|
+
src: r
|
|
213
|
+
};
|
|
214
|
+
} else if (ne(r)) return {
|
|
215
|
+
kind: "component",
|
|
216
|
+
Component: r
|
|
217
|
+
};
|
|
218
|
+
else return {
|
|
219
|
+
kind: "element",
|
|
220
|
+
element: r
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return i && te(i) ? {
|
|
224
|
+
kind: "emoji",
|
|
225
|
+
value: i.trim()
|
|
226
|
+
} : { kind: "default" };
|
|
227
|
+
}
|
|
228
|
+
var P = {
|
|
229
|
+
icon: "_icon_1o6v9_1",
|
|
230
|
+
image: "_image_1o6v9_13"
|
|
231
|
+
};
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/components/atoms/NotificationIcon/NotificationIcon.tsx
|
|
234
|
+
function F({ picture: e, alt: t }) {
|
|
235
|
+
let { defaultIcon: n } = j(), [r, i] = u([]), a = (e) => i((t) => t.includes(e) ? t : [...t, e]);
|
|
236
|
+
return /* @__PURE__ */ f("div", {
|
|
237
|
+
className: P.icon,
|
|
238
|
+
children: ((r) => {
|
|
239
|
+
let i = N(e, r);
|
|
240
|
+
switch (i.kind) {
|
|
241
|
+
case "image": return /* @__PURE__ */ f("img", {
|
|
242
|
+
className: P.image,
|
|
243
|
+
src: i.src,
|
|
244
|
+
alt: t,
|
|
245
|
+
onError: () => a(i.src),
|
|
246
|
+
"data-type": i.src.endsWith(".svg") ? "icon" : "image"
|
|
247
|
+
});
|
|
248
|
+
case "element": return i.element;
|
|
249
|
+
case "component": {
|
|
250
|
+
let e = i.Component;
|
|
251
|
+
return /* @__PURE__ */ f(e, {});
|
|
252
|
+
}
|
|
253
|
+
case "emoji": return /* @__PURE__ */ f("span", { children: i.value });
|
|
254
|
+
default: return M(n);
|
|
255
|
+
}
|
|
256
|
+
})((e) => r.includes(e))
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
var I = {
|
|
260
|
+
spinner: "_spinner_1t8lw_1",
|
|
261
|
+
rotation: "_rotation_1t8lw_1",
|
|
262
|
+
sm: "_sm_1t8lw_13",
|
|
263
|
+
md: "_md_1t8lw_17",
|
|
264
|
+
lg: "_lg_1t8lw_21",
|
|
265
|
+
primary: "_primary_1t8lw_25",
|
|
266
|
+
secondary: "_secondary_1t8lw_29"
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/components/atoms/Loaders/SpinnerLoader/SpinnerLoader.tsx
|
|
270
|
+
function L({ variant: e = "paper", size: t = "sm" }) {
|
|
271
|
+
return /* @__PURE__ */ f("div", { className: x(I.spinner, e !== "paper" && I[e], I[t]) });
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/components/atoms/icons/CheckIcon.tsx
|
|
275
|
+
function R({ width: e = 15, height: t = 10 }) {
|
|
276
|
+
return /* @__PURE__ */ f("svg", {
|
|
277
|
+
width: e,
|
|
278
|
+
height: t,
|
|
279
|
+
viewBox: "0 0 15 10",
|
|
280
|
+
fill: "none",
|
|
281
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
282
|
+
children: /* @__PURE__ */ f("path", {
|
|
283
|
+
d: "M0.5 4.20588L5.5 9.5L14 0.5",
|
|
284
|
+
strokeLinecap: "round",
|
|
285
|
+
strokeLinejoin: "round",
|
|
286
|
+
stroke: "currentColor"
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/config/settings.config.tsx
|
|
292
|
+
var z = {
|
|
293
|
+
defaultIcon: /* @__PURE__ */ f(v, {}),
|
|
294
|
+
notificationState: {
|
|
295
|
+
empty: {
|
|
296
|
+
icon: /* @__PURE__ */ f(v, {}),
|
|
297
|
+
title: "Пока нет уведомлений",
|
|
298
|
+
description: "Здесь появятся объявления компании и сообщения о ваших задачах."
|
|
299
|
+
},
|
|
300
|
+
error: {
|
|
301
|
+
icon: /* @__PURE__ */ f(v, {}),
|
|
302
|
+
title: "Не удалось загрузить уведомления",
|
|
303
|
+
description: "Проверьте соединение и повторите. Ничего не потеряется.",
|
|
304
|
+
btn: { title: "Повторить" }
|
|
305
|
+
},
|
|
306
|
+
allRead: {
|
|
307
|
+
icon: /* @__PURE__ */ f(R, {}),
|
|
308
|
+
title: "Все уведомления прочитаны",
|
|
309
|
+
description: "Прочитанные уведомления — на вкладке «Все»."
|
|
310
|
+
},
|
|
311
|
+
noUnreadLoaded: {
|
|
312
|
+
icon: /* @__PURE__ */ f(v, {}),
|
|
313
|
+
title: "Непрочитанных нет",
|
|
314
|
+
description: "На загруженных страницах нет непрочитанных уведомлений.",
|
|
315
|
+
btn: { title: "Показать больше" }
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
sidebarBackdrop: !0,
|
|
319
|
+
pageTitle: "Уведомления",
|
|
320
|
+
pageSubtitle: "Объявления компании и сообщения о ваших задачах, отпусках и опросах",
|
|
321
|
+
autoLoadUnread: !0
|
|
322
|
+
};
|
|
323
|
+
function re(e = {}) {
|
|
324
|
+
return {
|
|
325
|
+
...z,
|
|
326
|
+
...e,
|
|
327
|
+
defaultIcon: e.defaultIcon ?? z.defaultIcon,
|
|
328
|
+
sidebarBackdrop: e.sidebarBackdrop ?? z.sidebarBackdrop,
|
|
329
|
+
autoLoadUnread: e.autoLoadUnread ?? z.autoLoadUnread,
|
|
330
|
+
notificationState: {
|
|
331
|
+
empty: {
|
|
332
|
+
...z.notificationState.empty,
|
|
333
|
+
...e.notificationState?.empty
|
|
334
|
+
},
|
|
335
|
+
error: {
|
|
336
|
+
...z.notificationState.error,
|
|
337
|
+
...e.notificationState?.error
|
|
338
|
+
},
|
|
339
|
+
allRead: {
|
|
340
|
+
...z.notificationState.allRead,
|
|
341
|
+
...e.notificationState?.allRead
|
|
342
|
+
},
|
|
343
|
+
noUnreadLoaded: {
|
|
344
|
+
...z.notificationState.noUnreadLoaded,
|
|
345
|
+
...e.notificationState?.noUnreadLoaded
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/hooks/useNotificationsFeed.ts
|
|
352
|
+
var B = {
|
|
353
|
+
all: 0,
|
|
354
|
+
unread: 0
|
|
355
|
+
};
|
|
356
|
+
function ie(e, t) {
|
|
357
|
+
let n = /* @__PURE__ */ new Map();
|
|
358
|
+
for (let t of e) n.set(t.chit.message_id, t);
|
|
359
|
+
for (let e of t) n.set(e.chit.message_id, e);
|
|
360
|
+
return Array.from(n.values());
|
|
361
|
+
}
|
|
362
|
+
function ae(e) {
|
|
363
|
+
let [t, n] = u([]), [r, i] = u(null), [o, d] = u(0), [f, p] = u(B), [h, g] = u(null), [_, v] = u(!0), [y, b] = u(!1), [x, S] = u(!0), [C, w] = u(!1), T = l(e);
|
|
364
|
+
T.current = e;
|
|
365
|
+
let E = r === null || C ? !1 : e.getHasMore ? e.getHasMore(r, t.length) : t.length < f.all, D = l({
|
|
366
|
+
items: t,
|
|
367
|
+
page: o,
|
|
368
|
+
hasMore: E,
|
|
369
|
+
isLoading: _,
|
|
370
|
+
isLoadingMore: y
|
|
371
|
+
});
|
|
372
|
+
D.current = {
|
|
373
|
+
items: t,
|
|
374
|
+
page: o,
|
|
375
|
+
hasMore: E,
|
|
376
|
+
isLoading: _,
|
|
377
|
+
isLoadingMore: y
|
|
378
|
+
};
|
|
379
|
+
let O = l(null), k = a(async (e) => {
|
|
380
|
+
let t = e === 1;
|
|
381
|
+
O.current?.abort();
|
|
382
|
+
let r = new AbortController();
|
|
383
|
+
O.current = r;
|
|
384
|
+
let { signal: a } = r;
|
|
385
|
+
g(null), t ? (n([]), i(null), d(0), p(B), w(!1), v(!0), S(!0), b(!1)) : b(!0);
|
|
386
|
+
try {
|
|
387
|
+
let { fetchList: r, fetchCounts: o } = T.current, [s, c] = await Promise.all([r(e), t ? o() : void 0]);
|
|
388
|
+
if (a.aborted) return;
|
|
389
|
+
let l = c ? m(c) : null;
|
|
390
|
+
n((e) => t ? s.data : ie(e, s.data)), i(s.info), d(e), w(s.data.length === 0), l && p(l);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
if (a.aborted) return;
|
|
393
|
+
g(e instanceof Error ? e : Error(String(e)));
|
|
394
|
+
} finally {
|
|
395
|
+
a.aborted || (v(!1), b(!1), S(!1));
|
|
396
|
+
}
|
|
397
|
+
}, []);
|
|
398
|
+
s(() => (k(1), () => O.current?.abort()), [k]);
|
|
399
|
+
let A = a(() => {
|
|
400
|
+
let e = D.current;
|
|
401
|
+
!e.hasMore || e.isLoading || e.isLoadingMore || k(e.page + 1);
|
|
402
|
+
}, [k]), j = a(() => {
|
|
403
|
+
k(D.current.page + 1);
|
|
404
|
+
}, [k]), M = a((e) => {
|
|
405
|
+
let t = D.current.items.find((t) => t.chit.message_id === e);
|
|
406
|
+
return !t || t.is_read ? !1 : (n((t) => t.map((t) => t.chit.message_id === e ? {
|
|
407
|
+
...t,
|
|
408
|
+
is_read: !0
|
|
409
|
+
} : t)), p((e) => ({
|
|
410
|
+
...e,
|
|
411
|
+
unread: Math.max(0, e.unread - 1)
|
|
412
|
+
})), !0);
|
|
413
|
+
}, []);
|
|
414
|
+
return c(() => ({
|
|
415
|
+
items: t,
|
|
416
|
+
counts: f,
|
|
417
|
+
error: h,
|
|
418
|
+
isLoading: _,
|
|
419
|
+
isLoadingMore: y,
|
|
420
|
+
isCountsLoading: x,
|
|
421
|
+
hasMore: E,
|
|
422
|
+
loadMore: A,
|
|
423
|
+
retry: j,
|
|
424
|
+
markRead: M
|
|
425
|
+
}), [
|
|
426
|
+
t,
|
|
427
|
+
f,
|
|
428
|
+
h,
|
|
429
|
+
_,
|
|
430
|
+
y,
|
|
431
|
+
x,
|
|
432
|
+
E,
|
|
433
|
+
A,
|
|
434
|
+
j,
|
|
435
|
+
M
|
|
436
|
+
]);
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/app/contexts/NotificationsContext.ts
|
|
440
|
+
var V = e(null);
|
|
441
|
+
function H() {
|
|
442
|
+
let e = o(V);
|
|
443
|
+
if (!e) throw Error("NotificationFeedPage must be rendered inside NotificationsFeedProvider");
|
|
444
|
+
return e;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/app/providers/NotificationsFeedDataProvider.tsx
|
|
448
|
+
function oe({ api: e, getHasMore: n, settings: r, children: i }) {
|
|
449
|
+
let a = ae({
|
|
450
|
+
fetchList: (t) => e.fetchList(t),
|
|
451
|
+
fetchCounts: () => e.fetchCounts(),
|
|
452
|
+
getHasMore: n
|
|
453
|
+
}), o = c(() => async (t, n) => h(await e.fetchDetails(t, n), t), [e.fetchDetails]), s = c(() => (t) => e.markRead(t), [e.markRead]), l = c(() => re(r), [r]), u = c(() => ({
|
|
454
|
+
state: a,
|
|
455
|
+
onLoadDetails: o,
|
|
456
|
+
onMarkRead: s
|
|
457
|
+
}), [
|
|
458
|
+
a,
|
|
459
|
+
o,
|
|
460
|
+
s
|
|
461
|
+
]);
|
|
462
|
+
return t(A.Provider, { value: l }, t(V.Provider, { value: u }, i));
|
|
463
|
+
}
|
|
464
|
+
var U = {
|
|
465
|
+
section: "_section_gujr5_1",
|
|
466
|
+
loader: "_loader_gujr5_8",
|
|
467
|
+
action: "_action_gujr5_15"
|
|
468
|
+
}, se = { pageTitle: "_pageTitle_1upga_1" }, ce = {
|
|
469
|
+
" ": "\xA0",
|
|
470
|
+
"—": "—",
|
|
471
|
+
"–": "–",
|
|
472
|
+
"«": "«",
|
|
473
|
+
"»": "»",
|
|
474
|
+
"&": "&"
|
|
475
|
+
}, le = /&(?:nbsp|mdash|ndash|laquo|raquo|amp);/g;
|
|
476
|
+
function W(e) {
|
|
477
|
+
return e?.replace(le, (e) => ce[e]);
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/components/molecules/PageTitle/PageTitle.tsx
|
|
481
|
+
function ue() {
|
|
482
|
+
let { pageTitle: e, pageSubtitle: t } = j();
|
|
483
|
+
return /* @__PURE__ */ p("div", {
|
|
484
|
+
className: se.pageTitle,
|
|
485
|
+
children: [/* @__PURE__ */ f(D, {
|
|
486
|
+
as: "h1",
|
|
487
|
+
size: "xxl",
|
|
488
|
+
weight: "semibold",
|
|
489
|
+
children: e
|
|
490
|
+
}), /* @__PURE__ */ f(D, {
|
|
491
|
+
variant: "secondary",
|
|
492
|
+
children: W(t) ?? "Объявления компании и сообщения о ваших задачах, отпусках и опросах"
|
|
493
|
+
})]
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/app/contexts/TabContext.ts
|
|
498
|
+
var G = e(null);
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/hooks/useTab.ts
|
|
501
|
+
function K() {
|
|
502
|
+
let e = o(G);
|
|
503
|
+
if (!e) throw Error("useTab must be used within TabProvider");
|
|
504
|
+
return e;
|
|
505
|
+
}
|
|
506
|
+
var q = {
|
|
507
|
+
tabs: "_tabs_3pwwl_1",
|
|
508
|
+
tab: "_tab_3pwwl_1"
|
|
509
|
+
};
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/components/molecules/Tab/Tab.tsx
|
|
512
|
+
function de() {
|
|
513
|
+
let { tab: e, setTab: t, unreadCount: n, allCount: r, isLoading: i } = K();
|
|
514
|
+
return /* @__PURE__ */ p("div", {
|
|
515
|
+
className: q.tabs,
|
|
516
|
+
children: [/* @__PURE__ */ p(C, {
|
|
517
|
+
className: q.tab,
|
|
518
|
+
variant: e === "all" ? "primary" : "secondary",
|
|
519
|
+
"aria-pressed": e === "all",
|
|
520
|
+
onClick: () => t("all"),
|
|
521
|
+
children: [/* @__PURE__ */ f(D, {
|
|
522
|
+
variant: e === "all" ? "paper" : "secondary",
|
|
523
|
+
weight: "medium",
|
|
524
|
+
children: "Все"
|
|
525
|
+
}), i ? /* @__PURE__ */ f(L, { variant: e === "all" ? "paper" : "secondary" }) : /* @__PURE__ */ f(D, {
|
|
526
|
+
variant: e === "all" ? "paper" : "secondary",
|
|
527
|
+
weight: "medium",
|
|
528
|
+
children: r
|
|
529
|
+
})]
|
|
530
|
+
}), /* @__PURE__ */ p(C, {
|
|
531
|
+
className: q.tab,
|
|
532
|
+
variant: e === "unread" ? "primary" : "secondary",
|
|
533
|
+
"aria-pressed": e === "unread",
|
|
534
|
+
onClick: () => t("unread"),
|
|
535
|
+
children: [/* @__PURE__ */ f(D, {
|
|
536
|
+
variant: e === "unread" ? "paper" : "secondary",
|
|
537
|
+
weight: "medium",
|
|
538
|
+
children: "Непрочитанные"
|
|
539
|
+
}), i ? /* @__PURE__ */ f(L, { variant: e === "unread" ? "paper" : "secondary" }) : /* @__PURE__ */ f(D, {
|
|
540
|
+
variant: e === "unread" ? "paper" : "secondary",
|
|
541
|
+
weight: "medium",
|
|
542
|
+
children: n
|
|
543
|
+
})]
|
|
544
|
+
})]
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
var J = {
|
|
548
|
+
card: "_card_1ydb7_1",
|
|
549
|
+
unread: "_unread_1ydb7_24",
|
|
550
|
+
left: "_left_1ydb7_29",
|
|
551
|
+
content: "_content_1ydb7_35",
|
|
552
|
+
title: "_title_1ydb7_42",
|
|
553
|
+
description: "_description_1ydb7_43",
|
|
554
|
+
right: "_right_1ydb7_50",
|
|
555
|
+
time: "_time_1ydb7_56",
|
|
556
|
+
chevron: "_chevron_1ydb7_60"
|
|
557
|
+
};
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/components/molecules/NotificationCard/NotificationCard.tsx
|
|
560
|
+
function fe({ messageId: e, status: t, isRead: n, picture: r, title: i, description: a, action: o, time: s, onSelect: c }) {
|
|
561
|
+
let l = {
|
|
562
|
+
title: i,
|
|
563
|
+
description: a,
|
|
564
|
+
action: o,
|
|
565
|
+
messageId: e
|
|
566
|
+
};
|
|
567
|
+
return /* @__PURE__ */ p("button", {
|
|
568
|
+
className: x(J.card, !n && J.unread),
|
|
569
|
+
"data-status": t,
|
|
570
|
+
"data-is-read": n,
|
|
571
|
+
onClick: () => c?.(l),
|
|
572
|
+
children: [/* @__PURE__ */ p("div", {
|
|
573
|
+
className: J.left,
|
|
574
|
+
children: [/* @__PURE__ */ f(F, {
|
|
575
|
+
picture: r,
|
|
576
|
+
alt: `Картинка уведомления с названием ${i}`
|
|
577
|
+
}), /* @__PURE__ */ p("div", {
|
|
578
|
+
className: J.content,
|
|
579
|
+
children: [/* @__PURE__ */ f(D, {
|
|
580
|
+
className: J.title,
|
|
581
|
+
size: "lg",
|
|
582
|
+
weight: "medium",
|
|
583
|
+
children: i
|
|
584
|
+
}), /* @__PURE__ */ f(D, {
|
|
585
|
+
className: J.description,
|
|
586
|
+
variant: "secondary",
|
|
587
|
+
children: a
|
|
588
|
+
})]
|
|
589
|
+
})]
|
|
590
|
+
}), /* @__PURE__ */ p("div", {
|
|
591
|
+
className: J.right,
|
|
592
|
+
children: [/* @__PURE__ */ f(D, {
|
|
593
|
+
className: J.time,
|
|
594
|
+
as: "time",
|
|
595
|
+
variant: "secondary",
|
|
596
|
+
children: s
|
|
597
|
+
}), /* @__PURE__ */ f("div", {
|
|
598
|
+
className: J.chevron,
|
|
599
|
+
children: /* @__PURE__ */ f(y, {})
|
|
600
|
+
})]
|
|
601
|
+
})]
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
var Y = {
|
|
605
|
+
groups: "_groups_1kda6_1",
|
|
606
|
+
group: "_group_1kda6_1",
|
|
607
|
+
groupTitle: "_groupTitle_1kda6_13",
|
|
608
|
+
list: "_list_1kda6_21"
|
|
609
|
+
};
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/components/atoms/icons/CloseIcon.tsx
|
|
612
|
+
function pe({ width: e = 10, height: t = 10 }) {
|
|
613
|
+
return /* @__PURE__ */ f("svg", {
|
|
614
|
+
width: e,
|
|
615
|
+
height: t,
|
|
616
|
+
viewBox: "0 0 10 10",
|
|
617
|
+
fill: "none",
|
|
618
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
619
|
+
children: /* @__PURE__ */ f("path", {
|
|
620
|
+
d: "M0.5 0.5L5 5M5 5L0.5 9.5M5 5L9.5 9.5M5 5L9.5 0.5",
|
|
621
|
+
strokeLinecap: "round",
|
|
622
|
+
strokeLinejoin: "round",
|
|
623
|
+
stroke: "currentColor"
|
|
624
|
+
})
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
var X = {
|
|
628
|
+
state: "_state_a51iz_1",
|
|
629
|
+
error: "_error_a51iz_10",
|
|
630
|
+
content: "_content_a51iz_15",
|
|
631
|
+
title: "_title_a51iz_23",
|
|
632
|
+
subtitle: "_subtitle_a51iz_24",
|
|
633
|
+
button: "_button_a51iz_28"
|
|
634
|
+
};
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/components/molecules/NotificationsState/NotificationsState.tsx
|
|
637
|
+
function Z({ state: e, title: t, description: n, btn: r, className: i }) {
|
|
638
|
+
let { notificationState: a } = j(), o = a[e], s = r?.title ?? o.btn?.title, c = r?.onClick ?? o.btn?.onClick;
|
|
639
|
+
return /* @__PURE__ */ p("div", {
|
|
640
|
+
className: x(X.state, e === "error" && X.error, i),
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ f(F, { picture: { icon: o.icon } }),
|
|
643
|
+
/* @__PURE__ */ p("div", {
|
|
644
|
+
className: X.content,
|
|
645
|
+
children: [/* @__PURE__ */ f(D, {
|
|
646
|
+
className: X.title,
|
|
647
|
+
size: "lg",
|
|
648
|
+
weight: "medium",
|
|
649
|
+
children: W(t ?? o.title)
|
|
650
|
+
}), /* @__PURE__ */ f(D, {
|
|
651
|
+
className: X.subtitle,
|
|
652
|
+
variant: "secondary",
|
|
653
|
+
children: W(n ?? o.description)
|
|
654
|
+
})]
|
|
655
|
+
}),
|
|
656
|
+
s && c && /* @__PURE__ */ f(C, {
|
|
657
|
+
className: X.button,
|
|
658
|
+
onClick: c,
|
|
659
|
+
children: /* @__PURE__ */ f(D, {
|
|
660
|
+
size: "sm",
|
|
661
|
+
variant: "paper",
|
|
662
|
+
children: s
|
|
663
|
+
})
|
|
664
|
+
})
|
|
665
|
+
]
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
var Q = {
|
|
669
|
+
backdrop: "_backdrop_1m1f3_1",
|
|
670
|
+
filled: "_filled_1m1f3_13",
|
|
671
|
+
open: "_open_1m1f3_17",
|
|
672
|
+
sidebar: "_sidebar_1m1f3_22",
|
|
673
|
+
wrapper: "_wrapper_1m1f3_43",
|
|
674
|
+
loader: "_loader_1m1f3_49",
|
|
675
|
+
error: "_error_1m1f3_56",
|
|
676
|
+
header: "_header_1m1f3_61",
|
|
677
|
+
content: "_content_1m1f3_69",
|
|
678
|
+
actions: "_actions_1m1f3_81",
|
|
679
|
+
actionButton: "_actionButton_1m1f3_87",
|
|
680
|
+
closeButton: "_closeButton_1m1f3_92"
|
|
681
|
+
};
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/components/organisms/NotificationDetailsSidebar/NotificationDetailsSidebar.tsx
|
|
684
|
+
function me({ view: e, onClose: t, onRetry: n }) {
|
|
685
|
+
let { sidebarBackdrop: r } = j(), i = e.status !== "closed", a = l(e);
|
|
686
|
+
i && (a.current = e);
|
|
687
|
+
let o = a.current, s = o.status === "ready" ? o.details : o.status === "closed" ? null : o.preview, c = o.status === "ready" ? o.details.text || o.details.description : null, u = o.status === "ready" && o.details.action?.url && o.details.action.title ? o.details.action : null;
|
|
688
|
+
return /* @__PURE__ */ f("div", {
|
|
689
|
+
className: x(Q.backdrop, r && Q.filled, i && Q.open),
|
|
690
|
+
"aria-hidden": !i,
|
|
691
|
+
onMouseDown: (e) => {
|
|
692
|
+
e.target === e.currentTarget && t();
|
|
693
|
+
},
|
|
694
|
+
children: /* @__PURE__ */ f("aside", {
|
|
695
|
+
className: x(Q.sidebar, i && Q.open),
|
|
696
|
+
role: i ? "dialog" : void 0,
|
|
697
|
+
"aria-modal": i ? !0 : void 0,
|
|
698
|
+
"aria-labelledby": i ? "notification-details-title" : void 0,
|
|
699
|
+
"aria-hidden": !i,
|
|
700
|
+
children: /* @__PURE__ */ p("div", {
|
|
701
|
+
className: Q.wrapper,
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ p("div", {
|
|
704
|
+
className: Q.header,
|
|
705
|
+
children: [/* @__PURE__ */ f(D, {
|
|
706
|
+
as: "h2",
|
|
707
|
+
id: "notification-details-title",
|
|
708
|
+
size: "md",
|
|
709
|
+
weight: "semibold",
|
|
710
|
+
children: s?.title
|
|
711
|
+
}), /* @__PURE__ */ f(C, {
|
|
712
|
+
variant: "icon",
|
|
713
|
+
"aria-label": "Закрыть уведомление",
|
|
714
|
+
tabIndex: i ? void 0 : -1,
|
|
715
|
+
onClick: t,
|
|
716
|
+
children: /* @__PURE__ */ f(pe, {
|
|
717
|
+
width: 9,
|
|
718
|
+
height: 9
|
|
719
|
+
})
|
|
720
|
+
})]
|
|
721
|
+
}),
|
|
722
|
+
/* @__PURE__ */ p("div", {
|
|
723
|
+
className: Q.content,
|
|
724
|
+
children: [
|
|
725
|
+
o.status === "loading" && /* @__PURE__ */ f("div", {
|
|
726
|
+
className: Q.loader,
|
|
727
|
+
children: /* @__PURE__ */ f(L, {
|
|
728
|
+
variant: "primary",
|
|
729
|
+
size: "lg"
|
|
730
|
+
})
|
|
731
|
+
}),
|
|
732
|
+
o.status === "error" && /* @__PURE__ */ f(Z, {
|
|
733
|
+
className: Q.error,
|
|
734
|
+
state: "error",
|
|
735
|
+
btn: { onClick: n }
|
|
736
|
+
}),
|
|
737
|
+
c && /* @__PURE__ */ f(D, {
|
|
738
|
+
variant: "secondary",
|
|
739
|
+
children: c
|
|
740
|
+
})
|
|
741
|
+
]
|
|
742
|
+
}),
|
|
743
|
+
/* @__PURE__ */ p("div", {
|
|
744
|
+
className: Q.actions,
|
|
745
|
+
children: [u && /* @__PURE__ */ f(C, {
|
|
746
|
+
className: Q.actionButton,
|
|
747
|
+
as: "a",
|
|
748
|
+
href: u.url,
|
|
749
|
+
children: u.title
|
|
750
|
+
}), /* @__PURE__ */ f(C, {
|
|
751
|
+
className: Q.closeButton,
|
|
752
|
+
variant: "secondary",
|
|
753
|
+
onClick: t,
|
|
754
|
+
children: "Закрыть"
|
|
755
|
+
})]
|
|
756
|
+
})
|
|
757
|
+
]
|
|
758
|
+
})
|
|
759
|
+
})
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region src/hooks/useNotificationDetails.ts
|
|
764
|
+
function he(e, t) {
|
|
765
|
+
let [n, r] = u({ status: "closed" }), i = l(null), o = l(null), s = a((n) => {
|
|
766
|
+
if (i.current?.abort(), !e || !n.messageId) {
|
|
767
|
+
r({
|
|
768
|
+
status: "ready",
|
|
769
|
+
details: n
|
|
770
|
+
}), n.messageId && t?.(n);
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
let a = new AbortController();
|
|
774
|
+
i.current = a, r({
|
|
775
|
+
status: "loading",
|
|
776
|
+
preview: n
|
|
777
|
+
}), e(n.messageId, a.signal).then((e) => {
|
|
778
|
+
a.signal.aborted || (r({
|
|
779
|
+
status: "ready",
|
|
780
|
+
details: e
|
|
781
|
+
}), t?.(e));
|
|
782
|
+
}).catch(() => {
|
|
783
|
+
a.signal.aborted || r({
|
|
784
|
+
status: "error",
|
|
785
|
+
preview: n
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
}, [t, e]);
|
|
789
|
+
return {
|
|
790
|
+
view: n,
|
|
791
|
+
open: a((e) => {
|
|
792
|
+
o.current = e, s(e);
|
|
793
|
+
}, [s]),
|
|
794
|
+
retry: a(() => {
|
|
795
|
+
o.current && s(o.current);
|
|
796
|
+
}, [s]),
|
|
797
|
+
close: a(() => {
|
|
798
|
+
i.current?.abort(), r({ status: "closed" });
|
|
799
|
+
}, [])
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/components/molecules/NotificationList/NotificationList.tsx
|
|
804
|
+
var $ = {
|
|
805
|
+
today: "Сегодня",
|
|
806
|
+
yesterday: "Вчера",
|
|
807
|
+
earlier: "Ранее"
|
|
808
|
+
};
|
|
809
|
+
function ge(e) {
|
|
810
|
+
if (!e) return "earlier";
|
|
811
|
+
let t = new Date(e);
|
|
812
|
+
if (Number.isNaN(t.getTime())) return "earlier";
|
|
813
|
+
let n = /* @__PURE__ */ new Date(), r = (Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()) - Date.UTC(t.getFullYear(), t.getMonth(), t.getDate())) / 864e5;
|
|
814
|
+
return r === 0 ? "today" : r === 1 ? "yesterday" : "earlier";
|
|
815
|
+
}
|
|
816
|
+
function _e({ notifications: e, onAction: t }) {
|
|
817
|
+
let { onLoadDetails: n } = H(), { view: r, open: i, retry: o, close: s } = he(n, a((e) => {
|
|
818
|
+
if (e.messageId) return t?.({
|
|
819
|
+
type: "mark-read",
|
|
820
|
+
id: e.messageId
|
|
821
|
+
});
|
|
822
|
+
}, [t]));
|
|
823
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(ve, {
|
|
824
|
+
notifications: e,
|
|
825
|
+
onSelect: i
|
|
826
|
+
}), /* @__PURE__ */ f(me, {
|
|
827
|
+
view: r,
|
|
828
|
+
onClose: s,
|
|
829
|
+
onRetry: o
|
|
830
|
+
})] });
|
|
831
|
+
}
|
|
832
|
+
var ve = i(function({ notifications: e, onSelect: t }) {
|
|
833
|
+
let n = e.reduce((e, t) => (e[ge(t.createdAt)].push(t), e), {
|
|
834
|
+
today: [],
|
|
835
|
+
yesterday: [],
|
|
836
|
+
earlier: []
|
|
837
|
+
});
|
|
838
|
+
return /* @__PURE__ */ f("div", {
|
|
839
|
+
className: Y.groups,
|
|
840
|
+
children: Object.keys($).map((e) => {
|
|
841
|
+
let r = n[e];
|
|
842
|
+
return r.length === 0 ? null : /* @__PURE__ */ p("section", {
|
|
843
|
+
className: Y.group,
|
|
844
|
+
"aria-label": $[e],
|
|
845
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
846
|
+
className: Y.groupTitle,
|
|
847
|
+
children: $[e]
|
|
848
|
+
}), /* @__PURE__ */ f("ul", {
|
|
849
|
+
className: Y.list,
|
|
850
|
+
children: r.map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(ye, {
|
|
851
|
+
card: e,
|
|
852
|
+
onSelect: t
|
|
853
|
+
}) }, e.messageId ?? e.title))
|
|
854
|
+
})]
|
|
855
|
+
}, e);
|
|
856
|
+
})
|
|
857
|
+
});
|
|
858
|
+
}), ye = i(function({ card: e, onSelect: t }) {
|
|
859
|
+
return /* @__PURE__ */ f(fe, {
|
|
860
|
+
...e,
|
|
861
|
+
onSelect: t
|
|
862
|
+
});
|
|
863
|
+
}, be);
|
|
864
|
+
function be(e, t) {
|
|
865
|
+
let n = e.card.picture, r = t.card.picture, i = e.card.action, a = t.card.action;
|
|
866
|
+
return e.onSelect === t.onSelect && e.card.messageId === t.card.messageId && e.card.status === t.card.status && e.card.createdAt === t.card.createdAt && e.card.time === t.card.time && e.card.title === t.card.title && e.card.description === t.card.description && e.card.isRead === t.card.isRead && n.image === r.image && n.icon === r.icon && n.emoji === r.emoji && i?.url === a?.url && i?.title === a?.title;
|
|
867
|
+
}
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/components/organisms/NotificationsSection/NotificationsSection.tsx
|
|
870
|
+
function xe() {
|
|
871
|
+
let { state: e, onMarkRead: t } = H(), { items: n, error: r, isLoading: i, isLoadingMore: o, hasMore: d, markRead: m, loadMore: h, retry: g } = e, { tab: v, unreadCount: y } = K(), { autoLoadUnread: b } = j(), x = l(/* @__PURE__ */ new Set()), S = l(n);
|
|
872
|
+
S.current = n;
|
|
873
|
+
let [w, T] = u(null), E = c(() => n.map(_), [n]), D = c(() => v === "unread" ? E.filter((e) => !e.isRead) : E, [E, v]), O = v === "unread" && !i && !o && !r && D.length === 0 && y > 0 && d, k = !i && !r && n.length === 0, A = v === "unread" && !i && !r && n.length > 0 && D.length === 0;
|
|
874
|
+
s(() => {
|
|
875
|
+
O && b && h();
|
|
876
|
+
}, [
|
|
877
|
+
O,
|
|
878
|
+
b,
|
|
879
|
+
h
|
|
880
|
+
]);
|
|
881
|
+
let M = a(async (e) => {
|
|
882
|
+
if (x.current.has(e.id)) return !1;
|
|
883
|
+
x.current.add(e.id), T(null);
|
|
884
|
+
try {
|
|
885
|
+
let n = S.current.find((t) => t.chit.message_id === e.id);
|
|
886
|
+
return !n || n.is_read ? !1 : (await t(e.id), m(e.id));
|
|
887
|
+
} catch (e) {
|
|
888
|
+
return T(e instanceof Error ? e.message : "Не удалось выполнить действие"), !1;
|
|
889
|
+
} finally {
|
|
890
|
+
x.current.delete(e.id);
|
|
891
|
+
}
|
|
892
|
+
}, [m, t]);
|
|
893
|
+
return /* @__PURE__ */ p("section", {
|
|
894
|
+
className: U.section,
|
|
895
|
+
children: [
|
|
896
|
+
k && /* @__PURE__ */ f(Z, { state: "empty" }),
|
|
897
|
+
r && /* @__PURE__ */ f(Z, {
|
|
898
|
+
state: "error",
|
|
899
|
+
description: r.message,
|
|
900
|
+
btn: { onClick: g }
|
|
901
|
+
}),
|
|
902
|
+
w && /* @__PURE__ */ f("p", {
|
|
903
|
+
role: "alert",
|
|
904
|
+
children: w
|
|
905
|
+
}),
|
|
906
|
+
A && (y === 0 || !d ? /* @__PURE__ */ f(Z, { state: "allRead" }) : b ? null : /* @__PURE__ */ f(Z, {
|
|
907
|
+
state: "noUnreadLoaded",
|
|
908
|
+
btn: { onClick: h }
|
|
909
|
+
})),
|
|
910
|
+
/* @__PURE__ */ f(_e, {
|
|
911
|
+
notifications: D,
|
|
912
|
+
onAction: M
|
|
913
|
+
}),
|
|
914
|
+
d && (v !== "unread" || y !== 0) && /* @__PURE__ */ f("div", {
|
|
915
|
+
className: U.action,
|
|
916
|
+
children: /* @__PURE__ */ f(C, {
|
|
917
|
+
variant: "link",
|
|
918
|
+
onClick: h,
|
|
919
|
+
disabled: o,
|
|
920
|
+
children: o ? "Загрузка..." : "Показать больше"
|
|
921
|
+
})
|
|
922
|
+
})
|
|
923
|
+
]
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
var Se = { page: "_page_2uwvn_1" };
|
|
927
|
+
//#endregion
|
|
928
|
+
//#region src/app/providers/TabProvider.tsx
|
|
929
|
+
function Ce({ defaultTab: e = "all", allCount: t, unreadCount: n, isLoading: r = !1, children: i }) {
|
|
930
|
+
let [a, o] = u(e), s = c(() => ({
|
|
931
|
+
tab: a,
|
|
932
|
+
setTab: o,
|
|
933
|
+
allCount: t,
|
|
934
|
+
unreadCount: n,
|
|
935
|
+
isLoading: r
|
|
936
|
+
}), [
|
|
937
|
+
a,
|
|
938
|
+
t,
|
|
939
|
+
n,
|
|
940
|
+
r
|
|
941
|
+
]);
|
|
942
|
+
return /* @__PURE__ */ f(G.Provider, {
|
|
943
|
+
value: s,
|
|
944
|
+
children: i
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
//#endregion
|
|
948
|
+
//#region src/components/organisms/NotificationsRoot/NotificationsRoot.tsx
|
|
949
|
+
function we({ children: e }) {
|
|
950
|
+
let { state: t } = H();
|
|
951
|
+
return /* @__PURE__ */ f(Ce, {
|
|
952
|
+
allCount: t.counts.all,
|
|
953
|
+
unreadCount: t.counts.unread,
|
|
954
|
+
isLoading: t.isCountsLoading,
|
|
955
|
+
children: e
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
//#endregion
|
|
959
|
+
//#region src/components/pages/NotificationFeedPage.tsx
|
|
960
|
+
function Te({ header: e, slot: t, variant: n }) {
|
|
961
|
+
return /* @__PURE__ */ p("div", {
|
|
962
|
+
className: Se.page,
|
|
963
|
+
"data-slot": t,
|
|
964
|
+
"data-variant": n,
|
|
965
|
+
children: [e, /* @__PURE__ */ p(k, { children: [/* @__PURE__ */ f(ue, {}), /* @__PURE__ */ p(we, { children: [/* @__PURE__ */ f(de, {}), /* @__PURE__ */ f(xe, {})] })] })]
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
//#endregion
|
|
969
|
+
export { oe as n, Te as t };
|
|
970
|
+
|
|
971
|
+
//# sourceMappingURL=NotificationFeedPage-B7jnF1LL.js.map
|