awing-library 2.1.13-beta → 2.1.13

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 (197) hide show
  1. package/README.md +4 -19
  2. package/lib/ACM-AXN/Campaign/Container.js +6 -7
  3. package/lib/ACM-AXN/Campaign/Container.test.js +1 -1
  4. package/lib/ACM-AXN/Campaign/CreateOrEdit/Recoils.d.ts +3 -1
  5. package/lib/ACM-AXN/Campaign/CreateOrEdit/Recoils.js +22 -21
  6. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabInfomation.d.ts +1 -1
  7. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabInfomation.js +79 -24
  8. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AdDetail.test.js +1 -1
  9. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AdList.js +50 -6
  10. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AdRow.d.ts +5 -0
  11. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AdRow.js +6 -18
  12. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AddOrEditRule/AddOrEditRule.js +7 -12
  13. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AddOrEditRule/RuleForm/RetargetMacAddress/container.d.ts +1 -0
  14. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/AddOrEditRule/RuleForm/RetargetMacAddress/container.js +4 -12
  15. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/Advanced.js +16 -1
  16. package/lib/ACM-AXN/Campaign/CreateOrEdit/TabSubCampaign/SubCampaignList.test.js +1 -1
  17. package/lib/ACM-AXN/Campaign/CreateOrEdit/index.js +19 -3
  18. package/lib/ACM-AXN/Campaign/Types.d.ts +10 -0
  19. package/lib/ACM-AXN/Campaign/Utils.d.ts +8 -0
  20. package/lib/ACM-AXN/Campaign/Utils.js +22 -18
  21. package/lib/ACM-AXN/Campaign/index.js +3 -2
  22. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/Filter.d.ts +2 -2
  23. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/Filter.js +44 -42
  24. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/GroupPanel.d.ts +1 -1
  25. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/GroupPanel.js +38 -30
  26. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/index.d.ts +2 -2
  27. package/lib/ACM-AXN/CampaignSchedule/Components/ControlPanel/index.js +2 -2
  28. package/lib/ACM-AXN/CampaignSchedule/Components/EnhancedPagination/index.d.ts +1 -1
  29. package/lib/ACM-AXN/CampaignSchedule/Components/EnhancedPagination/index.js +4 -2
  30. package/lib/ACM-AXN/CampaignSchedule/Components/RowAdvance/component.js +33 -3
  31. package/lib/ACM-AXN/CampaignSchedule/Components/RowAdvance/container.d.ts +1 -1
  32. package/lib/ACM-AXN/CampaignSchedule/Components/RowAdvance/container.js +81 -34
  33. package/lib/ACM-AXN/CampaignSchedule/Components/TableHeaderDragable.d.ts +1 -1
  34. package/lib/ACM-AXN/CampaignSchedule/Components/TableHeaderDragable.js +38 -29
  35. package/lib/ACM-AXN/CampaignSchedule/DataConfigAXN.d.ts +4 -0
  36. package/lib/ACM-AXN/CampaignSchedule/DataConfigAXN.js +58 -0
  37. package/lib/ACM-AXN/CampaignSchedule/Enum.d.ts +14 -2
  38. package/lib/ACM-AXN/CampaignSchedule/Enum.js +12 -0
  39. package/lib/ACM-AXN/CampaignSchedule/component.js +6 -5
  40. package/lib/ACM-AXN/CampaignSchedule/container.d.ts +1 -1
  41. package/lib/ACM-AXN/CampaignSchedule/container.js +100 -99
  42. package/lib/ACM-AXN/CampaignSchedule/interface.d.ts +16 -3
  43. package/lib/ACM-AXN/Directory/MenuDirectory/index.js +7 -21
  44. package/lib/ACM-AXN/Directory/SystemDirectory/index.js +6 -5
  45. package/lib/ACM-AXN/Directory/components/Permission/Management.js +7 -5
  46. package/lib/ACM-AXN/Directory/components/Permission/MenuPermissions/MenuPermissionManagement.js +9 -7
  47. package/lib/ACM-AXN/Directory/function.d.ts +1 -0
  48. package/lib/ACM-AXN/Directory/function.js +15 -1
  49. package/lib/ACM-AXN/DomainPreview/PreviewButton.d.ts +15 -0
  50. package/lib/ACM-AXN/DomainPreview/PreviewButton.js +188 -0
  51. package/lib/ACM-AXN/DomainPreview/index.d.ts +7 -0
  52. package/lib/ACM-AXN/DomainPreview/index.js +10 -0
  53. package/lib/ACM-AXN/GroupUser/Constants.d.ts +7 -0
  54. package/lib/ACM-AXN/GroupUser/Constants.js +10 -0
  55. package/lib/ACM-AXN/GroupUser/Container.d.ts +2 -0
  56. package/lib/ACM-AXN/GroupUser/Container.js +55 -0
  57. package/lib/ACM-AXN/GroupUser/Container.test.d.ts +1 -0
  58. package/lib/ACM-AXN/GroupUser/Container.test.js +210 -0
  59. package/lib/ACM-AXN/GroupUser/CreateOrEdit.d.ts +3 -0
  60. package/lib/ACM-AXN/GroupUser/CreateOrEdit.js +91 -0
  61. package/lib/ACM-AXN/GroupUser/CreateOrEdit.test.d.ts +1 -0
  62. package/lib/ACM-AXN/GroupUser/CreateOrEdit.test.js +235 -0
  63. package/lib/ACM-AXN/GroupUser/Hooks.d.ts +5 -0
  64. package/lib/ACM-AXN/GroupUser/Hooks.js +13 -0
  65. package/lib/ACM-AXN/GroupUser/Types.d.ts +31 -0
  66. package/lib/ACM-AXN/GroupUser/Types.js +2 -0
  67. package/lib/ACM-AXN/GroupUser/User/SearchUser.d.ts +9 -0
  68. package/lib/ACM-AXN/GroupUser/User/SearchUser.js +63 -0
  69. package/lib/ACM-AXN/GroupUser/User/SearchUser.test.d.ts +1 -0
  70. package/lib/ACM-AXN/GroupUser/User/SearchUser.test.js +140 -0
  71. package/lib/ACM-AXN/GroupUser/User/UserComponent.d.ts +8 -0
  72. package/lib/ACM-AXN/GroupUser/User/UserComponent.js +77 -0
  73. package/lib/ACM-AXN/GroupUser/User/UserComponent.test.d.ts +1 -0
  74. package/lib/ACM-AXN/GroupUser/User/UserComponent.test.js +128 -0
  75. package/lib/ACM-AXN/GroupUser/index.d.ts +4 -0
  76. package/lib/ACM-AXN/GroupUser/index.js +27 -0
  77. package/lib/ACM-AXN/Notifications/Constant.d.ts +146 -0
  78. package/lib/ACM-AXN/Notifications/Constant.js +136 -0
  79. package/lib/ACM-AXN/Notifications/Context.d.ts +8 -0
  80. package/lib/ACM-AXN/Notifications/Context.js +10 -0
  81. package/lib/ACM-AXN/Notifications/Hooks.d.ts +7 -0
  82. package/lib/ACM-AXN/Notifications/Hooks.js +17 -0
  83. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/ButtonTabs.d.ts +3 -3
  84. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/ButtonTabs.js +31 -30
  85. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/MenuNotification.d.ts +1 -1
  86. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/MenuNotification.js +30 -39
  87. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/index.d.ts +3 -5
  88. package/lib/ACM-AXN/Notifications/NotificationDetail/HeaderInfo/index.js +18 -17
  89. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationEmpty.d.ts +1 -1
  90. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationEmpty.js +15 -15
  91. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationEmpty.test.d.ts +0 -6
  92. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationEmpty.test.js +29 -28
  93. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/Message.d.ts +10 -0
  94. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/Message.js +393 -0
  95. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationAvatar.d.ts +1 -1
  96. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationAvatar.js +3 -3
  97. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationAvatar.test.d.ts +0 -6
  98. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationAvatar.test.js +38 -48
  99. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationContent.d.ts +2 -2
  100. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationContent.js +36 -35
  101. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationContent.test.d.ts +0 -6
  102. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/NotificationContent.test.js +65 -73
  103. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/index.d.ts +4 -11
  104. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/index.js +46 -36
  105. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/index.test.d.ts +0 -6
  106. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationItem/index.test.js +56 -50
  107. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/NotificationLoading.js +30 -30
  108. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/index.d.ts +3 -15
  109. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/index.js +35 -4
  110. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/index.test.d.ts +0 -6
  111. package/lib/ACM-AXN/Notifications/NotificationDetail/NotificationList/index.test.js +88 -83
  112. package/lib/ACM-AXN/Notifications/NotificationDetail/index.d.ts +5 -2
  113. package/lib/ACM-AXN/Notifications/NotificationDetail/index.js +115 -101
  114. package/lib/ACM-AXN/Notifications/{NotificationPopover.d.ts → NotificationPopover/Container.d.ts} +2 -2
  115. package/lib/ACM-AXN/Notifications/NotificationPopover/Container.js +149 -0
  116. package/lib/ACM-AXN/Notifications/{NotificationPopover.test.d.ts → NotificationPopover/Container.test.d.ts} +1 -1
  117. package/lib/ACM-AXN/Notifications/{NotificationPopover.test.js → NotificationPopover/Container.test.js} +5 -5
  118. package/lib/ACM-AXN/Notifications/NotificationPopover/index.d.ts +8 -0
  119. package/lib/ACM-AXN/Notifications/NotificationPopover/index.js +13 -0
  120. package/lib/ACM-AXN/Notifications/NotificationScreen.d.ts +1 -1
  121. package/lib/ACM-AXN/Notifications/NotificationScreen.js +4 -4
  122. package/lib/ACM-AXN/Notifications/Types.d.ts +242 -0
  123. package/lib/ACM-AXN/Notifications/Types.js +290 -0
  124. package/lib/ACM-AXN/Notifications/index.d.ts +2 -2
  125. package/lib/ACM-AXN/Notifications/index.js +5 -5
  126. package/lib/ACM-AXN/Page/Container.js +101 -63
  127. package/lib/ACM-AXN/Page/CreateOrEdit/DrawerAction.js +22 -5
  128. package/lib/ACM-AXN/Page/CreateOrEdit/Recoil.d.ts +1 -0
  129. package/lib/ACM-AXN/Page/CreateOrEdit/Recoil.js +5 -1
  130. package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/ViewContent.js +1 -1
  131. package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/ViewInfo.js +11 -4
  132. package/lib/ACM-AXN/Page/CreateOrEdit/Utils.js +1 -1
  133. package/lib/ACM-AXN/Page/Types.d.ts +9 -0
  134. package/lib/ACM-AXN/Page/index.js +2 -1
  135. package/lib/ACM-AXN/Permission/Components/Management.test.js +1 -1
  136. package/lib/ACM-AXN/PlaceGroup/Context.d.ts +1 -1
  137. package/lib/ACM-AXN/Statistics/ControlPanel.js +49 -47
  138. package/lib/ACM-AXN/Statistics/Enums.d.ts +1 -0
  139. package/lib/ACM-AXN/Statistics/Enums.js +1 -0
  140. package/lib/ACM-AXN/Statistics/container.js +1 -1
  141. package/lib/ACM-AXN/StatisticsAudienceDemographic/container.d.ts +1 -1
  142. package/lib/ACM-AXN/StatisticsAudienceDemographic/container.js +2 -3
  143. package/lib/ACM-AXN/StatisticsAudienceDemographic/interfaces.d.ts +1 -0
  144. package/lib/ACM-AXN/StatisticsByProvince/container.d.ts +1 -1
  145. package/lib/ACM-AXN/StatisticsByProvince/container.js +2 -2
  146. package/lib/ACM-AXN/TaskScheduler/Container.js +1 -1
  147. package/lib/ACM-AXN/TaskScheduler/CreateOrEdit.js +1 -1
  148. package/lib/ACM-AXN/TaskScheduler/Utils.js +2 -0
  149. package/lib/ACM-AXN/User/Add.d.ts +2 -0
  150. package/lib/ACM-AXN/User/Add.js +64 -0
  151. package/lib/ACM-AXN/User/Add.test.d.ts +1 -0
  152. package/lib/ACM-AXN/User/Add.test.js +115 -0
  153. package/lib/ACM-AXN/User/Constants.d.ts +2 -0
  154. package/lib/ACM-AXN/User/Constants.js +5 -0
  155. package/lib/ACM-AXN/User/Container.d.ts +2 -0
  156. package/lib/ACM-AXN/User/Container.js +60 -0
  157. package/lib/ACM-AXN/User/Container.test.d.ts +1 -0
  158. package/lib/ACM-AXN/User/Container.test.js +202 -0
  159. package/lib/ACM-AXN/User/Hook.d.ts +5 -0
  160. package/lib/ACM-AXN/User/Hook.js +13 -0
  161. package/lib/ACM-AXN/User/Types.d.ts +45 -0
  162. package/lib/ACM-AXN/User/Types.js +2 -0
  163. package/lib/ACM-AXN/User/index.d.ts +4 -0
  164. package/lib/ACM-AXN/User/index.js +18 -0
  165. package/lib/ACM-AXN/ViewTemplate/TemplateField/Fields/BasicField/index.js +1 -1
  166. package/lib/AWING/AdvancedSearch/component.js +1 -1
  167. package/lib/AWING/AdvancedSearch/interface.d.ts +1 -0
  168. package/lib/AWING/ButtonDateRangePicker/ButtonDateRangePicker.js +2 -2
  169. package/lib/AWING/ButtonDateRangePicker/interface.d.ts +1 -0
  170. package/lib/AWING/Chart/BarLineComponent.d.ts +1 -0
  171. package/lib/AWING/Chart/BarLineComponent.js +39 -24
  172. package/lib/AWING/Chart/PieComponent.d.ts +1 -1
  173. package/lib/AWING/Chart/PieComponent.js +0 -1
  174. package/lib/AWING/Chart/Styles.d.ts +6 -2
  175. package/lib/AWING/Chart/Styles.js +6 -2
  176. package/lib/AWING/Chart/index.d.ts +3 -0
  177. package/lib/AWING/Chart/index.js +10 -0
  178. package/lib/AWING/DataForm/DataInput.js +17 -8
  179. package/lib/AWING/DataForm/interface.d.ts +6 -2
  180. package/lib/AWING/DataGrid/index.js +20 -5
  181. package/lib/AWING/DataGrid/interface.d.ts +6 -1
  182. package/lib/AWING/Directory/CreateDirectory.d.ts +3 -0
  183. package/lib/AWING/Directory/CreateDirectory.js +27 -10
  184. package/lib/AWING/PageManagement/PageManagement.js +1 -1
  185. package/lib/AWING/index.d.ts +1 -0
  186. package/lib/AWING/index.js +1 -0
  187. package/lib/AWING/ultis/validation.d.ts +2 -2
  188. package/lib/AWING/ultis/validation.js +6 -4
  189. package/lib/Commons/Components/ClassicBaseDrawer.d.ts +1 -0
  190. package/lib/Commons/Components/ClassicBaseDrawer.js +7 -3
  191. package/lib/Commons/Components/ClassicDrawer.js +2 -2
  192. package/lib/translate/en/translation.json +81 -2
  193. package/lib/translate/vi/translation.json +81 -2
  194. package/package.json +4 -2
  195. package/lib/ACM-AXN/Notifications/NotificationDetail/Common.d.ts +0 -39
  196. package/lib/ACM-AXN/Notifications/NotificationDetail/Common.js +0 -304
  197. package/lib/ACM-AXN/Notifications/NotificationPopover.js +0 -69
