@btst/stack 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.cjs +13 -0
- package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.mjs +11 -0
- package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.cjs +17 -0
- package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +18 -7
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +18 -7
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.cjs +48 -52
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.mjs +49 -53
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +34 -37
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +35 -38
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.cjs +4 -21
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.mjs +4 -21
- package/dist/packages/stack/src/plugins/comments/api/getters.cjs +284 -0
- package/dist/packages/stack/src/plugins/comments/api/getters.mjs +280 -0
- package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +118 -0
- package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +112 -0
- package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +335 -0
- package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +333 -0
- package/dist/packages/stack/src/plugins/comments/api/query-key-defs.cjs +60 -0
- package/dist/packages/stack/src/plugins/comments/api/query-key-defs.mjs +55 -0
- package/dist/packages/stack/src/plugins/comments/api/serializers.cjs +23 -0
- package/dist/packages/stack/src/plugins/comments/api/serializers.mjs +21 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +46 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +44 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-form.cjs +86 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-form.mjs +84 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +540 -0
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +538 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +64 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +426 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +424 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +62 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +66 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +256 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +254 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +64 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +86 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +191 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +189 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +84 -0
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +27 -0
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +25 -0
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +37 -0
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +35 -0
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +476 -0
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +464 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.cjs +67 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.mjs +65 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.cjs +27 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.mjs +25 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +30 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +28 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/index.cjs +13 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/index.mjs +11 -0
- package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +116 -0
- package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +114 -0
- package/dist/packages/stack/src/plugins/comments/client/utils.cjs +41 -0
- package/dist/packages/stack/src/plugins/comments/client/utils.mjs +37 -0
- package/dist/packages/stack/src/plugins/comments/db.cjs +75 -0
- package/dist/packages/stack/src/plugins/comments/db.mjs +73 -0
- package/dist/packages/stack/src/plugins/comments/schemas.cjs +45 -0
- package/dist/packages/stack/src/plugins/comments/schemas.mjs +38 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +0 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +0 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +39 -22
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +40 -23
- package/dist/packages/ui/src/components/avatar.mjs +1 -1
- package/dist/packages/ui/src/components/pagination-controls.cjs +64 -0
- package/dist/packages/ui/src/components/pagination-controls.mjs +62 -0
- package/dist/packages/ui/src/components/when-visible.cjs +39 -0
- package/dist/packages/ui/src/components/when-visible.mjs +37 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.mts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.ts +1 -1
- package/dist/plugins/blog/client/index.d.cts +24 -2
- package/dist/plugins/blog/client/index.d.mts +24 -2
- package/dist/plugins/blog/client/index.d.ts +24 -2
- package/dist/plugins/comments/api/index.cjs +21 -0
- package/dist/plugins/comments/api/index.d.cts +126 -0
- package/dist/plugins/comments/api/index.d.mts +126 -0
- package/dist/plugins/comments/api/index.d.ts +126 -0
- package/dist/plugins/comments/api/index.mjs +5 -0
- package/dist/plugins/comments/client/components/index.cjs +15 -0
- package/dist/plugins/comments/client/components/index.d.cts +125 -0
- package/dist/plugins/comments/client/components/index.d.mts +125 -0
- package/dist/plugins/comments/client/components/index.d.ts +125 -0
- package/dist/plugins/comments/client/components/index.mjs +5 -0
- package/dist/plugins/comments/client/hooks/index.cjs +17 -0
- package/dist/plugins/comments/client/hooks/index.d.cts +200 -0
- package/dist/plugins/comments/client/hooks/index.d.mts +200 -0
- package/dist/plugins/comments/client/hooks/index.d.ts +200 -0
- package/dist/plugins/comments/client/hooks/index.mjs +1 -0
- package/dist/plugins/comments/client/index.cjs +9 -0
- package/dist/plugins/comments/client/index.d.cts +262 -0
- package/dist/plugins/comments/client/index.d.mts +262 -0
- package/dist/plugins/comments/client/index.d.ts +262 -0
- package/dist/plugins/comments/client/index.mjs +2 -0
- package/dist/plugins/comments/client.css +2 -0
- package/dist/plugins/comments/query-keys.cjs +113 -0
- package/dist/plugins/comments/query-keys.d.cts +71 -0
- package/dist/plugins/comments/query-keys.d.mts +71 -0
- package/dist/plugins/comments/query-keys.d.ts +71 -0
- package/dist/plugins/comments/query-keys.mjs +111 -0
- package/dist/plugins/comments/style.css +15 -0
- package/dist/plugins/kanban/api/index.d.cts +1 -1
- package/dist/plugins/kanban/api/index.d.mts +1 -1
- package/dist/plugins/kanban/api/index.d.ts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
- package/dist/plugins/kanban/client/index.d.cts +1 -1
- package/dist/plugins/kanban/client/index.d.mts +1 -1
- package/dist/plugins/kanban/client/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.d.cts +1 -1
- package/dist/plugins/kanban/query-keys.d.mts +1 -1
- package/dist/plugins/kanban/query-keys.d.ts +1 -1
- package/dist/shared/{stack.FeaWkglm.d.ts → stack.BxFl46lB.d.cts} +24 -1
- package/dist/shared/stack.C-b3Sn8j.d.cts +142 -0
- package/dist/shared/stack.C-b3Sn8j.d.mts +142 -0
- package/dist/shared/stack.C-b3Sn8j.d.ts +142 -0
- package/dist/shared/stack.CJE9sAjV.d.ts +335 -0
- package/dist/shared/stack.CmHRdhl8.d.cts +335 -0
- package/dist/shared/{stack.CNLHlv7r.d.mts → stack.DOZ1EXjM.d.mts} +6 -12
- package/dist/shared/{stack.FeaWkglm.d.mts → stack.DRpeDS6X.d.ts} +24 -1
- package/dist/shared/{stack.CQAZwXhV.d.cts → stack.DX-tQ93o.d.cts} +6 -12
- package/dist/shared/stack.Dcz6636A.d.mts +335 -0
- package/dist/shared/{stack.FeaWkglm.d.cts → stack.Jb0kQDJC.d.mts} +24 -1
- package/dist/shared/stack.Ldfkr5b2.d.cts +112 -0
- package/dist/shared/stack.Ldfkr5b2.d.mts +112 -0
- package/dist/shared/stack.Ldfkr5b2.d.ts +112 -0
- package/dist/shared/{stack.D3BsrpAz.d.ts → stack.VF6FhyZw.d.ts} +6 -12
- package/package.json +69 -4
- package/src/plugins/blog/client/components/loading/post-navigation-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.tsx +18 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +23 -8
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +0 -5
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +1 -5
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +8 -33
- package/src/plugins/blog/client/overrides.ts +26 -1
- package/src/plugins/cms/client/components/shared/pagination.tsx +14 -42
- package/src/plugins/comments/api/getters.ts +444 -0
- package/src/plugins/comments/api/index.ts +21 -0
- package/src/plugins/comments/api/mutations.ts +206 -0
- package/src/plugins/comments/api/plugin.ts +628 -0
- package/src/plugins/comments/api/query-key-defs.ts +143 -0
- package/src/plugins/comments/api/serializers.ts +37 -0
- package/src/plugins/comments/client/components/comment-count.tsx +66 -0
- package/src/plugins/comments/client/components/comment-form.tsx +112 -0
- package/src/plugins/comments/client/components/comment-thread.tsx +799 -0
- package/src/plugins/comments/client/components/index.tsx +11 -0
- package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +550 -0
- package/src/plugins/comments/client/components/pages/moderation-page.tsx +70 -0
- package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +367 -0
- package/src/plugins/comments/client/components/pages/my-comments-page.tsx +72 -0
- package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +225 -0
- package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +97 -0
- package/src/plugins/comments/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/comments/client/components/shared/pagination.tsx +44 -0
- package/src/plugins/comments/client/hooks/index.tsx +13 -0
- package/src/plugins/comments/client/hooks/use-comments.tsx +717 -0
- package/src/plugins/comments/client/index.ts +14 -0
- package/src/plugins/comments/client/localization/comments-moderation.ts +75 -0
- package/src/plugins/comments/client/localization/comments-my.ts +32 -0
- package/src/plugins/comments/client/localization/comments-thread.ts +32 -0
- package/src/plugins/comments/client/localization/index.ts +11 -0
- package/src/plugins/comments/client/overrides.ts +164 -0
- package/src/plugins/comments/client/plugin.tsx +195 -0
- package/src/plugins/comments/client/utils.ts +67 -0
- package/src/plugins/comments/client.css +2 -0
- package/src/plugins/comments/db.ts +77 -0
- package/src/plugins/comments/query-keys.ts +189 -0
- package/src/plugins/comments/schemas.ts +72 -0
- package/src/plugins/comments/style.css +15 -0
- package/src/plugins/comments/types.ts +73 -0
- package/src/plugins/kanban/client/components/forms/task-form.tsx +0 -1
- package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +46 -27
- package/src/plugins/kanban/client/overrides.ts +27 -1
- package/dist/shared/{stack.Rtcvl8sS.d.cts → stack.BOokfhZD.d.cts} +3 -3
- package/dist/shared/{stack.D4Cea8II.d.ts → stack.BvCR4-9H.d.ts} +3 -3
- package/dist/shared/{stack.HE_IvqV5.d.mts → stack.CWxAl9K3.d.mts} +3 -3
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const table = require('../../../../../../../ui/src/components/table.cjs');
|
|
7
|
+
const alertDialog = require('../../../../../../../ui/src/components/alert-dialog.cjs');
|
|
8
|
+
const button = require('../../../../../../../ui/src/components/button.cjs');
|
|
9
|
+
const badge = require('../../../../../../../ui/src/components/badge.cjs');
|
|
10
|
+
const avatar = require('../../../../../../../ui/src/components/avatar.cjs');
|
|
11
|
+
const LucideIcons = require('lucide-react');
|
|
12
|
+
const sonner = require('sonner');
|
|
13
|
+
const dateFns = require('date-fns');
|
|
14
|
+
const paginationControls = require('../../../../../../../ui/src/components/pagination-controls.cjs');
|
|
15
|
+
const useComments = require('../../hooks/use-comments.cjs');
|
|
16
|
+
const index = require('../../localization/index.cjs');
|
|
17
|
+
const utils = require('../../utils.cjs');
|
|
18
|
+
|
|
19
|
+
const PAGE_LIMIT = 20;
|
|
20
|
+
function StatusBadge({
|
|
21
|
+
status,
|
|
22
|
+
loc
|
|
23
|
+
}) {
|
|
24
|
+
if (status === "approved") {
|
|
25
|
+
return /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", className: "text-green-700 border-green-300", children: loc.COMMENTS_MY_STATUS_APPROVED });
|
|
26
|
+
}
|
|
27
|
+
if (status === "pending") {
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", className: "text-yellow-700 border-yellow-300", children: loc.COMMENTS_MY_STATUS_PENDING });
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", className: "text-red-700 border-red-300", children: loc.COMMENTS_MY_STATUS_SPAM });
|
|
31
|
+
}
|
|
32
|
+
function UserCommentsPage({
|
|
33
|
+
apiBaseURL,
|
|
34
|
+
apiBasePath,
|
|
35
|
+
headers,
|
|
36
|
+
currentUserId: currentUserIdProp,
|
|
37
|
+
resourceLinks,
|
|
38
|
+
localization: localizationProp
|
|
39
|
+
}) {
|
|
40
|
+
const loc = { ...index.COMMENTS_LOCALIZATION, ...localizationProp };
|
|
41
|
+
const resolvedUserId = utils.useResolvedCurrentUserId(currentUserIdProp);
|
|
42
|
+
if (!resolvedUserId) {
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: "flex flex-col items-center justify-center gap-4 py-20 text-center",
|
|
47
|
+
"data-testid": "my-comments-login-prompt",
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.LogIn, { className: "h-10 w-10 text-muted-foreground" }),
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium", children: loc.COMMENTS_MY_LOGIN_TITLE }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: loc.COMMENTS_MY_LOGIN_DESCRIPTION })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
+
UserCommentsList,
|
|
58
|
+
{
|
|
59
|
+
apiBaseURL,
|
|
60
|
+
apiBasePath,
|
|
61
|
+
headers,
|
|
62
|
+
currentUserId: resolvedUserId,
|
|
63
|
+
resourceLinks,
|
|
64
|
+
loc
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function UserCommentsList({
|
|
69
|
+
apiBaseURL,
|
|
70
|
+
apiBasePath,
|
|
71
|
+
headers,
|
|
72
|
+
currentUserId,
|
|
73
|
+
resourceLinks,
|
|
74
|
+
loc
|
|
75
|
+
}) {
|
|
76
|
+
const [page, setPage] = React.useState(1);
|
|
77
|
+
const [deleteId, setDeleteId] = React.useState(null);
|
|
78
|
+
const config = { apiBaseURL, apiBasePath, headers };
|
|
79
|
+
const offset = (page - 1) * PAGE_LIMIT;
|
|
80
|
+
const { comments, total, refetch } = useComments.useSuspenseComments(config, {
|
|
81
|
+
authorId: currentUserId,
|
|
82
|
+
sort: "desc",
|
|
83
|
+
limit: PAGE_LIMIT,
|
|
84
|
+
offset
|
|
85
|
+
});
|
|
86
|
+
const deleteMutation = useComments.useDeleteComment(config);
|
|
87
|
+
const totalPages = Math.max(1, Math.ceil(total / PAGE_LIMIT));
|
|
88
|
+
const handleDelete = async () => {
|
|
89
|
+
if (!deleteId) return;
|
|
90
|
+
try {
|
|
91
|
+
await deleteMutation.mutateAsync(deleteId);
|
|
92
|
+
sonner.toast.success(loc.COMMENTS_MY_TOAST_DELETED);
|
|
93
|
+
refetch();
|
|
94
|
+
} catch {
|
|
95
|
+
sonner.toast.error(loc.COMMENTS_MY_TOAST_DELETE_ERROR);
|
|
96
|
+
} finally {
|
|
97
|
+
setDeleteId(null);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
if (comments.length === 0 && page === 1) {
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
className: "flex flex-col items-center justify-center gap-4 py-20 text-center",
|
|
105
|
+
"data-testid": "my-comments-empty",
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.MessageSquareOff, { className: "h-10 w-10 text-muted-foreground" }),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium", children: loc.COMMENTS_MY_EMPTY_TITLE }),
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: loc.COMMENTS_MY_EMPTY_DESCRIPTION })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "my-comments-page", className: "space-y-4", children: [
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
116
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-bold tracking-tight", children: loc.COMMENTS_MY_PAGE_TITLE }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: [
|
|
118
|
+
total,
|
|
119
|
+
" ",
|
|
120
|
+
loc.COMMENTS_MY_COL_COMMENT.toLowerCase(),
|
|
121
|
+
total !== 1 ? "s" : ""
|
|
122
|
+
] })
|
|
123
|
+
] }),
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: "rounded-lg border overflow-hidden",
|
|
128
|
+
"data-testid": "my-comments-list",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs(table.Table, { children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-10" }),
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.COMMENTS_MY_COL_COMMENT }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "hidden sm:table-cell w-32", children: loc.COMMENTS_MY_COL_RESOURCE }),
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-28", children: loc.COMMENTS_MY_COL_STATUS }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "hidden md:table-cell w-36", children: loc.COMMENTS_MY_COL_DATE }),
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-16" })
|
|
138
|
+
] }) }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableBody, { children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
CommentRow,
|
|
141
|
+
{
|
|
142
|
+
comment,
|
|
143
|
+
resourceLinks,
|
|
144
|
+
loc,
|
|
145
|
+
onDelete: () => setDeleteId(comment.id),
|
|
146
|
+
isDeleting: deleteMutation.isPending && deleteId === comment.id
|
|
147
|
+
},
|
|
148
|
+
comment.id
|
|
149
|
+
)) })
|
|
150
|
+
] }),
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
paginationControls.PaginationControls,
|
|
153
|
+
{
|
|
154
|
+
currentPage: page,
|
|
155
|
+
totalPages,
|
|
156
|
+
total,
|
|
157
|
+
limit: PAGE_LIMIT,
|
|
158
|
+
offset,
|
|
159
|
+
onPageChange: (p) => {
|
|
160
|
+
setPage(p);
|
|
161
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
169
|
+
alertDialog.AlertDialog,
|
|
170
|
+
{
|
|
171
|
+
open: !!deleteId,
|
|
172
|
+
onOpenChange: (open) => !open && setDeleteId(null),
|
|
173
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogContent, { children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogHeader, { children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogTitle, { children: loc.COMMENTS_MY_DELETE_TITLE }),
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogDescription, { children: loc.COMMENTS_MY_DELETE_DESCRIPTION })
|
|
177
|
+
] }),
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogFooter, { children: [
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogCancel, { children: loc.COMMENTS_MY_DELETE_CANCEL }),
|
|
180
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
+
alertDialog.AlertDialogAction,
|
|
182
|
+
{
|
|
183
|
+
onClick: handleDelete,
|
|
184
|
+
className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
185
|
+
children: loc.COMMENTS_MY_DELETE_CONFIRM
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
] })
|
|
189
|
+
] })
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
function CommentRow({
|
|
195
|
+
comment,
|
|
196
|
+
resourceLinks,
|
|
197
|
+
loc,
|
|
198
|
+
onDelete,
|
|
199
|
+
isDeleting
|
|
200
|
+
}) {
|
|
201
|
+
const resourceUrlBase = resourceLinks?.[comment.resourceType]?.(
|
|
202
|
+
comment.resourceId
|
|
203
|
+
);
|
|
204
|
+
const resourceUrl = resourceUrlBase ? `${resourceUrlBase}#comments` : void 0;
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { "data-testid": "my-comment-row", children: [
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs(avatar.Avatar, { className: "h-7 w-7", children: [
|
|
207
|
+
comment.resolvedAvatarUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
208
|
+
avatar.AvatarImage,
|
|
209
|
+
{
|
|
210
|
+
src: comment.resolvedAvatarUrl,
|
|
211
|
+
alt: comment.resolvedAuthorName
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { className: "text-xs", children: utils.getInitials(comment.resolvedAuthorName) })
|
|
215
|
+
] }) }),
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsxs(table.TableCell, { className: "max-w-xs", children: [
|
|
217
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm line-clamp-2", children: comment.body }),
|
|
218
|
+
comment.parentId && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground mt-0.5 block", children: loc.COMMENTS_MY_REPLY_INDICATOR })
|
|
219
|
+
] }),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "hidden sm:table-cell", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-muted-foreground capitalize", children: comment.resourceType.replace(/-/g, " ") }),
|
|
222
|
+
resourceUrl ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
223
|
+
"a",
|
|
224
|
+
{
|
|
225
|
+
href: resourceUrl,
|
|
226
|
+
className: "text-xs text-primary hover:underline inline-flex items-center gap-1",
|
|
227
|
+
target: "_blank",
|
|
228
|
+
rel: "noopener noreferrer",
|
|
229
|
+
children: [
|
|
230
|
+
loc.COMMENTS_MY_VIEW_LINK,
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ExternalLink, { className: "h-3 w-3" })
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground truncate max-w-[100px]", children: comment.resourceId })
|
|
235
|
+
] }) }),
|
|
236
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: comment.status, loc }) }),
|
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "hidden md:table-cell text-xs text-muted-foreground", children: dateFns.formatDistanceToNow(new Date(comment.createdAt), { addSuffix: true }) }),
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
239
|
+
button.Button,
|
|
240
|
+
{
|
|
241
|
+
variant: "ghost",
|
|
242
|
+
size: "icon",
|
|
243
|
+
className: "h-7 w-7 text-muted-foreground hover:text-destructive",
|
|
244
|
+
onClick: onDelete,
|
|
245
|
+
disabled: isDeleting,
|
|
246
|
+
"data-testid": "my-comment-delete-button",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Trash2, { className: "h-4 w-4" }),
|
|
249
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: loc.COMMENTS_MY_DELETE_BUTTON_SR })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
) })
|
|
253
|
+
] });
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
exports.UserCommentsPage = UserCommentsPage;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '../../../../../../../ui/src/components/table.mjs';
|
|
5
|
+
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '../../../../../../../ui/src/components/alert-dialog.mjs';
|
|
6
|
+
import { Button } from '../../../../../../../ui/src/components/button.mjs';
|
|
7
|
+
import { Badge } from '../../../../../../../ui/src/components/badge.mjs';
|
|
8
|
+
import { Avatar, AvatarImage, AvatarFallback } from '../../../../../../../ui/src/components/avatar.mjs';
|
|
9
|
+
import { LogIn, MessageSquareOff, ExternalLink, Trash2 } from 'lucide-react';
|
|
10
|
+
import { toast } from 'sonner';
|
|
11
|
+
import { formatDistanceToNow } from 'date-fns';
|
|
12
|
+
import { PaginationControls } from '../../../../../../../ui/src/components/pagination-controls.mjs';
|
|
13
|
+
import { useSuspenseComments, useDeleteComment } from '../../hooks/use-comments.mjs';
|
|
14
|
+
import { COMMENTS_LOCALIZATION } from '../../localization/index.mjs';
|
|
15
|
+
import { useResolvedCurrentUserId, getInitials } from '../../utils.mjs';
|
|
16
|
+
|
|
17
|
+
const PAGE_LIMIT = 20;
|
|
18
|
+
function StatusBadge({
|
|
19
|
+
status,
|
|
20
|
+
loc
|
|
21
|
+
}) {
|
|
22
|
+
if (status === "approved") {
|
|
23
|
+
return /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-green-700 border-green-300", children: loc.COMMENTS_MY_STATUS_APPROVED });
|
|
24
|
+
}
|
|
25
|
+
if (status === "pending") {
|
|
26
|
+
return /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-yellow-700 border-yellow-300", children: loc.COMMENTS_MY_STATUS_PENDING });
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-red-700 border-red-300", children: loc.COMMENTS_MY_STATUS_SPAM });
|
|
29
|
+
}
|
|
30
|
+
function UserCommentsPage({
|
|
31
|
+
apiBaseURL,
|
|
32
|
+
apiBasePath,
|
|
33
|
+
headers,
|
|
34
|
+
currentUserId: currentUserIdProp,
|
|
35
|
+
resourceLinks,
|
|
36
|
+
localization: localizationProp
|
|
37
|
+
}) {
|
|
38
|
+
const loc = { ...COMMENTS_LOCALIZATION, ...localizationProp };
|
|
39
|
+
const resolvedUserId = useResolvedCurrentUserId(currentUserIdProp);
|
|
40
|
+
if (!resolvedUserId) {
|
|
41
|
+
return /* @__PURE__ */ jsxs(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: "flex flex-col items-center justify-center gap-4 py-20 text-center",
|
|
45
|
+
"data-testid": "my-comments-login-prompt",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(LogIn, { className: "h-10 w-10 text-muted-foreground" }),
|
|
48
|
+
/* @__PURE__ */ jsx("p", { className: "text-lg font-medium", children: loc.COMMENTS_MY_LOGIN_TITLE }),
|
|
49
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: loc.COMMENTS_MY_LOGIN_DESCRIPTION })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
UserCommentsList,
|
|
56
|
+
{
|
|
57
|
+
apiBaseURL,
|
|
58
|
+
apiBasePath,
|
|
59
|
+
headers,
|
|
60
|
+
currentUserId: resolvedUserId,
|
|
61
|
+
resourceLinks,
|
|
62
|
+
loc
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function UserCommentsList({
|
|
67
|
+
apiBaseURL,
|
|
68
|
+
apiBasePath,
|
|
69
|
+
headers,
|
|
70
|
+
currentUserId,
|
|
71
|
+
resourceLinks,
|
|
72
|
+
loc
|
|
73
|
+
}) {
|
|
74
|
+
const [page, setPage] = useState(1);
|
|
75
|
+
const [deleteId, setDeleteId] = useState(null);
|
|
76
|
+
const config = { apiBaseURL, apiBasePath, headers };
|
|
77
|
+
const offset = (page - 1) * PAGE_LIMIT;
|
|
78
|
+
const { comments, total, refetch } = useSuspenseComments(config, {
|
|
79
|
+
authorId: currentUserId,
|
|
80
|
+
sort: "desc",
|
|
81
|
+
limit: PAGE_LIMIT,
|
|
82
|
+
offset
|
|
83
|
+
});
|
|
84
|
+
const deleteMutation = useDeleteComment(config);
|
|
85
|
+
const totalPages = Math.max(1, Math.ceil(total / PAGE_LIMIT));
|
|
86
|
+
const handleDelete = async () => {
|
|
87
|
+
if (!deleteId) return;
|
|
88
|
+
try {
|
|
89
|
+
await deleteMutation.mutateAsync(deleteId);
|
|
90
|
+
toast.success(loc.COMMENTS_MY_TOAST_DELETED);
|
|
91
|
+
refetch();
|
|
92
|
+
} catch {
|
|
93
|
+
toast.error(loc.COMMENTS_MY_TOAST_DELETE_ERROR);
|
|
94
|
+
} finally {
|
|
95
|
+
setDeleteId(null);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
if (comments.length === 0 && page === 1) {
|
|
99
|
+
return /* @__PURE__ */ jsxs(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: "flex flex-col items-center justify-center gap-4 py-20 text-center",
|
|
103
|
+
"data-testid": "my-comments-empty",
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsx(MessageSquareOff, { className: "h-10 w-10 text-muted-foreground" }),
|
|
106
|
+
/* @__PURE__ */ jsx("p", { className: "text-lg font-medium", children: loc.COMMENTS_MY_EMPTY_TITLE }),
|
|
107
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: loc.COMMENTS_MY_EMPTY_DESCRIPTION })
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */ jsxs("div", { "data-testid": "my-comments-page", className: "space-y-4", children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
114
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: loc.COMMENTS_MY_PAGE_TITLE }),
|
|
115
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: [
|
|
116
|
+
total,
|
|
117
|
+
" ",
|
|
118
|
+
loc.COMMENTS_MY_COL_COMMENT.toLowerCase(),
|
|
119
|
+
total !== 1 ? "s" : ""
|
|
120
|
+
] })
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ jsxs(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
className: "rounded-lg border overflow-hidden",
|
|
126
|
+
"data-testid": "my-comments-list",
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsxs(Table, { children: [
|
|
129
|
+
/* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
130
|
+
/* @__PURE__ */ jsx(TableHead, { className: "w-10" }),
|
|
131
|
+
/* @__PURE__ */ jsx(TableHead, { children: loc.COMMENTS_MY_COL_COMMENT }),
|
|
132
|
+
/* @__PURE__ */ jsx(TableHead, { className: "hidden sm:table-cell w-32", children: loc.COMMENTS_MY_COL_RESOURCE }),
|
|
133
|
+
/* @__PURE__ */ jsx(TableHead, { className: "w-28", children: loc.COMMENTS_MY_COL_STATUS }),
|
|
134
|
+
/* @__PURE__ */ jsx(TableHead, { className: "hidden md:table-cell w-36", children: loc.COMMENTS_MY_COL_DATE }),
|
|
135
|
+
/* @__PURE__ */ jsx(TableHead, { className: "w-16" })
|
|
136
|
+
] }) }),
|
|
137
|
+
/* @__PURE__ */ jsx(TableBody, { children: comments.map((comment) => /* @__PURE__ */ jsx(
|
|
138
|
+
CommentRow,
|
|
139
|
+
{
|
|
140
|
+
comment,
|
|
141
|
+
resourceLinks,
|
|
142
|
+
loc,
|
|
143
|
+
onDelete: () => setDeleteId(comment.id),
|
|
144
|
+
isDeleting: deleteMutation.isPending && deleteId === comment.id
|
|
145
|
+
},
|
|
146
|
+
comment.id
|
|
147
|
+
)) })
|
|
148
|
+
] }),
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
PaginationControls,
|
|
151
|
+
{
|
|
152
|
+
currentPage: page,
|
|
153
|
+
totalPages,
|
|
154
|
+
total,
|
|
155
|
+
limit: PAGE_LIMIT,
|
|
156
|
+
offset,
|
|
157
|
+
onPageChange: (p) => {
|
|
158
|
+
setPage(p);
|
|
159
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
AlertDialog,
|
|
168
|
+
{
|
|
169
|
+
open: !!deleteId,
|
|
170
|
+
onOpenChange: (open) => !open && setDeleteId(null),
|
|
171
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
172
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
173
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: loc.COMMENTS_MY_DELETE_TITLE }),
|
|
174
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { children: loc.COMMENTS_MY_DELETE_DESCRIPTION })
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
177
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { children: loc.COMMENTS_MY_DELETE_CANCEL }),
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
AlertDialogAction,
|
|
180
|
+
{
|
|
181
|
+
onClick: handleDelete,
|
|
182
|
+
className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
183
|
+
children: loc.COMMENTS_MY_DELETE_CONFIRM
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] })
|
|
187
|
+
] })
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
function CommentRow({
|
|
193
|
+
comment,
|
|
194
|
+
resourceLinks,
|
|
195
|
+
loc,
|
|
196
|
+
onDelete,
|
|
197
|
+
isDeleting
|
|
198
|
+
}) {
|
|
199
|
+
const resourceUrlBase = resourceLinks?.[comment.resourceType]?.(
|
|
200
|
+
comment.resourceId
|
|
201
|
+
);
|
|
202
|
+
const resourceUrl = resourceUrlBase ? `${resourceUrlBase}#comments` : void 0;
|
|
203
|
+
return /* @__PURE__ */ jsxs(TableRow, { "data-testid": "my-comment-row", children: [
|
|
204
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(Avatar, { className: "h-7 w-7", children: [
|
|
205
|
+
comment.resolvedAvatarUrl && /* @__PURE__ */ jsx(
|
|
206
|
+
AvatarImage,
|
|
207
|
+
{
|
|
208
|
+
src: comment.resolvedAvatarUrl,
|
|
209
|
+
alt: comment.resolvedAuthorName
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(AvatarFallback, { className: "text-xs", children: getInitials(comment.resolvedAuthorName) })
|
|
213
|
+
] }) }),
|
|
214
|
+
/* @__PURE__ */ jsxs(TableCell, { className: "max-w-xs", children: [
|
|
215
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm line-clamp-2", children: comment.body }),
|
|
216
|
+
comment.parentId && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground mt-0.5 block", children: loc.COMMENTS_MY_REPLY_INDICATOR })
|
|
217
|
+
] }),
|
|
218
|
+
/* @__PURE__ */ jsx(TableCell, { className: "hidden sm:table-cell", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
219
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground capitalize", children: comment.resourceType.replace(/-/g, " ") }),
|
|
220
|
+
resourceUrl ? /* @__PURE__ */ jsxs(
|
|
221
|
+
"a",
|
|
222
|
+
{
|
|
223
|
+
href: resourceUrl,
|
|
224
|
+
className: "text-xs text-primary hover:underline inline-flex items-center gap-1",
|
|
225
|
+
target: "_blank",
|
|
226
|
+
rel: "noopener noreferrer",
|
|
227
|
+
children: [
|
|
228
|
+
loc.COMMENTS_MY_VIEW_LINK,
|
|
229
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" })
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground truncate max-w-[100px]", children: comment.resourceId })
|
|
233
|
+
] }) }),
|
|
234
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(StatusBadge, { status: comment.status, loc }) }),
|
|
235
|
+
/* @__PURE__ */ jsx(TableCell, { className: "hidden md:table-cell text-xs text-muted-foreground", children: formatDistanceToNow(new Date(comment.createdAt), { addSuffix: true }) }),
|
|
236
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(
|
|
237
|
+
Button,
|
|
238
|
+
{
|
|
239
|
+
variant: "ghost",
|
|
240
|
+
size: "icon",
|
|
241
|
+
className: "h-7 w-7 text-muted-foreground hover:text-destructive",
|
|
242
|
+
onClick: onDelete,
|
|
243
|
+
disabled: isDeleting,
|
|
244
|
+
"data-testid": "my-comment-delete-button",
|
|
245
|
+
children: [
|
|
246
|
+
/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }),
|
|
247
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loc.COMMENTS_MY_DELETE_BUTTON_SR })
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
) })
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export { UserCommentsPage };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { lazy } from 'react';
|
|
4
|
+
import { ComposedRoute } from '@btst/stack/client/components';
|
|
5
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
6
|
+
import { COMMENTS_LOCALIZATION } from '../../localization/index.mjs';
|
|
7
|
+
import { useRouteLifecycle } from '../../../../../../../ui/src/hooks/use-route-lifecycle.mjs';
|
|
8
|
+
import { PageWrapper } from '../shared/page-wrapper.mjs';
|
|
9
|
+
|
|
10
|
+
const UserCommentsPageInternal = lazy(
|
|
11
|
+
() => import('./my-comments-page.internal.mjs').then((m) => ({
|
|
12
|
+
default: m.UserCommentsPage
|
|
13
|
+
}))
|
|
14
|
+
);
|
|
15
|
+
function UserCommentsPageSkeleton() {
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full max-w-3xl mx-auto space-y-4 animate-pulse", children: [
|
|
17
|
+
/* @__PURE__ */ jsx("div", { className: "h-8 w-48 rounded bg-muted" }),
|
|
18
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-64 rounded bg-muted" }),
|
|
19
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-lg border h-96 bg-muted" })
|
|
20
|
+
] });
|
|
21
|
+
}
|
|
22
|
+
function UserCommentsPageComponent() {
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
ComposedRoute,
|
|
25
|
+
{
|
|
26
|
+
path: "/comments",
|
|
27
|
+
PageComponent: UserCommentsPageWrapper,
|
|
28
|
+
LoadingComponent: UserCommentsPageSkeleton,
|
|
29
|
+
onError: (error) => console.error("[btst/comments] User Comments error:", error)
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function UserCommentsPageWrapper() {
|
|
34
|
+
const overrides = usePluginOverrides("comments");
|
|
35
|
+
const loc = { ...COMMENTS_LOCALIZATION, ...overrides.localization };
|
|
36
|
+
useRouteLifecycle({
|
|
37
|
+
routeName: "userComments",
|
|
38
|
+
context: {
|
|
39
|
+
path: "/comments",
|
|
40
|
+
isSSR: typeof window === "undefined"
|
|
41
|
+
},
|
|
42
|
+
overrides,
|
|
43
|
+
beforeRenderHook: (o, context) => {
|
|
44
|
+
if (o.onBeforeUserCommentsPageRendered) {
|
|
45
|
+
const result = o.onBeforeUserCommentsPageRendered(context);
|
|
46
|
+
return result === false ? false : true;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(
|
|
52
|
+
UserCommentsPageInternal,
|
|
53
|
+
{
|
|
54
|
+
apiBaseURL: overrides.apiBaseURL,
|
|
55
|
+
apiBasePath: overrides.apiBasePath,
|
|
56
|
+
headers: overrides.headers,
|
|
57
|
+
currentUserId: overrides.currentUserId,
|
|
58
|
+
resourceLinks: overrides.resourceLinks,
|
|
59
|
+
localization: loc
|
|
60
|
+
}
|
|
61
|
+
) });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { UserCommentsPageComponent };
|
package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const components = require('@btst/stack/client/components');
|
|
7
|
+
const context = require('@btst/stack/context');
|
|
8
|
+
const index = require('../../localization/index.cjs');
|
|
9
|
+
const useRouteLifecycle = require('../../../../../../../ui/src/hooks/use-route-lifecycle.cjs');
|
|
10
|
+
const pageWrapper = require('../shared/page-wrapper.cjs');
|
|
11
|
+
const utils = require('../../utils.cjs');
|
|
12
|
+
|
|
13
|
+
const ResourceCommentsPageInternal = React.lazy(
|
|
14
|
+
() => import('./resource-comments-page.internal.cjs').then((m) => ({
|
|
15
|
+
default: m.ResourceCommentsPage
|
|
16
|
+
}))
|
|
17
|
+
);
|
|
18
|
+
function ResourceCommentsSkeleton() {
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-3xl mx-auto space-y-4 animate-pulse", children: [
|
|
20
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-48 rounded bg-muted" }),
|
|
21
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-64 rounded bg-muted" }),
|
|
22
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border h-32 bg-muted" })
|
|
23
|
+
] });
|
|
24
|
+
}
|
|
25
|
+
function ResourceCommentsPageComponent({
|
|
26
|
+
resourceId,
|
|
27
|
+
resourceType
|
|
28
|
+
}) {
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30
|
+
components.ComposedRoute,
|
|
31
|
+
{
|
|
32
|
+
path: `/comments/${resourceType}/${resourceId}`,
|
|
33
|
+
PageComponent: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
ResourceCommentsPageWrapper,
|
|
35
|
+
{
|
|
36
|
+
resourceId,
|
|
37
|
+
resourceType
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
LoadingComponent: ResourceCommentsSkeleton,
|
|
41
|
+
onError: (error) => console.error("[btst/comments] Resource comments error:", error)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function ResourceCommentsPageWrapper({
|
|
46
|
+
resourceId,
|
|
47
|
+
resourceType
|
|
48
|
+
}) {
|
|
49
|
+
const overrides = context.usePluginOverrides("comments");
|
|
50
|
+
const loc = { ...index.COMMENTS_LOCALIZATION, ...overrides.localization };
|
|
51
|
+
const resolvedUserId = utils.useResolvedCurrentUserId(overrides.currentUserId);
|
|
52
|
+
useRouteLifecycle.useRouteLifecycle({
|
|
53
|
+
routeName: "resourceComments",
|
|
54
|
+
context: {
|
|
55
|
+
path: `/comments/${resourceType}/${resourceId}`,
|
|
56
|
+
params: { resourceId, resourceType },
|
|
57
|
+
isSSR: typeof window === "undefined"
|
|
58
|
+
},
|
|
59
|
+
overrides,
|
|
60
|
+
beforeRenderHook: (o, context) => {
|
|
61
|
+
if (o.onBeforeResourceCommentsRendered) {
|
|
62
|
+
return o.onBeforeResourceCommentsRendered(
|
|
63
|
+
resourceType,
|
|
64
|
+
resourceId,
|
|
65
|
+
context
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsx(pageWrapper.PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
|
+
ResourceCommentsPageInternal,
|
|
73
|
+
{
|
|
74
|
+
resourceId,
|
|
75
|
+
resourceType,
|
|
76
|
+
apiBaseURL: overrides.apiBaseURL,
|
|
77
|
+
apiBasePath: overrides.apiBasePath,
|
|
78
|
+
headers: overrides.headers,
|
|
79
|
+
currentUserId: resolvedUserId,
|
|
80
|
+
loginHref: overrides.loginHref,
|
|
81
|
+
localization: loc
|
|
82
|
+
}
|
|
83
|
+
) });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
exports.ResourceCommentsPageComponent = ResourceCommentsPageComponent;
|