@endora-commerce/admin-shell 0.103.1 → 0.105.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/components/AppShell.d.ts.map +1 -1
- package/dist/components/AppShell.js +59 -11
- package/dist/components/AppShell.js.map +1 -1
- package/dist/components/IdleLogout.d.ts.map +1 -1
- package/dist/components/IdleLogout.js +19 -40
- package/dist/components/IdleLogout.js.map +1 -1
- package/dist/components/RoleRequiredNotice.d.ts +16 -0
- package/dist/components/RoleRequiredNotice.d.ts.map +1 -0
- package/dist/components/RoleRequiredNotice.js +22 -0
- package/dist/components/RoleRequiredNotice.js.map +1 -0
- package/dist/components/VersionBadge.d.ts +28 -0
- package/dist/components/VersionBadge.d.ts.map +1 -0
- package/dist/components/VersionBadge.js +35 -0
- package/dist/components/VersionBadge.js.map +1 -0
- package/dist/components/notifications/NotificationBell.d.ts +4 -0
- package/dist/components/notifications/NotificationBell.d.ts.map +1 -1
- package/dist/components/notifications/NotificationBell.js +11 -1
- package/dist/components/notifications/NotificationBell.js.map +1 -1
- package/dist/components/notifications/index.d.ts +1 -0
- package/dist/components/notifications/index.d.ts.map +1 -1
- package/dist/components/notifications/index.js +1 -0
- package/dist/components/notifications/index.js.map +1 -1
- package/dist/components/notifications/notification-text.d.ts +42 -0
- package/dist/components/notifications/notification-text.d.ts.map +1 -0
- package/dist/components/notifications/notification-text.js +65 -0
- package/dist/components/notifications/notification-text.js.map +1 -0
- package/dist/components/notifications/useAdminNotifications.d.ts +7 -0
- package/dist/components/notifications/useAdminNotifications.d.ts.map +1 -1
- package/dist/components/notifications/useAdminNotifications.js.map +1 -1
- package/dist/lib/platform-info/api.d.ts +10 -0
- package/dist/lib/platform-info/api.d.ts.map +1 -0
- package/dist/lib/platform-info/api.js +12 -0
- package/dist/lib/platform-info/api.js.map +1 -0
- package/dist/lib/platform-info/usePlatformVersion.d.ts +24 -0
- package/dist/lib/platform-info/usePlatformVersion.d.ts.map +1 -0
- package/dist/lib/platform-info/usePlatformVersion.js +49 -0
- package/dist/lib/platform-info/usePlatformVersion.js.map +1 -0
- package/dist/modules/home/HomePage.d.ts.map +1 -1
- package/dist/modules/home/HomePage.js +142 -97
- package/dist/modules/home/HomePage.js.map +1 -1
- package/dist/modules/profile/ProfilePage.d.ts +8 -0
- package/dist/modules/profile/ProfilePage.d.ts.map +1 -1
- package/dist/modules/profile/ProfilePage.js +38 -5
- package/dist/modules/profile/ProfilePage.js.map +1 -1
- package/package.json +5 -5
|
@@ -2,7 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
4
|
import { Bell, CheckCheck } from 'lucide-react';
|
|
5
|
+
import { useTranslationContext } from '../../i18n/TranslationProvider.js';
|
|
5
6
|
import { useTranslation } from '../../i18n/useTranslation.js';
|
|
7
|
+
import { notificationText } from './notification-text.js';
|
|
6
8
|
import { useAdminNotifications } from './useAdminNotifications.js';
|
|
7
9
|
/**
|
|
8
10
|
* Admin notification bell — toolbar button in the top-nav.
|
|
@@ -13,9 +15,14 @@ import { useAdminNotifications } from './useAdminNotifications.js';
|
|
|
13
15
|
* marks it read and navigates to `linkPath` if present. "Mark all read"
|
|
14
16
|
* acts on the visible-to-this-admin set (broadcasts insert a per-admin
|
|
15
17
|
* read cursor; per-admin entries flip `read_at` directly).
|
|
18
|
+
*
|
|
19
|
+
* An entry's title and body are drawn in the reader's language when the entry
|
|
20
|
+
* carries a message for them, and as recorded when it does not — see
|
|
21
|
+
* `notificationText`.
|
|
16
22
|
*/
|
|
17
23
|
export function NotificationBell() {
|
|
18
24
|
const t = useTranslation('core');
|
|
25
|
+
const bundles = useTranslationContext();
|
|
19
26
|
const navigate = useNavigate();
|
|
20
27
|
const { items, unreadCount, refresh, markRead, markAllRead } = useAdminNotifications();
|
|
21
28
|
const [open, setOpen] = useState(false);
|
|
@@ -60,7 +67,10 @@ export function NotificationBell() {
|
|
|
60
67
|
if (!open)
|
|
61
68
|
void refresh();
|
|
62
69
|
setOpen((v) => !v);
|
|
63
|
-
}, children: [_jsx(Bell, { size: 16 }), badge ? _jsx("span", { style: BADGE_STYLE, children: badge }) : null] }), open ? (_jsxs("div", { ref: dropdownRef, style: DROPDOWN_STYLE, role: "menu", children: [_jsxs("div", { style: DROPDOWN_HEADER_STYLE, children: [_jsx("strong", { children: t('appShell.notifications.title') }), unreadCount > 0 ? (_jsxs("button", { type: "button", style: MARK_ALL_BTN, onClick: () => void markAllRead(), title: t('appShell.notifications.markAllRead'), children: [_jsx(CheckCheck, { size: 14 }), t('appShell.notifications.markAllRead')] })) : null] }), _jsx("div", { style: { maxHeight: 360, overflowY: 'auto' }, children: items.length === 0 ? (_jsx("div", { style: EMPTY_STYLE, children: t('appShell.notifications.empty') })) : (items.map((it) =>
|
|
70
|
+
}, children: [_jsx(Bell, { size: 16 }), badge ? _jsx("span", { style: BADGE_STYLE, children: badge }) : null] }), open ? (_jsxs("div", { ref: dropdownRef, style: DROPDOWN_STYLE, role: "menu", children: [_jsxs("div", { style: DROPDOWN_HEADER_STYLE, children: [_jsx("strong", { children: t('appShell.notifications.title') }), unreadCount > 0 ? (_jsxs("button", { type: "button", style: MARK_ALL_BTN, onClick: () => void markAllRead(), title: t('appShell.notifications.markAllRead'), children: [_jsx(CheckCheck, { size: 14 }), t('appShell.notifications.markAllRead')] })) : null] }), _jsx("div", { style: { maxHeight: 360, overflowY: 'auto' }, children: items.length === 0 ? (_jsx("div", { style: EMPTY_STYLE, children: t('appShell.notifications.empty') })) : (items.map((it) => {
|
|
71
|
+
const body = notificationText(bundles, it.bodyMessage, it.body);
|
|
72
|
+
return (_jsxs("button", { type: "button", role: "menuitem", style: { ...ROW_STYLE, ...(it.isRead ? ROW_READ_STYLE : ROW_UNREAD_STYLE) }, onClick: () => handleClick(it), children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', gap: 8 }, children: [_jsx("span", { style: { fontWeight: it.isRead ? 400 : 600, flex: 1 }, children: notificationText(bundles, it.titleMessage, it.title) }), _jsx("time", { style: { fontSize: 11, color: 'var(--text-muted, #888)' }, dateTime: it.createdAt, children: formatRelative(it.createdAt) })] }), body ? (_jsx("div", { style: { fontSize: 12, color: 'var(--text-muted, #888)', marginTop: 2 }, children: body })) : null] }, it.id));
|
|
73
|
+
})) })] })) : null] }));
|
|
64
74
|
}
|
|
65
75
|
function formatUnreadBadge(n) {
|
|
66
76
|
if (n <= 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationBell.js","sourceRoot":"","sources":["../../../src/components/notifications/NotificationBell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAyC,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAA8B,MAAM,4BAA4B,CAAC;AAE/F
|
|
1
|
+
{"version":3,"file":"NotificationBell.js","sourceRoot":"","sources":["../../../src/components/notifications/NotificationBell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAyC,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAA8B,MAAM,4B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AE,QAAQ;IACpB,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,yBAAyB;IAChC,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,SAAS,GAAkB;IAC/B,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,wCAAwC;IACtD,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,gBAAgB,GAAkB;IACtC,UAAU,EAAE,mBAAmB;IAC/B,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF,MAAM,cAAc,GAAkB;IACpC,UAAU,EAAE,uBAAuB;IACnC,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF,MAAM,WAAW,GAAkB;IACjC,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,QAAQ;IACnB,KAAK,EAAE,yBAAyB;IAChC,QAAQ,EAAE,EAAE;CACb,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { NotificationBell } from './NotificationBell.js';
|
|
2
2
|
export { useAdminNotifications, type AdminNotificationItem, type AdminNotificationFeed, type UseAdminNotificationsResult, } from './useAdminNotifications.js';
|
|
3
|
+
export { notificationText, type NotificationMessage, type NotificationTextBundles, } from './notification-text.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,qBAAqB,GAItB,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,qBAAqB,GAItB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Bundle, SupportedAdminLanguage } from '../../i18n/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A translatable sentence as the feed delivers it — `AdminNotificationMessage`
|
|
4
|
+
* in `@endora-commerce/contracts`, restated structurally because what arrives
|
|
5
|
+
* here is JSON and is read as such: every member is checked before it is used.
|
|
6
|
+
*/
|
|
7
|
+
export interface NotificationMessage {
|
|
8
|
+
scope: string;
|
|
9
|
+
key: string;
|
|
10
|
+
params?: Record<string, string | number>;
|
|
11
|
+
}
|
|
12
|
+
/** The slice of the translation context a notification is resolved against. */
|
|
13
|
+
export interface NotificationTextBundles {
|
|
14
|
+
language: SupportedAdminLanguage;
|
|
15
|
+
bundle: Bundle;
|
|
16
|
+
fallbackBundle: Bundle | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The text of a bell entry in the reader's language, or the finished sentence
|
|
20
|
+
* it was recorded with.
|
|
21
|
+
*
|
|
22
|
+
* An entry is one row read by several administrators, so it cannot arrive
|
|
23
|
+
* translated (`specs/conventions/module-i18n.md`, the reader-is-plural case):
|
|
24
|
+
* it carries the address of a template and the sentence its writer composed in
|
|
25
|
+
* English. `fallback` is that sentence and it is answered whenever the message
|
|
26
|
+
* cannot be drawn whole:
|
|
27
|
+
*
|
|
28
|
+
* - there is no message — an older entry, an older backend, a writer that
|
|
29
|
+
* gives none;
|
|
30
|
+
* - no loaded bundle holds the key, in the reader's language or in English.
|
|
31
|
+
* The module that wrote the entry may be switched off or uninstalled by the
|
|
32
|
+
* time it is read, and an entry outlives both;
|
|
33
|
+
* - the template names a param the entry does not carry — a sentence with a
|
|
34
|
+
* hole in it is worse than a whole one in English.
|
|
35
|
+
*
|
|
36
|
+
* So the lookup goes through `resolve` and not through `t()`: `t()` answers
|
|
37
|
+
* `scope.key` for a miss, and a raw key in the bell is exactly what this
|
|
38
|
+
* exists to prevent. The result is a string for a React text node; a param is
|
|
39
|
+
* never markup.
|
|
40
|
+
*/
|
|
41
|
+
export declare function notificationText<T extends string | null>(bundles: NotificationTextBundles, message: unknown, fallback: T): string | T;
|
|
42
|
+
//# sourceMappingURL=notification-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-text.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/notification-text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C;AAED,+EAA+E;AAC/E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EACtD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GACV,MAAM,GAAG,CAAC,CAmBZ"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { interpolate } from '../../i18n/interpolate.js';
|
|
2
|
+
import { resolve } from '../../i18n/resolver.js';
|
|
3
|
+
const PLACEHOLDER_RE = /\{(\w+)\}/g;
|
|
4
|
+
/**
|
|
5
|
+
* The text of a bell entry in the reader's language, or the finished sentence
|
|
6
|
+
* it was recorded with.
|
|
7
|
+
*
|
|
8
|
+
* An entry is one row read by several administrators, so it cannot arrive
|
|
9
|
+
* translated (`specs/conventions/module-i18n.md`, the reader-is-plural case):
|
|
10
|
+
* it carries the address of a template and the sentence its writer composed in
|
|
11
|
+
* English. `fallback` is that sentence and it is answered whenever the message
|
|
12
|
+
* cannot be drawn whole:
|
|
13
|
+
*
|
|
14
|
+
* - there is no message — an older entry, an older backend, a writer that
|
|
15
|
+
* gives none;
|
|
16
|
+
* - no loaded bundle holds the key, in the reader's language or in English.
|
|
17
|
+
* The module that wrote the entry may be switched off or uninstalled by the
|
|
18
|
+
* time it is read, and an entry outlives both;
|
|
19
|
+
* - the template names a param the entry does not carry — a sentence with a
|
|
20
|
+
* hole in it is worse than a whole one in English.
|
|
21
|
+
*
|
|
22
|
+
* So the lookup goes through `resolve` and not through `t()`: `t()` answers
|
|
23
|
+
* `scope.key` for a miss, and a raw key in the bell is exactly what this
|
|
24
|
+
* exists to prevent. The result is a string for a React text node; a param is
|
|
25
|
+
* never markup.
|
|
26
|
+
*/
|
|
27
|
+
export function notificationText(bundles, message, fallback) {
|
|
28
|
+
// No finished sentence means nothing to draw: a message never travels alone.
|
|
29
|
+
if (fallback === null)
|
|
30
|
+
return fallback;
|
|
31
|
+
const parsed = parseMessage(message);
|
|
32
|
+
if (!parsed)
|
|
33
|
+
return fallback;
|
|
34
|
+
const template = resolve({
|
|
35
|
+
scope: parsed.scope,
|
|
36
|
+
key: parsed.key,
|
|
37
|
+
language: bundles.language,
|
|
38
|
+
bundle: bundles.bundle,
|
|
39
|
+
...(bundles.fallbackBundle !== undefined ? { fallbackBundle: bundles.fallbackBundle } : {}),
|
|
40
|
+
});
|
|
41
|
+
if (template.outcome === 'placeholder')
|
|
42
|
+
return fallback;
|
|
43
|
+
for (const [, name] of template.value.matchAll(PLACEHOLDER_RE)) {
|
|
44
|
+
if (name === undefined || !Object.hasOwn(parsed.params, name))
|
|
45
|
+
return fallback;
|
|
46
|
+
}
|
|
47
|
+
return interpolate(template.value, parsed.params);
|
|
48
|
+
}
|
|
49
|
+
function parseMessage(message) {
|
|
50
|
+
if (typeof message !== 'object' || message === null)
|
|
51
|
+
return null;
|
|
52
|
+
const { scope, key, params } = message;
|
|
53
|
+
if (typeof scope !== 'string' || scope === '' || typeof key !== 'string' || key === '')
|
|
54
|
+
return null;
|
|
55
|
+
const plain = {};
|
|
56
|
+
if (typeof params === 'object' && params !== null && !Array.isArray(params)) {
|
|
57
|
+
for (const [name, value] of Object.entries(params)) {
|
|
58
|
+
if (typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value))) {
|
|
59
|
+
plain[name] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { scope, key, params: plain };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=notification-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-text.js","sourceRoot":"","sources":["../../../src/components/notifications/notification-text.ts"],"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,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAA8D,CAAC;IAC9F,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,EAAE;QACpF,OAAO,IAAI,CAAC;IACd,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5E,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBACvF,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NotificationMessage } from './notification-text.js';
|
|
1
2
|
export interface AdminNotificationItem {
|
|
2
3
|
id: string;
|
|
3
4
|
audience: 'all_admins' | 'admin_user';
|
|
@@ -7,6 +8,12 @@ export interface AdminNotificationItem {
|
|
|
7
8
|
title: string;
|
|
8
9
|
body: string | null;
|
|
9
10
|
linkPath: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* `title` and `body`, translatable — resolved by `notificationText` when the
|
|
13
|
+
* entry is drawn. Optional: a backend that predates the fields sends neither.
|
|
14
|
+
*/
|
|
15
|
+
titleMessage?: NotificationMessage | null;
|
|
16
|
+
bodyMessage?: NotificationMessage | null;
|
|
10
17
|
createdAt: string;
|
|
11
18
|
isRead: boolean;
|
|
12
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAdminNotifications.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/useAdminNotifications.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAdminNotifications.d.ts","sourceRoot":"","sources":["../../../src/components/notifications/useAdminNotifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,YAAY,GAAG,YAAY,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,2BAA2B,CA2E9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAdminNotifications.js","sourceRoot":"","sources":["../../../src/components/notifications/useAdminNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"useAdminNotifications.js","sourceRoot":"","sources":["../../../src/components/notifications/useAdminNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAsCpD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAIrC;IACC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC;IACzC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACnC,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,KAAK,CAAC;IAEhD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B,EAAE,CAAC,CAAC;IAChE,MAAM,CAAC,WAAW,EAAE,cAAc,CAA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,GAAG,UAAU,CAAC,GAAG,EAAE;gBACjC,KAAK,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC,EAAE,MAAM,CAAC,CAAC;QACb,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;QACP,OAAO,GAAS,EAAE;YAChB,IAAI,QAAQ,CAAC,OAAO;gBAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,QAAQ,CAAC,OAAO;gBAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAEtB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PlatformInfo } from '@endora-commerce/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Which Endora Commerce release the API is — the version of the
|
|
4
|
+
* `@endora-commerce/platform` package the serving process loaded.
|
|
5
|
+
*
|
|
6
|
+
* Any signed-in admin may read it; there is no permission code. A bare fetch,
|
|
7
|
+
* like the other clients in this application: the hook owns the state.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPlatformInfo(): Promise<PlatformInfo>;
|
|
10
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/lib/platform-info/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;;;;GAMG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAE7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { apiClient } from '../api-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Which Endora Commerce release the API is — the version of the
|
|
4
|
+
* `@endora-commerce/platform` package the serving process loaded.
|
|
5
|
+
*
|
|
6
|
+
* Any signed-in admin may read it; there is no permission code. A bare fetch,
|
|
7
|
+
* like the other clients in this application: the hook owns the state.
|
|
8
|
+
*/
|
|
9
|
+
export async function getPlatformInfo() {
|
|
10
|
+
return apiClient.get('/api/v1/admin/platform-info');
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/lib/platform-info/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,OAAO,SAAS,CAAC,GAAG,CAAe,6BAA6B,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release the header badge shows, or `null` for "say nothing".
|
|
3
|
+
*
|
|
4
|
+
* **The number is the API's, not this bundle's.** "Which Endora Commerce is
|
|
5
|
+
* this?" is a question about the instance — its schema, its modules, what its
|
|
6
|
+
* endpoints answer — and the admin is a client of that. It is also the only
|
|
7
|
+
* number that is right in all three ways an admin runs: built from the
|
|
8
|
+
* monorepo's sources, installed from npm into a scaffolded instance, and built
|
|
9
|
+
* elsewhere against published packages. A constant baked into this package
|
|
10
|
+
* would be right in each of them only for as long as the admin and the API
|
|
11
|
+
* were deployed together.
|
|
12
|
+
*
|
|
13
|
+
* **`null` covers three states on purpose**, and the badge renders nothing for
|
|
14
|
+
* any of them: still loading, the read failed (an API older than the route
|
|
15
|
+
* answers 404), and the platform could not tell. They are not distinguished
|
|
16
|
+
* because there is nothing an operator can do about any of them from the
|
|
17
|
+
* header, and every placeholder that could stand in — a dash, a skeleton, a
|
|
18
|
+
* `0.0.0` — reads as a version.
|
|
19
|
+
*
|
|
20
|
+
* Read once per mount. The shell mounts once per session and the answer cannot
|
|
21
|
+
* change without the API restarting, so there is no refresh and no cache.
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePlatformVersion(): string | null;
|
|
24
|
+
//# sourceMappingURL=usePlatformVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlatformVersion.d.ts","sourceRoot":"","sources":["../../../src/lib/platform-info/usePlatformVersion.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAuBlD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { getPlatformInfo } from './api.js';
|
|
3
|
+
/**
|
|
4
|
+
* The release the header badge shows, or `null` for "say nothing".
|
|
5
|
+
*
|
|
6
|
+
* **The number is the API's, not this bundle's.** "Which Endora Commerce is
|
|
7
|
+
* this?" is a question about the instance — its schema, its modules, what its
|
|
8
|
+
* endpoints answer — and the admin is a client of that. It is also the only
|
|
9
|
+
* number that is right in all three ways an admin runs: built from the
|
|
10
|
+
* monorepo's sources, installed from npm into a scaffolded instance, and built
|
|
11
|
+
* elsewhere against published packages. A constant baked into this package
|
|
12
|
+
* would be right in each of them only for as long as the admin and the API
|
|
13
|
+
* were deployed together.
|
|
14
|
+
*
|
|
15
|
+
* **`null` covers three states on purpose**, and the badge renders nothing for
|
|
16
|
+
* any of them: still loading, the read failed (an API older than the route
|
|
17
|
+
* answers 404), and the platform could not tell. They are not distinguished
|
|
18
|
+
* because there is nothing an operator can do about any of them from the
|
|
19
|
+
* header, and every placeholder that could stand in — a dash, a skeleton, a
|
|
20
|
+
* `0.0.0` — reads as a version.
|
|
21
|
+
*
|
|
22
|
+
* Read once per mount. The shell mounts once per session and the answer cannot
|
|
23
|
+
* change without the API restarting, so there is no refresh and no cache.
|
|
24
|
+
*/
|
|
25
|
+
export function usePlatformVersion() {
|
|
26
|
+
const [version, setVersion] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
let cancelled = false;
|
|
29
|
+
getPlatformInfo()
|
|
30
|
+
.then((info) => {
|
|
31
|
+
if (cancelled)
|
|
32
|
+
return;
|
|
33
|
+
// Liberal in what is accepted: anything that is not a non-blank string
|
|
34
|
+
// is "unknown", whatever shape it arrived in.
|
|
35
|
+
const candidate = info?.version;
|
|
36
|
+
const trimmed = typeof candidate === 'string' ? candidate.trim() : '';
|
|
37
|
+
setVersion(trimmed.length > 0 ? trimmed : null);
|
|
38
|
+
})
|
|
39
|
+
.catch(() => {
|
|
40
|
+
if (!cancelled)
|
|
41
|
+
setVersion(null);
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
cancelled = true;
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
return version;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=usePlatformVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlatformVersion.js","sourceRoot":"","sources":["../../../src/lib/platform-info/usePlatformVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,eAAe,EAAE;aACd,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,IAAI,SAAS;gBAAE,OAAO;YACtB,uEAAuE;YACvE,8CAA8C;YAC9C,MAAM,SAAS,GAAa,IAAiD,EAAE,OAAO,CAAC;YACvF,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,SAAS;gBAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACL,OAAO,GAAS,EAAE;YAChB,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomePage.d.ts","sourceRoot":"","sources":["../../../src/modules/home/HomePage.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HomePage.d.ts","sourceRoot":"","sources":["../../../src/modules/home/HomePage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkMzE,wBAAgB,QAAQ,IAAI,SAAS,CAsEpC"}
|