@@ -1,84 +1,89 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- var jsx_runtime_1 = require("react/jsx-runtime");
18
- var react_1 = require("@testing-library/react");
19
- require("@testing-library/jest-dom");
20
- // Component
21
- var _1 = __importDefault(require("."));
22
- jest.mock('./NotificationItem', function () { return function (props) {
23
- var data = props.data, onUpdateStatus = props.onUpdateStatus;
24
- return ((0, jsx_runtime_1.jsx)("div", { "data-testid": "notification-item", onClick: function () { return onUpdateStatus(data.id); }, children: (0, jsx_runtime_1.jsx)("span", { children: data.content }) }));
25
- }; });
26
- jest.mock("./NotificationLoading", function () { return function () {
27
- return (0, jsx_runtime_1.jsx)("div", { children: "icon Loading" });
28
- }; });
29
- describe("NotificationList component", function () {
30
- it("Hiển thị thông báo đối với trường hợp 'notifications' chưa có dữ liệu", function () {
31
- var props = {
32
- isLoading: false,
33
- notifications: [],
34
- onUpdateStatus: function () { return null; },
35
- valueFilter: { textSearch: "", tabs: "" },
36
- };
37
- var getByText = (0, react_1.render)((0, jsx_runtime_1.jsx)(_1.default, __assign({}, props))).getByText;
38
- var noNotificationsText = getByText("Notifications.TitleNoNotifications");
39
- expect(noNotificationsText).toBeInTheDocument();
40
- });
41
- it("Hiện thị danh sách thông báo khi notifications có dữ liệu", function () {
42
- var props = {
43
- isLoading: false,
44
- notifications: [
45
- {
46
- id: "1",
47
- content: '<p>Chiến dịch <a href="https://github.com/dauquan1108" target="_blank" style="text-decoration: none; color: blue;" title="Đậu Xuân Quân">Đậu Xuân Quân</a> đã được cập nhật.</p>',
48
- url: "https://awing.vn/",
49
- status: true,
50
- userName: "Đậu Xuân Quân",
51
- avatarUrl: "https://i.pinimg.com/564x/7d/be/68/7dbe686677277a06de561b16c1e2740b.jpg",
52
- time: "2023-12-06 10:30",
53
- },
54
- ],
55
- onUpdateStatus: function () { return null; },
56
- valueFilter: { textSearch: "", tabs: "" },
57
- };
58
- var notifications = [
59
- {
60
- id: "1",
61
- content: '<p>Chiến dịch <a href="https://github.com/dauquan1108" target="_blank" style="text-decoration: none; color: blue;" title="Đậu Xuân Quân">Đậu Xuân Quân</a> đã được cập nhật.</p>',
62
- url: "https://awing.vn/",
63
- status: true,
64
- userName: "Đậu Xuân Quân",
65
- avatarUrl: "https://i.pinimg.com/564x/7d/be/68/7dbe686677277a06de561b16c1e2740b.jpg",
66
- time: "2023-12-06 10:30",
67
- },
68
- ];
69
- var getAllByTestId = (0, react_1.render)((0, jsx_runtime_1.jsx)(_1.default, { valueFilter: { textSearch: "", tabs: "" }, onUpdateStatus: function () { return null; }, isLoading: false, notifications: notifications })).getAllByTestId;
70
- var notificationItems = getAllByTestId('notification-item');
71
- expect(notificationItems).toHaveLength(notifications.length);
72
- });
73
- it("Hiển thị trạng thái Loading khi 'isLoading=true'.", function () {
74
- var props = {
75
- isLoading: true,
76
- notifications: [],
77
- onUpdateStatus: function () { return null; },
78
- valueFilter: { textSearch: "", tabs: "" },
79
- };
80
- var getByText = (0, react_1.render)((0, jsx_runtime_1.jsx)(_1.default, __assign({}, props))).getByText;
81
- var iconLoading = getByText("icon Loading");
82
- expect(iconLoading).toBeInTheDocument();
83
- });
84
- });
2
+ // /**
3
+ // *
4
+ // * @author dauquan1108@gmail.com on 12/7/2023.
5
+ // *
6
+ // **/
7
+ // import React from "react";
8
+ // import { render } from "@testing-library/react";
9
+ // import "@testing-library/jest-dom";
10
+ // // Component
11
+ // import NotificationList from ".";
12
+ // jest.mock('./NotificationItem', () => (props:any) => {
13
+ // const { data, onUpdateStatus } = props;
14
+ // return (
15
+ // <div data-testid="notification-item" onClick={() => onUpdateStatus(data.id)}>
16
+ // <span>{data.content}</span>
17
+ // </div>
18
+ // );
19
+ // });
20
+ // jest.mock("./NotificationLoading", () => () => {
21
+ // return <div>icon Loading</div>;
22
+ // });
23
+ // describe("NotificationList component", () => {
24
+ // it("Hiển thị thông báo đối với trường hợp 'notifications' chưa dữ liệu", () => {
25
+ // const props = {
26
+ // isLoading: false,
27
+ // notifications: [],
28
+ // onUpdateStatus: () => null,
29
+ // valueFilter: { textSearch: "", tabs: "" },
30
+ // };
31
+ // const { getByText } = render(<NotificationList {...props} />);
32
+ // const noNotificationsText = getByText("Notifications.TitleNoNotifications");
33
+ // expect(noNotificationsText).toBeInTheDocument();
34
+ // });
35
+ // it("Hiện thị danh sách thông báo khi notifications có dữ liệu", () => {
36
+ // const props = {
37
+ // isLoading: false,
38
+ // notifications: [
39
+ // {
40
+ // id: "1",
41
+ // content:
42
+ // '<p>Chiến dịch <a href="https://github.com/dauquan1108" target="_blank" style="text-decoration: none; color: blue;" title="Đậu Xuân Quân">Đậu Xuân Quân</a> đã được cập nhật.</p>',
43
+ // url: "https://awing.vn/",
44
+ // status: true,
45
+ // userName: "Đậu Xuân Quân",
46
+ // avatarUrl:
47
+ // "https://i.pinimg.com/564x/7d/be/68/7dbe686677277a06de561b16c1e2740b.jpg",
48
+ // time: "2023-12-06 10:30",
49
+ // },
50
+ // ],
51
+ // onUpdateStatus: () => null,
52
+ // valueFilter: { textSearch: "", tabs: "" },
53
+ // };
54
+ // const notifications = [
55
+ // {
56
+ // id: "1",
57
+ // content:
58
+ // '<p>Chiến dịch <a href="https://github.com/dauquan1108" target="_blank" style="text-decoration: none; color: blue;" title="Đậu Xuân Quân">Đậu Xuân Quân</a> đã được cập nhật.</p>',
59
+ // url: "https://awing.vn/",
60
+ // status: true,
61
+ // userName: "Đậu Xuân Quân",
62
+ // avatarUrl:
63
+ // "https://i.pinimg.com/564x/7d/be/68/7dbe686677277a06de561b16c1e2740b.jpg",
64
+ // time: "2023-12-06 10:30",
65
+ // },
66
+ // ];
67
+ // const { getAllByTestId } = render(
68
+ // <NotificationList
69
+ // valueFilter={{ textSearch: "", tabs: "" }}
70
+ // onUpdateStatus={() => null}
71
+ // isLoading={false}
72
+ // notifications={notifications}
73
+ // />
74
+ // );
75
+ // const notificationItems = getAllByTestId('notification-item');
76
+ // expect(notificationItems).toHaveLength(notifications.length);
77
+ // });
78
+ // it("Hiển thị trạng thái Loading khi 'isLoading=true'.", () => {
79
+ // const props = {
80
+ // isLoading: true,
81
+ // notifications: [],
82
+ // onUpdateStatus: () => null,
83
+ // valueFilter: { textSearch: "", tabs: "" },
84
+ // };
85
+ // const { getByText } = render(<NotificationList {...props} />);
86
+ // const iconLoading = getByText("icon Loading");
87
+ // expect(iconLoading).toBeInTheDocument();
88
+ // });
89
+ // });
@@ -3,6 +3,9 @@
3
3
  * @author dauquan1108@gmail.com on 11/27/2023.
