sea-react-components 1.3.28 → 1.3.29

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.
Files changed (87) hide show
  1. package/dist/HOC/can-access-application/index.d.ts.map +1 -1
  2. package/dist/HOC/with-authorization/index.d.ts.map +1 -1
  3. package/dist/components/comments-container/comment-event-bus/index.d.ts +1 -1
  4. package/dist/components/comments-container/comment-event-bus/index.d.ts.map +1 -1
  5. package/dist/components/day-calendar/index.d.ts +2 -1
  6. package/dist/components/day-calendar/index.d.ts.map +1 -1
  7. package/dist/components/month-calendar/index.d.ts +2 -1
  8. package/dist/components/month-calendar/index.d.ts.map +1 -1
  9. package/dist/components/text-editor/utils/index.d.ts.map +1 -1
  10. package/dist/components/tree-checkbox/index.d.ts.map +1 -1
  11. package/dist/components/tree-checkbox/utils/index.d.ts.map +1 -1
  12. package/dist/components/week-calendar/index.d.ts +2 -1
  13. package/dist/components/week-calendar/index.d.ts.map +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/utils/axios/index.d.ts.map +1 -1
  16. package/dist/utils/color/index.d.ts.map +1 -1
  17. package/dist/utils/cookie/index.d.ts.map +1 -1
  18. package/dist/utils/file/index.d.ts.map +1 -1
  19. package/dist/utils/notification-localstorage/index.d.ts.map +1 -1
  20. package/dist/utils/validation/index.d.ts.map +1 -1
  21. package/package.json +4 -4
  22. package/dist/components/activity-message/index.d.ts +0 -7
  23. package/dist/components/activity-message/index.d.ts.map +0 -1
  24. package/dist/components/activity-message/index.js +0 -63
  25. package/dist/components/comments-container copy/comment-event-bus/index.d.ts +0 -4
  26. package/dist/components/comments-container copy/comment-event-bus/index.d.ts.map +0 -1
  27. package/dist/components/comments-container copy/comment-event-bus/index.js +0 -4
  28. package/dist/components/comments-container copy/comment-form/index.d.ts +0 -39
  29. package/dist/components/comments-container copy/comment-form/index.d.ts.map +0 -1
  30. package/dist/components/comments-container copy/comment-form/index.js +0 -83
  31. package/dist/components/comments-container copy/comment-item/index.d.ts +0 -13
  32. package/dist/components/comments-container copy/comment-item/index.d.ts.map +0 -1
  33. package/dist/components/comments-container copy/comment-item/index.js +0 -20
  34. package/dist/components/comments-container copy/comments-list/index.d.ts +0 -24
  35. package/dist/components/comments-container copy/comments-list/index.d.ts.map +0 -1
  36. package/dist/components/comments-container copy/comments-list/index.js +0 -35
  37. package/dist/components/comments-container copy/constants/index.d.ts +0 -5
  38. package/dist/components/comments-container copy/constants/index.d.ts.map +0 -1
  39. package/dist/components/comments-container copy/constants/index.js +0 -5
  40. package/dist/components/comments-container copy/index.d.ts +0 -21
  41. package/dist/components/comments-container copy/index.d.ts.map +0 -1
  42. package/dist/components/comments-container copy/index.js +0 -27
  43. package/dist/components/comments-container copy/use-comments/index.d.ts +0 -17
  44. package/dist/components/comments-container copy/use-comments/index.d.ts.map +0 -1
  45. package/dist/components/comments-container copy/use-comments/index.js +0 -59
  46. package/dist/components/jwt-checker/index.d.ts +0 -5
  47. package/dist/components/jwt-checker/index.d.ts.map +0 -1
  48. package/dist/components/jwt-checker/index.js +0 -14
  49. package/dist/components/jwt-token-checker/index.d.ts +0 -1
  50. package/dist/components/jwt-token-checker/index.d.ts.map +0 -1
  51. package/dist/components/jwt-token-checker/index.js +0 -0
  52. package/dist/components/log-activities-container/activity-message/index.d.ts +0 -7
  53. package/dist/components/log-activities-container/activity-message/index.d.ts.map +0 -1
  54. package/dist/components/log-activities-container/activity-message/index.js +0 -63
  55. package/dist/components/log-activities-container/comment-event-bus/index.d.ts +0 -4
  56. package/dist/components/log-activities-container/comment-event-bus/index.d.ts.map +0 -1
  57. package/dist/components/log-activities-container/comment-event-bus/index.js +0 -4
  58. package/dist/components/log-activities-container/comment-form/index.d.ts +0 -39
  59. package/dist/components/log-activities-container/comment-form/index.d.ts.map +0 -1
  60. package/dist/components/log-activities-container/comment-form/index.js +0 -83
  61. package/dist/components/log-activities-container/comment-item/index.d.ts +0 -13
  62. package/dist/components/log-activities-container/comment-item/index.d.ts.map +0 -1
  63. package/dist/components/log-activities-container/comment-item/index.js +0 -20
  64. package/dist/components/log-activities-container/comments-list/index.d.ts +0 -24
  65. package/dist/components/log-activities-container/comments-list/index.d.ts.map +0 -1
  66. package/dist/components/log-activities-container/comments-list/index.js +0 -35
  67. package/dist/components/log-activities-container/constants/index.d.ts +0 -5
  68. package/dist/components/log-activities-container/constants/index.d.ts.map +0 -1
  69. package/dist/components/log-activities-container/constants/index.js +0 -5
  70. package/dist/components/log-activities-container/use-comments/index.d.ts +0 -17
  71. package/dist/components/log-activities-container/use-comments/index.d.ts.map +0 -1
  72. package/dist/components/log-activities-container/use-comments/index.js +0 -59
  73. package/dist/hooks/use-/index.d.ts +0 -1
  74. package/dist/hooks/use-/index.d.ts.map +0 -1
  75. package/dist/hooks/use-/index.js +0 -0
  76. package/dist/hooks/use-interval/index.d.ts +0 -2
  77. package/dist/hooks/use-interval/index.d.ts.map +0 -1
  78. package/dist/hooks/use-interval/index.js +0 -16
  79. package/dist/hooks/use-token-watcher/index.d.ts +0 -7
  80. package/dist/hooks/use-token-watcher/index.d.ts.map +0 -1
  81. package/dist/hooks/use-token-watcher/index.js +0 -23
  82. package/dist/services/remote-action/index.d.ts +0 -14
  83. package/dist/services/remote-action/index.d.ts.map +0 -1
  84. package/dist/services/remote-action/index.js +0 -21
  85. package/dist/utils/remote-action/index.d.ts +0 -14
  86. package/dist/utils/remote-action/index.d.ts.map +0 -1
  87. package/dist/utils/remote-action/index.js +0 -21
