@kodiak-finance/orderly-ui-notification 2.8.18-rc.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/dist/index.d.mts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +865 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +859 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +48 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var orderlyI18n = require('@kodiak-finance/orderly-i18n');
|
|
5
|
+
var orderlyUi = require('@kodiak-finance/orderly-ui');
|
|
6
|
+
var orderlyTypes = require('@kodiak-finance/orderly-types');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var utc = require('@date-fns/utc');
|
|
9
|
+
var dateFns = require('date-fns');
|
|
10
|
+
var immer = require('immer');
|
|
11
|
+
var orderlyHooks = require('@kodiak-finance/orderly-hooks');
|
|
12
|
+
var orderlyReactApp = require('@kodiak-finance/orderly-react-app');
|
|
13
|
+
|
|
14
|
+
// src/components/announcementCenter/announcementCenter.ui.tsx
|
|
15
|
+
var BattleIcon = (props) => {
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: [
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18
|
+
"linearGradient",
|
|
19
|
+
{
|
|
20
|
+
id: "paint0_linear_555_7374",
|
|
21
|
+
x1: "17.0157",
|
|
22
|
+
y1: "9.26513",
|
|
23
|
+
x2: "0.969849",
|
|
24
|
+
y2: "9.26513",
|
|
25
|
+
gradientUnits: "userSpaceOnUse",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "rgb(var(--oui-gradient-brand-start))" })
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
) }),
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
+
"path",
|
|
34
|
+
{
|
|
35
|
+
fill: "url(#paint0_linear_555_7374)",
|
|
36
|
+
fillOpacity: 1,
|
|
37
|
+
d: "m1.5 1.5.75 3 4.843 4.56-1.808 1.919-.63-.633-1.06 1.06.665.665-1.88 1.996-.35-.346-1.06 1.06 2.25 2.25 1.06-1.06-.348-.349 1.998-1.878.665.662 1.06-1.06-.63-.63L9 10.852l1.969 1.854-.639.639 1.06 1.06.672-.67 1.998 1.877-.358.358 1.064 1.06 2.25-2.25-1.06-1.06-.34.34-1.881-1.998.656-.657-1.06-1.06-.625.624-1.799-1.91.003-.003L9 7.03 4.5 2.25zm15 0-3 .75-3.636 3.861 2.022 2.025L15.75 4.5z"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
var CampaignIcon = (props) => {
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
44
|
+
"path",
|
|
45
|
+
{
|
|
46
|
+
fill: "currentcolor",
|
|
47
|
+
fillOpacity: 1,
|
|
48
|
+
d: "m1.5 1.5.75 3 4.843 4.56-1.808 1.919-.63-.633-1.06 1.06.665.665-1.88 1.996-.35-.346-1.06 1.06 2.25 2.25 1.06-1.06-.348-.349 1.998-1.878.665.662 1.06-1.06-.63-.63L9 10.852l1.969 1.854-.639.639 1.06 1.06.672-.67 1.998 1.877-.358.358 1.064 1.06 2.25-2.25-1.06-1.06-.34.34-1.881-1.998.656-.657-1.06-1.06-.625.624-1.799-1.91.003-.003L9 7.03 4.5 2.25zm15 0-3 .75-3.636 3.861 2.022 2.025L15.75 4.5z"
|
|
49
|
+
}
|
|
50
|
+
) });
|
|
51
|
+
};
|
|
52
|
+
var ArrowRightShortIcon = (props) => {
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: [
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55
|
+
"linearGradient",
|
|
56
|
+
{
|
|
57
|
+
id: "paint0_linear_555_7374",
|
|
58
|
+
x1: "17.0157",
|
|
59
|
+
y1: "9.26513",
|
|
60
|
+
x2: "0.969849",
|
|
61
|
+
y2: "9.26513",
|
|
62
|
+
gradientUnits: "userSpaceOnUse",
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "rgb(var(--oui-gradient-brand-start))" })
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
) }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
"path",
|
|
71
|
+
{
|
|
72
|
+
fill: "url(#paint0_linear_555_7374)",
|
|
73
|
+
fillOpacity: 1,
|
|
74
|
+
d: "M4.509 8.995a.75.75 0 0 1 .75-.75h5.666L8.7 5.998l1.054-1.054 3.535 3.512c.147.146.22.343.22.54a.76.76 0 0 1-.22.537l-3.535 3.512L8.7 11.992l2.225-2.248H5.258a.75.75 0 0 1-.749-.75"
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
var FundIcon = (props) => {
|
|
80
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
"path",
|
|
82
|
+
{
|
|
83
|
+
fill: "currentcolor",
|
|
84
|
+
fillOpacity: 0.8,
|
|
85
|
+
d: "M15.694 7.087c-.788-.393-1.857-.618-2.925-.618-1.125 0-2.138.225-2.925.618-.056 0-.113.057-.113.057V3.769c0-.9-.731-1.575-1.462-1.913-.788-.394-1.857-.619-2.925-.619-1.069 0-2.25.225-3.038.62C1.575 2.193.844 2.868.844 3.768v10.519c0 .9.731 1.575 1.462 1.912.788.394 1.856.619 2.925.619s2.138-.225 2.925-.619c.281-.169.563-.337.788-.562.225.225.506.393.787.562.788.394 1.857.619 2.925.619 1.125 0 2.138-.225 2.925-.619.732-.394 1.463-1.012 1.463-1.912V9c.112-.9-.619-1.519-1.35-1.913m-7.369 7.144c0 .113-.112.45-.731.732-.563.28-1.407.506-2.363.506s-1.8-.169-2.362-.506c-.619-.282-.731-.62-.731-.732V13.5c.056 0 .112 0 .168.056.788.394 1.856.619 2.925.619s2.138-.225 2.925-.619c.056 0 .113-.056.113-.056v.731zm0-2.587c0 .112-.112.45-.731.731-.563.281-1.407.506-2.363.506s-1.8-.168-2.362-.506c-.619-.281-.731-.619-.731-.731v-.788c.056 0 .112.056.112.056.788.394 1.856.62 2.925.62s2.138-.226 2.925-.62c.056 0 .113-.056.113-.056v.788zm0-2.644c0 .112-.112.45-.731.731-.563.281-1.407.507-2.363.507s-1.8-.17-2.362-.507C2.25 9.45 2.138 9.112 2.138 9v-.788c.056 0 .112.057.112.057.788.393 1.856.618 2.925.618S7.313 8.662 8.1 8.27c.056 0 .113-.057.113-.057V9zm0-2.644c0 .113-.112.45-.731.731-.563.282-1.407.507-2.363.507s-1.8-.169-2.362-.507c-.619-.28-.731-.618-.731-.73v-.732c.056 0 .112 0 .168.056.788.394 1.856.619 2.925.619s2.138-.225 2.925-.619c.056 0 .113-.056.113-.056v.731zM7.594 4.5c-.563.281-1.407.506-2.363.506S3.488 4.781 2.925 4.5c-.619-.338-.731-.619-.731-.731 0-.113.112-.45.731-.732.563-.28 1.406-.506 2.363-.506.956 0 1.8.169 2.362.506.619.282.731.62.731.732-.056.112-.168.393-.787.731m8.212 9.731c0 .113-.112.45-.731.732-.562.28-1.406.506-2.362.506s-1.8-.169-2.363-.506c-.619-.282-.731-.62-.731-.732V13.5c.056 0 .112.056.112.056.788.394 1.857.619 2.925.619 1.125 0 2.138-.225 2.925-.619.056 0 .113-.056.113-.056v.731zm0-2.587c0 .112-.112.45-.731.731-.562.281-1.406.506-2.362.506s-1.8-.168-2.363-.506c-.619-.281-.731-.619-.731-.731v-.788c.056 0 .112.056.112.056.788.394 1.857.62 2.925.62 1.125 0 2.138-.226 2.925-.62.056 0 .113-.056.113-.056v.788zm-.675-1.913c-.562.281-1.406.507-2.362.507s-1.8-.17-2.363-.507c-.619-.281-.731-.619-.731-.731 0-.113.112-.45.731-.731.563-.282 1.406-.507 2.363-.507.956 0 1.8.17 2.362.507.619.281.732.618.732.731-.057.112-.17.45-.732.731"
|
|
86
|
+
}
|
|
87
|
+
) });
|
|
88
|
+
};
|
|
89
|
+
var AnnouncementIcon = (props) => {
|
|
90
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
"path",
|
|
92
|
+
{
|
|
93
|
+
fill: "currentcolor",
|
|
94
|
+
fillOpacity: 0.8,
|
|
95
|
+
d: "M11.53 2.255a.745.745 0 0 0-.82.165c-.525.524-1.188.959-1.947 1.284-.77.33-2.353.757-3.508.75-2.248-.015-3.756 1.259-3.756 3.726 0 2.163 1.228 3.42 2.994 3.703l.006 1.565a2.25 2.25 0 0 0 2.25 2.247c1.142 0 2.083-.883 2.228-1.988.007-.053.022-.26.022-1.01.674.315 1.232.812 1.711 1.29.473.472 1.29.13 1.29-.538 0-.678-.004-1.906-.004-3.13.884-.327 1.503-1.165 1.503-2.115s-.585-1.81-1.496-2.129c0-1.225-.004-2.439-.004-3.117a.76.76 0 0 0-.469-.703m1.805 1.335a.73.73 0 0 0-.445.351.75.75 0 0 0 .258 1.03 3.74 3.74 0 0 1 1.851 3.233 3.74 3.74 0 0 1-1.851 3.231.76.76 0 0 0-.282 1.03.754.754 0 0 0 1.032.258 5.24 5.24 0 0 0 2.601-4.52 5.24 5.24 0 0 0-2.601-4.519.74.74 0 0 0-.563-.094m-2.832.884c0 .694-.004 1.417-.004 2.231v2.997c0 .815.003 1.508.003 2.202-1.52-.896-3.085-1.294-4.501-1.421 0-1.144-.004-3.406-.004-4.584.147-.007.318-.026.565-.06a11.2 11.2 0 0 0 2.812-.773c.43-.184.75-.35 1.129-.592m-6.005 1.55-.001 4.34c-.976-.27-1.498-.959-1.498-2.184 0-1.21.47-1.928 1.499-2.155M6 11.998c.238.008 1.098.161 1.493.261l.007 1.19a.75.75 0 0 1-1.5 0z"
|
|
96
|
+
}
|
|
97
|
+
) });
|
|
98
|
+
};
|
|
99
|
+
var SecurityIcon = (props) => {
|
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Icon, { size: 18, viewBox: "0 0 18 18", ...props, children: [
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
102
|
+
"path",
|
|
103
|
+
{
|
|
104
|
+
d: "M6.563 7.678V6.603c0-1.153 1.09-2.088 2.437-2.088s2.438.935 2.438 2.088v1.075c.448 0 .812.311.812.696v3.479c0 .384-.364.696-.812.696H6.563c-.449 0-.813-.312-.813-.696v-3.48c0-.384.364-.695.813-.695m1.187-.006 1.431.006h1.07V6.564c0-.64-.504-1.104-1.25-1.104-.748 0-1.25.465-1.25 1.104zm1.956 2.14c0-.335-.317-.605-.706-.605-.39 0-.706.27-.706.604v.77c0 .335.316.605.706.605s.706-.27.706-.604z",
|
|
105
|
+
fill: "currentcolor",
|
|
106
|
+
fillOpacity: ".8"
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
+
"path",
|
|
111
|
+
{
|
|
112
|
+
d: "M2 3.607c.003 5.606.146 11.651 6.879 13.378.078.02.164.02.242 0C15.854 15.258 15.997 9.213 16 3.607c0-.217-.14-.41-.345-.477L9.31 1.05a1 1 0 0 0-.62 0L2.345 3.13A.5.5 0 0 0 2 3.607m2.326 7.63c-.707-1.954-.81-4.33-.824-6.902L9 2.532l5.498 1.803c-.014 2.573-.117 4.948-.824 6.901-.697 1.93-1.987 3.463-4.674 4.222-2.687-.759-3.977-2.293-4.674-4.222",
|
|
113
|
+
fill: "currentcolor",
|
|
114
|
+
fillOpacity: ".8"
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] });
|
|
118
|
+
};
|
|
119
|
+
var AnnouncementItem = (props) => {
|
|
120
|
+
const { t } = orderlyI18n.useTranslation();
|
|
121
|
+
const Icon2 = react.useMemo(() => {
|
|
122
|
+
switch (props.type) {
|
|
123
|
+
case orderlyTypes.AnnouncementType.Campaign:
|
|
124
|
+
return CampaignIcon;
|
|
125
|
+
case orderlyTypes.AnnouncementType.Listing:
|
|
126
|
+
return FundIcon;
|
|
127
|
+
case orderlyTypes.AnnouncementType.Maintenance:
|
|
128
|
+
return SecurityIcon;
|
|
129
|
+
case orderlyTypes.AnnouncementType.Delisting:
|
|
130
|
+
default:
|
|
131
|
+
return AnnouncementIcon;
|
|
132
|
+
}
|
|
133
|
+
}, [props.type]);
|
|
134
|
+
const title = react.useMemo(() => {
|
|
135
|
+
switch (props.type) {
|
|
136
|
+
case orderlyTypes.AnnouncementType.Campaign:
|
|
137
|
+
return t("notification.campaign");
|
|
138
|
+
case orderlyTypes.AnnouncementType.Delisting:
|
|
139
|
+
return t("notification.delisting");
|
|
140
|
+
case orderlyTypes.AnnouncementType.Listing:
|
|
141
|
+
return t("notification.listing");
|
|
142
|
+
case orderlyTypes.AnnouncementType.Maintenance:
|
|
143
|
+
return t("notification.maintenance");
|
|
144
|
+
default:
|
|
145
|
+
return t("notification.general");
|
|
146
|
+
}
|
|
147
|
+
}, [props.type, t]);
|
|
148
|
+
const action = react.useMemo(() => {
|
|
149
|
+
if (props.type === orderlyTypes.AnnouncementType.Campaign && typeof props.url === "string" && props.url !== "" && typeof props.onItemClick === "function") {
|
|
150
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
151
|
+
orderlyUi.Flex,
|
|
152
|
+
{
|
|
153
|
+
gap: 1,
|
|
154
|
+
itemAlign: "center",
|
|
155
|
+
className: "oui-cursor-pointer",
|
|
156
|
+
onClick: (event) => {
|
|
157
|
+
event.stopPropagation();
|
|
158
|
+
props.onItemClick(props.url);
|
|
159
|
+
},
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
+
orderlyUi.Text,
|
|
163
|
+
{
|
|
164
|
+
size: "xs",
|
|
165
|
+
color: "buy",
|
|
166
|
+
className: "oui-bg-clip-text oui-text-transparent oui-gradient-brand",
|
|
167
|
+
children: t("notification.joinNow")
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowRightShortIcon, { size: 18 })
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}, [props.type, props.url, t]);
|
|
177
|
+
const updateTime = react.useMemo(() => {
|
|
178
|
+
if (props.type === orderlyTypes.AnnouncementType.Maintenance) {
|
|
179
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "2xs", intensity: 36, children: t("notification.recentlyUpdated") });
|
|
180
|
+
}
|
|
181
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
+
orderlyUi.Text.formatted,
|
|
183
|
+
{
|
|
184
|
+
size: "2xs",
|
|
185
|
+
intensity: 36,
|
|
186
|
+
rule: "date",
|
|
187
|
+
formatString: "yyyy-MM-dd HH:mm:ss",
|
|
188
|
+
children: props.updatedTime
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}, [props.updatedTime, props.type, t]);
|
|
192
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
193
|
+
orderlyUi.Flex,
|
|
194
|
+
{
|
|
195
|
+
gap: 2,
|
|
196
|
+
itemAlign: "start",
|
|
197
|
+
className: orderlyUi.cn(
|
|
198
|
+
"oui-px-2 oui-py-[6px] oui-text-base-contrast-80",
|
|
199
|
+
!props.showDivider && "oui-rounded-md hover:oui-bg-base-6",
|
|
200
|
+
!props.showDivider && props.expanded && "oui-bg-base-6",
|
|
201
|
+
props.className
|
|
202
|
+
),
|
|
203
|
+
onClick: () => {
|
|
204
|
+
props.onExpandToggle?.();
|
|
205
|
+
},
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon2, { color: "white", className: "oui-mt-3 oui-shrink-0" }),
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", itemAlign: "start", grow: true, children: [
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "xs", intensity: 80, weight: "bold", children: title }),
|
|
210
|
+
updateTime,
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
212
|
+
"div",
|
|
213
|
+
{
|
|
214
|
+
className: "oui-grid oui-transition-all oui-duration-300 oui-ease-in-out",
|
|
215
|
+
style: {
|
|
216
|
+
gridTemplateRows: props.expanded ? "1fr" : "0fr"
|
|
217
|
+
},
|
|
218
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-2 oui-overflow-hidden", children: [
|
|
219
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "2xs", intensity: 80, as: "div", className: "oui-pt-2", children: props.message }),
|
|
220
|
+
action
|
|
221
|
+
] })
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
] }),
|
|
225
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-pt-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
226
|
+
orderlyUi.ChevronDownIcon,
|
|
227
|
+
{
|
|
228
|
+
color: "white",
|
|
229
|
+
size: 18,
|
|
230
|
+
className: `oui-transition-transform oui-duration-300 oui-ease-in-out ${props.expanded ? "oui-rotate-180" : "oui-rotate-0"}`
|
|
231
|
+
}
|
|
232
|
+
) })
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
var AnnouncementContent = (props) => {
|
|
238
|
+
const { dataSource, current, onExpandToggle, onItemClick } = props;
|
|
239
|
+
const { t } = orderlyI18n.useTranslation();
|
|
240
|
+
if (!Array.isArray(dataSource) || dataSource.length === 0) {
|
|
241
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-h-[160px] oui-items-center oui-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
242
|
+
orderlyUi.ExtensionSlot,
|
|
243
|
+
{
|
|
244
|
+
position: orderlyUi.ExtensionPositionEnum.EmptyDataIdentifier,
|
|
245
|
+
title: t("notification.empty")
|
|
246
|
+
}
|
|
247
|
+
) });
|
|
248
|
+
}
|
|
249
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
className: orderlyUi.cn(
|
|
253
|
+
"oui-flex oui-flex-col oui-space-y-1",
|
|
254
|
+
props.showDivider && "[&>*:not(:first-child)]:oui-border-t [&>*:not(:first-child)]:oui-border-line-12 [&>*:not(:first-child)]:oui-pt-1"
|
|
255
|
+
),
|
|
256
|
+
children: dataSource.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
+
AnnouncementItem,
|
|
258
|
+
{
|
|
259
|
+
url: item.url,
|
|
260
|
+
onItemClick,
|
|
261
|
+
message: item.message,
|
|
262
|
+
updatedTime: item.updated_time ?? 0,
|
|
263
|
+
expanded: current === item.announcement_id,
|
|
264
|
+
type: item.type,
|
|
265
|
+
showDivider: props.showDivider,
|
|
266
|
+
onExpandToggle: () => {
|
|
267
|
+
if (current === item.announcement_id) {
|
|
268
|
+
onExpandToggle(null);
|
|
269
|
+
} else {
|
|
270
|
+
onExpandToggle(item.announcement_id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
item.announcement_id
|
|
275
|
+
))
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
var AnnouncementCenterUI = (props) => {
|
|
280
|
+
const { t } = orderlyI18n.useTranslation();
|
|
281
|
+
const [expanded, setExpanded] = react.useState(null);
|
|
282
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
283
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-5 oui-pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 80, weight: "bold", children: t("notification.title") }) }),
|
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ScrollArea, { className: "oui-flex oui-h-[300px] oui-flex-col oui-space-y-1 oui-p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
285
|
+
AnnouncementContent,
|
|
286
|
+
{
|
|
287
|
+
dataSource: props.dataSource,
|
|
288
|
+
current: expanded,
|
|
289
|
+
onExpandToggle: setExpanded,
|
|
290
|
+
onItemClick: props.onItemClick
|
|
291
|
+
}
|
|
292
|
+
) })
|
|
293
|
+
] });
|
|
294
|
+
};
|
|
295
|
+
var CampaignContentCard = ({ message, coverImage, url, onItemClick }) => {
|
|
296
|
+
const { t } = orderlyI18n.useTranslation();
|
|
297
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-5", children: [
|
|
298
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", weight: "bold", children: message }),
|
|
299
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
300
|
+
"div",
|
|
301
|
+
{
|
|
302
|
+
className: "oui-rounded-xl oui-bg-base-9 oui-bg-cover oui-bg-center oui-bg-no-repeat",
|
|
303
|
+
style: {
|
|
304
|
+
backgroundImage: `url(${coverImage})`,
|
|
305
|
+
height: "100px"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
typeof url === "string" && url !== "" && typeof onItemClick === "function" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
310
|
+
"button",
|
|
311
|
+
{
|
|
312
|
+
className: "oui-flex oui-items-center oui-gap-1",
|
|
313
|
+
onClick: () => onItemClick(url),
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
316
|
+
orderlyUi.Text,
|
|
317
|
+
{
|
|
318
|
+
size: "xs",
|
|
319
|
+
color: "buy",
|
|
320
|
+
className: "oui-bg-clip-text oui-text-transparent oui-gradient-brand",
|
|
321
|
+
children: t("notification.joinNow")
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowRightShortIcon, { size: 18, color: "success" })
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
] });
|
|
329
|
+
};
|
|
330
|
+
var MaintenanceContentCard = ({ message, startTime, endTime }) => {
|
|
331
|
+
const { t } = orderlyI18n.useTranslation();
|
|
332
|
+
const formattedMessage = react.useMemo(() => {
|
|
333
|
+
const hours = dateFns.differenceInHours(endTime, startTime);
|
|
334
|
+
const minutes = dateFns.differenceInMinutes(endTime, startTime) - hours * 60;
|
|
335
|
+
const startUtc = new utc.UTCDate(startTime);
|
|
336
|
+
const endUtc = new utc.UTCDate(endTime);
|
|
337
|
+
const startTimeFormatted = dateFns.format(startUtc, "HH:mm");
|
|
338
|
+
const endTimeFormatted = dateFns.format(endUtc, "hh:mm a");
|
|
339
|
+
if (hours > 0) {
|
|
340
|
+
return t("notification.maintenanceDuration.hours", {
|
|
341
|
+
hours: minutes > 0 ? (hours + minutes / 60).toFixed(1) : hours,
|
|
342
|
+
startTimeFormatted,
|
|
343
|
+
endTimeFormatted
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return t("notification.maintenanceDuration.minutes", {
|
|
347
|
+
minutes,
|
|
348
|
+
startTimeFormatted,
|
|
349
|
+
endTimeFormatted
|
|
350
|
+
});
|
|
351
|
+
}, [startTime, endTime, t]);
|
|
352
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
353
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "xs", intensity: 54, children: t("notification.recentlyUpdated") }),
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { itemAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "xs", weight: "bold", children: formattedMessage }) }),
|
|
355
|
+
message && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "2xs", intensity: 80, as: "div", className: "oui-mt-2", children: message })
|
|
356
|
+
] });
|
|
357
|
+
};
|
|
358
|
+
var DelistingContentCard = ({ message, updateTime }) => {
|
|
359
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
360
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
361
|
+
orderlyUi.Text.formatted,
|
|
362
|
+
{
|
|
363
|
+
rule: "date",
|
|
364
|
+
intensity: 54,
|
|
365
|
+
formatString: "yyyy-MM-dd HH:mm:ss",
|
|
366
|
+
size: "xs",
|
|
367
|
+
children: updateTime
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", weight: "bold", children: message })
|
|
371
|
+
] });
|
|
372
|
+
};
|
|
373
|
+
var ListingContentCard = ({ message, updateTime }) => {
|
|
374
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
375
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
376
|
+
orderlyUi.Text.formatted,
|
|
377
|
+
{
|
|
378
|
+
rule: "date",
|
|
379
|
+
intensity: 54,
|
|
380
|
+
formatString: "yyyy-MM-dd HH:mm:ss",
|
|
381
|
+
size: "xs",
|
|
382
|
+
children: updateTime
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", weight: "bold", children: message })
|
|
386
|
+
] });
|
|
387
|
+
};
|
|
388
|
+
var NotificationHeader = (props) => {
|
|
389
|
+
const { t } = orderlyI18n.useTranslation();
|
|
390
|
+
const { expanded } = props;
|
|
391
|
+
const { type } = props.dataSource[props.current];
|
|
392
|
+
const title = react.useMemo(() => {
|
|
393
|
+
switch (type) {
|
|
394
|
+
case orderlyTypes.AnnouncementType.Campaign:
|
|
395
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
396
|
+
orderlyUi.Text,
|
|
397
|
+
{
|
|
398
|
+
size: "sm",
|
|
399
|
+
className: "oui-text-transparent oui-bg-clip-text oui-gradient-brand",
|
|
400
|
+
children: t("notification.campaign")
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
case orderlyTypes.AnnouncementType.Delisting:
|
|
404
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", children: t("notification.delistingTitle") });
|
|
405
|
+
case orderlyTypes.AnnouncementType.Listing:
|
|
406
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", color: "buy", children: t("notification.listing") });
|
|
407
|
+
case orderlyTypes.AnnouncementType.Maintenance:
|
|
408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", color: "warning", children: t("notification.maintenanceTitle") });
|
|
409
|
+
default:
|
|
410
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", color: "inherit", children: t("notification.generalTitle") });
|
|
411
|
+
}
|
|
412
|
+
}, [type, t]);
|
|
413
|
+
const icon = react.useMemo(() => {
|
|
414
|
+
switch (type) {
|
|
415
|
+
case orderlyTypes.AnnouncementType.Campaign:
|
|
416
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BattleIcon, { color: "white" });
|
|
417
|
+
case orderlyTypes.AnnouncementType.Listing:
|
|
418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FundIcon, { color: "success" });
|
|
419
|
+
case orderlyTypes.AnnouncementType.Maintenance:
|
|
420
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SecurityIcon, { color: "warning" });
|
|
421
|
+
case orderlyTypes.AnnouncementType.Delisting:
|
|
422
|
+
default:
|
|
423
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AnnouncementIcon, { color: "white" });
|
|
424
|
+
}
|
|
425
|
+
}, [type]);
|
|
426
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { itemAlign: "center", justify: "between", className: "oui-px-4 oui-py-3", children: [
|
|
427
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orderly-notification-header oui-flex oui-items-center oui-gap-2", children: [
|
|
428
|
+
icon,
|
|
429
|
+
title
|
|
430
|
+
] }),
|
|
431
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
onClick: props.onExpandToggle,
|
|
435
|
+
className: "oui-transition-transform oui-duration-300",
|
|
436
|
+
style: {
|
|
437
|
+
transform: !expanded ? "rotate(180deg)" : "rotate(0deg)"
|
|
438
|
+
},
|
|
439
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ChevronDownIcon, { size: 18, color: "white" })
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] });
|
|
443
|
+
};
|
|
444
|
+
var NotificationFooter = (props) => {
|
|
445
|
+
const { total, current, onCloseAll, onPrev, onNext } = props;
|
|
446
|
+
const { t } = orderlyI18n.useTranslation();
|
|
447
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
448
|
+
orderlyUi.Flex,
|
|
449
|
+
{
|
|
450
|
+
className: "orderly-notification-footer oui-px-4 oui-py-2",
|
|
451
|
+
itemAlign: "center",
|
|
452
|
+
justify: "between",
|
|
453
|
+
children: [
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gap: 2, children: [
|
|
455
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
456
|
+
"button",
|
|
457
|
+
{
|
|
458
|
+
disabled: current - 1 < 0,
|
|
459
|
+
onClick: onPrev,
|
|
460
|
+
className: "oui-flex oui-size-[18px] oui-items-center oui-justify-center oui-rounded-full oui-bg-base-6 hover:oui-bg-base-5 disabled:oui-opacity-50",
|
|
461
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ChevronLeftIcon, { size: 14, color: "white" })
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Text, { intensity: 54, size: "sm", children: [
|
|
465
|
+
current + 1,
|
|
466
|
+
"/",
|
|
467
|
+
total
|
|
468
|
+
] }),
|
|
469
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
470
|
+
"button",
|
|
471
|
+
{
|
|
472
|
+
disabled: current + 1 >= total,
|
|
473
|
+
onClick: onNext,
|
|
474
|
+
className: "oui-flex oui-size-[18px] oui-items-center oui-justify-center oui-rounded-full oui-bg-base-6 hover:oui-bg-base-5 disabled:oui-opacity-50",
|
|
475
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ChevronRightIcon, { size: 14, color: "white" })
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onCloseAll, children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "xs", color: "primary", children: t("notification.closeAll", { total }) }) })
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
};
|
|
484
|
+
var NotificationContent = (props) => {
|
|
485
|
+
const elements = react.useMemo(() => {
|
|
486
|
+
return props.dataSource.map((message) => {
|
|
487
|
+
const { type } = message;
|
|
488
|
+
switch (type) {
|
|
489
|
+
case orderlyTypes.AnnouncementType.Campaign:
|
|
490
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
491
|
+
CampaignContentCard,
|
|
492
|
+
{
|
|
493
|
+
message: message.message,
|
|
494
|
+
coverImage: message.coverImage ?? "",
|
|
495
|
+
updateTime: message.updated_time ?? 0,
|
|
496
|
+
url: message.url ?? "",
|
|
497
|
+
onItemClick: props.onItemClick
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
case orderlyTypes.AnnouncementType.Maintenance:
|
|
501
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
502
|
+
MaintenanceContentCard,
|
|
503
|
+
{
|
|
504
|
+
message: message.message,
|
|
505
|
+
startTime: message.startTime ?? 0,
|
|
506
|
+
endTime: message.endTime ?? 0
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
case orderlyTypes.AnnouncementType.Delisting:
|
|
510
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
511
|
+
DelistingContentCard,
|
|
512
|
+
{
|
|
513
|
+
message: message.message,
|
|
514
|
+
updateTime: message.updated_time ?? 0
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
default:
|
|
518
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
+
ListingContentCard,
|
|
520
|
+
{
|
|
521
|
+
message: message.message,
|
|
522
|
+
updateTime: message.updated_time ?? 0
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}, [props.dataSource]);
|
|
528
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: elements[props.current] });
|
|
529
|
+
};
|
|
530
|
+
var NotificationUI = (props) => {
|
|
531
|
+
const [expanded, setExpanded] = react.useState(true);
|
|
532
|
+
const [current, setCurrent] = react.useState(0);
|
|
533
|
+
const len = react.useMemo(() => props.dataSource?.length ?? 0, [props.dataSource]);
|
|
534
|
+
if (len === 0) {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "orderly-notification oui-w-full ", children: [
|
|
538
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
539
|
+
NotificationHeader,
|
|
540
|
+
{
|
|
541
|
+
dataSource: props.dataSource ?? [],
|
|
542
|
+
current,
|
|
543
|
+
expanded,
|
|
544
|
+
onExpandToggle: () => {
|
|
545
|
+
setExpanded(!expanded);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, { className: "oui-mx-4" }),
|
|
550
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
551
|
+
"div",
|
|
552
|
+
{
|
|
553
|
+
className: "oui-grid oui-transition-all oui-duration-300 oui-ease-in-out",
|
|
554
|
+
style: {
|
|
555
|
+
gridTemplateRows: expanded ? "1fr" : "0fr"
|
|
556
|
+
},
|
|
557
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-min-h-0 oui-overflow-hidden ", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-4 oui-py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
558
|
+
NotificationContent,
|
|
559
|
+
{
|
|
560
|
+
dataSource: props.dataSource ?? [],
|
|
561
|
+
current,
|
|
562
|
+
onItemClick: props.onItemClick
|
|
563
|
+
}
|
|
564
|
+
) }) })
|
|
565
|
+
}
|
|
566
|
+
),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
568
|
+
NotificationFooter,
|
|
569
|
+
{
|
|
570
|
+
total: len,
|
|
571
|
+
current,
|
|
572
|
+
onCloseAll: props.onClose ?? (() => {
|
|
573
|
+
}),
|
|
574
|
+
onPrev: () => {
|
|
575
|
+
if (current - 1 < 0) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
setCurrent(current - 1);
|
|
579
|
+
},
|
|
580
|
+
onNext: () => {
|
|
581
|
+
if (current + 1 >= len) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
setCurrent(current + 1);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
)
|
|
588
|
+
] });
|
|
589
|
+
};
|
|
590
|
+
var maintentanceId = "-1";
|
|
591
|
+
var ORDERLY_ANNOUNCEMENT_KEY = "orderly_announcement";
|
|
592
|
+
var getTimeString = (timestamp) => {
|
|
593
|
+
const date = dateFns.format(new utc.UTCDateMini(timestamp), "MMM dd");
|
|
594
|
+
const time = dateFns.format(new utc.UTCDateMini(timestamp), "h:mm aa");
|
|
595
|
+
return `${time} (UTC) on ${date}`;
|
|
596
|
+
};
|
|
597
|
+
var sortDataByUpdatedTime = (ori) => {
|
|
598
|
+
return immer.produce(ori, (draft) => {
|
|
599
|
+
if (Array.isArray(draft.rows)) {
|
|
600
|
+
draft.rows.sort((a, b) => {
|
|
601
|
+
if (a.updated_time && b.updated_time) {
|
|
602
|
+
return b.updated_time - a.updated_time;
|
|
603
|
+
}
|
|
604
|
+
return 0;
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
var useAnnouncementData = () => {
|
|
610
|
+
const ws = orderlyHooks.useWS();
|
|
611
|
+
const [announcementStore, setStore] = orderlyHooks.useLocalStorage(
|
|
612
|
+
ORDERLY_ANNOUNCEMENT_KEY,
|
|
613
|
+
{}
|
|
614
|
+
);
|
|
615
|
+
const [tips, setTips] = react.useState({});
|
|
616
|
+
const [maintenanceDialogInfo, setMaintenanceDialogInfo] = react.useState();
|
|
617
|
+
const { startTime, endTime, status, brokerName } = orderlyHooks.useMaintenanceStatus();
|
|
618
|
+
const { t } = orderlyI18n.useTranslation();
|
|
619
|
+
const { data: announcements } = orderlyHooks.useQuery(
|
|
620
|
+
`/v2/public/announcement`,
|
|
621
|
+
{
|
|
622
|
+
revalidateOnFocus: false,
|
|
623
|
+
refreshInterval: 60 * 60 * 1e3,
|
|
624
|
+
// refresh every 1 hour
|
|
625
|
+
formatter: (data) => data
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
const getMaintentTipsContent = (brokerName2, startDate, endDate) => t("maintenance.tips.description", { brokerName: brokerName2, startDate, endDate });
|
|
629
|
+
const getMaintentDialogContent = (brokerName2, endDate) => t("maintenance.dialog.description", { brokerName: brokerName2, endDate });
|
|
630
|
+
react.useEffect(() => {
|
|
631
|
+
const unsubscribe = ws.subscribe("announcement", {
|
|
632
|
+
onMessage(message) {
|
|
633
|
+
if (message) {
|
|
634
|
+
setTips((prev) => {
|
|
635
|
+
return immer.produce(prev, (draft) => {
|
|
636
|
+
if (!Array.isArray(draft.rows)) {
|
|
637
|
+
draft.rows = [];
|
|
638
|
+
}
|
|
639
|
+
const idx = draft.rows.findIndex(
|
|
640
|
+
(tip) => tip.announcement_id === message.announcement_id
|
|
641
|
+
);
|
|
642
|
+
if (idx !== -1) {
|
|
643
|
+
draft.rows.splice(idx, 1);
|
|
644
|
+
}
|
|
645
|
+
draft.rows.push({
|
|
646
|
+
announcement_id: message.announcement_id,
|
|
647
|
+
message: message.message,
|
|
648
|
+
url: message.url,
|
|
649
|
+
i18n: message.i18n,
|
|
650
|
+
type: message.type,
|
|
651
|
+
updated_time: message.updated_time
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
setStore((prev) => ({ ...prev, show: true }));
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
onError(err) {
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
return () => {
|
|
662
|
+
unsubscribe?.();
|
|
663
|
+
};
|
|
664
|
+
}, [ws]);
|
|
665
|
+
react.useEffect(() => {
|
|
666
|
+
if (!announcements?.rows) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const apiTime = announcements.last_updated_time ?? 0;
|
|
670
|
+
const cachedTime = announcementStore.lastUpdateTime ?? 0;
|
|
671
|
+
if (cachedTime < apiTime) {
|
|
672
|
+
setTips((prev) => ({ ...prev, rows: announcements?.rows }));
|
|
673
|
+
setStore({ show: true, lastUpdateTime: apiTime });
|
|
674
|
+
} else {
|
|
675
|
+
setTips((prev) => {
|
|
676
|
+
return immer.produce(prev, (draft) => {
|
|
677
|
+
if (announcements?.rows?.length) {
|
|
678
|
+
const existingIds = new Set(
|
|
679
|
+
prev.rows?.map((tip) => tip.announcement_id)
|
|
680
|
+
);
|
|
681
|
+
const maintenanceTip = prev.rows?.find(
|
|
682
|
+
(tip) => tip.announcement_id === maintentanceId
|
|
683
|
+
);
|
|
684
|
+
draft.rows = [];
|
|
685
|
+
announcements.rows.forEach((item) => {
|
|
686
|
+
if (!existingIds.has(item.announcement_id)) {
|
|
687
|
+
draft.rows?.push(item);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
if (maintenanceTip) {
|
|
691
|
+
draft.rows.unshift(maintenanceTip);
|
|
692
|
+
}
|
|
693
|
+
} else {
|
|
694
|
+
const idx = draft.rows?.findIndex(
|
|
695
|
+
(tip) => tip.announcement_id === maintentanceId
|
|
696
|
+
);
|
|
697
|
+
if (idx !== void 0 && idx !== -1) {
|
|
698
|
+
draft.rows?.splice(idx, 1);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
}, [announcements]);
|
|
705
|
+
react.useEffect(() => {
|
|
706
|
+
const startDate = startTime ? getTimeString(startTime) : "-";
|
|
707
|
+
const endDate = endTime ? getTimeString(endTime) : "-";
|
|
708
|
+
if (status === orderlyHooks.MaintenanceStatus.Maintenance) {
|
|
709
|
+
setMaintenanceDialogInfo(getMaintentDialogContent(brokerName, endDate));
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
setMaintenanceDialogInfo(void 0);
|
|
713
|
+
if (startTime && endTime) {
|
|
714
|
+
setTips(
|
|
715
|
+
(prev) => immer.produce(prev, (draft) => {
|
|
716
|
+
if (!Array.isArray(draft.rows)) {
|
|
717
|
+
draft.rows = [];
|
|
718
|
+
}
|
|
719
|
+
draft.rows = [
|
|
720
|
+
{
|
|
721
|
+
announcement_id: maintentanceId,
|
|
722
|
+
type: orderlyTypes.AnnouncementType.Maintenance,
|
|
723
|
+
/** @ts-ignore */
|
|
724
|
+
startTime,
|
|
725
|
+
/** @ts-ignore */
|
|
726
|
+
endTime,
|
|
727
|
+
message: getMaintentTipsContent(brokerName, startDate, endDate)
|
|
728
|
+
},
|
|
729
|
+
...draft.rows.filter(
|
|
730
|
+
(tip) => tip.type !== orderlyTypes.AnnouncementType.Maintenance
|
|
731
|
+
)
|
|
732
|
+
];
|
|
733
|
+
})
|
|
734
|
+
);
|
|
735
|
+
} else {
|
|
736
|
+
setTips((prev) => {
|
|
737
|
+
return immer.produce(prev, (draft) => {
|
|
738
|
+
const index = draft.rows?.findIndex(
|
|
739
|
+
(tip) => tip.announcement_id === maintentanceId
|
|
740
|
+
);
|
|
741
|
+
if (index !== void 0 && index !== -1) {
|
|
742
|
+
draft.rows?.splice(index, 1);
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}, [startTime, endTime, status, brokerName, t]);
|
|
748
|
+
const { customAnnouncements } = orderlyReactApp.useAppContext();
|
|
749
|
+
const mergedTips = react.useMemo(() => {
|
|
750
|
+
const tipsCopy = { ...tips };
|
|
751
|
+
if (customAnnouncements && customAnnouncements.length > 0) {
|
|
752
|
+
tipsCopy.rows = [...customAnnouncements, ...tips.rows || []];
|
|
753
|
+
}
|
|
754
|
+
return sortDataByUpdatedTime(tipsCopy);
|
|
755
|
+
}, [tips, customAnnouncements]);
|
|
756
|
+
return {
|
|
757
|
+
tips: mergedTips,
|
|
758
|
+
maintenanceDialogInfo
|
|
759
|
+
};
|
|
760
|
+
};
|
|
761
|
+
var useAnnouncement = (options) => {
|
|
762
|
+
const { showAnnouncement, setShowAnnouncement } = orderlyReactApp.useAppContext();
|
|
763
|
+
const { dataAdapter } = orderlyHooks.useOrderlyContext();
|
|
764
|
+
const { tips: mergedTips, maintenanceDialogInfo } = useAnnouncementData();
|
|
765
|
+
const memoizedTips = react.useMemo(() => {
|
|
766
|
+
if (typeof dataAdapter?.announcementList === "function") {
|
|
767
|
+
return dataAdapter.announcementList(
|
|
768
|
+
mergedTips?.rows ?? orderlyTypes.EMPTY_LIST
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
return mergedTips?.rows ?? orderlyTypes.EMPTY_LIST;
|
|
772
|
+
}, [dataAdapter?.announcementList, mergedTips?.rows]);
|
|
773
|
+
const [announcementStore, setStore] = orderlyHooks.useLocalStorage(
|
|
774
|
+
ORDERLY_ANNOUNCEMENT_KEY,
|
|
775
|
+
{}
|
|
776
|
+
);
|
|
777
|
+
const closeTips = () => {
|
|
778
|
+
setStore((prev) => ({ ...prev, show: false }));
|
|
779
|
+
};
|
|
780
|
+
react.useEffect(() => {
|
|
781
|
+
const len = memoizedTips.length;
|
|
782
|
+
setShowAnnouncement(
|
|
783
|
+
Boolean(len) && announcementStore.show && !options?.hideTips
|
|
784
|
+
);
|
|
785
|
+
}, [
|
|
786
|
+
memoizedTips,
|
|
787
|
+
announcementStore.show,
|
|
788
|
+
options?.hideTips,
|
|
789
|
+
setShowAnnouncement
|
|
790
|
+
]);
|
|
791
|
+
return {
|
|
792
|
+
maintenanceDialogInfo,
|
|
793
|
+
tips: memoizedTips,
|
|
794
|
+
closeTips,
|
|
795
|
+
showAnnouncement
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
// src/pages/announcementCenter.script.tsx
|
|
800
|
+
var useAnnouncementCenterScript = () => {
|
|
801
|
+
const { tips } = useAnnouncement();
|
|
802
|
+
const [current, setCurrent] = react.useState(null);
|
|
803
|
+
return {
|
|
804
|
+
dataSource: tips,
|
|
805
|
+
current,
|
|
806
|
+
setCurrent
|
|
807
|
+
};
|
|
808
|
+
};
|
|
809
|
+
var AnnouncementCenterUI2 = (props) => {
|
|
810
|
+
const { dataSource, current, setCurrent, onItemClick } = props;
|
|
811
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-m-1 oui-rounded-xl oui-bg-base-9 oui-p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
812
|
+
AnnouncementContent,
|
|
813
|
+
{
|
|
814
|
+
dataSource,
|
|
815
|
+
current,
|
|
816
|
+
onExpandToggle: setCurrent,
|
|
817
|
+
onItemClick,
|
|
818
|
+
showDivider: true
|
|
819
|
+
}
|
|
820
|
+
) });
|
|
821
|
+
};
|
|
822
|
+
var AnnouncementCenterWidget = (props) => {
|
|
823
|
+
const { dataSource, current, setCurrent } = useAnnouncementCenterScript();
|
|
824
|
+
const onItemClick = react.useCallback(
|
|
825
|
+
(url) => {
|
|
826
|
+
if (!url)
|
|
827
|
+
return;
|
|
828
|
+
props.onRouteChange(url);
|
|
829
|
+
},
|
|
830
|
+
[props.onRouteChange]
|
|
831
|
+
);
|
|
832
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
833
|
+
AnnouncementCenterUI2,
|
|
834
|
+
{
|
|
835
|
+
dataSource,
|
|
836
|
+
current,
|
|
837
|
+
setCurrent,
|
|
838
|
+
onItemClick
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
};
|
|
842
|
+
var AnnouncementCenterPage = (props) => {
|
|
843
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
844
|
+
AnnouncementCenterWidget,
|
|
845
|
+
{
|
|
846
|
+
onRouteChange: (url) => {
|
|
847
|
+
if (!url)
|
|
848
|
+
return;
|
|
849
|
+
props.routerAdapter?.onRouteChange({
|
|
850
|
+
href: url,
|
|
851
|
+
name: url,
|
|
852
|
+
target: "_blank"
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
exports.AnnouncementCenterPage = AnnouncementCenterPage;
|
|
860
|
+
exports.AnnouncementCenterUI = AnnouncementCenterUI;
|
|
861
|
+
exports.AnnouncementItem = AnnouncementItem;
|
|
862
|
+
exports.NotificationUI = NotificationUI;
|
|
863
|
+
exports.useAnnouncement = useAnnouncement;
|
|
864
|
+
//# sourceMappingURL=out.js.map
|
|
865
|
+
//# sourceMappingURL=index.js.map
|