4
4
  *
5
5
  **/
6
- import React from "react";
7
- declare const NotificationDetail: React.FC;
6
+ /// <reference types="react" />
7
+ interface NotificationDetailProps {
8
+ onClosePopover?: () => void;
9
+ }
10
+ declare const NotificationDetail: (props: NotificationDetailProps) => JSX.Element;
8
11
  export default NotificationDetail;
@@ -10,41 +10,37 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
21
35
  };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
37
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
38
+ if (ar || !(i in from)) {
39
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
40
+ ar[i] = from[i];
41
+ }
47
42
  }
43
+ return to.concat(ar || Array.prototype.slice.call(from));
48
44
  };
49
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -56,63 +52,30 @@ var jsx_runtime_1 = require("react/jsx-runtime");
56
52
  * @author dauquan1108@gmail.com on 11/27/2023.
57
53
  *
58
54
  **/
59
- var react_1 = __importDefault(require("react"));
55
+ var react_1 = __importStar(require("react"));
60
56
  var Box_1 = __importDefault(require("@mui/material/Box"));
57
+ var react_i18next_1 = require("react-i18next");
58
+ var i18n_1 = __importDefault(require("../../../i18n"));
61
59
  var HeaderInfo_1 = __importDefault(require("./HeaderInfo"));