@@ -1,21 +0,0 @@
1
- import { DTO } from "sea-platform-helpers";
2
- import { CommentFormRenderProps } from "./comment-form";
3
- export type Props = {
4
- commentsBaseUrl: string;
5
- objectId: string;
6
- model: DTO.Comment.CommentSupportedModels;
7
- limit?: number;
8
- highlightCommentId?: string;
9
- renderCommentItem?: (comment: DTO.Comment.IComment, commonProps: {
10
- currentAccountId?: string;
11
- editComment: (comment: DTO.Comment.IComment | undefined) => void;
12
- replyOnComment: (comment: DTO.Comment.IComment | undefined) => void;
13
- commentsBaseUrl: string;
14
- objectId: string;
15
- limit?: number;
16
- highlightCommentId?: string;
17
- }) => React.ReactNode;
18
- renderForm?: (props: CommentFormRenderProps) => React.ReactNode;
19
- };
20
- export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit, highlightCommentId, renderCommentItem, renderForm, }: Props): import("react/jsx-runtime").JSX.Element;
21
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/comments-container copy/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAa,MAAM,sBAAsB,CAAC;AAItD,OAAoB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAC7B,WAAW,EAAE;QACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACjE,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACpE,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,KACE,KAAK,CAAC,SAAS,CAAC;IAErB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,eAAe,EACf,QAAQ,EACR,KAAK,EACL,KAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,EAAE,KAAK,2CAmDP"}
@@ -1,27 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState, useEffect } from "react";
4
- import { CONSTANTS } from "sea-platform-helpers";
5
- import { getCookie } from "../../utils/cookie";
6
- import { jwtDecode } from "../../utils/jwt";
7
- import CommentForm from "./comment-form";
8
- import CommentsList from "./comments-list";
9
- import CommentItem from "./comment-item";
10
- export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit = 10, highlightCommentId, renderCommentItem, renderForm, }) {
11
- const [accountId, setAccountId] = useState("");
12
- const [commentToEdit, setCommentToEdit] = useState();
13
- const [replyOnComment, setReplyOnComment] = useState();
14
- useEffect(() => {
15
- var _a, _b;
16
- const accessToken = (_a = getCookie(CONSTANTS.JWT.JWTCookieKey)) !== null && _a !== void 0 ? _a : "";
17
- const payload = (_b = jwtDecode(accessToken)) !== null && _b !== void 0 ? _b : null;
18
- setAccountId((payload === null || payload === void 0 ? void 0 : payload.id) || "");
19
- }, []);
20
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(CommentForm, { commentsBaseUrl: commentsBaseUrl, objectId: objectId, model: model, commentToEdit: commentToEdit, setCommentToEdit: setCommentToEdit, replyOnComment: replyOnComment, setReplyOnComment: setReplyOnComment, onCreateCommentSuccess: () => {
21
- setCommentToEdit(undefined);
22
- setReplyOnComment(undefined);
23
- }, onEditCommentSuccess: () => {
24
- setCommentToEdit(undefined);
25
- setReplyOnComment(undefined);
26
- }, renderForm: renderForm }), _jsx(CommentsList, { editComment: setCommentToEdit, replyOnComment: setReplyOnComment, highlightCommentId: highlightCommentId, currentAccountId: accountId, commentsBaseUrl: commentsBaseUrl, objectId: objectId, limit: limit, renderCommentItem: renderCommentItem !== null && renderCommentItem !== void 0 ? renderCommentItem : ((comment, props) => (_jsx(CommentItem, { comment: comment, ...props }, comment.id))) })] }));
27
- }
@@ -1,17 +0,0 @@
1
- import { DTO } from "sea-platform-helpers";
2
- export declare function useComments({ commentsBaseUrl, objectId, limit, parentCommentId, }: {
3
- commentsBaseUrl: string;
4
- objectId: string;
5
- limit?: number;
6
- parentCommentId?: string;
7
- }): {
8
- comments: DTO.Comment.IComment[];
9
- loading: boolean;
10
- totalCount: number;
11
- totalPages: number;
12
- pushNewComment: (comment: DTO.Comment.IComment) => void;
13
- updateComment: (comment: DTO.Comment.IComment) => void;
14
- loadMoreComments: () => void;
15
- hasMoreComments: boolean;
16
- };
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/comments-container copy/use-comments/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,WAAW,CAAC,EAC1B,eAAe,EACf,QAAQ,EACR,KAAU,EACV,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;;;;;8BA0CkC,GAAG,CAAC,OAAO,CAAC,QAAQ;6BAkBrB,GAAG,CAAC,OAAO,CAAC,QAAQ;;;EAkBrD"}
@@ -1,59 +0,0 @@
1
- "use client";
2
- import { useEffect, useState } from "react";
3
- import { Utils } from "sea-platform-helpers";
4
- import { authAxiosInstance } from "../../../utils/auth-axios";
5
- export function useComments({ commentsBaseUrl, objectId, limit = 10, parentCommentId, }) {
6
- const [loading, setLoading] = useState(false);
7
- const [page, setPage] = useState(1);
8
- const [totalCount, setTotalCount] = useState(0);
9
- const [totalPages, setTotalPages] = useState(1);
10
- const [comments, setComments] = useState([]);
11
- useEffect(() => {
12
- setLoading(true);
13
- const params = new URLSearchParams({
14
- page: String(page),
15
- limit: String(limit),
16
- objectId,
17
- ...(parentCommentId ? { parentCommentId } : {}),
18
- });
19
- authAxiosInstance
20
- .get(`${commentsBaseUrl}?${params.toString()}`)
21
- .then((response) => {
22
- const { data, totalCount: tc, totalPages: tp } = response.data;
23
- setTotalCount(tc);
24
- setTotalPages(tp);
25
- setComments((prev) => Utils.Array.concatWithoutDuplicates(prev, data, (a, b) => a.id === b.id));
26
- })
27
- .finally(() => {
28
- setLoading(false);
29
- });
30
- }, [commentsBaseUrl, limit, objectId, page]);
31
- const pushNewComment = (comment) => {
32
- setComments((prev) => {
33
- if (comment.isReply && !parentCommentId) {
34
- return prev.map((c) => c.id === comment.parentCommentId
35
- ? { ...c, repliesCount: c.repliesCount + 1 }
36
- : c);
37
- }
38
- else {
39
- return Utils.Array.concatWithoutDuplicates([comment], prev, (a, b) => a.id === b.id);
40
- }
41
- });
42
- };
43
- const updateComment = (comment) => {
44
- setComments((prev) => prev.map((c) => (c.id === comment.id ? comment : c)));
45
- };
46
- const loadMoreComments = () => {
47
- setPage((prev) => Math.min(prev + 1, totalPages));
48
- };
49
- return {
50
- comments,
51
- loading,
52
- totalCount,
53
- totalPages,
54
- pushNewComment,
55
- updateComment,
56
- loadMoreComments,
57
- hasMoreComments: totalCount !== comments.length,
58
- };
59
- }
@@ -1,5 +0,0 @@
1
- export type Props = {
2
- delay?: number;
3
- };
4
- export default function JWTChecker({ delay }: Props): import("react/jsx-runtime").JSX.Element;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/jwt-checker/index.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,KAAY,EAAE,EAAE,KAAK,2CAOzD"}
@@ -1,14 +0,0 @@
1
- "use client";
2
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
- import { CONSTANTS } from "sea-platform-helpers";
4
- import { useInterval } from "../../hooks/use-interval";
5
- import { getCookie } from "../../utils/cookie";
6
- export default function JWTChecker({ delay = 2000 }) {
7
- useInterval(() => {
8
- const jwt = getCookie(CONSTANTS.JWT.JWTCookieKey);
9
- console.log("JWTChecker - current JWT:", jwt);
10
- if (!jwt)
11
- window.location.reload();
12
- }, delay);
13
- return _jsx(_Fragment, {});
14
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/jwt-token-checker/index.tsx"],"names":[],"mappings":""}
File without changes
@@ -1,7 +0,0 @@
1
- import { DTO } from "sea-platform-helpers";
2
- type Props = {
3
- activity: DTO.Activity.IActivity;
4
- };
5
- export default function ActivityMessage({ activity }: Props): import("react/jsx-runtime").JSX.Element;
6
- export {};
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/activity-message/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAG7D,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;CAClC,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAoQ1D"}
@@ -1,63 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { CONSTANTS, Utils } from "sea-platform-helpers";
4
- const NONE = "N/A";
5
- export default function ActivityMessage({ activity }) {
6
- var _a, _b, _c, _d, _e, _f;
7
- let message = null;
8
- switch (activity.type) {
9
- case CONSTANTS.Activity.ActivityTypes.SystemAction: {
10
- break;
11
- }
12
- case CONSTANTS.Activity.ActivityTypes.NewCommentAdded: {
13
- const metadata = activity.metadata;
14
- message = (_jsxs("p", { children: ["New comment added", " ", _jsx("span", { className: "font-semibold", children: metadata.description })] }));
15
- break;
16
- }
17
- case CONSTANTS.Activity.ActivityTypes.CommentGetUpdated: {
18
- const metadata = activity.metadata;
19
- message = (_jsxs("div", { className: "flex flex-col gap-[1px]", children: [_jsx("p", { children: "Comment updated" }), _jsxs("div", { className: "text-sm", children: [_jsxs("p", { children: ["From:", " ", _jsx("span", { className: "font-semibold", children: metadata.description.from })] }), _jsxs("p", { children: ["To:", " ", _jsx("span", { className: "font-semibold", children: metadata.description.to })] })] })] }));
20
- break;
21
- }
22
- case CONSTANTS.Activity.ActivityTypes.CommentGetDeleted: {
23
- const metadata = activity.metadata;
24
- message = (_jsxs("p", { children: ["Comment delete", " ", _jsx("span", { className: "font-semibold", children: metadata.description })] }));
25
- break;
26
- }
27
- case CONSTANTS.Activity.ActivityTypes.NewProjectCreated: {
28
- const metadata = activity.metadata;
29
- message = (_jsxs("p", { children: ["New project created", " ", _jsx("span", { className: "font-semibold", children: metadata.title })] }));
30
- break;
31
- }
32
- case CONSTANTS.Activity.ActivityTypes.ProjectGetUpdated: {
33
- const metadata = activity.metadata;
34
- message = (_jsxs("div", { className: "flex flex-col gap-[1px]", children: [_jsx("p", { children: "Project updated" }), _jsxs("div", { className: "text-sm", children: [metadata.title && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Title:", " ", _jsx("span", { className: "font-semibold", children: metadata.title.to })] }) })), metadata.description && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Description:", " ", _jsx("span", { className: "font-semibold", children: metadata.description.to })] }) })), metadata.budget && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Budget:", " ", _jsx("span", { className: "font-semibold", children: Utils.Number.numeralUtils(metadata.budget.to).format(`0,0.00`) })] }) })), metadata.owner && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Owner:", " ", _jsx("span", { className: "font-semibold", children: (_b = (_a = metadata.owner.to) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : NONE })] }) })), metadata.startDate && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Start Date:", " ", _jsx("span", { className: "font-semibold", children: Utils.Moment.formatDate(metadata.startDate.to) })] }) })), metadata.endDate && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["End Date:", " ", _jsx("span", { className: "font-semibold", children: Utils.Moment.formatDate(metadata.endDate.to) })] }) }))] })] }));
35
- break;
36
- }
37
- case CONSTANTS.Activity.ActivityTypes.ProjectGetDeleted: {
38
- const metadata = activity.metadata;
39
- message = (_jsxs("p", { children: ["Project deleted", " ", _jsx("span", { className: "font-semibold", children: metadata.title })] }));
40
- break;
41
- }
42
- case CONSTANTS.Activity.ActivityTypes.NewTaskCreated: {
43
- const metadata = activity.metadata;
44
- message = (_jsxs("p", { children: ["New task created", " ", _jsx("span", { className: "font-semibold", children: metadata.title })] }));
45
- break;
46
- }
47
- case CONSTANTS.Activity.ActivityTypes.TaskGetUpdated: {
48
- const metadata = activity.metadata;
49
- message = (_jsxs("div", { className: "flex flex-col gap-[1px]", children: [_jsx("p", { children: "Task updated" }), _jsxs("div", { className: "text-sm", children: [metadata.title && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Title:", " ", _jsx("span", { className: "font-semibold", children: metadata.title.to })] }) })), metadata.description && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Description:", " ", _jsx("span", { className: "font-semibold", children: metadata.description.to })] }) })), metadata.section && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Section:", " ", _jsx("span", { className: "font-semibold", children: (_d = (_c = metadata.section.to) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : NONE })] }) })), metadata.milestone && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Milestone:", " ", _jsx("span", { className: "font-semibold", children: (_f = (_e = metadata.milestone.to) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : NONE })] }) })), metadata.priority && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Priority:", " ", _jsx("span", { className: "font-semibold", children: metadata.priority.to })] }) })), metadata.dueDate && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Due date:", " ", _jsx("span", { className: "font-semibold", children: Utils.Moment.formatDate(metadata.dueDate.to) })] }) })), metadata.isCompleted && (_jsx("div", { className: "flex gap-1", children: _jsxs("p", { children: ["Completed:", " ", _jsx("span", { className: "font-semibold", children: metadata.isCompleted.to ? "Yes" : "No" })] }) }))] })] }));
50
- break;
51
- }
52
- case CONSTANTS.Activity.ActivityTypes.TaskGetDeleted: {
53
- const metadata = activity.metadata;
54
- message = (_jsxs("p", { children: ["Task deleted ", _jsx("span", { className: "font-semibold", children: metadata.title })] }));
55
- break;
56
- }
57
- default: {
58
- message = _jsxs("p", { children: ["Activity type ", activity.type, " is not supported."] });
59
- break;
60
- }
61
- }
62
- return _jsxs("div", { className: "text-text line-clamp-2 truncate", children: [" ", message, " "] });
63
- }
@@ -1,4 +0,0 @@
1
- import { EventEmitter } from "events";
2
- declare const eventBus: EventEmitter<[never]>;
3
- export default eventBus;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/comment-event-bus/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,QAAA,MAAM,QAAQ,uBAAqB,CAAC;AAEpC,eAAe,QAAQ,CAAC"}
@@ -1,4 +0,0 @@
1
- "use client";
2
- import { EventEmitter } from "events";
3
- const eventBus = new EventEmitter();
4
- export default eventBus;
@@ -1,39 +0,0 @@
1
- import React from "react";
2
- import { useFormik } from "formik";
3
- import { DTO } from "sea-platform-helpers";
4
- import * as Yup from "yup";
5
- export declare const createNewCommentValidation: () => Yup.ObjectSchema<{
6
- description: string;
7
- }, Yup.AnyObject, {
8
- description: undefined;
9
- }, "">;
10
- type Values = {
11
- objectId: string;
12
- model: DTO.Comment.CommentSupportedModels;
13
- description: string;
14
- parentCommentId?: string;
15
- };
16
- export type CommentFormRenderProps = {
17
- formik: ReturnType<typeof useFormik<Values>>;
18
- isReplying: boolean;
19
- isEditing: boolean;
20
- replyOnComment?: DTO.Comment.IComment;
21
- cancelReply: () => void;
22
- cancelEdit: () => void;
23
- handleKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
24
- };
25
- export type Props = {
26
- objectId: string;
27
- model: DTO.Comment.CommentSupportedModels;
28
- commentsBaseUrl: string;
29
- commentToEdit?: DTO.Comment.IComment;
30
- setCommentToEdit: (comment: DTO.Comment.IComment | undefined) => void;
31
- replyOnComment?: DTO.Comment.IComment;
32
- setReplyOnComment: (comment: DTO.Comment.IComment | undefined) => void;
33
- onCreateCommentSuccess?: (comment: DTO.Comment.IComment) => void;
34
- onEditCommentSuccess?: (comment: DTO.Comment.IComment) => void;
35
- renderForm?: (props: CommentFormRenderProps) => React.ReactNode;
36
- };
37
- export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, }: Props): import("react/jsx-runtime").JSX.Element;
38
- export {};
39
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/comment-form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,eAAO,MAAM,0BAA0B;;;;MAQtC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IAExB,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrC,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEtE,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,iBAAiB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEvE,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IACjE,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAE/D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,KAAK,EACL,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,GACX,EAAE,KAAK,2CAsIP"}
@@ -1,83 +0,0 @@
1
- "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import Textarea from "../../textarea";
4
- import Button from "../../button";
5
- import { useFormik } from "formik";
6
- import * as Yup from "yup";
7
- import { authAxiosInstance } from "../../../utils/auth-axios";
8
- import eventBus from "../comment-event-bus";
9
- import { COMMENT_EVENTS } from "../constants";
10
- export const createNewCommentValidation = () => {
11
- return Yup.object({
12
- description: Yup.string()
13
- .trim()
14
- .min(1, "Required")
15
- .max(1000, "Must be at most 1000 characters")
16
- .required("Required"),
17
- });
18
- };
19
- export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, }) {
20
- var _a;
21
- const initialValues = {
22
- model,
23
- objectId,
24
- description: (commentToEdit === null || commentToEdit === void 0 ? void 0 : commentToEdit.description) || "",
25
- parentCommentId: (replyOnComment === null || replyOnComment === void 0 ? void 0 : replyOnComment.id) || "",
26
- };
27
- const onSubmit = async (values, helpers) => {
28
- try {
29
- if (commentToEdit) {
30
- const response = await authAxiosInstance.put(`${commentsBaseUrl}/${commentToEdit.id}`, { description: values.description });
31
- eventBus.emit(COMMENT_EVENTS.UpdateComment, response.data);
32
- onEditCommentSuccess === null || onEditCommentSuccess === void 0 ? void 0 : onEditCommentSuccess(response.data);
33
- }
34
- else {
35
- const response = await authAxiosInstance.post(commentsBaseUrl, {
36
- objectId: values.objectId,
37
- model: values.model,
38
- description: values.description,
39
- parentCommentId: values.parentCommentId,
40
- });
41
- eventBus.emit(COMMENT_EVENTS.NewComment, response.data);
42
- onCreateCommentSuccess === null || onCreateCommentSuccess === void 0 ? void 0 : onCreateCommentSuccess(response.data);
43
- }
44
- helpers.resetForm();
45
- }
46
- finally {
47
- helpers.setSubmitting(false);
48
- }
49
- };
50
- const formik = useFormik({
51
- initialValues,
52
- validationSchema: createNewCommentValidation,
53
- onSubmit,
54
- enableReinitialize: true,
55
- });
56
- const handleKeyDown = (e) => {
57
- // If user pressed Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac)
58
- if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
59
- e.preventDefault(); // prevent new line
60
- if (!formik.isSubmitting && formik.isValid) {
61
- formik.submitForm();
62
- }
63
- }
64
- };
65
- const cancelReply = () => setReplyOnComment(undefined);
66
- const cancelEdit = () => setCommentToEdit(undefined);
67
- const renderProps = {
68
- formik,
69
- isReplying: Boolean(replyOnComment),
70
- isEditing: Boolean(commentToEdit),
71
- replyOnComment,
72
- cancelReply,
73
- cancelEdit,
74
- handleKeyDown,
75
- };
76
- if (renderForm)
77
- return _jsx(_Fragment, { children: renderForm(renderProps) });
78
- return (_jsxs("form", { onSubmit: formik.handleSubmit, className: "flex flex-col gap-3", children: [replyOnComment && (_jsxs("div", { className: "flex items-center justify-between bg-primary/5 px-3 py-2 rounded-lg border border-primary/10", children: [_jsxs("p", { className: "text-sm text-gray-700", children: ["Replying to", " ", _jsx("span", { className: "font-semibold text-primary", children: (_a = replyOnComment.account) === null || _a === void 0 ? void 0 : _a.name })] }), _jsx(Button, { type: "button", onClick: () => setReplyOnComment(undefined), className: "bg-transparent", children: _jsx("p", { className: "text-error hover:text-opacity-75 custom-animation", children: "Cancel" }) })] })), _jsx(Textarea, { name: "description", placeholder: commentToEdit
79
- ? "Edit your comment..."
80
- : replyOnComment
81
- ? "Write a reply..."
82
- : "Add a comment...", onChange: formik.handleChange, onBlur: formik.handleBlur, value: formik.values.description, errorMessage: formik.touched.description ? formik.errors.description : "", className: "min-h-[80px]", onKeyDown: handleKeyDown }), _jsxs("div", { className: "flex justify-end gap-2 pt-1", children: [commentToEdit && (_jsx(Button, { type: "button", onClick: () => setCommentToEdit(undefined), className: "bg-transparent", children: _jsx("p", { className: "text-error hover:text-opacity-75 custom-animation", children: "Cancel" }) })), _jsx(Button, { type: "submit", loading: formik.isSubmitting, disabled: formik.isSubmitting || !formik.isValid, children: commentToEdit ? "Update Comment" : "Add Comment" })] })] }));
83
- }
@@ -1,13 +0,0 @@
1
- import { DTO } from "sea-platform-helpers";
2
- export type Props = {
3
- comment: DTO.Comment.IComment;
4
- isHighlight?: boolean;
5
- currentAccountId?: string;
6
- replyOnComment: (comment: DTO.Comment.IComment | undefined) => void;
7
- editComment: (comment: DTO.Comment.IComment | undefined) => void;
8
- commentsBaseUrl: string;
9
- objectId: string;
10
- limit?: number;
11
- };
12
- export default function CommentItem({ comment, isHighlight, currentAccountId, replyOnComment, editComment, commentsBaseUrl, objectId, limit, }: Props): import("react/jsx-runtime").JSX.Element;
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/comment-item/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAK7D,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IACpE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IACjE,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACR,KAAK,GACN,EAAE,KAAK,2CAkHP"}
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo, useState } from "react";
4
- import clsx from "clsx";
5
- import { CONSTANTS, Utils } from "sea-platform-helpers";
6
- import Icon from "../../icon";
7
- import Avatar from "../../avatar";
8
- import CommentsList from "../log-activities-list";
9
- export default function CommentItem({ comment, isHighlight = false, currentAccountId, replyOnComment, editComment, commentsBaseUrl, objectId, limit, }) {
10
- var _a, _b;
11
- const [isReplyListOpen, setIsReplyListOpen] = useState(true);
12
- const highlightedCommentId = useMemo(() => {
13
- if (typeof window === "undefined")
14
- return null;
15
- const params = new URLSearchParams(window.location.search);
16
- return params.get(CONSTANTS.Routes.global.QUERY_PARAMETER_KEYS.HIGHLIGHTED_COMMENT_ID);
17
- }, []);
18
- const shouldHighlight = isHighlight || comment.id === highlightedCommentId;
19
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: clsx("relative flex flex-col gap-2 p-2 border border-gray-100 rounded-lg bg-white shadow-sm transition-all", shouldHighlight && "ring-2 ring-primary/50 bg-primary/5"), children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Avatar, { alt: ((_a = comment.account) === null || _a === void 0 ? void 0 : _a.name) || "", placeholderSource: "letters", size: "sm" }), _jsxs("div", { className: "flex flex-col flex-1 gap-1", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm font-semibold text-gray-900", children: (_b = comment.account) === null || _b === void 0 ? void 0 : _b.name }), _jsx("p", { className: "text-xs text-gray-500", children: Utils.Moment.formatDateAsLabel(comment.createdAt) })] }), _jsx("p", { className: "text-sm text-gray-700 leading-relaxed", children: comment.description }), comment.edited && (_jsxs("p", { className: "text-xs text-info italic", children: ["(Edited ", Utils.Moment.formatDateAsLabel(comment.updatedAt), ")"] })), _jsxs("div", { className: "flex items-center gap-4 text-xs text-gray-500", children: [comment.account && currentAccountId === comment.account.id && (_jsxs("button", { type: "button", onClick: () => editComment(comment), className: "flex items-center gap-1 hover:text-info transition", children: [_jsx(Icon, { icon: "bitcoin-icons:edit-outline", className: "h-4 w-4" }), _jsx("span", { children: "Edit" })] })), _jsxs("button", { type: "button", onClick: () => replyOnComment(comment), className: "flex items-center gap-1 hover:text-success transition", children: [_jsx(Icon, { icon: "basil:reply-outline", className: "h-4 w-4" }), _jsx("span", { children: "Reply" })] }), comment.repliesCount > 0 && (_jsxs("button", { type: "button", onClick: () => setIsReplyListOpen((prev) => !prev), className: "flex items-center gap-1 hover:text-info transition", children: [_jsx(Icon, { icon: isReplyListOpen ? "mdi:chevron-up" : "mdi:chevron-down", className: "h-4 w-4" }), _jsxs("span", { children: [comment.repliesCount, " replies"] })] }))] })] })] }) }), comment.repliesCount !== 0 && isReplyListOpen && (_jsx("div", { className: "pl-4 mt-1", children: _jsx(CommentsList, { editComment: editComment, replyOnComment: replyOnComment, highlightCommentId: isHighlight ? comment.id : "", currentAccountId: currentAccountId, commentsBaseUrl: commentsBaseUrl, objectId: objectId, limit: limit, parentCommentId: comment.id }) }))] }));
20
- }
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import { DTO } from "sea-platform-helpers";
3
- type Props = {
4
- currentAccountId?: string;
5
- highlightCommentId?: string;
6
- editComment: (comment: DTO.Comment.IComment | undefined) => void;
7
- replyOnComment: (comment: DTO.Comment.IComment | undefined) => void;
8
- commentsBaseUrl: string;
9
- objectId: string;
10
- limit?: number;
11
- parentCommentId?: string;
12
- renderCommentItem?: (comment: DTO.Comment.IComment, commonProps: {
13
- currentAccountId?: string;
14
- editComment: (comment: DTO.Comment.IComment | undefined) => void;
15
- replyOnComment: (comment: DTO.Comment.IComment | undefined) => void;
16
- commentsBaseUrl: string;
17
- objectId: string;
18
- limit?: number;
19
- highlightCommentId?: string;
20
- }) => React.ReactNode;
21
- };
22
- export default function CommentsList({ currentAccountId, highlightCommentId, editComment, replyOnComment, commentsBaseUrl, objectId, parentCommentId, limit, renderCommentItem, }: Props): import("react/jsx-runtime").JSX.Element;
23
- export {};
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/comments-list/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAQ3C,KAAK,KAAK,GAAG;IACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IACjE,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAC7B,WAAW,EAAE;QACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACjE,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACpE,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,KACE,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,KAAU,EACV,iBAAiB,GAClB,EAAE,KAAK,2CAgGP"}
@@ -1,35 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEffect } from "react";
4
- import Skeleton from "../../skeleton";
5
- import CommentItem from "../comment-item";
6
- import Button from "../../button";
7
- import { useComments } from "../use-comments";
8
- import eventBus from "../comment-event-bus";
9
- import { COMMENT_EVENTS } from "../constants";
10
- import clsx from "clsx";
11
- export default function CommentsList({ currentAccountId, highlightCommentId, editComment, replyOnComment, commentsBaseUrl, objectId, parentCommentId, limit = 10, renderCommentItem, }) {
12
- const { comments, loading, totalCount, pushNewComment, updateComment, loadMoreComments, hasMoreComments, } = useComments({ commentsBaseUrl, objectId, limit, parentCommentId });
13
- const isReplyList = Boolean(parentCommentId);
14
- useEffect(() => {
15
- const handleNewComment = (data) => pushNewComment(data);
16
- const handleUpdateComment = (data) => updateComment(data);
17
- eventBus.on(COMMENT_EVENTS.NewComment, handleNewComment);
18
- eventBus.on(COMMENT_EVENTS.UpdateComment, handleUpdateComment);
19
- return () => {
20
- eventBus.off(COMMENT_EVENTS.NewComment, handleNewComment);
21
- eventBus.off(COMMENT_EVENTS.UpdateComment, handleUpdateComment);
22
- };
23
- }, []);
24
- return (_jsx("div", { className: clsx("flex flex-col", isReplyList ? "gap-2" : "gap-4"), children: comments.length === 0 && !loading ? (_jsx("p", { className: "text-gray-500 text-sm text-center py-4", children: "There are no comments yet" })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex flex-col gap-2", children: comments.map((comment) => renderCommentItem ? (renderCommentItem(comment, {
25
- currentAccountId,
26
- editComment,
27
- replyOnComment,
28
- commentsBaseUrl,
29
- objectId,
30
- limit,
31
- highlightCommentId,
32
- })) : (_jsx(CommentItem, { comment: comment, isHighlight: highlightCommentId === comment.id, currentAccountId: currentAccountId, editComment: editComment, replyOnComment: replyOnComment, commentsBaseUrl: commentsBaseUrl, objectId: objectId, limit: limit }, comment.id))) }), loading && (_jsx("div", { className: "flex flex-col gap-3", children: Array(3)
33
- .fill(null)
34
- .map((_, i) => (_jsx(Skeleton, { className: "h-20 w-full rounded-lg" }, `comment-loading-${i}`))) })), totalCount !== 0 && !isReplyList && (_jsxs("p", { className: "text-gray-500 text-xs text-right mt-1", children: ["Showing ", comments.length, " of ", totalCount, " comments"] })), hasMoreComments && !loading && (_jsx("div", { className: clsx("flex justify-center mt-2"), children: _jsx(Button, { type: "button", onClick: loadMoreComments, variant: "secondary", children: "Load More" }) }))] })) }));
35
- }
@@ -1,5 +0,0 @@
1
- export declare const COMMENT_EVENTS: {
2
- NewComment: string;
3
- UpdateComment: string;
4
- };
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/constants/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc;;;CAG1B,CAAC"}
@@ -1,5 +0,0 @@
1
- "use client";
2
- export const COMMENT_EVENTS = {
3
- NewComment: "NewComment",
4
- UpdateComment: "UpdateComment",
5
- };
@@ -1,17 +0,0 @@
1
- import { DTO } from "sea-platform-helpers";
2
- export declare function useComments({ commentsBaseUrl, objectId, limit, parentCommentId, }: {
3
- commentsBaseUrl: string;
4
- objectId: string;
5
- limit?: number;
6
- parentCommentId?: string;
7
- }): {
8
- comments: DTO.Comment.IComment[];
9
- loading: boolean;
10
- totalCount: number;
11
- totalPages: number;
12
- pushNewComment: (comment: DTO.Comment.IComment) => void;
13
- updateComment: (comment: DTO.Comment.IComment) => void;
14
- loadMoreComments: () => void;
15
- hasMoreComments: boolean;
16
- };
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/use-comments/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,WAAW,CAAC,EAC1B,eAAe,EACf,QAAQ,EACR,KAAU,EACV,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;;;;;8BA0CkC,GAAG,CAAC,OAAO,CAAC,QAAQ;6BAkBrB,GAAG,CAAC,OAAO,CAAC,QAAQ;;;EAkBrD"}
@@ -1,59 +0,0 @@
1
- "use client";
2
- import { useEffect, useState } from "react";
3
- import { Utils } from "sea-platform-helpers";
4
- import { authAxiosInstance } from "../../../utils/auth-axios";
5
- export function useComments({ commentsBaseUrl, objectId, limit = 10, parentCommentId, }) {
6
- const [loading, setLoading] = useState(false);
7
- const [page, setPage] = useState(1);
8
- const [totalCount, setTotalCount] = useState(0);
9
- const [totalPages, setTotalPages] = useState(1);
10
- const [comments, setComments] = useState([]);
11
- useEffect(() => {
12
- setLoading(true);
13
- const params = new URLSearchParams({
14
- page: String(page),
15
- limit: String(limit),
16
- objectId,
17
- ...(parentCommentId ? { parentCommentId } : {}),
18
- });
19
- authAxiosInstance
20
- .get(`${commentsBaseUrl}?${params.toString()}`)
21
- .then((response) => {
22
- const { data, totalCount: tc, totalPages: tp } = response.data;
23
- setTotalCount(tc);
24
- setTotalPages(tp);
25
- setComments((prev) => Utils.Array.concatWithoutDuplicates(prev, data, (a, b) => a.id === b.id));
26
- })
27
- .finally(() => {
28
- setLoading(false);
29
- });
30
- }, [commentsBaseUrl, limit, objectId, page]);
31
- const pushNewComment = (comment) => {
32
- setComments((prev) => {
33
- if (comment.isReply && !parentCommentId) {
34
- return prev.map((c) => c.id === comment.parentCommentId
35
- ? { ...c, repliesCount: c.repliesCount + 1 }
36
- : c);
37
- }
38
- else {
39
- return Utils.Array.concatWithoutDuplicates([comment], prev, (a, b) => a.id === b.id);
40
- }
41
- });
42
- };
43
- const updateComment = (comment) => {
44
- setComments((prev) => prev.map((c) => (c.id === comment.id ? comment : c)));
45
- };
46
- const loadMoreComments = () => {
47
- setPage((prev) => Math.min(prev + 1, totalPages));
48
- };
49
- return {
50
- comments,
51
- loading,
52
- totalCount,
53
- totalPages,
54
- pushNewComment,
55
- updateComment,
56
- loadMoreComments,
57
- hasMoreComments: totalCount !== comments.length,
58
- };
59
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-/index.tsx"],"names":[],"mappings":""}
File without changes