60
+ var Constant_1 = require("../Constant");
61
+ var Hooks_1 = __importDefault(require("../Hooks"));
62
62
  var NotificationList_1 = __importDefault(require("./NotificationList"));
63
- var Common_1 = require("../NotificationDetail/Common");
64
- var NotificationDetail = function () {
65
- var _a = react_1.default.useState([]), notifications = _a[0], setNotifications = _a[1];
66
- var _b = react_1.default.useState({
67
- textSearch: "",
68
- tabs: Common_1.types.ALL,
69
- }), valueFilter = _b[0], setValueFilter = _b[1];
70
- var _c = react_1.default.useState(false), isLoading = _c[0], setIsLoading = _c[1];
71
- var handleCallApi = function (apiUrl) { return __awaiter(void 0, void 0, void 0, function () {
72
- var response, data, error_1;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0:
76
- if (isLoading) {
77
- return [2 /*return*/];
78
- }
79
- // Thực hiện Call API ở đoạn này và thêm 1 số ĐK nữa để xử lý trong đoạn code sau ("Chưa hoàn thành").
80
- // 1: Nếu gặp lỗi, data trả về rộng tắt trạng thái loading.
81
- setIsLoading(true);
82
- _a.label = 1;
83
- case 1:
84
- _a.trys.push([1, 4, 5, 6]);
85
- return [4 /*yield*/, fetch(apiUrl)];
86
- case 2:
87
- response = _a.sent();
88
- if (!response.ok) {
89
- throw new Error("HTTP error! Status: ".concat(response.status));
90
- }
91
- return [4 /*yield*/, response.json()];
92
- case 3:
93
- data = (_a.sent()) || [];
94
- setNotifications(data);
95
- return [3 /*break*/, 6];
96
- case 4:
97
- error_1 = _a.sent();
98
- console.error('Error fetching data:', error_1);
99
- return [3 /*break*/, 6];
100
- case 5:
101
- setIsLoading(false);
102
- return [7 /*endfinally*/];
103
- case 6: return [2 /*return*/];
104
- }
105
- });
106
- }); };
107
- var handleIntersection = react_1.default.useCallback(function (entries) {
108
- var firsEntry = entries[0];
109
- if (firsEntry.isIntersecting) {
110
- handleCallApi('https://run.mocky.io/v3/68ae1ad5-8e13-4d00-a8ef-134215e61978');
111
- }
112
- }, []);
113
- react_1.default.useEffect(function () {
63
+ var Types_1 = require("../Types");
64
+ var NotificationDetail = function (props) {
65
+ var service = (0, Hooks_1.default)().service;
66
+ var onClosePopover = props.onClosePopover;
67
+ var _a = (0, react_1.useState)({
68
+ textSearch: '',
69
+ tabs: Constant_1.Constants.ALL,
70
+ status: Constant_1.Constants.ALL_STATUS,
71
+ }), valueFilter = _a[0], setValueFilter = _a[1];
72
+ var _b = react_1.default.useState(false), isLoading = _b[0], setIsLoading = _b[1];
73
+ var _c = react_1.default.useState(-1), count = _c[0], setCount = _c[1];
74
+ var _d = (0, react_1.useState)([]), notificationMessage = _d[0], setNotificationMessage = _d[1];
75
+ var totalItemCount = (0, react_1.useRef)(0);
76
+ (0, react_1.useEffect)(function () {
114
77
  var observer = new IntersectionObserver(handleIntersection);
115
- var lastItem = document.getElementById("last-Item");
78
+ var lastItem = document.getElementById('last-Item');
116
79
  if (observer && lastItem) {
117
80
  setIsLoading(true);
118
81
  observer.observe(lastItem);
@@ -123,28 +86,79 @@ var NotificationDetail = function () {
123
86
  }
124
87
  };
125
88
  }, []);
126
- var handleValueFilter = react_1.default.useCallback(function (textSearch, tabs) {
127
- // Cập nhật từ khóa tìm kiếm và tabs
128
- setValueFilter({ textSearch: textSearch, tabs: tabs });
89
+ (0, react_1.useEffect)(function () {
90
+ if (count >= 0 &&
91
+ (totalItemCount.current > notificationMessage.length ||
92
+ notificationMessage.length === 0)) {
93
+ setIsLoading(true);
94
+ service
95
+ .notificationsPaging(count, Constant_1.Constants.PAGE_SIZE_DEFAULT, valueFilter.textSearch, valueFilter.status, [])
96
+ .then(function (res) {
97
+ setNotificationMessage(function (prevMessages) {
98
+ var newItems = res.items.filter(function (newItem) {
99
+ return !prevMessages.some(function (prevItem) { return prevItem.id === newItem.id; });
100
+ });
101
+ return __spreadArray(__spreadArray([], prevMessages, true), newItems, true);
102
+ });
103
+ totalItemCount.current = res.totalItemCount;
104
+ })
105
+ .finally(function () {
106
+ setIsLoading(false);
107
+ });
108
+ }
109
+ // eslint-disable-next-line react-hooks/exhaustive-deps
110
+ }, [count, valueFilter.textSearch, valueFilter.status]);
111
+ var handleIntersection = (0, react_1.useCallback)(function (entries) {
112
+ var firsEntry = entries[0];
113
+ if (firsEntry.isIntersecting) {
114
+ setCount(function (old) { return old + 1; });
115
+ }
129
116
  }, []);
130
- var handleUpdateStatus = react_1.default.useCallback(function (dataSent) {
131
- // Cập nhật trạng thái item trong notifications
132
- if (typeof dataSent === "string") {
133
- var isCheckStatus = notifications.some(function (item) { return item.status; });
117
+ var handleValueFilter = function (textSearch, tabs) {
118
+ textSearch.length === 0 ? setCount(0) : setCount(-1);
119
+ setNotificationMessage([]);
120
+ totalItemCount.current = 0;
121
+ setValueFilter({
122
+ textSearch: textSearch,
123
+ tabs: tabs,
124
+ status: tabs === Constant_1.Constants.ALL
125
+ ? Constant_1.Constants.ALL_STATUS
126
+ : Constant_1.Constants.UNREAD_STATUS,
127
+ });
128
+ };
129
+ var handleUpdateStatus = (0, react_1.useCallback)(function (dataSent) {
130
+ if (typeof dataSent === 'string') {
131
+ var isCheckStatus = notificationMessage.some(function (item) {
132
+ return item.status === Types_1.NotificationMessageStatus.Unread;
133
+ });
134
134
  if (isCheckStatus) {
135
- setNotifications(function (prevNotifications) {
136
- return prevNotifications.map(function (item) { return (__assign(__assign({}, item), { status: false })); });
135
+ service.notificationsReadAll().then(function () {
136
+ setNotificationMessage(function (prevNotifications) {
137
+ return prevNotifications.map(function (item) { return (__assign(__assign({}, item), { status: Types_1.NotificationMessageStatus.Read })); });
138
+ });
137
139
  });
138
140
  }
139
141
  }
140
142
  else {
141
- setNotifications(function (prevNotifications) {
142
- return prevNotifications.map(function (item) {
143
- return item.id === dataSent.id ? __assign(__assign({}, item), { status: !item.status }) : item;
143
+ var handleUpdateStatusItem_1 = function () {
144
+ setNotificationMessage(function (prevNotifications) {
145
+ return prevNotifications.map(function (item) { return (__assign(__assign({}, item), { status: item.id === dataSent.id
146
+ ? item.status ===
147
+ Types_1.NotificationMessageStatus.Read
148
+ ? Types_1.NotificationMessageStatus.Unread
149
+ : Types_1.NotificationMessageStatus.Read
150
+ : item.status })); });
151
+ });
152
+ };
153
+ dataSent.status === Types_1.NotificationMessageStatus.Unread
154
+ ? service.notificationsRead([dataSent.id]).then(function () {
155
+ handleUpdateStatusItem_1();
156
+ })
157
+ : service.notificationsUnread([dataSent.id]).then(function () {
158
+ handleUpdateStatusItem_1();
144
159
  });
145
- });
146
160
  }
147
- }, [notifications]);
148
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Box_1.default, { pt: 2, pl: 2, pr: 2, pb: 1, component: "div", children: (0, jsx_runtime_1.jsx)(HeaderInfo_1.default, { valueFilter: valueFilter, onValueFilter: handleValueFilter, onUpdateStatus: handleUpdateStatus }) }), (0, jsx_runtime_1.jsx)(Box_1.default, { pl: 1, pr: 1, pb: 1, component: "div", children: (0, jsx_runtime_1.jsx)(NotificationList_1.default, { isLoading: isLoading, valueFilter: valueFilter, notifications: notifications, onUpdateStatus: handleUpdateStatus }) }), (0, jsx_runtime_1.jsx)(Box_1.default, { id: "last-Item", component: "div" })] }));
161
+ }, [notificationMessage, service]);
162
+ return ((0, jsx_runtime_1.jsxs)(react_i18next_1.I18nextProvider, { i18n: i18n_1.default, children: [(0, jsx_runtime_1.jsx)(Box_1.default, { pt: 2, pl: 2, pr: 2, pb: 1, component: "div", children: (0, jsx_runtime_1.jsx)(HeaderInfo_1.default, { valueFilter: valueFilter, onClosePopover: onClosePopover, onValueFilter: handleValueFilter, onUpdateStatus: handleUpdateStatus }) }), (0, jsx_runtime_1.jsx)(Box_1.default, { pl: 1, pr: 1, pb: 1, component: "div", children: (0, jsx_runtime_1.jsx)(NotificationList_1.default, { isLoading: isLoading, valueFilter: valueFilter, notificationMessage: notificationMessage, onUpdateStatus: handleUpdateStatus }) }), (0, jsx_runtime_1.jsx)(Box_1.default, { id: "last-Item", component: "div", sx: { height: '20px' } })] }));
149
163
  };
150
164
  exports.default = NotificationDetail;
@@ -4,5 +4,5 @@
4
4
  *
5
5
  **/
6
6
  import React from 'react';
7
- declare const NotificationPopover: React.FC;
8
- export default NotificationPopover;
7
+ declare const Container: React.FC;
8
+ export default Container;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var jsx_runtime_1 = require("react/jsx-runtime");
43
+ /**
44
+ *
45
+ * @author dauquan1108@gmail.com on 12/1/2023.
46
+ *
47
+ **/
48
+ var react_1 = require("react");
49
+ var material_1 = require("@mui/material");
50
+ var Notifications_1 = __importDefault(require("@mui/icons-material/Notifications"));
51
+ var signalr_1 = require("@microsoft/signalr");
52
+ var Constant_1 = require("../Constant");
53
+ var Hooks_1 = __importDefault(require("../Hooks"));
54
+ var NotificationDetail_1 = __importDefault(require("../NotificationDetail"));
55
+ var Container = function () {
56
+ var service = (0, Hooks_1.default)().service;
57
+ var _a = (0, react_1.useState)(null), anchorEl = _a[0], setAnchorEl = _a[1];
58
+ var _b = (0, react_1.useState)(0), totalNotification = _b[0], setTotalNotification = _b[1];
59
+ var _c = (0, react_1.useState)(null), signalRConnection = _c[0], setSignalRConnection = _c[1];
60
+ (0, react_1.useEffect)(function () {
61
+ service.notificationsCountUnreadMessages().then(setTotalNotification);
62
+ setUpSignalRConnection().then(function (connection) { return __awaiter(void 0, void 0, void 0, function () {
63
+ return __generator(this, function (_a) {
64
+ setSignalRConnection(connection);
65
+ return [2 /*return*/];
66
+ });
67
+ }); });
68
+ return function () {
69
+ if (signalRConnection)
70
+ signalRConnection.stop();
71
+ };
72
+ // eslint-disable-next-line react-hooks/exhaustive-deps
73
+ }, []);
74
+ var setUpSignalRConnection = function () { return __awaiter(void 0, void 0, void 0, function () {
75
+ var connection, err_1;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ connection = new signalr_1.HubConnectionBuilder()
80
+ .withUrl("".concat(Constant_1.Constants.API_ENDPOINT, "/api/hubs/notification"))
81
+ .configureLogging(signalr_1.LogLevel.None)
82
+ .withAutomaticReconnect([0, 5000, 10000, 15000])
83
+ .build();
84
+ connection.on('ReceiveMessage', function (message) {
85
+ setTotalNotification(function (prev) { return prev + 1; });
86
+ });
87
+ _a.label = 1;
88
+ case 1:
89
+ _a.trys.push([1, 3, , 4]);
90
+ return [4 /*yield*/, connection.start()];
91
+ case 2:
92
+ _a.sent();
93
+ return [3 /*break*/, 4];
94
+ case 3:
95
+ err_1 = _a.sent();
96
+ console.log(err_1);
97
+ return [3 /*break*/, 4];
98
+ case 4: return [2 /*return*/, connection];
99
+ }
100
+ });
101
+ }); };
102
+ var handleClick = function (event) {
103
+ var href = window.location.href;
104
+ // nếu đang ở notifications thì click vào quả chuông sẽ không mở popover nữa.
105
+ if (!href.includes(Constant_1.Constants.NOTIFICATIONS_PATH)) {
106
+ setTotalNotification(0);
107
+ setAnchorEl(event.currentTarget);
108
+ }
109
+ };
110
+ var handleClose = function () {
111
+ setAnchorEl(null);
112
+ };
113
+ var open = Boolean(anchorEl);
114
+ var id = open ? 'simple-popover' : undefined;
115
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "div", children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-describedby": id, onClick: handleClick, sx: { backgroundColor: open ? '#F98D9C' : 'inherit' }, children: (0, jsx_runtime_1.jsx)(material_1.Badge, { badgeContent: totalNotification, color: "error", children: (0, jsx_runtime_1.jsx)(Notifications_1.default, { "data-testid": "notification-icon", sx: { color: open ? '#DD040C' : 'inherit' } }) }) }), (0, jsx_runtime_1.jsx)(material_1.Popover, { id: id, open: open, anchorEl: anchorEl, onClose: handleClose, sx: { zIndex: 1100 }, anchorOrigin: {
116
+ vertical: 'bottom',
117
+ horizontal: 'center',
118
+ }, transformOrigin: {
119
+ vertical: 'top',
120
+ horizontal: 'center',
121
+ }, PaperProps: {
122
+ style: {
123
+ borderRadius: '8px',
124
+ },
125
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { "data-testid": "popover", component: "div", sx: [
126
+ {
127
+ width: '400px',
128
+ overflowY: 'auto',
129
+ maxHeight: 'calc(90vh - 8px)',
130
+ },
131
+ {
132
+ '&::-webkit-scrollbar': {
133
+ width: '10px',
134
+ },
135
+ },
136
+ {
137
+ '&::-webkit-scrollbar-track': {
138
+ backgroundColor: '#f1f1f1',
139
+ },
140
+ },
141
+ {
142
+ '&::-webkit-scrollbar-thumb': {
143
+ borderRadius: '4px',
144
+ backgroundColor: '#c1c1c1',
145
+ },
146
+ },
147
+ ], children: (0, jsx_runtime_1.jsx)(NotificationDetail_1.default, { onClosePopover: handleClose }) }) })] }));
148
+ };
149
+ exports.default = Container;
@@ -3,4 +3,4 @@
3
3
  * @author dauquan1108@gmail.com on 12/7/2023.
4
4
  *
5
5
  **/
6
- import "@testing-library/jest-dom";
6
+ import '@testing-library/jest-dom';
@@ -7,11 +7,11 @@ var jsx_runtime_1 = require("react/jsx-runtime");
7
7
  require("@testing-library/jest-dom");
8
8
  var react_1 = require("@testing-library/react");
9
9
  // Component
10
- var NotificationPopover_1 = __importDefault(require("./NotificationPopover"));
11
- describe("NotificationPopover", function () {
12
- it("renders the component", function () {
13
- var getByTestId = (0, react_1.render)((0, jsx_runtime_1.jsx)(NotificationPopover_1.default, {})).getByTestId;
14
- var notificationsIcon = getByTestId("notification-icon");
10
+ var Container_1 = __importDefault(require("./Container"));
11
+ describe('NotificationPopover', function () {
12
+ it('renders the component', function () {
13
+ var getByTestId = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.default, {})).getByTestId;
14
+ var notificationsIcon = getByTestId('notification-icon');
15
15
  expect(notificationsIcon).toBeInTheDocument();
16
16
  });
17
17
  // it("Mở dao diện 'NotificationPopover' khi click vào quả chuông.", async () => {