oa-componentbook 1.0.1-stage.41 → 1.0.1-stage.411

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 (137) hide show
  1. package/build/components/oa-component-accordion/Accordion.js +129 -40
  2. package/build/components/oa-component-accordion/styles.js +2 -2
  3. package/build/components/oa-component-button/CustomButton.js +24 -19
  4. package/build/components/oa-component-button/styles.js +1 -1
  5. package/build/components/oa-component-checkbox/CustomCheckBox.js +20 -17
  6. package/build/components/oa-component-checkbox/styles.js +1 -1
  7. package/build/components/oa-component-datepicker/CustomDatePicker.js +37 -26
  8. package/build/components/oa-component-drawer/CustomDrawer.js +2 -0
  9. package/build/components/oa-component-dropdown/CustomDropdown.js +16 -4
  10. package/build/components/oa-component-icons/MaterialIcon.js +1 -1
  11. package/build/components/oa-component-info/CustomInfo.js +9 -4
  12. package/build/components/oa-component-info/styles.js +3 -3
  13. package/build/components/oa-component-modal/CustomModal.js +51 -46
  14. package/build/components/oa-component-modal/styles.js +3 -2
  15. package/build/components/oa-component-pagination/CustomPagination.js +111 -0
  16. package/build/components/oa-component-pagination/styles.js +12 -0
  17. package/build/components/oa-component-select/CustomSelect.js +116 -56
  18. package/build/components/oa-component-steps/CustomSteps.js +117 -0
  19. package/build/components/oa-component-steps/styles.js +12 -0
  20. package/build/components/oa-component-table/CustomTable.js +28 -5
  21. package/build/components/oa-component-table/CustomTableV1.js +610 -0
  22. package/build/components/oa-component-table/styles.js +1 -1
  23. package/build/components/oa-component-table/stylesV1.js +19 -0
  24. package/build/components/oa-component-tabs/CustomTabs.js +1 -1
  25. package/build/components/oa-component-tag/CustomTag.js +29 -11
  26. package/build/components/oa-component-tag/styles.js +30 -3
  27. package/build/components/oa-component-textarea/{TextArea.js → CustomTextArea.js} +4 -4
  28. package/build/components/oa-component-tooltip/CustomTooltip.js +8 -4
  29. package/build/components/oa-component-upload/CustomUpload.js +120 -40
  30. package/build/components/oa-component-viewer/CustomViewer.js +3 -1
  31. package/build/dev/oa-component-document-viewer/CustomDocumentViewer.js +367 -0
  32. package/build/dev/oa-component-document-viewer/styles.js +12 -0
  33. package/build/dev/oa-component-upload/CustomUpload.js +3 -0
  34. package/build/dev/oa-widget-document-modal/DocumentSideModal.js +166 -0
  35. package/build/dev/oa-widget-document-modal/styles.js +12 -0
  36. package/build/dev/oa-widget-document-side-drawer/DocumentSideDrawer.js +196 -0
  37. package/build/dev/oa-widget-document-side-drawer/styles.js +12 -0
  38. package/build/global-css/GlobalCss.js +2 -1
  39. package/build/global-css/GridLayout.js +1 -1
  40. package/build/global-css/commonStyles.js +11 -0
  41. package/build/images/Car.png +0 -0
  42. package/build/images/TwoWheeler.png +0 -0
  43. package/build/images/astronaut_emptystate.png +0 -0
  44. package/build/images/exportGrp01.png +0 -0
  45. package/build/images/exportGrp02.png +0 -0
  46. package/build/images/exportGrp03.png +0 -0
  47. package/build/images/outOfStock.png +0 -0
  48. package/build/index.js +110 -5
  49. package/build/layout/DetailDataLayout/DetailDataLayout.js +20 -0
  50. package/build/layout/DetailDataLayout/components/Form.js +22 -0
  51. package/build/layout/DetailDataLayout/components/Header.js +32 -0
  52. package/build/layout/DetailDataLayout/style.css +9 -0
  53. package/build/layout/DetailDataLayout/styles.js +12 -0
  54. package/build/layout/EntityOverviewLayout/EntityOverviewLayout.js +262 -0
  55. package/build/layout/EntityOverviewLayout/reducer/entityOverviewLayoutReducer.js +68 -0
  56. package/build/layout/EntityOverviewLayout/styles.js +13 -0
  57. package/build/layout/GenricLayOut/GenricLayOut.js +2381 -0
  58. package/build/layout/GenricLayOut/components/AppliedFilters.js +90 -0
  59. package/build/layout/GenricLayOut/components/CardList.js +34 -0
  60. package/build/layout/GenricLayOut/components/DropdownSearch.js +48 -0
  61. package/build/layout/GenricLayOut/components/Header.js +74 -0
  62. package/build/layout/GenricLayOut/components/Modal.js +95 -0
  63. package/build/layout/GenricLayOut/components/ProfileSection.js +219 -0
  64. package/build/layout/GenricLayOut/components/Search.js +51 -0
  65. package/build/layout/GenricLayOut/components/StaticFilter.css +73 -0
  66. package/build/layout/GenricLayOut/components/StaticFilter.js +37 -0
  67. package/build/layout/GenricLayOut/reducer/layoutReducer.js +306 -0
  68. package/build/layout/GenricLayOut/resolver/staticConfigResolver.js +98 -0
  69. package/build/layout/GenricLayOut/styles.js +42 -0
  70. package/build/utils/download-file.js +23 -0
  71. package/build/widgets/oa-form-widget/FormWidget.js +576 -0
  72. package/build/widgets/oa-form-widget/FormWidgetStyle.js +18 -0
  73. package/build/widgets/oa-widget-add-spare-part/AddSparePartCollapseWidget.js +80 -16
  74. package/build/widgets/oa-widget-add-spare-part/AddSparePartWidget.js +50 -7
  75. package/build/widgets/oa-widget-address/AddressWidget.js +12 -17
  76. package/build/widgets/oa-widget-approval/ApprovalWidget.js +19 -11
  77. package/build/widgets/oa-widget-approval/ApprovalWidgetNew.js +492 -0
  78. package/build/widgets/oa-widget-approval/styles.js +2 -2
  79. package/build/widgets/oa-widget-chat/ChatWidget.js +5 -5
  80. package/build/widgets/oa-widget-close-claim/CloseClaimWidget.js +17 -5
  81. package/build/widgets/oa-widget-collapsible-key-value/CollapsibleKeyValueWidget.js +396 -0
  82. package/build/widgets/oa-widget-collapsible-key-value/styles.js +16 -0
  83. package/build/widgets/oa-widget-content-panel/ContentPanel.js +82 -0
  84. package/build/widgets/oa-widget-content-panel/styles.js +12 -0
  85. package/build/widgets/oa-widget-customer-rating-card/CustomerRatingCard.js +5 -5
  86. package/build/widgets/oa-widget-detailcard/styles.js +1 -1
  87. package/build/widgets/oa-widget-document-upload/DocUploadWidget.js +6 -9
  88. package/build/widgets/oa-widget-dropdown-search-input/DropdownSearchInput.js +53 -19
  89. package/build/widgets/oa-widget-dropdown-search-input/styles.js +1 -1
  90. package/build/widgets/oa-widget-guide/GuideWidget.js +70 -0
  91. package/build/widgets/oa-widget-guide/GuideWidgetStyle.js +12 -0
  92. package/build/widgets/oa-widget-hub-automation-modal/HubAutomationDeleteBiker.js +24 -0
  93. package/build/widgets/oa-widget-hub-automation-modal/HubAutomationModal.js +34 -0
  94. package/build/widgets/oa-widget-hub-automation-modal/HubAutomationModalStyle.js +13 -0
  95. package/build/widgets/oa-widget-image-carousel/ImageCarouselWidget.js +101 -69
  96. package/build/widgets/oa-widget-image-carousel/styles.js +16 -5
  97. package/build/widgets/oa-widget-image-gallery/FullscreenViewer.js +169 -0
  98. package/build/widgets/oa-widget-image-gallery/ImageGallery.js +87 -0
  99. package/build/widgets/oa-widget-image-gallery/ThumbnailGrid.js +146 -0
  100. package/build/widgets/oa-widget-image-gallery/imageCache.js +15 -0
  101. package/build/widgets/oa-widget-image-gallery/imageGalleryStyle.js +16 -0
  102. package/build/widgets/oa-widget-item-info-card/InfoCardListWidget.js +60 -0
  103. package/build/widgets/oa-widget-item-info-card/ItemInfoCardWidget.js +83 -0
  104. package/build/widgets/oa-widget-item-info-card/styles.css +50 -0
  105. package/build/widgets/oa-widget-item-info-card/styles.js +14 -0
  106. package/build/widgets/oa-widget-key-value/KeyValueWidget.js +46 -12
  107. package/build/widgets/oa-widget-key-value/styles.js +1 -1
  108. package/build/widgets/oa-widget-kpi/KPICardWidget.js +86 -0
  109. package/build/widgets/oa-widget-kpi/styles.js +12 -0
  110. package/build/widgets/oa-widget-map-base-location/AddressDetails.js +21 -7
  111. package/build/widgets/oa-widget-map-base-location/AddressForm.js +32 -5
  112. package/build/widgets/oa-widget-map-base-location/MapBaseLocation.js +9 -3
  113. package/build/widgets/oa-widget-map-base-location/MapComponent.js +17 -2
  114. package/build/widgets/oa-widget-membershipcard/MembershipCard.js +14 -3
  115. package/build/widgets/oa-widget-membershipcard/styles.js +1 -1
  116. package/build/widgets/oa-widget-notes/NotesWidget.js +32 -30
  117. package/build/widgets/oa-widget-notes/styles.js +4 -3
  118. package/build/widgets/oa-widget-profile-data/ProfileDataWidget.js +165 -0
  119. package/build/widgets/oa-widget-profile-data/styles.js +13 -0
  120. package/build/widgets/oa-widget-progressive-steps/ProgressiveStepsWidget.js +362 -0
  121. package/build/widgets/oa-widget-progressive-steps/styles.js +12 -0
  122. package/build/widgets/oa-widget-reimbursement-breakup/ReimbursementBreakupWidget.js +18 -9
  123. package/build/widgets/oa-widget-reimbursement-breakup/styles.js +1 -1
  124. package/build/widgets/oa-widget-reupload-drawer/ReUploadDrawer.js +164 -0
  125. package/build/widgets/oa-widget-select-list-item-modal/SelectListItemModal.js +91 -0
  126. package/build/widgets/oa-widget-sidebar/SidebarWidget.js +175 -0
  127. package/build/widgets/oa-widget-sidebar/components/Header.js +33 -0
  128. package/build/widgets/oa-widget-sidebar/styles.js +13 -0
  129. package/build/widgets/oa-widget-spare-part/SparePartsWidget.js +63 -35
  130. package/build/widgets/oa-widget-track-shipment/TrackShipmentWidget.js +28 -6
  131. package/build/widgets/oa-widget-track-shipment-list/TrackShipmentWidgetList.js +103 -0
  132. package/build/widgets/oa-widget-track-shipment-list/fn.js +81 -0
  133. package/build/widgets/oa-widget-user-management/UserManagementWidget.js +352 -0
  134. package/build/widgets/oa-widget-user-management/styles.js +15 -0
  135. package/package.json +3 -1
  136. package/build/dev/oa-widget-track-shipment/TrackShipmentWidget.js +0 -195
  137. /package/build/{dev/oa-widget-track-shipment → widgets/oa-widget-track-shipment-list}/styles.js +0 -0
@@ -0,0 +1,2381 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.weak-map.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/es.promise.js");
10
+ require("core-js/modules/es.string.trim.js");
11
+ require("core-js/modules/es.symbol.description.js");
12
+ require("core-js/modules/es.object.assign.js");
13
+ var _react = _interopRequireWildcard(require("react"));
14
+ var _layoutReducer = require("./reducer/layoutReducer");
15
+ var _GlobalCss = _interopRequireDefault(require("../../global-css/GlobalCss"));
16
+ var _SidebarWidget = _interopRequireDefault(require("../../widgets/oa-widget-sidebar/SidebarWidget"));
17
+ var _CardList = _interopRequireDefault(require("./components/CardList"));
18
+ var _DropdownSearch = _interopRequireDefault(require("./components/DropdownSearch"));
19
+ var _Header = _interopRequireDefault(require("./components/Header"));
20
+ var _Search = _interopRequireDefault(require("./components/Search"));
21
+ var _staticConfigResolver = _interopRequireWildcard(require("./resolver/staticConfigResolver"));
22
+ var _CustomTableV = _interopRequireDefault(require("../../components/oa-component-table/CustomTableV1"));
23
+ var _CustomDrawer = _interopRequireDefault(require("../../components/oa-component-drawer/CustomDrawer"));
24
+ var _DetailDataLayout = _interopRequireDefault(require("../DetailDataLayout/DetailDataLayout"));
25
+ var _CustomTabs = _interopRequireDefault(require("../../components/oa-component-tabs/CustomTabs"));
26
+ var _CustomNotification = _interopRequireDefault(require("../../components/oa-component-notification/CustomNotification"));
27
+ var _ContentPanel = _interopRequireDefault(require("../../widgets/oa-widget-content-panel/ContentPanel"));
28
+ var _styles = require("./styles");
29
+ var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
30
+ var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
31
+ var _MaterialIcon = _interopRequireDefault(require("../../components/oa-component-icons/MaterialIcon"));
32
+ var _Modal = _interopRequireDefault(require("./components/Modal"));
33
+ var _antd = require("antd");
34
+ var _astronaut_emptystate = _interopRequireDefault(require("../../images/astronaut_emptystate.png"));
35
+ var _CustomViewer = _interopRequireDefault(require("../../components/oa-component-viewer/CustomViewer"));
36
+ var _StaticFilter = _interopRequireDefault(require("./components/StaticFilter"));
37
+ var _downloadFile = _interopRequireDefault(require("../../utils/download-file"));
38
+ var _AppliedFilters = _interopRequireDefault(require("./components/AppliedFilters"));
39
+ var _ProfileSection = _interopRequireDefault(require("./components/ProfileSection"));
40
+ var _FilterListRounded = _interopRequireDefault(require("@material-ui/icons/FilterListRounded"));
41
+ var _CustomInfo = _interopRequireDefault(require("../../components/oa-component-info/CustomInfo"));
42
+ const _excluded = ["filteredValue"],
43
+ _excluded2 = ["sortOrder"];
44
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
47
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
48
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
49
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
50
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
51
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
52
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
54
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable */
55
+ function GenricLayOut(_ref) {
56
+ var _state$misc29, _sidebar$mobileMenuIt, _imageViewer$content, _imageViewer$content2, _leftHeaderFirstButto, _leftHeaderFirstButto2, _infoPanel$data, _infoPanel$data2, _infoPanel$data3, _infoPanel$data4, _infoPanel$data5, _state$customDrawer3, _state$customDrawer4, _tabs$list, _tables$columns3, _tables$columns4, _tabs$active3, _state$tables4, _tables$selectionType, _tabs$active4, _tables$selectionType2, _tables$pagination17, _drawer$data, _tabs$active5, _drawer$data$drawer$a, _drawer$data2, _tabs$active6, _tabs$active7, _nestedDrawer$data, _nestedDrawer$data$ca, _nestedDrawer$data2, _customDrawer$data, _customDrawer$data2, _contentPanel$dataSou, _tables$tableFooter, _tables$selectedRowKe, _tables$tableFooter2, _tables$tableFooter3, _tables$tableFooter5;
57
+ let {
58
+ config,
59
+ getInitialData,
60
+ generateS3Url,
61
+ uploadOnS3,
62
+ handlers: {
63
+ handleTabClick,
64
+ handleFooterClick,
65
+ handleTableChange,
66
+ handleDropdownSearchInputChange,
67
+ handleDropdownSearchOptionChange,
68
+ handleTableColumnClick,
69
+ handleSecondaryTableCTAClick,
70
+ handleDropdownSearchEnter,
71
+ handleDropdownSearchClear,
72
+ handleInputSearchChange,
73
+ handleInputSearchEnter,
74
+ handleInputSearchClear,
75
+ handleDrawerFormOnFinish,
76
+ downloadFileOnS3,
77
+ handleModalDataSet,
78
+ handleActionOnTableCTAClick,
79
+ handleModalCloseSuccess,
80
+ handleSubHeadingSelectClick,
81
+ handleCollapsibleKeyData,
82
+ handleProfileReroute,
83
+ handleTableFooterApi,
84
+ handleSwitchSelectItem
85
+ } = {}
86
+ } = _ref;
87
+ const [state, dispatch] = (0, _react.useReducer)(_layoutReducer.genericLayoutReducer, config !== null && config !== void 0 ? config : _layoutReducer.initialState);
88
+ const [headerButtons, setHeaderButtons] = (0, _react.useState)(null);
89
+ const stateRef = (0, _react.useRef)(state);
90
+ const notificationRef = (0, _react.useRef)(null);
91
+ const openNotification = (0, _react.useCallback)(params => notificationRef.current.openNotification(params), []);
92
+ const {
93
+ header,
94
+ cards,
95
+ sidebar,
96
+ dropdownSearch,
97
+ inputSearch,
98
+ tables,
99
+ drawer,
100
+ tabs,
101
+ contentPanel,
102
+ nestedDrawer,
103
+ modal,
104
+ leftHeaderFirstButton,
105
+ rightHeaderFirstButton,
106
+ rightHeaderSecondButton,
107
+ imageViewer,
108
+ customDrawer,
109
+ staticFilter,
110
+ profileData,
111
+ infoPanel
112
+ } = state !== null && state !== void 0 ? state : {};
113
+ (0, _react.useEffect)(() => {
114
+ init();
115
+ }, []);
116
+ (0, _react.useEffect)(() => {
117
+ stateRef.current = state;
118
+ }, [state]);
119
+ (0, _react.useEffect)(() => {
120
+ const observer = new MutationObserver(e => {
121
+ const parent = document.querySelector(".oaheaderButtons");
122
+ if (parent) {
123
+ var _parent$children;
124
+ setHeaderButtons(parent);
125
+ if ((parent === null || parent === void 0 || (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.length) === 1) {
126
+ parent.classList.add("single-child");
127
+ }
128
+ }
129
+ });
130
+ observer.observe(document.body, {
131
+ childList: true,
132
+ subtree: true
133
+ });
134
+ return () => {
135
+ observer.disconnect();
136
+ };
137
+ }, [headerButtons]);
138
+
139
+ // Check for notification data after component mounts (after reload)
140
+ (0, _react.useEffect)(() => {
141
+ const notificationData = sessionStorage.getItem("showEnterpriseNotification");
142
+ if (notificationData) {
143
+ try {
144
+ const {
145
+ message
146
+ } = JSON.parse(notificationData);
147
+ showSuccessNotification(message);
148
+ sessionStorage.removeItem("showEnterpriseNotification");
149
+ } catch (error) {
150
+ console.error("Error parsing notification data:", error);
151
+ sessionStorage.removeItem("showEnterpriseNotification");
152
+ }
153
+ }
154
+ }, []);
155
+
156
+ /**
157
+ * Initializes the layout by fetching initial data and updating the state.
158
+ *
159
+ * If `getInitialData` is provided, it fetches data using the currently active tab and any additional state information.
160
+ * On error, it shows an error notification and sets the table to empty.
161
+ * On success, it replaces variables in the config with the fetched data and initializes the state.
162
+ */
163
+
164
+ const init = async () => {
165
+ dispatch({
166
+ type: _layoutReducer.actionTypes.SET_LOADING,
167
+ payload: true
168
+ });
169
+ if (getInitialData) {
170
+ var _config$tabs, _config$misc;
171
+ const {
172
+ error,
173
+ data
174
+ } = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread(_objectSpread({}, config !== null && config !== void 0 && (_config$tabs = config.tabs) !== null && _config$tabs !== void 0 && _config$tabs.active ? {
175
+ selectedTab: config.tabs.active
176
+ } : {}), (_config$misc = config === null || config === void 0 ? void 0 : config.misc) !== null && _config$misc !== void 0 ? _config$misc : {})));
177
+ if (error) {
178
+ showErrorNotification(error);
179
+ const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
180
+ dispatch({
181
+ type: _layoutReducer.actionTypes.INIT,
182
+ payload: dynamicConfig
183
+ });
184
+ dispatch({
185
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
186
+ });
187
+ } else {
188
+ const dynamicConfig = (0, _staticConfigResolver.default)(config, data !== null && data !== void 0 ? data : {});
189
+ dispatch({
190
+ type: _layoutReducer.actionTypes.INIT,
191
+ payload: dynamicConfig
192
+ });
193
+ }
194
+ }
195
+ dispatch({
196
+ type: _layoutReducer.actionTypes.SET_LOADING,
197
+ payload: false
198
+ });
199
+ };
200
+
201
+ /**
202
+ * Shows an error notification.
203
+ *
204
+ * @param {string} message - Error message to show in the notification.
205
+ *
206
+ * @returns {void}
207
+ */
208
+ const showErrorNotification = message => {
209
+ openNotification({
210
+ description: message,
211
+ type: "failure",
212
+ mode: "dark",
213
+ showIcon: true,
214
+ placement: "bottomRight"
215
+ });
216
+ };
217
+
218
+ /**
219
+ * Shows a success notification.
220
+ *
221
+ * @param {string} message - Message to show in the notification.
222
+ *
223
+ * @returns {void}
224
+ */
225
+ const showSuccessNotification = message => {
226
+ openNotification({
227
+ description: message,
228
+ type: "success",
229
+ mode: "dark",
230
+ showIcon: true,
231
+ placement: "bottomRight"
232
+ });
233
+ };
234
+ const setStaticFilterData = data => {
235
+ var _staticFilter$data$fi, _config$staticFilter, _staticFilter$data;
236
+ const selectedKey = staticFilter === null || staticFilter === void 0 || (_staticFilter$data$fi = staticFilter.data.find(item => item.selected)) === null || _staticFilter$data$fi === void 0 ? void 0 : _staticFilter$data$fi.value;
237
+ const dynamicConfig = (0, _staticConfigResolver.default)(config === null || config === void 0 || (_config$staticFilter = config.staticFilter) === null || _config$staticFilter === void 0 ? void 0 : _config$staticFilter.data, data !== null && data !== void 0 ? data : {});
238
+ const storePreviousFilters = staticFilter === null || staticFilter === void 0 || (_staticFilter$data = staticFilter.data) === null || _staticFilter$data === void 0 ? void 0 : _staticFilter$data.map((filter, idx) => {
239
+ var _dynamicConfig$idx;
240
+ return _objectSpread(_objectSpread({}, filter), {}, {
241
+ label: (dynamicConfig === null || dynamicConfig === void 0 || (_dynamicConfig$idx = dynamicConfig[idx]) === null || _dynamicConfig$idx === void 0 ? void 0 : _dynamicConfig$idx.label) || filter.label
242
+ });
243
+ });
244
+ dispatch({
245
+ type: _layoutReducer.actionTypes.SET_STATIC_FILTER,
246
+ payload: storePreviousFilters
247
+ });
248
+ dispatch({
249
+ type: _layoutReducer.actionTypes.SET_STATIC_FILTER_SELECTION,
250
+ payload: selectedKey
251
+ });
252
+ };
253
+
254
+ /**
255
+ * Handles the change of the search input value.
256
+ *
257
+ * Updates the `inputSearchValue` state with the new search input value,
258
+ * and if the value is empty, calls the `handleInputSearchChange` callback
259
+ * with the current selected tab and pagination state.
260
+ *
261
+ * @param {{ target: { value: string } }} e - The change event.
262
+ *
263
+ * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
264
+ */
265
+ const onSearchInputChange = async _ref2 => {
266
+ let {
267
+ target: {
268
+ value
269
+ }
270
+ } = _ref2;
271
+ dispatch({
272
+ type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_VALUE,
273
+ payload: value
274
+ });
275
+ if (value === "") {
276
+ if (handleInputSearchChange) {
277
+ var _state$inputSearch, _state$tabs, _customDrawer$applied, _config$tables, _config$tables2, _tables$sorting, _tables$sorting2, _header$subHeading, _header$subHeading2, _state$misc;
278
+ dispatch({
279
+ type: _layoutReducer.actionTypes.SET_LOADING,
280
+ payload: true
281
+ });
282
+ const {
283
+ error,
284
+ data
285
+ } = await handleInputSearchChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, state === null || state === void 0 || (_state$inputSearch = state.inputSearch) === null || _state$inputSearch === void 0 ? void 0 : _state$inputSearch.request), state !== null && state !== void 0 && (_state$tabs = state.tabs) !== null && _state$tabs !== void 0 && _state$tabs.active ? {
286
+ selectedTab: state.tabs.active
287
+ } : {}), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied !== void 0 ? _customDrawer$applied : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), {}, {
288
+ current: config === null || config === void 0 || (_config$tables = config.tables) === null || _config$tables === void 0 || (_config$tables = _config$tables.pagination) === null || _config$tables === void 0 ? void 0 : _config$tables.current,
289
+ pageSize: config === null || config === void 0 || (_config$tables2 = config.tables) === null || _config$tables2 === void 0 || (_config$tables2 = _config$tables2.pagination) === null || _config$tables2 === void 0 ? void 0 : _config$tables2.pageSize,
290
+ field: tables === null || tables === void 0 || (_tables$sorting = tables.sorting) === null || _tables$sorting === void 0 ? void 0 : _tables$sorting.sortBy,
291
+ order: tables === null || tables === void 0 || (_tables$sorting2 = tables.sorting) === null || _tables$sorting2 === void 0 ? void 0 : _tables$sorting2.sortDirection
292
+ }, (header === null || header === void 0 || (_header$subHeading = header.subHeading) === null || _header$subHeading === void 0 || (_header$subHeading = _header$subHeading.jsxConfig) === null || _header$subHeading === void 0 ? void 0 : _header$subHeading.type) == "select" ? {
293
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading2 = header.subHeading) === null || _header$subHeading2 === void 0 || (_header$subHeading2 = _header$subHeading2.jsxConfig) === null || _header$subHeading2 === void 0 ? void 0 : _header$subHeading2.value
294
+ } : {}), (_state$misc = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc !== void 0 ? _state$misc : {}));
295
+ if (error) {
296
+ showErrorNotification(error);
297
+ dispatch({
298
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
299
+ });
300
+ } else {
301
+ var _config$tables3, _config$tables4;
302
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
303
+ setStaticFilterData(data);
304
+ }
305
+ dispatch({
306
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
307
+ payload: data
308
+ });
309
+ dispatch({
310
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
311
+ payload: {
312
+ current: config === null || config === void 0 || (_config$tables3 = config.tables) === null || _config$tables3 === void 0 || (_config$tables3 = _config$tables3.pagination) === null || _config$tables3 === void 0 ? void 0 : _config$tables3.current,
313
+ pageSize: config === null || config === void 0 || (_config$tables4 = config.tables) === null || _config$tables4 === void 0 || (_config$tables4 = _config$tables4.pagination) === null || _config$tables4 === void 0 ? void 0 : _config$tables4.pageSize
314
+ }
315
+ });
316
+ }
317
+ dispatch({
318
+ type: _layoutReducer.actionTypes.SET_LOADING,
319
+ payload: false
320
+ });
321
+ }
322
+ }
323
+ };
324
+
325
+ /**
326
+ * Handles the "Enter" key press event for the search input.
327
+ *
328
+ * Trims the search input value and validates it. If the value is invalid or empty,
329
+ * an error is dispatched. If valid, it dispatches the search value and invokes the
330
+ * `handleInputSearchEnter` callback to fetch data based on the search criteria.
331
+ *
332
+ * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
333
+ */
334
+
335
+ const onSearchPressEnter = async () => {
336
+ var _state$inputSearch2;
337
+ const {
338
+ value,
339
+ validateInput,
340
+ request
341
+ } = (_state$inputSearch2 = state === null || state === void 0 ? void 0 : state.inputSearch) !== null && _state$inputSearch2 !== void 0 ? _state$inputSearch2 : {};
342
+ const trimedValue = value === null || value === void 0 ? void 0 : value.trim();
343
+ if (trimedValue === "" || !(validateInput !== null && validateInput !== void 0 && validateInput(trimedValue))) {
344
+ dispatch({
345
+ type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_ERROR,
346
+ payload: trimedValue === "" ? null : "Please enter a valid ".concat(selectedOption)
347
+ });
348
+ return;
349
+ }
350
+ dispatch({
351
+ type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_VALUE,
352
+ payload: trimedValue
353
+ });
354
+ if (handleInputSearchEnter) {
355
+ var _state$tabs2, _config$tables5, _config$tables6, _tables$sorting3, _tables$sorting4, _customDrawer$applied2, _header$subHeading3, _header$subHeading4, _state$misc2;
356
+ const {
357
+ error,
358
+ data
359
+ } = await handleInputSearchEnter(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, state !== null && state !== void 0 && (_state$tabs2 = state.tabs) !== null && _state$tabs2 !== void 0 && _state$tabs2.active ? {
360
+ selectedTab: state.tabs.active
361
+ } : {}), {}, {
362
+ searchedValue: trimedValue,
363
+ current: config === null || config === void 0 || (_config$tables5 = config.tables) === null || _config$tables5 === void 0 || (_config$tables5 = _config$tables5.pagination) === null || _config$tables5 === void 0 ? void 0 : _config$tables5.current,
364
+ pageSize: config === null || config === void 0 || (_config$tables6 = config.tables) === null || _config$tables6 === void 0 || (_config$tables6 = _config$tables6.pagination) === null || _config$tables6 === void 0 ? void 0 : _config$tables6.pageSize,
365
+ field: tables === null || tables === void 0 || (_tables$sorting3 = tables.sorting) === null || _tables$sorting3 === void 0 ? void 0 : _tables$sorting3.sortBy,
366
+ order: tables === null || tables === void 0 || (_tables$sorting4 = tables.sorting) === null || _tables$sorting4 === void 0 ? void 0 : _tables$sorting4.sortDirection
367
+ }, (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied2 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied2 !== void 0 ? _customDrawer$applied2 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), inputSearch !== null && inputSearch !== void 0 && inputSearch.queryField ? {
368
+ queryField: inputSearch.queryField
369
+ } : {}), (header === null || header === void 0 || (_header$subHeading3 = header.subHeading) === null || _header$subHeading3 === void 0 || (_header$subHeading3 = _header$subHeading3.jsxConfig) === null || _header$subHeading3 === void 0 ? void 0 : _header$subHeading3.type) == "select" ? {
370
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading4 = header.subHeading) === null || _header$subHeading4 === void 0 || (_header$subHeading4 = _header$subHeading4.jsxConfig) === null || _header$subHeading4 === void 0 ? void 0 : _header$subHeading4.value
371
+ } : {}), (_state$misc2 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc2 !== void 0 ? _state$misc2 : {}));
372
+ if (error) {
373
+ showErrorNotification(error);
374
+ dispatch({
375
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
376
+ });
377
+ } else {
378
+ var _config$tables7, _config$tables8;
379
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
380
+ setStaticFilterData(data);
381
+ }
382
+ dispatch({
383
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
384
+ payload: data
385
+ });
386
+ dispatch({
387
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
388
+ payload: {
389
+ current: config === null || config === void 0 || (_config$tables7 = config.tables) === null || _config$tables7 === void 0 || (_config$tables7 = _config$tables7.pagination) === null || _config$tables7 === void 0 ? void 0 : _config$tables7.current,
390
+ pageSize: config === null || config === void 0 || (_config$tables8 = config.tables) === null || _config$tables8 === void 0 || (_config$tables8 = _config$tables8.pagination) === null || _config$tables8 === void 0 ? void 0 : _config$tables8.pageSize
391
+ }
392
+ });
393
+ }
394
+ }
395
+ };
396
+
397
+ /**
398
+ * Handles changes in the dropdown search input value.
399
+ *
400
+ * Updates the `dropdownSearchValue` in the state with the new value.
401
+ * If the input value is empty, triggers the `handleDropdownSearchInputChange` callback
402
+ * to fetch data based on the current selected tab, pagination, sorting, and additional
403
+ * state information. Displays an error notification and sets the table to empty in case of an error.
404
+ *
405
+ * @param {{ target: { value: string } }} param0 - The change event with the new input value.
406
+ *
407
+ * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
408
+ */
409
+
410
+ const onDropdownSearchInputChange = async _ref3 => {
411
+ let {
412
+ target: {
413
+ value
414
+ }
415
+ } = _ref3;
416
+ dispatch({
417
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_VALUE,
418
+ payload: value
419
+ });
420
+ if (value === "") {
421
+ if (handleDropdownSearchInputChange) {
422
+ var _state$tabs3, _config$tables9, _config$tables10, _tables$sorting5, _tables$sorting6, _tables$filter, _staticFilter$data2, _customDrawer$applied3, _header$subHeading5, _header$subHeading6, _state$misc3, _state$staticFilter$m, _state$staticFilter;
423
+ dispatch({
424
+ type: _layoutReducer.actionTypes.SET_LOADING,
425
+ payload: true
426
+ });
427
+ const {
428
+ error,
429
+ data
430
+ } = await handleDropdownSearchInputChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
431
+ selectedTab: state === null || state === void 0 || (_state$tabs3 = state.tabs) === null || _state$tabs3 === void 0 ? void 0 : _state$tabs3.active,
432
+ current: config === null || config === void 0 || (_config$tables9 = config.tables) === null || _config$tables9 === void 0 || (_config$tables9 = _config$tables9.pagination) === null || _config$tables9 === void 0 ? void 0 : _config$tables9.current,
433
+ pageSize: config === null || config === void 0 || (_config$tables10 = config.tables) === null || _config$tables10 === void 0 || (_config$tables10 = _config$tables10.pagination) === null || _config$tables10 === void 0 ? void 0 : _config$tables10.pageSize,
434
+ field: tables === null || tables === void 0 || (_tables$sorting5 = tables.sorting) === null || _tables$sorting5 === void 0 ? void 0 : _tables$sorting5.sortBy,
435
+ order: tables === null || tables === void 0 || (_tables$sorting6 = tables.sorting) === null || _tables$sorting6 === void 0 ? void 0 : _tables$sorting6.sortDirection
436
+ }, (tables === null || tables === void 0 || (_tables$filter = tables.filter) === null || _tables$filter === void 0 ? void 0 : _tables$filter.key) && {
437
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
438
+ }), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data2 = staticFilter.data) === null || _staticFilter$data2 === void 0 || (_staticFilter$data2 = _staticFilter$data2.find(item => item.selected)) === null || _staticFilter$data2 === void 0 ? void 0 : _staticFilter$data2.value) && {
439
+ staticFilter: staticFilter.data.find(item => item.selected).value
440
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied3 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied3 !== void 0 ? _customDrawer$applied3 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (header === null || header === void 0 || (_header$subHeading5 = header.subHeading) === null || _header$subHeading5 === void 0 || (_header$subHeading5 = _header$subHeading5.jsxConfig) === null || _header$subHeading5 === void 0 ? void 0 : _header$subHeading5.type) == "select" ? {
441
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading6 = header.subHeading) === null || _header$subHeading6 === void 0 || (_header$subHeading6 = _header$subHeading6.jsxConfig) === null || _header$subHeading6 === void 0 ? void 0 : _header$subHeading6.value
442
+ } : {}), (_state$misc3 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc3 !== void 0 ? _state$misc3 : {}), {}, {
443
+ multiSelectValue: (_state$staticFilter$m = state === null || state === void 0 || (_state$staticFilter = state.staticFilter) === null || _state$staticFilter === void 0 ? void 0 : _state$staticFilter.multiSelectValue) !== null && _state$staticFilter$m !== void 0 ? _state$staticFilter$m : []
444
+ }));
445
+ if (error) {
446
+ showErrorNotification(error);
447
+ dispatch({
448
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
449
+ });
450
+ } else {
451
+ var _config$tables11, _config$tables12;
452
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
453
+ setStaticFilterData(data);
454
+ }
455
+ dispatch({
456
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
457
+ payload: data
458
+ });
459
+ dispatch({
460
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
461
+ payload: {
462
+ current: config === null || config === void 0 || (_config$tables11 = config.tables) === null || _config$tables11 === void 0 || (_config$tables11 = _config$tables11.pagination) === null || _config$tables11 === void 0 ? void 0 : _config$tables11.current,
463
+ pageSize: config === null || config === void 0 || (_config$tables12 = config.tables) === null || _config$tables12 === void 0 || (_config$tables12 = _config$tables12.pagination) === null || _config$tables12 === void 0 ? void 0 : _config$tables12.pageSize
464
+ }
465
+ });
466
+ }
467
+ dispatch({
468
+ type: _layoutReducer.actionTypes.SET_LOADING,
469
+ payload: false
470
+ });
471
+ }
472
+ }
473
+ };
474
+
475
+ /**
476
+ * Handles the "Enter" key press event for the dropdown search input.
477
+ *
478
+ * Validates the trimmed search input value against the selected option.
479
+ * If invalid or empty, dispatches an error with a message indicating the required input.
480
+ * If valid, it updates the dropdown search value in the state and invokes the
481
+ * `handleDropdownSearchEnter` callback to fetch data based on the search criteria.
482
+ * The callback is provided with details such as the searched value, selected tab,
483
+ * pagination, sorting, filter status, and additional state information.
484
+ * Displays an error notification and sets the table to empty in case of an error.
485
+ * On successful data retrieval, updates the table data in the state.
486
+ *
487
+ * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
488
+ */
489
+
490
+ const onDropdownSearchPressEnter = async () => {
491
+ var _state$dropdownSearch;
492
+ const {
493
+ value,
494
+ validateInput,
495
+ selectedOption,
496
+ menuItems,
497
+ request
498
+ } = (_state$dropdownSearch = state === null || state === void 0 ? void 0 : state.dropdownSearch) !== null && _state$dropdownSearch !== void 0 ? _state$dropdownSearch : {};
499
+ const trimedValue = value === null || value === void 0 ? void 0 : value.trim();
500
+ if (trimedValue === "" || !(validateInput !== null && validateInput !== void 0 && validateInput(selectedOption, trimedValue))) {
501
+ var _menuItems$find;
502
+ const errorLabel = (Array.isArray(menuItems) ? (_menuItems$find = menuItems.find(item => item.value === selectedOption)) === null || _menuItems$find === void 0 ? void 0 : _menuItems$find.label : null) || selectedOption || "input";
503
+ dispatch({
504
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_ERROR,
505
+ payload: trimedValue === "" ? null : "Please enter a valid ".concat(errorLabel)
506
+ });
507
+ return;
508
+ }
509
+ dispatch({
510
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_VALUE,
511
+ payload: value
512
+ });
513
+ if (handleDropdownSearchEnter) {
514
+ var _state$tabs4, _config$tables13, _config$tables14, _tables$sorting7, _tables$sorting8, _tables$filter2, _staticFilter$data3, _customDrawer$applied4, _header$subHeading7, _header$subHeading8, _state$misc4, _state$staticFilter$m2, _state$staticFilter2;
515
+ const {
516
+ error,
517
+ data
518
+ } = await handleDropdownSearchEnter(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
519
+ searchedValue: value,
520
+ selectedTab: state === null || state === void 0 || (_state$tabs4 = state.tabs) === null || _state$tabs4 === void 0 ? void 0 : _state$tabs4.active,
521
+ selectedOption: state === null || state === void 0 ? void 0 : state.dropdownSearch.selectedOption,
522
+ current: config === null || config === void 0 || (_config$tables13 = config.tables) === null || _config$tables13 === void 0 || (_config$tables13 = _config$tables13.pagination) === null || _config$tables13 === void 0 ? void 0 : _config$tables13.current,
523
+ pageSize: config === null || config === void 0 || (_config$tables14 = config.tables) === null || _config$tables14 === void 0 || (_config$tables14 = _config$tables14.pagination) === null || _config$tables14 === void 0 ? void 0 : _config$tables14.pageSize,
524
+ field: tables === null || tables === void 0 || (_tables$sorting7 = tables.sorting) === null || _tables$sorting7 === void 0 ? void 0 : _tables$sorting7.sortBy,
525
+ order: tables === null || tables === void 0 || (_tables$sorting8 = tables.sorting) === null || _tables$sorting8 === void 0 ? void 0 : _tables$sorting8.sortDirection
526
+ }, (tables === null || tables === void 0 || (_tables$filter2 = tables.filter) === null || _tables$filter2 === void 0 ? void 0 : _tables$filter2.key) && {
527
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
528
+ }), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data3 = staticFilter.data) === null || _staticFilter$data3 === void 0 || (_staticFilter$data3 = _staticFilter$data3.find(item => item.selected)) === null || _staticFilter$data3 === void 0 ? void 0 : _staticFilter$data3.value) && {
529
+ staticFilter: staticFilter.data.find(item => item.selected).value
530
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied4 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied4 !== void 0 ? _customDrawer$applied4 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (header === null || header === void 0 || (_header$subHeading7 = header.subHeading) === null || _header$subHeading7 === void 0 || (_header$subHeading7 = _header$subHeading7.jsxConfig) === null || _header$subHeading7 === void 0 ? void 0 : _header$subHeading7.type) == "select" ? {
531
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading8 = header.subHeading) === null || _header$subHeading8 === void 0 || (_header$subHeading8 = _header$subHeading8.jsxConfig) === null || _header$subHeading8 === void 0 ? void 0 : _header$subHeading8.value
532
+ } : {}), (_state$misc4 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc4 !== void 0 ? _state$misc4 : {}), {}, {
533
+ multiSelectValue: (_state$staticFilter$m2 = state === null || state === void 0 || (_state$staticFilter2 = state.staticFilter) === null || _state$staticFilter2 === void 0 ? void 0 : _state$staticFilter2.multiSelectValue) !== null && _state$staticFilter$m2 !== void 0 ? _state$staticFilter$m2 : []
534
+ }));
535
+ if (error) {
536
+ showErrorNotification(error);
537
+ dispatch({
538
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
539
+ });
540
+ } else {
541
+ var _config$tables15, _config$tables16;
542
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
543
+ setStaticFilterData(data);
544
+ }
545
+ dispatch({
546
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
547
+ payload: data
548
+ });
549
+ dispatch({
550
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
551
+ payload: {
552
+ current: config === null || config === void 0 || (_config$tables15 = config.tables) === null || _config$tables15 === void 0 || (_config$tables15 = _config$tables15.pagination) === null || _config$tables15 === void 0 ? void 0 : _config$tables15.current,
553
+ pageSize: config === null || config === void 0 || (_config$tables16 = config.tables) === null || _config$tables16 === void 0 || (_config$tables16 = _config$tables16.pagination) === null || _config$tables16 === void 0 ? void 0 : _config$tables16.pageSize
554
+ }
555
+ });
556
+ }
557
+ }
558
+ };
559
+
560
+ /**
561
+ * Handles the change of the selected option in the dropdown search input.
562
+ *
563
+ * Updates the selected option in the state and invokes the
564
+ * `handleDropdownSearchOptionChange` callback to fetch data based on the selected option.
565
+ * The callback is provided with no arguments.
566
+ * Displays an error notification and sets the table to empty in case of an error.
567
+ * On successful data retrieval, updates the table data in the state and triggers a tab click.
568
+ *
569
+ * @param {object} option - The selected option object.
570
+ * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
571
+ */
572
+ const onDropdownSearchOptionChange = async option => {
573
+ dispatch({
574
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_OPTION,
575
+ payload: option === null || option === void 0 ? void 0 : option.value
576
+ });
577
+ if (handleDropdownSearchOptionChange) {
578
+ var _config$tables17, _config$tables18, _staticFilter$data4, _customDrawer$applied5, _header$subHeading9, _header$subHeading10, _state$misc5, _state$staticFilter$m3, _state$staticFilter3;
579
+ dispatch({
580
+ type: _layoutReducer.actionTypes.SET_LOADING,
581
+ payload: true
582
+ });
583
+ const {
584
+ error,
585
+ data
586
+ } = await handleDropdownSearchOptionChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
587
+ selectedTab: tabs === null || tabs === void 0 ? void 0 : tabs.active,
588
+ current: config === null || config === void 0 || (_config$tables17 = config.tables) === null || _config$tables17 === void 0 || (_config$tables17 = _config$tables17.pagination) === null || _config$tables17 === void 0 ? void 0 : _config$tables17.current,
589
+ pageSize: config === null || config === void 0 || (_config$tables18 = config.tables) === null || _config$tables18 === void 0 || (_config$tables18 = _config$tables18.pagination) === null || _config$tables18 === void 0 ? void 0 : _config$tables18.pageSize
590
+ }, (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data4 = staticFilter.data) === null || _staticFilter$data4 === void 0 || (_staticFilter$data4 = _staticFilter$data4.find(item => item.selected)) === null || _staticFilter$data4 === void 0 ? void 0 : _staticFilter$data4.value) && {
591
+ staticFilter: staticFilter.data.find(item => item.selected).value
592
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied5 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied5 !== void 0 ? _customDrawer$applied5 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (header === null || header === void 0 || (_header$subHeading9 = header.subHeading) === null || _header$subHeading9 === void 0 || (_header$subHeading9 = _header$subHeading9.jsxConfig) === null || _header$subHeading9 === void 0 ? void 0 : _header$subHeading9.type) == "select" ? {
593
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading10 = header.subHeading) === null || _header$subHeading10 === void 0 || (_header$subHeading10 = _header$subHeading10.jsxConfig) === null || _header$subHeading10 === void 0 ? void 0 : _header$subHeading10.value
594
+ } : {}), (_state$misc5 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc5 !== void 0 ? _state$misc5 : {}), {}, {
595
+ multiSelectValue: (_state$staticFilter$m3 = state === null || state === void 0 || (_state$staticFilter3 = state.staticFilter) === null || _state$staticFilter3 === void 0 ? void 0 : _state$staticFilter3.multiSelectValue) !== null && _state$staticFilter$m3 !== void 0 ? _state$staticFilter$m3 : []
596
+ }));
597
+ if (error) {
598
+ showErrorNotification(error);
599
+ dispatch({
600
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
601
+ });
602
+ } else {
603
+ var _config$tables19, _config$tables20;
604
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
605
+ setStaticFilterData(data);
606
+ }
607
+ dispatch({
608
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
609
+ payload: data
610
+ });
611
+ dispatch({
612
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
613
+ payload: {
614
+ current: config === null || config === void 0 || (_config$tables19 = config.tables) === null || _config$tables19 === void 0 || (_config$tables19 = _config$tables19.pagination) === null || _config$tables19 === void 0 ? void 0 : _config$tables19.current,
615
+ pageSize: config === null || config === void 0 || (_config$tables20 = config.tables) === null || _config$tables20 === void 0 || (_config$tables20 = _config$tables20.pagination) === null || _config$tables20 === void 0 ? void 0 : _config$tables20.pageSize
616
+ }
617
+ });
618
+ if (config !== null && config !== void 0 && config.tabs) {
619
+ dispatch({
620
+ type: _layoutReducer.actionTypes.TAB_CLICK,
621
+ payload: {
622
+ active: tabs === null || tabs === void 0 ? void 0 : tabs.active
623
+ }
624
+ });
625
+ }
626
+ }
627
+ dispatch({
628
+ type: _layoutReducer.actionTypes.SET_LOADING,
629
+ payload: false
630
+ });
631
+ }
632
+ };
633
+
634
+ /**
635
+ * Handles the blur event for the input search.
636
+ *
637
+ * Checks if the input search value is empty, and if so,
638
+ * clears any existing input search error in the state.
639
+ *
640
+ * @returns {Promise<void>} - Resolves when the input search error state has been updated.
641
+ */
642
+
643
+ const onInputSearchBlur = async () => {
644
+ var _state$inputSearch3;
645
+ const {
646
+ value
647
+ } = (_state$inputSearch3 = state === null || state === void 0 ? void 0 : state.inputSearch) !== null && _state$inputSearch3 !== void 0 ? _state$inputSearch3 : {};
648
+ if (value === "") {
649
+ dispatch({
650
+ type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_ERROR,
651
+ payload: null
652
+ });
653
+ }
654
+ };
655
+
656
+ /**
657
+ * Handles the blur event for the dropdown search input.
658
+ *
659
+ * Checks if the dropdown search value is empty, and if so,
660
+ * clears any existing dropdown search error in the state.
661
+ *
662
+ * @returns {Promise<void>} - Resolves when the dropdown search error state has been updated.
663
+ */
664
+ const onDropdownSearchBlur = async () => {
665
+ var _state$dropdownSearch2;
666
+ const {
667
+ value
668
+ } = (_state$dropdownSearch2 = state === null || state === void 0 ? void 0 : state.dropdownSearch) !== null && _state$dropdownSearch2 !== void 0 ? _state$dropdownSearch2 : {};
669
+ if (value === "") {
670
+ dispatch({
671
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_ERROR,
672
+ payload: null
673
+ });
674
+ }
675
+ };
676
+
677
+ /**
678
+ * Handles the clear event for the dropdown search input.
679
+ *
680
+ * Clears the current value of the dropdown search input and triggers
681
+ * a call to the handleDropdownSearchClear callback function, passing
682
+ * the current state of the component as an argument.
683
+ *
684
+ * If the callback function returns an error, shows an error notification
685
+ * and sets the table data to an empty array. If the callback function
686
+ * returns data, sets the table data to the returned data.
687
+ *
688
+ * @returns {Promise<void>} - Resolves when the table data has been updated.
689
+ */
690
+ const onDropdownSearchClear = async () => {
691
+ dispatch({
692
+ type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_VALUE,
693
+ payload: null
694
+ });
695
+ if (handleDropdownSearchClear) {
696
+ var _state$tabs5, _config$tables21, _config$tables22, _tables$sorting9, _tables$sorting10, _tables$filter3, _staticFilter$data5, _customDrawer$applied6, _header$subHeading11, _header$subHeading12, _state$misc6, _state$staticFilter$m4, _state$staticFilter4;
697
+ const {
698
+ error,
699
+ data
700
+ } = await handleDropdownSearchClear(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
701
+ selectedTab: state === null || state === void 0 || (_state$tabs5 = state.tabs) === null || _state$tabs5 === void 0 ? void 0 : _state$tabs5.active,
702
+ current: config === null || config === void 0 || (_config$tables21 = config.tables) === null || _config$tables21 === void 0 || (_config$tables21 = _config$tables21.pagination) === null || _config$tables21 === void 0 ? void 0 : _config$tables21.current,
703
+ pageSize: config === null || config === void 0 || (_config$tables22 = config.tables) === null || _config$tables22 === void 0 || (_config$tables22 = _config$tables22.pagination) === null || _config$tables22 === void 0 ? void 0 : _config$tables22.pageSize,
704
+ field: tables === null || tables === void 0 || (_tables$sorting9 = tables.sorting) === null || _tables$sorting9 === void 0 ? void 0 : _tables$sorting9.sortBy,
705
+ order: tables === null || tables === void 0 || (_tables$sorting10 = tables.sorting) === null || _tables$sorting10 === void 0 ? void 0 : _tables$sorting10.sortDirection
706
+ }, (tables === null || tables === void 0 || (_tables$filter3 = tables.filter) === null || _tables$filter3 === void 0 ? void 0 : _tables$filter3.key) && {
707
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
708
+ }), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data5 = staticFilter.data) === null || _staticFilter$data5 === void 0 || (_staticFilter$data5 = _staticFilter$data5.find(item => item.selected)) === null || _staticFilter$data5 === void 0 ? void 0 : _staticFilter$data5.value) && {
709
+ staticFilter: staticFilter.data.find(item => item.selected).value
710
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied6 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied6 !== void 0 ? _customDrawer$applied6 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (header === null || header === void 0 || (_header$subHeading11 = header.subHeading) === null || _header$subHeading11 === void 0 || (_header$subHeading11 = _header$subHeading11.jsxConfig) === null || _header$subHeading11 === void 0 ? void 0 : _header$subHeading11.type) == "select" ? {
711
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading12 = header.subHeading) === null || _header$subHeading12 === void 0 || (_header$subHeading12 = _header$subHeading12.jsxConfig) === null || _header$subHeading12 === void 0 ? void 0 : _header$subHeading12.value
712
+ } : {}), (_state$misc6 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc6 !== void 0 ? _state$misc6 : {}), {}, {
713
+ multiSelectValue: (_state$staticFilter$m4 = state === null || state === void 0 || (_state$staticFilter4 = state.staticFilter) === null || _state$staticFilter4 === void 0 ? void 0 : _state$staticFilter4.multiSelectValue) !== null && _state$staticFilter$m4 !== void 0 ? _state$staticFilter$m4 : []
714
+ }));
715
+ if (error) {
716
+ showErrorNotification(error);
717
+ dispatch({
718
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
719
+ });
720
+ } else {
721
+ var _config$tables23, _config$tables24;
722
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
723
+ setStaticFilterData(data);
724
+ }
725
+ dispatch({
726
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
727
+ payload: data
728
+ });
729
+ dispatch({
730
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
731
+ payload: {
732
+ current: config === null || config === void 0 || (_config$tables23 = config.tables) === null || _config$tables23 === void 0 || (_config$tables23 = _config$tables23.pagination) === null || _config$tables23 === void 0 ? void 0 : _config$tables23.current,
733
+ pageSize: config === null || config === void 0 || (_config$tables24 = config.tables) === null || _config$tables24 === void 0 || (_config$tables24 = _config$tables24.pagination) === null || _config$tables24 === void 0 ? void 0 : _config$tables24.pageSize
734
+ }
735
+ });
736
+ }
737
+ }
738
+ };
739
+
740
+ /**
741
+ * Handles the clear event for the input search input.
742
+ *
743
+ * Clears the current value of the input search input and triggers
744
+ * a call to the handleInputSearchClear callback function, passing
745
+ * the current selected tab, pagination state, and sorting state
746
+ * as an argument.
747
+ *
748
+ * If the callback function returns an error, shows an error notification
749
+ * and sets the table data to an empty array. If the callback function
750
+ * returns data, sets the table data to the returned data.
751
+ *
752
+ * @returns {Promise<void>} - Resolves when the table data has been updated.
753
+ */
754
+ const onInputSearchClear = async () => {
755
+ dispatch({
756
+ type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_VALUE,
757
+ payload: null
758
+ });
759
+ if (handleInputSearchClear) {
760
+ var _state$tabs6, _config$tables25, _config$tables26, _tables$sorting11, _tables$sorting12, _customDrawer$applied7, _header$subHeading13, _header$subHeading14, _state$misc7;
761
+ const {
762
+ error,
763
+ data
764
+ } = await handleInputSearchClear(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, state !== null && state !== void 0 && (_state$tabs6 = state.tabs) !== null && _state$tabs6 !== void 0 && _state$tabs6.active ? {
765
+ selectedTab: state.tabs.active
766
+ } : {}), {}, {
767
+ current: config === null || config === void 0 || (_config$tables25 = config.tables) === null || _config$tables25 === void 0 || (_config$tables25 = _config$tables25.pagination) === null || _config$tables25 === void 0 ? void 0 : _config$tables25.current,
768
+ pageSize: config === null || config === void 0 || (_config$tables26 = config.tables) === null || _config$tables26 === void 0 || (_config$tables26 = _config$tables26.pagination) === null || _config$tables26 === void 0 ? void 0 : _config$tables26.pageSize,
769
+ field: tables === null || tables === void 0 || (_tables$sorting11 = tables.sorting) === null || _tables$sorting11 === void 0 ? void 0 : _tables$sorting11.sortBy,
770
+ order: tables === null || tables === void 0 || (_tables$sorting12 = tables.sorting) === null || _tables$sorting12 === void 0 ? void 0 : _tables$sorting12.sortDirection
771
+ }, (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied7 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied7 !== void 0 ? _customDrawer$applied7 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (header === null || header === void 0 || (_header$subHeading13 = header.subHeading) === null || _header$subHeading13 === void 0 || (_header$subHeading13 = _header$subHeading13.jsxConfig) === null || _header$subHeading13 === void 0 ? void 0 : _header$subHeading13.type) == "select" ? {
772
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading14 = header.subHeading) === null || _header$subHeading14 === void 0 || (_header$subHeading14 = _header$subHeading14.jsxConfig) === null || _header$subHeading14 === void 0 ? void 0 : _header$subHeading14.value
773
+ } : {}), (_state$misc7 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc7 !== void 0 ? _state$misc7 : {}));
774
+ if (error) {
775
+ showErrorNotification(error);
776
+ dispatch({
777
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
778
+ });
779
+ } else {
780
+ var _config$tables27, _config$tables28;
781
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
782
+ setStaticFilterData(data);
783
+ }
784
+ dispatch({
785
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
786
+ payload: data
787
+ });
788
+ dispatch({
789
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
790
+ payload: {
791
+ current: config === null || config === void 0 || (_config$tables27 = config.tables) === null || _config$tables27 === void 0 || (_config$tables27 = _config$tables27.pagination) === null || _config$tables27 === void 0 ? void 0 : _config$tables27.current,
792
+ pageSize: config === null || config === void 0 || (_config$tables28 = config.tables) === null || _config$tables28 === void 0 || (_config$tables28 = _config$tables28.pagination) === null || _config$tables28 === void 0 ? void 0 : _config$tables28.pageSize
793
+ }
794
+ });
795
+ }
796
+ }
797
+ };
798
+
799
+ /**
800
+ * Handles various table actions based on the provided configuration arguments.
801
+ *
802
+ * @async
803
+ * @function
804
+ * @param {Object} record - The record object representing the table row.
805
+ * @param {Object} configArgs - The configuration arguments for the action.
806
+ * @returns {Promise<void>} - Resolves after the action is handled.
807
+ *
808
+ * The function performs different actions depending on the `action` specified in `configArgs`:
809
+ * - "OPEN_DRAWER_AND_FETCH": Opens a drawer and fetches data; updates the drawer's state.
810
+ * - "EXPORT_DATA": Triggers data export functionality.
811
+ * - "OPEN_URL_IN_NEW_TAB": Opens a URL in a new browser tab.
812
+ * - "OPEN_MODAL": Opens a modal with updated content.
813
+ * - "ACTION_ON_CTA": Executes a custom table action and displays a success notification.
814
+ *
815
+ * If an error occurs during any action, an error notification is shown.
816
+ */
817
+
818
+ const customTableChange = async (record, configArgs, optKey) => {
819
+ var _state$tables;
820
+ const isRowSelected = state === null || state === void 0 || (_state$tables = state.tables) === null || _state$tables === void 0 || (_state$tables = _state$tables.selectedRows) === null || _state$tables === void 0 ? void 0 : _state$tables.some(row => row.rowKey === record.rowKey);
821
+ if (isRowSelected) {
822
+ return;
823
+ }
824
+ if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "OPEN_DRAWER_AND_FETCH") {
825
+ const selectkey = optKey || (configArgs === null || configArgs === void 0 ? void 0 : configArgs.key);
826
+ if (handleTableColumnClick) {
827
+ var _state$misc8;
828
+ const {
829
+ error,
830
+ data
831
+ } = await (handleTableColumnClick === null || handleTableColumnClick === void 0 ? void 0 : handleTableColumnClick(_objectSpread({
832
+ record: record,
833
+ type: configArgs === null || configArgs === void 0 ? void 0 : configArgs.call
834
+ }, (_state$misc8 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc8 !== void 0 ? _state$misc8 : {})));
835
+ if (error) {
836
+ showErrorNotification(error);
837
+ } else {
838
+ if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.type) === "openNestedDrawer") {
839
+ var _config$nestedDrawer;
840
+ const record = config === null || config === void 0 || (_config$nestedDrawer = config.nestedDrawer) === null || _config$nestedDrawer === void 0 || (_config$nestedDrawer = _config$nestedDrawer.data) === null || _config$nestedDrawer === void 0 ? void 0 : _config$nestedDrawer.cancelOrder;
841
+ const dynamicConfig = (0, _staticConfigResolver.default)(record, data !== null && data !== void 0 ? data : {});
842
+ dispatch({
843
+ type: _layoutReducer.actionTypes.SET_NESTED_DRAWER,
844
+ payload: dynamicConfig
845
+ });
846
+ dispatch({
847
+ type: _layoutReducer.actionTypes.NESTED_DRAWER_OPEN
848
+ });
849
+ } else {
850
+ var _config$drawer, _state$tabs$active, _state$tabs7;
851
+ const record = _objectSpread({}, config === null || config === void 0 || (_config$drawer = config.drawer) === null || _config$drawer === void 0 || (_config$drawer = _config$drawer.data) === null || _config$drawer === void 0 || (_config$drawer = _config$drawer[(_state$tabs$active = state === null || state === void 0 || (_state$tabs7 = state.tabs) === null || _state$tabs7 === void 0 ? void 0 : _state$tabs7.active) !== null && _state$tabs$active !== void 0 ? _state$tabs$active : "default"]) === null || _config$drawer === void 0 ? void 0 : _config$drawer[selectkey]);
852
+ const dynamicConfig = (0, _staticConfigResolver.removeHidden)((0, _staticConfigResolver.default)(record, data !== null && data !== void 0 ? data : {}));
853
+ dispatch({
854
+ type: _layoutReducer.actionTypes.SET_DRAWER,
855
+ payload: {
856
+ dynamicConfig: dynamicConfig,
857
+ active: selectkey
858
+ }
859
+ });
860
+ dispatch({
861
+ type: _layoutReducer.actionTypes.TOGGLE_DRAWER,
862
+ payload: selectkey
863
+ });
864
+ }
865
+ }
866
+ }
867
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "EXPORT_DATA") {
868
+ if (handleSecondaryTableCTAClick) {
869
+ var _state$misc9;
870
+ const {
871
+ error,
872
+ data
873
+ } = await (handleSecondaryTableCTAClick === null || handleSecondaryTableCTAClick === void 0 ? void 0 : handleSecondaryTableCTAClick(_objectSpread({
874
+ rentalId: record === null || record === void 0 ? void 0 : record.rentalId
875
+ }, (_state$misc9 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc9 !== void 0 ? _state$misc9 : {})));
876
+ if (error) {
877
+ showErrorNotification(error);
878
+ } else {
879
+ (0, _downloadFile.default)(data, configArgs === null || configArgs === void 0 ? void 0 : configArgs.fileName);
880
+ }
881
+ }
882
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "OPEN_URL_IN_NEW_TAB") {
883
+ if (handleTableColumnClick) {
884
+ var _state$misc10;
885
+ handleTableColumnClick === null || handleTableColumnClick === void 0 || handleTableColumnClick(_objectSpread({
886
+ record: record,
887
+ type: configArgs === null || configArgs === void 0 ? void 0 : configArgs.call
888
+ }, (_state$misc10 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc10 !== void 0 ? _state$misc10 : {}));
889
+ }
890
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "OPEN_MODAL") {
891
+ if (handleTableColumnClick) {
892
+ var _state$misc11;
893
+ const {
894
+ error,
895
+ data
896
+ } = await (handleTableColumnClick === null || handleTableColumnClick === void 0 ? void 0 : handleTableColumnClick(_objectSpread({
897
+ record: record,
898
+ type: configArgs === null || configArgs === void 0 ? void 0 : configArgs.call
899
+ }, (_state$misc11 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc11 !== void 0 ? _state$misc11 : {})));
900
+ if (error) {
901
+ showErrorNotification(error);
902
+ } else {
903
+ const updatedModalContent = (0, _staticConfigResolver.default)(config === null || config === void 0 ? void 0 : config.modal, data);
904
+ dispatch({
905
+ type: _layoutReducer.actionTypes.SET_MODAL,
906
+ payload: {
907
+ modalData: updatedModalContent
908
+ }
909
+ });
910
+ dispatch({
911
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
912
+ payload: true
913
+ });
914
+ }
915
+ }
916
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "ACTION_ON_CTA") {
917
+ if (handleActionOnTableCTAClick) {
918
+ var _state$misc12;
919
+ const {
920
+ error,
921
+ data
922
+ } = await (handleActionOnTableCTAClick === null || handleActionOnTableCTAClick === void 0 ? void 0 : handleActionOnTableCTAClick(_objectSpread({
923
+ record: record,
924
+ type: configArgs === null || configArgs === void 0 ? void 0 : configArgs.call
925
+ }, (_state$misc12 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc12 !== void 0 ? _state$misc12 : {})));
926
+ if (error) {
927
+ showErrorNotification(error);
928
+ } else {
929
+ showSuccessNotification(data);
930
+ init();
931
+ }
932
+ }
933
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.action) === "VIEW_PHOTO") {
934
+ if (handleTableColumnClick) {
935
+ var _state$misc13;
936
+ const {
937
+ error,
938
+ data
939
+ } = await (handleTableColumnClick === null || handleTableColumnClick === void 0 ? void 0 : handleTableColumnClick(_objectSpread({
940
+ record: record,
941
+ type: configArgs === null || configArgs === void 0 ? void 0 : configArgs.call
942
+ }, (_state$misc13 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc13 !== void 0 ? _state$misc13 : {})));
943
+ if (error) {
944
+ showErrorNotification(error);
945
+ } else {
946
+ var _config$imageViewer;
947
+ const record = config === null || config === void 0 || (_config$imageViewer = config.imageViewer) === null || _config$imageViewer === void 0 ? void 0 : _config$imageViewer.content;
948
+ const dynamicConfig = (0, _staticConfigResolver.default)(record, data !== null && data !== void 0 ? data : {});
949
+ dispatch({
950
+ type: _layoutReducer.actionTypes.TOGGLE_IMAGE_VIEW,
951
+ payload: dynamicConfig
952
+ });
953
+ }
954
+ }
955
+ }
956
+ };
957
+
958
+ /**
959
+ * Handles various table footer actions based on the provided configuration arguments.
960
+ *
961
+ * @async
962
+ * @function
963
+ * @param {Object} config - The configuration arguments for the action.
964
+ * @returns {Promise<void>} - Resolves after the action is handled.
965
+ *
966
+ * The function performs different actions depending on the `action` specified in `config`:
967
+ * - "OPEN_MODAL": Opens a modal with updated content.
968
+ *
969
+ * If an error occurs during any action, an error notification is shown.
970
+ */
971
+ const customTableSelectFooterClick = async configData => {
972
+ if ((configData === null || configData === void 0 ? void 0 : configData.action) === "OPEN_MODAL") {
973
+ var _state$modal;
974
+ const modalContent = state === null || state === void 0 || (_state$modal = state.modal) === null || _state$modal === void 0 ? void 0 : _state$modal.modalContent;
975
+ if (handleModalDataSet) {
976
+ const {
977
+ error,
978
+ data
979
+ } = await (handleModalDataSet === null || handleModalDataSet === void 0 ? void 0 : handleModalDataSet(modalContent, state));
980
+ if (error) {
981
+ showErrorNotification(error);
982
+ } else {
983
+ const updatedModalContent = (0, _staticConfigResolver.default)(config === null || config === void 0 ? void 0 : config.modal, data);
984
+ dispatch({
985
+ type: _layoutReducer.actionTypes.SET_MODAL,
986
+ payload: {
987
+ modalData: updatedModalContent
988
+ }
989
+ });
990
+ dispatch({
991
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
992
+ payload: true
993
+ });
994
+ }
995
+ }
996
+ } else if ((configData === null || configData === void 0 ? void 0 : configData.action) === "CALL_API") {
997
+ if (handleTableFooterApi) {
998
+ const {
999
+ error,
1000
+ data
1001
+ } = await (handleTableFooterApi === null || handleTableFooterApi === void 0 ? void 0 : handleTableFooterApi(state));
1002
+ if (error) {
1003
+ showErrorNotification(error);
1004
+ } else {
1005
+ const updatedModalContent = (0, _staticConfigResolver.default)(config === null || config === void 0 ? void 0 : config.modal, data);
1006
+ dispatch({
1007
+ type: _layoutReducer.actionTypes.SET_MODAL,
1008
+ payload: {
1009
+ modalData: updatedModalContent
1010
+ }
1011
+ });
1012
+ dispatch({
1013
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
1014
+ payload: true
1015
+ });
1016
+ }
1017
+ }
1018
+ } else if ((configData === null || configData === void 0 ? void 0 : configData.action) === "ACTION_ON_CTA") {
1019
+ if (handleTableFooterApi) {
1020
+ var _state$tables2;
1021
+ const {
1022
+ error,
1023
+ data
1024
+ } = await (handleTableFooterApi === null || handleTableFooterApi === void 0 ? void 0 : handleTableFooterApi(state === null || state === void 0 || (_state$tables2 = state.tables) === null || _state$tables2 === void 0 ? void 0 : _state$tables2.selectedRowKeys, state));
1025
+ if (error) {
1026
+ showErrorNotification(error);
1027
+ } else {
1028
+ showSuccessNotification(data);
1029
+ }
1030
+ init();
1031
+ }
1032
+ }
1033
+ };
1034
+
1035
+ /**
1036
+ * Handles table change events.
1037
+ *
1038
+ * @async
1039
+ * @function
1040
+ * @param {Object} pagination - The current pagination state.
1041
+ * @param {Object} _f - The current filter state.
1042
+ * @param {Object} sorter - The current sort state.
1043
+ * @returns {Promise<void>} - Resolves after the event is handled.
1044
+ *
1045
+ * Updates the pagination, filter, and sorting state based on the provided event data.
1046
+ * If `handleTableChange` is provided, calls it with the current state and the updated event data.
1047
+ * If an error occurs during the handling of the event, an error notification is shown.
1048
+ */
1049
+ const onTableChange = async (pagination, _f, sorter) => {
1050
+ var _tables$columns, _tabs$active, _tabs$active2, _tables$filter4;
1051
+ const {
1052
+ current,
1053
+ pageSize
1054
+ } = pagination;
1055
+
1056
+ // Check if filters have meaningful values (not empty arrays or null/undefined)
1057
+ const hasActiveFilters = Object.values(_f).some(filterValue => filterValue && Array.isArray(filterValue) && filterValue.length > 0);
1058
+ const currentColumns = (tables === null || tables === void 0 || (_tables$columns = tables.columns) === null || _tables$columns === void 0 ? void 0 : _tables$columns[(_tabs$active = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active !== void 0 ? _tabs$active : "default"]) || [];
1059
+ const updatedColumns = currentColumns.map(column => {
1060
+ // Check both dataIndex and key for filter matching
1061
+ const filterKey = column.key || column.dataIndex;
1062
+ const columnKey = column.key || column.dataIndex;
1063
+ let updatedColumn = _objectSpread({}, column);
1064
+
1065
+ // Handle filters
1066
+ if (column.filters) {
1067
+ if (hasActiveFilters && _f[filterKey] && Array.isArray(_f[filterKey]) && _f[filterKey].length > 0) {
1068
+ // Set filtered value when filter is active
1069
+ updatedColumn.filteredValue = _f[filterKey];
1070
+ } else {
1071
+ // Clear filtered value when filter is not active or empty
1072
+ const {
1073
+ filteredValue
1074
+ } = updatedColumn,
1075
+ columnWithoutFilter = _objectWithoutProperties(updatedColumn, _excluded);
1076
+ updatedColumn = columnWithoutFilter;
1077
+ }
1078
+ }
1079
+
1080
+ // Handle sorting - update sortOrder to reflect current sort state in UI
1081
+ if (sorter && sorter.columnKey === columnKey) {
1082
+ updatedColumn.sortOrder = sorter.order;
1083
+ } else {
1084
+ // Clear sort order for other columns
1085
+ const {
1086
+ sortOrder
1087
+ } = updatedColumn,
1088
+ columnWithoutSort = _objectWithoutProperties(updatedColumn, _excluded2);
1089
+ updatedColumn = columnWithoutSort;
1090
+ }
1091
+ return updatedColumn;
1092
+ });
1093
+ dispatch({
1094
+ type: _layoutReducer.actionTypes.SET_TABLE_COLUMNS_RESET,
1095
+ payload: {
1096
+ tabKey: (_tabs$active2 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active2 !== void 0 ? _tabs$active2 : "default",
1097
+ columns: updatedColumns
1098
+ }
1099
+ });
1100
+ dispatch({
1101
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
1102
+ payload: {
1103
+ current: current,
1104
+ pageSize: pageSize
1105
+ }
1106
+ });
1107
+ dispatch({
1108
+ type: _layoutReducer.actionTypes.SET_TABLE_FILTER,
1109
+ payload: {
1110
+ key: tables === null || tables === void 0 || (_tables$filter4 = tables.filter) === null || _tables$filter4 === void 0 ? void 0 : _tables$filter4.key,
1111
+ value: _f
1112
+ }
1113
+ });
1114
+ dispatch({
1115
+ type: _layoutReducer.actionTypes.SET_SORTING,
1116
+ payload: {
1117
+ sortBy: sorter === null || sorter === void 0 ? void 0 : sorter.columnKey,
1118
+ sortDirection: (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "ascend" && "ASC" || (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "descend" && "DESC" || ""
1119
+ }
1120
+ });
1121
+ if (handleTableChange) {
1122
+ var _state$dropdownSearch3, _state$inputSearch4, _state$tabs8, _header$subHeading15, _header$subHeading16, _staticFilter$data6, _customDrawer$applied8, _state$misc14, _state$staticFilter$m5, _state$staticFilter5;
1123
+ dispatch({
1124
+ type: _layoutReducer.actionTypes.SET_LOADING,
1125
+ payload: true
1126
+ });
1127
+ const {
1128
+ error,
1129
+ data
1130
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch3 = state.dropdownSearch) === null || _state$dropdownSearch3 === void 0 || (_state$dropdownSearch3 = _state$dropdownSearch3.value) === null || _state$dropdownSearch3 === void 0 ? void 0 : _state$dropdownSearch3.trim()) && {
1131
+ searchedValue: state.dropdownSearch.value,
1132
+ selectedOption: state.dropdownSearch.selectedOption
1133
+ }), (state === null || state === void 0 || (_state$inputSearch4 = state.inputSearch) === null || _state$inputSearch4 === void 0 || (_state$inputSearch4 = _state$inputSearch4.value) === null || _state$inputSearch4 === void 0 ? void 0 : _state$inputSearch4.trim()) && {
1134
+ searchedValue: state.inputSearch.value
1135
+ }), {}, {
1136
+ selectedTab: state === null || state === void 0 || (_state$tabs8 = state.tabs) === null || _state$tabs8 === void 0 ? void 0 : _state$tabs8.active,
1137
+ current: current,
1138
+ pageSize: pageSize,
1139
+ columnFilterStatus: _f,
1140
+ field: sorter === null || sorter === void 0 ? void 0 : sorter.columnKey
1141
+ }, (header === null || header === void 0 || (_header$subHeading15 = header.subHeading) === null || _header$subHeading15 === void 0 || (_header$subHeading15 = _header$subHeading15.jsxConfig) === null || _header$subHeading15 === void 0 ? void 0 : _header$subHeading15.type) == "select" ? {
1142
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading16 = header.subHeading) === null || _header$subHeading16 === void 0 || (_header$subHeading16 = _header$subHeading16.jsxConfig) === null || _header$subHeading16 === void 0 ? void 0 : _header$subHeading16.value
1143
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data6 = staticFilter.data) === null || _staticFilter$data6 === void 0 || (_staticFilter$data6 = _staticFilter$data6.find(item => item.selected)) === null || _staticFilter$data6 === void 0 ? void 0 : _staticFilter$data6.value) && {
1144
+ staticFilter: staticFilter.data.find(item => item.selected).value
1145
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied8 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied8 !== void 0 ? _customDrawer$applied8 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), {}, {
1146
+ order: (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "ascend" && "ASC" || (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "descend" && "DESC" || ""
1147
+ }, (_state$misc14 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc14 !== void 0 ? _state$misc14 : {}), {}, {
1148
+ multiSelectValue: (_state$staticFilter$m5 = state === null || state === void 0 || (_state$staticFilter5 = state.staticFilter) === null || _state$staticFilter5 === void 0 ? void 0 : _state$staticFilter5.multiSelectValue) !== null && _state$staticFilter$m5 !== void 0 ? _state$staticFilter$m5 : []
1149
+ }));
1150
+ if (error) {
1151
+ showErrorNotification(error);
1152
+ dispatch({
1153
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1154
+ });
1155
+ } else {
1156
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1157
+ setStaticFilterData(data);
1158
+ }
1159
+ dispatch({
1160
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1161
+ payload: data
1162
+ });
1163
+ }
1164
+ dispatch({
1165
+ type: _layoutReducer.actionTypes.SET_LOADING,
1166
+ payload: false
1167
+ });
1168
+ }
1169
+ };
1170
+
1171
+ /**
1172
+ * @function onTabClick
1173
+ * @description A function to handle the tab click action. It dispatches the active tab state and calls the handleTabClick function
1174
+ * @param {string} key - The key of the tab
1175
+ * @returns {void}
1176
+ */
1177
+ const onTabClick = async key => {
1178
+ var _tables$filter5, _tables$columns2, _staticFilter$data$fi2;
1179
+ dispatch({
1180
+ type: _layoutReducer.actionTypes.TAB_CLICK,
1181
+ payload: {
1182
+ active: key
1183
+ }
1184
+ });
1185
+ if (tables !== null && tables !== void 0 && tables.selectionType) {
1186
+ var _state$tabs9;
1187
+ const selectionKey = Object.keys(tables === null || tables === void 0 ? void 0 : tables.selectionType).find(key => (tables === null || tables === void 0 ? void 0 : tables.selectionType[key]) === "checkbox");
1188
+ if ((state === null || state === void 0 || (_state$tabs9 = state.tabs) === null || _state$tabs9 === void 0 ? void 0 : _state$tabs9.activeKey) !== selectionKey) {
1189
+ dispatch({
1190
+ type: _layoutReducer.actionTypes.TABLE_FOOTER_TOGGLE,
1191
+ payload: false
1192
+ });
1193
+ dispatch({
1194
+ type: _layoutReducer.actionTypes.TABLE_ROW_SELECTED_DATA,
1195
+ payload: []
1196
+ });
1197
+ }
1198
+ }
1199
+
1200
+ // Reset table column filters in state
1201
+ dispatch({
1202
+ type: _layoutReducer.actionTypes.SET_TABLE_FILTER,
1203
+ payload: {
1204
+ key: tables === null || tables === void 0 || (_tables$filter5 = tables.filter) === null || _tables$filter5 === void 0 ? void 0 : _tables$filter5.key,
1205
+ value: {}
1206
+ }
1207
+ });
1208
+
1209
+ // Reset UI filters by updating columns with filteredValue: []
1210
+ const currentColumns = (tables === null || tables === void 0 || (_tables$columns2 = tables.columns) === null || _tables$columns2 === void 0 ? void 0 : _tables$columns2[key]) || [];
1211
+ const resetColumns = currentColumns.map(column => {
1212
+ if (column.filters) {
1213
+ return _objectSpread(_objectSpread({}, column), {}, {
1214
+ filteredValue: [] // Empty array resets the UI filter
1215
+ });
1216
+ }
1217
+ return column;
1218
+ });
1219
+
1220
+ // Update columns with reset filters
1221
+ dispatch({
1222
+ type: _layoutReducer.actionTypes.SET_TABLE_COLUMNS_RESET,
1223
+ payload: {
1224
+ tabKey: key,
1225
+ columns: resetColumns
1226
+ }
1227
+ });
1228
+ const selectedStaticFilterValue = tables !== null && tables !== void 0 && tables.staticFilterKey && (tables === null || tables === void 0 ? void 0 : tables.staticFilterKey) == key && Array.isArray(staticFilter.data) ? (_staticFilter$data$fi2 = staticFilter.data.find(item => item.selected)) === null || _staticFilter$data$fi2 === void 0 ? void 0 : _staticFilter$data$fi2.value : undefined;
1229
+ if (handleTabClick) {
1230
+ var _state$misc15, _tables$pagination, _tables$pagination2, _tables$sorting13, _tables$sorting14, _state$dropdownSearch4, _header$subHeading17, _header$subHeading18, _customDrawer$applied9, _state$misc16, _state$staticFilter$m6, _state$staticFilter6;
1231
+ dispatch({
1232
+ type: _layoutReducer.actionTypes.SET_LOADING,
1233
+ payload: true
1234
+ });
1235
+ const {
1236
+ error,
1237
+ data
1238
+ } = await handleTabClick(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (_state$misc15 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc15 !== void 0 ? _state$misc15 : {}), {}, {
1239
+ selectedTab: key,
1240
+ current: tables === null || tables === void 0 || (_tables$pagination = tables.pagination) === null || _tables$pagination === void 0 ? void 0 : _tables$pagination.current,
1241
+ pageSize: tables === null || tables === void 0 || (_tables$pagination2 = tables.pagination) === null || _tables$pagination2 === void 0 ? void 0 : _tables$pagination2.pageSize,
1242
+ field: tables === null || tables === void 0 || (_tables$sorting13 = tables.sorting) === null || _tables$sorting13 === void 0 ? void 0 : _tables$sorting13.sortBy
1243
+ }, selectedStaticFilterValue && {
1244
+ staticFilter: selectedStaticFilterValue
1245
+ }), {}, {
1246
+ order: tables === null || tables === void 0 || (_tables$sorting14 = tables.sorting) === null || _tables$sorting14 === void 0 ? void 0 : _tables$sorting14.sortDirection
1247
+ }, (state === null || state === void 0 || (_state$dropdownSearch4 = state.dropdownSearch) === null || _state$dropdownSearch4 === void 0 || (_state$dropdownSearch4 = _state$dropdownSearch4.value) === null || _state$dropdownSearch4 === void 0 ? void 0 : _state$dropdownSearch4.trim()) && {
1248
+ searchedValue: state.dropdownSearch.value,
1249
+ selectedOption: state.dropdownSearch.selectedOption
1250
+ }), (header === null || header === void 0 || (_header$subHeading17 = header.subHeading) === null || _header$subHeading17 === void 0 || (_header$subHeading17 = _header$subHeading17.jsxConfig) === null || _header$subHeading17 === void 0 ? void 0 : _header$subHeading17.type) == "select" ? {
1251
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading18 = header.subHeading) === null || _header$subHeading18 === void 0 || (_header$subHeading18 = _header$subHeading18.jsxConfig) === null || _header$subHeading18 === void 0 ? void 0 : _header$subHeading18.value
1252
+ } : {}), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied9 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied9 !== void 0 ? _customDrawer$applied9 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (_state$misc16 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc16 !== void 0 ? _state$misc16 : {}), {}, {
1253
+ multiSelectValue: (_state$staticFilter$m6 = state === null || state === void 0 || (_state$staticFilter6 = state.staticFilter) === null || _state$staticFilter6 === void 0 ? void 0 : _state$staticFilter6.multiSelectValue) !== null && _state$staticFilter$m6 !== void 0 ? _state$staticFilter$m6 : []
1254
+ }));
1255
+ if (error) {
1256
+ showErrorNotification(error);
1257
+ dispatch({
1258
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1259
+ });
1260
+ } else {
1261
+ if (selectedStaticFilterValue) {
1262
+ setStaticFilterData(data);
1263
+ }
1264
+ dispatch({
1265
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1266
+ payload: data
1267
+ });
1268
+ }
1269
+ dispatch({
1270
+ type: _layoutReducer.actionTypes.SET_LOADING,
1271
+ payload: false
1272
+ });
1273
+ }
1274
+ };
1275
+
1276
+ /**
1277
+ * @function onChange
1278
+ * @description Handles the row selection change event.
1279
+ * @param {Array<string>} selectedRowKeys - The keys of the selected rows.
1280
+ * @param {Array<Object>} selectedRows - The selected rows.
1281
+ * @returns {void}
1282
+ *
1283
+ * Dispatches the {@link actionTypes.TABLE_FOOTER_TOGGLE} action with the selected rows length
1284
+ * as the payload to toggle the table footer.
1285
+ * Dispatches the {@link actionTypes.TABLE_ROW_SELECTED_DATA} action with the selected rows
1286
+ * as the payload to update the selected rows state.
1287
+ */
1288
+ const rowSelection = {
1289
+ onChange: (selectedRowKeys, selectedRows) => {
1290
+ dispatch({
1291
+ type: _layoutReducer.actionTypes.TABLE_FOOTER_TOGGLE,
1292
+ payload: (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) != 0
1293
+ });
1294
+ dispatch({
1295
+ type: _layoutReducer.actionTypes.TABLE_ROW_SELECTED_DATA,
1296
+ payload: selectedRows
1297
+ });
1298
+ }
1299
+ };
1300
+
1301
+ /**
1302
+ * @function onSubHeadingClick
1303
+ * @description Handles the subheading click event to perform specific actions.
1304
+ * @param {string} action - The action to be performed when the subheading is clicked.
1305
+ *
1306
+ * If the action is "OPEN_MODAL", dispatches actions to set the modal data and toggle the modal visibility.
1307
+ */
1308
+
1309
+ const onSubHeadingClick = action => {
1310
+ if (action === "OPEN_MODAL") {
1311
+ dispatch({
1312
+ type: _layoutReducer.actionTypes.SET_MODAL,
1313
+ payload: {
1314
+ modalData: config === null || config === void 0 ? void 0 : config.modal
1315
+ }
1316
+ });
1317
+ dispatch({
1318
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
1319
+ payload: true
1320
+ });
1321
+ }
1322
+ };
1323
+
1324
+ /**
1325
+ * Handles the form submission event for the drawer.
1326
+ *
1327
+ * @async
1328
+ * @function
1329
+ * @param {Object} formData - The data submitted from the drawer form.
1330
+ * @returns {Promise<void>} - Resolves after the form data is processed.
1331
+ *
1332
+ * If the `formData` type is "openNestedDrawer", triggers a custom table change
1333
+ * with the current record and form data. Otherwise, attempts to handle the form
1334
+ * submission by calling `handleDrawerFormOnFinish`. Shows an error notification
1335
+ * if an error occurs, or a success notification if successful, and then closes
1336
+ * the drawer. If a nested drawer is visible, dispatches an action to close it.
1337
+ * Finally, re-initializes the state.
1338
+ */
1339
+
1340
+ const drawerFormOnFinish = async formData => {
1341
+ var _state$drawer, _state$tabs$active2, _state$tabs10, _state$drawer2;
1342
+ const record = _objectSpread({}, state === null || state === void 0 || (_state$drawer = state.drawer) === null || _state$drawer === void 0 || (_state$drawer = _state$drawer.data) === null || _state$drawer === void 0 || (_state$drawer = _state$drawer[(_state$tabs$active2 = state === null || state === void 0 || (_state$tabs10 = state.tabs) === null || _state$tabs10 === void 0 ? void 0 : _state$tabs10.active) !== null && _state$tabs$active2 !== void 0 ? _state$tabs$active2 : "default"]) === null || _state$drawer === void 0 || (_state$drawer = _state$drawer[state === null || state === void 0 || (_state$drawer2 = state.drawer) === null || _state$drawer2 === void 0 ? void 0 : _state$drawer2.active]) === null || _state$drawer === void 0 ? void 0 : _state$drawer.value);
1343
+ if ((formData === null || formData === void 0 ? void 0 : formData.type) === "openNestedDrawer") {
1344
+ customTableChange(record, _objectSpread({}, formData));
1345
+ return;
1346
+ }
1347
+ if (handleDrawerFormOnFinish) {
1348
+ var _state$misc17;
1349
+ const {
1350
+ error,
1351
+ data
1352
+ } = await (handleDrawerFormOnFinish === null || handleDrawerFormOnFinish === void 0 ? void 0 : handleDrawerFormOnFinish(_objectSpread(_objectSpread(_objectSpread({}, record), formData), (_state$misc17 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc17 !== void 0 ? _state$misc17 : {})));
1353
+ if (error) {
1354
+ showErrorNotification(error);
1355
+ } else {
1356
+ showSuccessNotification(data === null || data === void 0 ? void 0 : data.message);
1357
+ dispatch({
1358
+ type: _layoutReducer.actionTypes.CLOSE_DRAWER
1359
+ });
1360
+ (nestedDrawer === null || nestedDrawer === void 0 ? void 0 : nestedDrawer.visible) && dispatch({
1361
+ type: _layoutReducer.actionTypes.NESTED_DRAWER_CLOSED
1362
+ });
1363
+ init();
1364
+ }
1365
+ }
1366
+ };
1367
+ const onRemoveAppliedFilter = async filterKey => {
1368
+ var _state$customDrawer;
1369
+ const currentFilters = _objectSpread({}, state === null || state === void 0 || (_state$customDrawer = state.customDrawer) === null || _state$customDrawer === void 0 ? void 0 : _state$customDrawer.appliedFilters);
1370
+
1371
+ // Remove the specific filter
1372
+ delete currentFilters[filterKey];
1373
+
1374
+ // If there are remaining filters, reapply them
1375
+ if (Object.keys(currentFilters).length > 0) {
1376
+ var _state$dropdownSearch5, _state$inputSearch5, _state$tabs11, _tables$pagination3, _tables$pagination4, _tables$filter6, _tables$sorting15, _header$subHeading19, _header$subHeading20, _staticFilter$data7, _tables$sorting16, _state$misc18, _state$staticFilter$m7, _state$staticFilter7;
1377
+ const {
1378
+ error,
1379
+ data
1380
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch5 = state.dropdownSearch) === null || _state$dropdownSearch5 === void 0 || (_state$dropdownSearch5 = _state$dropdownSearch5.value) === null || _state$dropdownSearch5 === void 0 ? void 0 : _state$dropdownSearch5.trim()) && {
1381
+ searchedValue: state.dropdownSearch.value,
1382
+ selectedOption: state.dropdownSearch.selectedOption
1383
+ }), (state === null || state === void 0 || (_state$inputSearch5 = state.inputSearch) === null || _state$inputSearch5 === void 0 || (_state$inputSearch5 = _state$inputSearch5.value) === null || _state$inputSearch5 === void 0 ? void 0 : _state$inputSearch5.trim()) && {
1384
+ searchedValue: state.inputSearch.value
1385
+ }), {}, {
1386
+ filterOn: currentFilters === null || currentFilters === void 0 ? void 0 : currentFilters.filterBy,
1387
+ fromDate: currentFilters === null || currentFilters === void 0 ? void 0 : currentFilters.fromDate,
1388
+ toDate: currentFilters === null || currentFilters === void 0 ? void 0 : currentFilters.toDate,
1389
+ selectedTab: state === null || state === void 0 || (_state$tabs11 = state.tabs) === null || _state$tabs11 === void 0 ? void 0 : _state$tabs11.active,
1390
+ current: tables === null || tables === void 0 || (_tables$pagination3 = tables.pagination) === null || _tables$pagination3 === void 0 ? void 0 : _tables$pagination3.current,
1391
+ pageSize: tables === null || tables === void 0 || (_tables$pagination4 = tables.pagination) === null || _tables$pagination4 === void 0 ? void 0 : _tables$pagination4.pageSize
1392
+ }, (tables === null || tables === void 0 || (_tables$filter6 = tables.filter) === null || _tables$filter6 === void 0 ? void 0 : _tables$filter6.key) && {
1393
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
1394
+ }), {}, {
1395
+ field: tables === null || tables === void 0 || (_tables$sorting15 = tables.sorting) === null || _tables$sorting15 === void 0 ? void 0 : _tables$sorting15.sortBy
1396
+ }, (header === null || header === void 0 || (_header$subHeading19 = header.subHeading) === null || _header$subHeading19 === void 0 || (_header$subHeading19 = _header$subHeading19.jsxConfig) === null || _header$subHeading19 === void 0 ? void 0 : _header$subHeading19.type) == "select" ? {
1397
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading20 = header.subHeading) === null || _header$subHeading20 === void 0 || (_header$subHeading20 = _header$subHeading20.jsxConfig) === null || _header$subHeading20 === void 0 ? void 0 : _header$subHeading20.value
1398
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data7 = staticFilter.data) === null || _staticFilter$data7 === void 0 || (_staticFilter$data7 = _staticFilter$data7.find(item => item.selected)) === null || _staticFilter$data7 === void 0 ? void 0 : _staticFilter$data7.value) && {
1399
+ staticFilter: staticFilter.data.find(item => item.selected).value
1400
+ }), {}, {
1401
+ order: tables === null || tables === void 0 || (_tables$sorting16 = tables.sorting) === null || _tables$sorting16 === void 0 ? void 0 : _tables$sorting16.sortDirection
1402
+ }, (_state$misc18 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc18 !== void 0 ? _state$misc18 : {}), {}, {
1403
+ multiSelectValue: (_state$staticFilter$m7 = state === null || state === void 0 || (_state$staticFilter7 = state.staticFilter) === null || _state$staticFilter7 === void 0 ? void 0 : _state$staticFilter7.multiSelectValue) !== null && _state$staticFilter$m7 !== void 0 ? _state$staticFilter$m7 : []
1404
+ }));
1405
+ if (error) {
1406
+ showErrorNotification(error);
1407
+ dispatch({
1408
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1409
+ });
1410
+ } else {
1411
+ dispatch({
1412
+ type: _layoutReducer.actionTypes.SET_APPLIED_FILTERS,
1413
+ payload: currentFilters
1414
+ });
1415
+ dispatch({
1416
+ type: _layoutReducer.actionTypes.REMOVE_APPLIED_FILTER,
1417
+ payload: {
1418
+ filterKey
1419
+ }
1420
+ });
1421
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1422
+ setStaticFilterData(data);
1423
+ }
1424
+ // Sync the filter form with remaining applied filters
1425
+ syncFilterFormWithAppliedFilters(currentFilters);
1426
+ dispatch({
1427
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1428
+ payload: data
1429
+ });
1430
+ }
1431
+ }
1432
+ };
1433
+ const filterFormOnFinish = async formData => {
1434
+ // Check if this is a cancel/clear action - check both buttonClickType and the actual button data
1435
+ if (formData.type === "FILTER-CANCEL") {
1436
+ var _state$dropdownSearch6, _state$inputSearch6, _state$tabs12, _tables$pagination5, _tables$pagination6, _tables$filter7, _tables$sorting17, _header$subHeading21, _header$subHeading22, _staticFilter$data8, _tables$sorting18, _state$misc19, _state$staticFilter$m8, _state$staticFilter8;
1437
+ if (isFiltersEmpty(customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)) {
1438
+ dispatch({
1439
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1440
+ });
1441
+ return;
1442
+ }
1443
+ const {
1444
+ error,
1445
+ data
1446
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch6 = state.dropdownSearch) === null || _state$dropdownSearch6 === void 0 || (_state$dropdownSearch6 = _state$dropdownSearch6.value) === null || _state$dropdownSearch6 === void 0 ? void 0 : _state$dropdownSearch6.trim()) && {
1447
+ searchedValue: state.dropdownSearch.value,
1448
+ selectedOption: state.dropdownSearch.selectedOption
1449
+ }), (state === null || state === void 0 || (_state$inputSearch6 = state.inputSearch) === null || _state$inputSearch6 === void 0 || (_state$inputSearch6 = _state$inputSearch6.value) === null || _state$inputSearch6 === void 0 ? void 0 : _state$inputSearch6.trim()) && {
1450
+ searchedValue: state.inputSearch.value
1451
+ }), {}, {
1452
+ selectedTab: state === null || state === void 0 || (_state$tabs12 = state.tabs) === null || _state$tabs12 === void 0 ? void 0 : _state$tabs12.active,
1453
+ current: tables === null || tables === void 0 || (_tables$pagination5 = tables.pagination) === null || _tables$pagination5 === void 0 ? void 0 : _tables$pagination5.current,
1454
+ pageSize: tables === null || tables === void 0 || (_tables$pagination6 = tables.pagination) === null || _tables$pagination6 === void 0 ? void 0 : _tables$pagination6.pageSize
1455
+ }, (tables === null || tables === void 0 || (_tables$filter7 = tables.filter) === null || _tables$filter7 === void 0 ? void 0 : _tables$filter7.key) && {
1456
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
1457
+ }), {}, {
1458
+ field: tables === null || tables === void 0 || (_tables$sorting17 = tables.sorting) === null || _tables$sorting17 === void 0 ? void 0 : _tables$sorting17.sortBy
1459
+ }, (header === null || header === void 0 || (_header$subHeading21 = header.subHeading) === null || _header$subHeading21 === void 0 || (_header$subHeading21 = _header$subHeading21.jsxConfig) === null || _header$subHeading21 === void 0 ? void 0 : _header$subHeading21.type) == "select" ? {
1460
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading22 = header.subHeading) === null || _header$subHeading22 === void 0 || (_header$subHeading22 = _header$subHeading22.jsxConfig) === null || _header$subHeading22 === void 0 ? void 0 : _header$subHeading22.value
1461
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data8 = staticFilter.data) === null || _staticFilter$data8 === void 0 || (_staticFilter$data8 = _staticFilter$data8.find(item => item.selected)) === null || _staticFilter$data8 === void 0 ? void 0 : _staticFilter$data8.value) && {
1462
+ staticFilter: staticFilter.data.find(item => item.selected).value
1463
+ }), {}, {
1464
+ order: tables === null || tables === void 0 || (_tables$sorting18 = tables.sorting) === null || _tables$sorting18 === void 0 ? void 0 : _tables$sorting18.sortDirection
1465
+ }, (_state$misc19 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc19 !== void 0 ? _state$misc19 : {}), {}, {
1466
+ multiSelectValue: (_state$staticFilter$m8 = state === null || state === void 0 || (_state$staticFilter8 = state.staticFilter) === null || _state$staticFilter8 === void 0 ? void 0 : _state$staticFilter8.multiSelectValue) !== null && _state$staticFilter$m8 !== void 0 ? _state$staticFilter$m8 : []
1467
+ }));
1468
+ if (error) {
1469
+ showErrorNotification(error);
1470
+ dispatch({
1471
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1472
+ });
1473
+ } else {
1474
+ var _config$customDrawer;
1475
+ dispatch({
1476
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1477
+ payload: data
1478
+ });
1479
+ dispatch({
1480
+ type: _layoutReducer.actionTypes.CLEAR_ALL_APPLIED_FILTERS
1481
+ });
1482
+ dispatch({
1483
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1484
+ });
1485
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1486
+ setStaticFilterData(data);
1487
+ }
1488
+ const drawerData = config === null || config === void 0 || (_config$customDrawer = config.customDrawer) === null || _config$customDrawer === void 0 || (_config$customDrawer = _config$customDrawer.data) === null || _config$customDrawer === void 0 ? void 0 : _config$customDrawer[rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.drawerKey];
1489
+ if (drawerData) {
1490
+ dispatch({
1491
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER,
1492
+ payload: drawerData
1493
+ });
1494
+ }
1495
+ }
1496
+ return;
1497
+ }
1498
+ if (formData.type === "EXPORT-CANCEL") {
1499
+ var _config$customDrawer2;
1500
+ const drawerData = config === null || config === void 0 || (_config$customDrawer2 = config.customDrawer) === null || _config$customDrawer2 === void 0 || (_config$customDrawer2 = _config$customDrawer2.data) === null || _config$customDrawer2 === void 0 ? void 0 : _config$customDrawer2[leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.drawerKey];
1501
+ if (drawerData) {
1502
+ dispatch({
1503
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER,
1504
+ payload: drawerData
1505
+ });
1506
+ }
1507
+ dispatch({
1508
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1509
+ });
1510
+ return;
1511
+ }
1512
+
1513
+ // Only process filter data if this is actually a filter drawer
1514
+ if (formData.type === "FILTER-SUBMIT") {
1515
+ var _state$dropdownSearch7, _state$inputSearch7, _ref4, _appliedFilters$filte, _state$tabs13, _config$tables29, _config$tables30, _tables$filter8, _tables$sorting19, _header$subHeading23, _header$subHeading24, _staticFilter$data9, _tables$sorting20, _state$misc20, _state$staticFilter$m9, _state$staticFilter9;
1516
+ const appliedFilters = {};
1517
+ Object.keys(formData).forEach(key => {
1518
+ const value = formData[key];
1519
+ if (value !== undefined && value !== "" && value !== null) {
1520
+ appliedFilters[key] = value;
1521
+ }
1522
+ });
1523
+ if (isFiltersEmpty(appliedFilters)) {
1524
+ dispatch({
1525
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1526
+ });
1527
+ return;
1528
+ }
1529
+ const {
1530
+ error,
1531
+ data
1532
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch7 = state.dropdownSearch) === null || _state$dropdownSearch7 === void 0 || (_state$dropdownSearch7 = _state$dropdownSearch7.value) === null || _state$dropdownSearch7 === void 0 ? void 0 : _state$dropdownSearch7.trim()) && {
1533
+ searchedValue: state.dropdownSearch.value,
1534
+ selectedOption: state.dropdownSearch.selectedOption
1535
+ }), (state === null || state === void 0 || (_state$inputSearch7 = state.inputSearch) === null || _state$inputSearch7 === void 0 || (_state$inputSearch7 = _state$inputSearch7.value) === null || _state$inputSearch7 === void 0 ? void 0 : _state$inputSearch7.trim()) && {
1536
+ searchedValue: state.inputSearch.value
1537
+ }), appliedFilters), {}, {
1538
+ filterOn: (_ref4 = (_appliedFilters$filte = appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.filterBy) !== null && _appliedFilters$filte !== void 0 ? _appliedFilters$filte : customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.defaultAppliedFilter) !== null && _ref4 !== void 0 ? _ref4 : "",
1539
+ fromDate: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.fromDate,
1540
+ toDate: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toDate,
1541
+ selectedTab: state === null || state === void 0 || (_state$tabs13 = state.tabs) === null || _state$tabs13 === void 0 ? void 0 : _state$tabs13.active,
1542
+ current: config === null || config === void 0 || (_config$tables29 = config.tables) === null || _config$tables29 === void 0 || (_config$tables29 = _config$tables29.pagination) === null || _config$tables29 === void 0 ? void 0 : _config$tables29.current,
1543
+ pageSize: config === null || config === void 0 || (_config$tables30 = config.tables) === null || _config$tables30 === void 0 || (_config$tables30 = _config$tables30.pagination) === null || _config$tables30 === void 0 ? void 0 : _config$tables30.pageSize
1544
+ }, (tables === null || tables === void 0 || (_tables$filter8 = tables.filter) === null || _tables$filter8 === void 0 ? void 0 : _tables$filter8.key) && {
1545
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
1546
+ }), {}, {
1547
+ field: tables === null || tables === void 0 || (_tables$sorting19 = tables.sorting) === null || _tables$sorting19 === void 0 ? void 0 : _tables$sorting19.sortBy
1548
+ }, (header === null || header === void 0 || (_header$subHeading23 = header.subHeading) === null || _header$subHeading23 === void 0 || (_header$subHeading23 = _header$subHeading23.jsxConfig) === null || _header$subHeading23 === void 0 ? void 0 : _header$subHeading23.type) == "select" ? {
1549
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading24 = header.subHeading) === null || _header$subHeading24 === void 0 || (_header$subHeading24 = _header$subHeading24.jsxConfig) === null || _header$subHeading24 === void 0 ? void 0 : _header$subHeading24.value
1550
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data9 = staticFilter.data) === null || _staticFilter$data9 === void 0 || (_staticFilter$data9 = _staticFilter$data9.find(item => item.selected)) === null || _staticFilter$data9 === void 0 ? void 0 : _staticFilter$data9.value) && {
1551
+ staticFilter: staticFilter.data.find(item => item.selected).value
1552
+ }), {}, {
1553
+ order: tables === null || tables === void 0 || (_tables$sorting20 = tables.sorting) === null || _tables$sorting20 === void 0 ? void 0 : _tables$sorting20.sortDirection
1554
+ }, (_state$misc20 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc20 !== void 0 ? _state$misc20 : {}), {}, {
1555
+ multiSelectValue: (_state$staticFilter$m9 = state === null || state === void 0 || (_state$staticFilter9 = state.staticFilter) === null || _state$staticFilter9 === void 0 ? void 0 : _state$staticFilter9.multiSelectValue) !== null && _state$staticFilter$m9 !== void 0 ? _state$staticFilter$m9 : []
1556
+ }));
1557
+ if (error) {
1558
+ showErrorNotification(error);
1559
+ dispatch({
1560
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1561
+ });
1562
+ } else {
1563
+ var _config$tables31, _config$tables32;
1564
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1565
+ var _staticFilter$data$fi3, _config$staticFilter2;
1566
+ const selectedKey = staticFilter === null || staticFilter === void 0 || (_staticFilter$data$fi3 = staticFilter.data.find(item => item.selected)) === null || _staticFilter$data$fi3 === void 0 ? void 0 : _staticFilter$data$fi3.value;
1567
+ const dynamicConfig = (0, _staticConfigResolver.default)(config === null || config === void 0 || (_config$staticFilter2 = config.staticFilter) === null || _config$staticFilter2 === void 0 ? void 0 : _config$staticFilter2.data, data !== null && data !== void 0 ? data : {});
1568
+ dispatch({
1569
+ type: _layoutReducer.actionTypes.SET_STATIC_FILTER,
1570
+ payload: dynamicConfig
1571
+ });
1572
+ dispatch({
1573
+ type: _layoutReducer.actionTypes.SET_STATIC_FILTER_SELECTION,
1574
+ payload: selectedKey
1575
+ });
1576
+ }
1577
+ dispatch({
1578
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1579
+ payload: data
1580
+ });
1581
+ dispatch({
1582
+ type: _layoutReducer.actionTypes.SET_APPLIED_FILTERS,
1583
+ payload: appliedFilters
1584
+ });
1585
+ dispatch({
1586
+ type: _layoutReducer.actionTypes.UPDATE_FILTER_DEFAULT_VALUES,
1587
+ payload: formData
1588
+ });
1589
+ dispatch({
1590
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
1591
+ payload: {
1592
+ current: config === null || config === void 0 || (_config$tables31 = config.tables) === null || _config$tables31 === void 0 || (_config$tables31 = _config$tables31.pagination) === null || _config$tables31 === void 0 ? void 0 : _config$tables31.current,
1593
+ pageSize: config === null || config === void 0 || (_config$tables32 = config.tables) === null || _config$tables32 === void 0 || (_config$tables32 = _config$tables32.pagination) === null || _config$tables32 === void 0 ? void 0 : _config$tables32.pageSize
1594
+ }
1595
+ });
1596
+ dispatch({
1597
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1598
+ });
1599
+ }
1600
+ } else if (formData.drawerKey === "exportDrawer") {
1601
+ const appliedFilters = {};
1602
+ Object.keys(formData).forEach(key => {
1603
+ const value = formData[key];
1604
+ if (value !== undefined && value !== "" && value !== null) {
1605
+ appliedFilters[key] = value;
1606
+ }
1607
+ });
1608
+ if (handleSecondaryTableCTAClick) {
1609
+ var _state$dropdownSearch8, _state$inputSearch8, _state$tabs14, _tables$pagination7, _tables$pagination8, _tables$filter9, _tables$sorting21, _tables$sorting22, _header$subHeading25, _header$subHeading26, _staticFilter$data10, _state$misc21, _state$staticFilter$m10, _state$staticFilter10;
1610
+ const {
1611
+ error,
1612
+ data
1613
+ } = await (handleSecondaryTableCTAClick === null || handleSecondaryTableCTAClick === void 0 ? void 0 : handleSecondaryTableCTAClick(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch8 = state.dropdownSearch) === null || _state$dropdownSearch8 === void 0 || (_state$dropdownSearch8 = _state$dropdownSearch8.value) === null || _state$dropdownSearch8 === void 0 ? void 0 : _state$dropdownSearch8.trim()) && {
1614
+ searchedValue: state.dropdownSearch.value,
1615
+ selectedOption: state.dropdownSearch.selectedOption
1616
+ }), (state === null || state === void 0 || (_state$inputSearch8 = state.inputSearch) === null || _state$inputSearch8 === void 0 || (_state$inputSearch8 = _state$inputSearch8.value) === null || _state$inputSearch8 === void 0 ? void 0 : _state$inputSearch8.trim()) && {
1617
+ searchedValue: state.inputSearch.value
1618
+ }), {}, {
1619
+ selectedTab: state === null || state === void 0 || (_state$tabs14 = state.tabs) === null || _state$tabs14 === void 0 ? void 0 : _state$tabs14.active,
1620
+ current: tables === null || tables === void 0 || (_tables$pagination7 = tables.pagination) === null || _tables$pagination7 === void 0 ? void 0 : _tables$pagination7.current,
1621
+ pageSize: tables === null || tables === void 0 || (_tables$pagination8 = tables.pagination) === null || _tables$pagination8 === void 0 ? void 0 : _tables$pagination8.pageSize,
1622
+ columnFilterStatus: tables === null || tables === void 0 || (_tables$filter9 = tables.filter) === null || _tables$filter9 === void 0 ? void 0 : _tables$filter9.value,
1623
+ field: tables === null || tables === void 0 || (_tables$sorting21 = tables.sorting) === null || _tables$sorting21 === void 0 ? void 0 : _tables$sorting21.sortBy,
1624
+ order: tables === null || tables === void 0 || (_tables$sorting22 = tables.sorting) === null || _tables$sorting22 === void 0 ? void 0 : _tables$sorting22.sortDirection
1625
+ }, (header === null || header === void 0 || (_header$subHeading25 = header.subHeading) === null || _header$subHeading25 === void 0 || (_header$subHeading25 = _header$subHeading25.jsxConfig) === null || _header$subHeading25 === void 0 ? void 0 : _header$subHeading25.type) == "select" ? {
1626
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading26 = header.subHeading) === null || _header$subHeading26 === void 0 || (_header$subHeading26 = _header$subHeading26.jsxConfig) === null || _header$subHeading26 === void 0 ? void 0 : _header$subHeading26.value
1627
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data10 = staticFilter.data) === null || _staticFilter$data10 === void 0 || (_staticFilter$data10 = _staticFilter$data10.find(item => item.selected)) === null || _staticFilter$data10 === void 0 ? void 0 : _staticFilter$data10.value) && {
1628
+ staticFilter: staticFilter.data.find(item => item.selected).value
1629
+ }), {}, {
1630
+ fromDate: formData === null || formData === void 0 ? void 0 : formData.fromDate,
1631
+ toDate: formData === null || formData === void 0 ? void 0 : formData.toDate
1632
+ }, appliedFilters), (formData === null || formData === void 0 ? void 0 : formData.exportType) && {
1633
+ exportType: formData === null || formData === void 0 ? void 0 : formData.exportType
1634
+ }), (_state$misc21 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc21 !== void 0 ? _state$misc21 : {}), {}, {
1635
+ multiSelectValue: (_state$staticFilter$m10 = state === null || state === void 0 || (_state$staticFilter10 = state.staticFilter) === null || _state$staticFilter10 === void 0 ? void 0 : _state$staticFilter10.multiSelectValue) !== null && _state$staticFilter$m10 !== void 0 ? _state$staticFilter$m10 : []
1636
+ })));
1637
+ if (error) {
1638
+ showErrorNotification(error);
1639
+ } else {
1640
+ var _formData$fileName;
1641
+ (0, _downloadFile.default)(data, (_formData$fileName = formData.fileName) !== null && _formData$fileName !== void 0 ? _formData$fileName : undefined);
1642
+ dispatch({
1643
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
1644
+ });
1645
+ }
1646
+ }
1647
+ }
1648
+ };
1649
+ const onClearAllAppliedFilters = async () => {
1650
+ var _state$dropdownSearch9, _state$inputSearch9, _state$tabs15, _tables$pagination9, _tables$pagination10, _tables$filter10, _tables$sorting23, _header$subHeading27, _header$subHeading28, _staticFilter$data11, _tables$sorting24, _state$misc22, _state$staticFilter$m11, _state$staticFilter11;
1651
+ const {
1652
+ error,
1653
+ data
1654
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch9 = state.dropdownSearch) === null || _state$dropdownSearch9 === void 0 || (_state$dropdownSearch9 = _state$dropdownSearch9.value) === null || _state$dropdownSearch9 === void 0 ? void 0 : _state$dropdownSearch9.trim()) && {
1655
+ searchedValue: state.dropdownSearch.value,
1656
+ selectedOption: state.dropdownSearch.selectedOption
1657
+ }), (state === null || state === void 0 || (_state$inputSearch9 = state.inputSearch) === null || _state$inputSearch9 === void 0 || (_state$inputSearch9 = _state$inputSearch9.value) === null || _state$inputSearch9 === void 0 ? void 0 : _state$inputSearch9.trim()) && {
1658
+ searchedValue: state.inputSearch.value
1659
+ }), {}, {
1660
+ selectedTab: state === null || state === void 0 || (_state$tabs15 = state.tabs) === null || _state$tabs15 === void 0 ? void 0 : _state$tabs15.active,
1661
+ current: tables === null || tables === void 0 || (_tables$pagination9 = tables.pagination) === null || _tables$pagination9 === void 0 ? void 0 : _tables$pagination9.current,
1662
+ pageSize: tables === null || tables === void 0 || (_tables$pagination10 = tables.pagination) === null || _tables$pagination10 === void 0 ? void 0 : _tables$pagination10.pageSize
1663
+ }, (tables === null || tables === void 0 || (_tables$filter10 = tables.filter) === null || _tables$filter10 === void 0 ? void 0 : _tables$filter10.key) && {
1664
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
1665
+ }), {}, {
1666
+ field: tables === null || tables === void 0 || (_tables$sorting23 = tables.sorting) === null || _tables$sorting23 === void 0 ? void 0 : _tables$sorting23.sortBy
1667
+ }, (header === null || header === void 0 || (_header$subHeading27 = header.subHeading) === null || _header$subHeading27 === void 0 || (_header$subHeading27 = _header$subHeading27.jsxConfig) === null || _header$subHeading27 === void 0 ? void 0 : _header$subHeading27.type) == "select" ? {
1668
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading28 = header.subHeading) === null || _header$subHeading28 === void 0 || (_header$subHeading28 = _header$subHeading28.jsxConfig) === null || _header$subHeading28 === void 0 ? void 0 : _header$subHeading28.value
1669
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data11 = staticFilter.data) === null || _staticFilter$data11 === void 0 || (_staticFilter$data11 = _staticFilter$data11.find(item => item.selected)) === null || _staticFilter$data11 === void 0 ? void 0 : _staticFilter$data11.value) && {
1670
+ staticFilter: staticFilter.data.find(item => item.selected).value
1671
+ }), {}, {
1672
+ order: tables === null || tables === void 0 || (_tables$sorting24 = tables.sorting) === null || _tables$sorting24 === void 0 ? void 0 : _tables$sorting24.sortDirection
1673
+ }, (_state$misc22 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc22 !== void 0 ? _state$misc22 : {}), {}, {
1674
+ multiSelectValue: (_state$staticFilter$m11 = state === null || state === void 0 || (_state$staticFilter11 = state.staticFilter) === null || _state$staticFilter11 === void 0 ? void 0 : _state$staticFilter11.multiSelectValue) !== null && _state$staticFilter$m11 !== void 0 ? _state$staticFilter$m11 : []
1675
+ }));
1676
+ if (error) {
1677
+ showErrorNotification(error);
1678
+ dispatch({
1679
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1680
+ });
1681
+ } else {
1682
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1683
+ setStaticFilterData(data);
1684
+ }
1685
+ dispatch({
1686
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1687
+ payload: data
1688
+ });
1689
+ dispatch({
1690
+ type: _layoutReducer.actionTypes.CLEAR_ALL_APPLIED_FILTERS
1691
+ });
1692
+ }
1693
+ };
1694
+ const syncFilterFormWithAppliedFilters = appliedFilters => {
1695
+ dispatch({
1696
+ type: _layoutReducer.actionTypes.UPDATE_FILTER_FORM_VALUES,
1697
+ payload: {
1698
+ formValues: appliedFilters
1699
+ }
1700
+ });
1701
+ };
1702
+
1703
+ /**
1704
+ * Handles the modal footer click event.
1705
+ *
1706
+ * @async
1707
+ * @function
1708
+ * @param {String} action - The action to be performed.
1709
+ * @param {Object} buttonConfig - The button configuration.
1710
+ * @returns {Promise<void>} - Resolves after the action is handled.
1711
+ *
1712
+ * Handles the modal footer button clicks with the following actions:
1713
+ * - "CLOSE_MODAL": Closes the modal.
1714
+ * - "CLOSE_MODAL_AND_FETCH": Calls the `handleModalCloseSuccess` function
1715
+ * if provided, and closes the modal if successful. Also re-initializes the
1716
+ * state.
1717
+ * - Any other action: Calls the `handleDrawerFormOnFinish` function if
1718
+ * provided, with the action as "APPROVE" and the order UUIDs from the
1719
+ * selected row keys. Closes the modal and re-initializes the state if
1720
+ * successful.
1721
+ */
1722
+
1723
+ const onClickModalFooter = async (action, buttonConfig) => {
1724
+ if (action === "CLOSE_MODAL") {
1725
+ dispatch({
1726
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
1727
+ payload: false
1728
+ });
1729
+ return;
1730
+ } else if (action === "CLOSE_MODAL_AND_FETCH") {
1731
+ if (handleModalCloseSuccess) {
1732
+ var _stateRef$current, _state$misc23;
1733
+ const {
1734
+ error,
1735
+ data
1736
+ } = await (handleModalCloseSuccess === null || handleModalCloseSuccess === void 0 ? void 0 : handleModalCloseSuccess(_objectSpread({
1737
+ modalValue: stateRef === null || stateRef === void 0 || (_stateRef$current = stateRef.current) === null || _stateRef$current === void 0 || (_stateRef$current = _stateRef$current.modal) === null || _stateRef$current === void 0 ? void 0 : _stateRef$current.value,
1738
+ call: buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.call
1739
+ }, (_state$misc23 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc23 !== void 0 ? _state$misc23 : {})));
1740
+ if (error) {
1741
+ showErrorNotification(error);
1742
+ } else {
1743
+ showSuccessNotification(data === null || data === void 0 ? void 0 : data.message);
1744
+ dispatch({
1745
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
1746
+ payload: false
1747
+ });
1748
+ init();
1749
+ }
1750
+ }
1751
+ } else {
1752
+ if (handleDrawerFormOnFinish) {
1753
+ var _state$tables$selecte, _state$tables3, _state$misc24;
1754
+ let req = {};
1755
+ req.type = "APPROVE";
1756
+ req.orderUUID = (_state$tables$selecte = state === null || state === void 0 || (_state$tables3 = state.tables) === null || _state$tables3 === void 0 || (_state$tables3 = _state$tables3.selectedRowKeys) === null || _state$tables3 === void 0 ? void 0 : _state$tables3.map(item => item.orderUUID)) !== null && _state$tables$selecte !== void 0 ? _state$tables$selecte : [];
1757
+ req.misc = (_state$misc24 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc24 !== void 0 ? _state$misc24 : {};
1758
+ const {
1759
+ error,
1760
+ data
1761
+ } = await (handleDrawerFormOnFinish === null || handleDrawerFormOnFinish === void 0 ? void 0 : handleDrawerFormOnFinish(req));
1762
+ if (error) {
1763
+ showErrorNotification(error);
1764
+ } else {
1765
+ showSuccessNotification(data === null || data === void 0 ? void 0 : data.message);
1766
+ dispatch({
1767
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
1768
+ payload: false
1769
+ });
1770
+ init();
1771
+ }
1772
+ }
1773
+ }
1774
+ };
1775
+ const emptyTableState = /*#__PURE__*/_react.default.createElement(_antd.Empty, {
1776
+ image: /*#__PURE__*/_react.default.createElement("img", {
1777
+ src: _astronaut_emptystate.default,
1778
+ alt: "Nothing to show yet"
1779
+ }),
1780
+ description: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1781
+ className: "margin-top-24"
1782
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
1783
+ color: "primary-content",
1784
+ typography: "type-t1-500"
1785
+ }, "Nothing available at the moment")), /*#__PURE__*/_react.default.createElement("div", {
1786
+ className: "margin-top-12"
1787
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
1788
+ color: "secondary-content",
1789
+ typography: "type-b1-400"
1790
+ }, "There is currently no data to display. We will update automatically when new information is available.")))
1791
+ });
1792
+
1793
+ /**
1794
+ * Handles the left header button click event.
1795
+ *
1796
+ * @async
1797
+ * @function
1798
+ * @param {Object} configArgs - The button configuration arguments.
1799
+ * @returns {Promise<void>} - Resolves after the action is handled.
1800
+ *
1801
+ * Handles the left header button clicks with the following actions:
1802
+ * - "EXPORT_DATA": Triggers data export functionality.
1803
+ * - "OPEN_DRAWER": Opens a drawer with the specified key.
1804
+ * - "OPEN_MODAL": Opens a modal with updated content.
1805
+ */
1806
+ const leftHeaderFirstButtonClick = async () => {
1807
+ if ((leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.action) === "OPEN_CUSTOM_DRAWER") {
1808
+ var _config$customDrawer3;
1809
+ const drawerData = config === null || config === void 0 || (_config$customDrawer3 = config.customDrawer) === null || _config$customDrawer3 === void 0 || (_config$customDrawer3 = _config$customDrawer3.data) === null || _config$customDrawer3 === void 0 ? void 0 : _config$customDrawer3[leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.drawerKey];
1810
+ dispatch({
1811
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER,
1812
+ payload: drawerData
1813
+ });
1814
+ dispatch({
1815
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_OPEN
1816
+ });
1817
+ }
1818
+ };
1819
+
1820
+ /**
1821
+ * Handles the right header button click event.
1822
+ *
1823
+ * @async
1824
+ * @function
1825
+ * @param {Object} configArgs - The button configuration arguments.
1826
+ * @returns {Promise<void>} - Resolves after the action is handled.
1827
+ *
1828
+ * Handles the right header button clicks with the following actions:
1829
+ * - "OPEN_FILTER_DRAWER": Opens the filter drawer.
1830
+ * - "OPEN_DRAWER": Opens a drawer with the specified key.
1831
+ */
1832
+ const rightHeaderFirstButtonClick = async () => {
1833
+ if ((rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.action) === "OPEN_CUSTOM_DRAWER") {
1834
+ var _config$customDrawer4, _state$customDrawer2;
1835
+ const drawerData = config === null || config === void 0 || (_config$customDrawer4 = config.customDrawer) === null || _config$customDrawer4 === void 0 || (_config$customDrawer4 = _config$customDrawer4.data) === null || _config$customDrawer4 === void 0 ? void 0 : _config$customDrawer4[rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.drawerKey];
1836
+ dispatch({
1837
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER,
1838
+ payload: drawerData
1839
+ });
1840
+ dispatch({
1841
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_OPEN
1842
+ });
1843
+
1844
+ // Sync the filter form with applied filters if they exist
1845
+ if (state !== null && state !== void 0 && (_state$customDrawer2 = state.customDrawer) !== null && _state$customDrawer2 !== void 0 && _state$customDrawer2.appliedFilters && Object.keys(state.customDrawer.appliedFilters).length > 0) {
1846
+ syncFilterFormWithAppliedFilters(state.customDrawer.appliedFilters);
1847
+ }
1848
+ } else if ((rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.action) === "OPEN_DRAWER") {
1849
+ dispatch({
1850
+ type: _layoutReducer.actionTypes.TOGGLE_DRAWER,
1851
+ payload: rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.key
1852
+ });
1853
+ }
1854
+ };
1855
+ const rightHeaderSecondButtonClick = async () => {
1856
+ if ((rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.action) === "RESET_CUSTOM_DRAWER") {
1857
+ var _state$dropdownSearch10, _state$inputSearch10, _state$tabs16, _tables$pagination11, _tables$pagination12, _tables$filter11, _tables$sorting25, _header$subHeading29, _header$subHeading30, _staticFilter$data12, _tables$sorting26, _state$misc25, _state$staticFilter$m12, _state$staticFilter12;
1858
+ const {
1859
+ error,
1860
+ data
1861
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch10 = state.dropdownSearch) === null || _state$dropdownSearch10 === void 0 || (_state$dropdownSearch10 = _state$dropdownSearch10.value) === null || _state$dropdownSearch10 === void 0 ? void 0 : _state$dropdownSearch10.trim()) && {
1862
+ searchedValue: state.dropdownSearch.value,
1863
+ selectedOption: state.dropdownSearch.selectedOption
1864
+ }), (state === null || state === void 0 || (_state$inputSearch10 = state.inputSearch) === null || _state$inputSearch10 === void 0 || (_state$inputSearch10 = _state$inputSearch10.value) === null || _state$inputSearch10 === void 0 ? void 0 : _state$inputSearch10.trim()) && {
1865
+ searchedValue: state.inputSearch.value
1866
+ }), {}, {
1867
+ selectedTab: state === null || state === void 0 || (_state$tabs16 = state.tabs) === null || _state$tabs16 === void 0 ? void 0 : _state$tabs16.active,
1868
+ current: tables === null || tables === void 0 || (_tables$pagination11 = tables.pagination) === null || _tables$pagination11 === void 0 ? void 0 : _tables$pagination11.current,
1869
+ pageSize: tables === null || tables === void 0 || (_tables$pagination12 = tables.pagination) === null || _tables$pagination12 === void 0 ? void 0 : _tables$pagination12.pageSize
1870
+ }, (tables === null || tables === void 0 || (_tables$filter11 = tables.filter) === null || _tables$filter11 === void 0 ? void 0 : _tables$filter11.key) && {
1871
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
1872
+ }), {}, {
1873
+ field: tables === null || tables === void 0 || (_tables$sorting25 = tables.sorting) === null || _tables$sorting25 === void 0 ? void 0 : _tables$sorting25.sortBy
1874
+ }, (header === null || header === void 0 || (_header$subHeading29 = header.subHeading) === null || _header$subHeading29 === void 0 || (_header$subHeading29 = _header$subHeading29.jsxConfig) === null || _header$subHeading29 === void 0 ? void 0 : _header$subHeading29.type) == "select" ? {
1875
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading30 = header.subHeading) === null || _header$subHeading30 === void 0 || (_header$subHeading30 = _header$subHeading30.jsxConfig) === null || _header$subHeading30 === void 0 ? void 0 : _header$subHeading30.value
1876
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data12 = staticFilter.data) === null || _staticFilter$data12 === void 0 || (_staticFilter$data12 = _staticFilter$data12.find(item => item.selected)) === null || _staticFilter$data12 === void 0 ? void 0 : _staticFilter$data12.value) && {
1877
+ staticFilter: staticFilter.data.find(item => item.selected).value
1878
+ }), {}, {
1879
+ order: tables === null || tables === void 0 || (_tables$sorting26 = tables.sorting) === null || _tables$sorting26 === void 0 ? void 0 : _tables$sorting26.sortDirection
1880
+ }, (_state$misc25 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc25 !== void 0 ? _state$misc25 : {}), {}, {
1881
+ multiSelectValue: (_state$staticFilter$m12 = state === null || state === void 0 || (_state$staticFilter12 = state.staticFilter) === null || _state$staticFilter12 === void 0 ? void 0 : _state$staticFilter12.multiSelectValue) !== null && _state$staticFilter$m12 !== void 0 ? _state$staticFilter$m12 : []
1882
+ }));
1883
+ if (error) {
1884
+ showErrorNotification(error);
1885
+ dispatch({
1886
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1887
+ });
1888
+ } else {
1889
+ var _config$customDrawer5;
1890
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
1891
+ setStaticFilterData(data);
1892
+ }
1893
+ dispatch({
1894
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1895
+ payload: data
1896
+ });
1897
+ dispatch({
1898
+ type: _layoutReducer.actionTypes.CLEAR_ALL_APPLIED_FILTERS
1899
+ });
1900
+ const drawerData = config === null || config === void 0 || (_config$customDrawer5 = config.customDrawer) === null || _config$customDrawer5 === void 0 || (_config$customDrawer5 = _config$customDrawer5.data) === null || _config$customDrawer5 === void 0 ? void 0 : _config$customDrawer5[rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.drawerKey];
1901
+ if (drawerData) {
1902
+ dispatch({
1903
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER,
1904
+ payload: drawerData
1905
+ });
1906
+ }
1907
+ }
1908
+ }
1909
+ };
1910
+
1911
+ /**
1912
+ * @function
1913
+ * @param {Object} selectedOption - The selected option from the custom select.
1914
+ * @param {String} key - The key of the drawer data to be updated.
1915
+ * @param {String} action - The custom select action.
1916
+ * @description
1917
+ * Updates the state of the drawer data with the selected option value
1918
+ * for the given key when the action is "changeBillingAddress".
1919
+ */
1920
+ const updateStateData = (selectedOption, key, action) => {
1921
+ if (action === "changeBillingAddress") {
1922
+ dispatch({
1923
+ type: _layoutReducer.actionTypes.SET_CUSTOM_DRAWER_DATA_SELECT,
1924
+ payload: {
1925
+ key: key,
1926
+ value: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.subLabel
1927
+ }
1928
+ });
1929
+ }
1930
+ };
1931
+ const handleSubHeadingSelect = async val => {
1932
+ if (val) {
1933
+ var _state$tabs17, _tables$pagination13, _tables$pagination14, _state$misc26;
1934
+ dispatch({
1935
+ type: _layoutReducer.actionTypes.SET_SUBHEADING_SELECTED_CONFIG,
1936
+ payload: val
1937
+ });
1938
+ const {
1939
+ error,
1940
+ data
1941
+ } = await handleSubHeadingSelectClick(_objectSpread({
1942
+ selectedTab: state === null || state === void 0 || (_state$tabs17 = state.tabs) === null || _state$tabs17 === void 0 ? void 0 : _state$tabs17.active,
1943
+ searchedValue: inputSearch === null || inputSearch === void 0 ? void 0 : inputSearch.value,
1944
+ current: tables === null || tables === void 0 || (_tables$pagination13 = tables.pagination) === null || _tables$pagination13 === void 0 ? void 0 : _tables$pagination13.current,
1945
+ pageSize: tables === null || tables === void 0 || (_tables$pagination14 = tables.pagination) === null || _tables$pagination14 === void 0 ? void 0 : _tables$pagination14.pageSize,
1946
+ subHeadingSelectVal: val
1947
+ }, (_state$misc26 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc26 !== void 0 ? _state$misc26 : {}));
1948
+ if (error) {
1949
+ showErrorNotification(error);
1950
+ dispatch({
1951
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
1952
+ });
1953
+ } else {
1954
+ dispatch({
1955
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
1956
+ payload: data
1957
+ });
1958
+ }
1959
+ }
1960
+ };
1961
+
1962
+ /**
1963
+ * Handles static filter selection
1964
+ * @param {string} filterValue - The value of the selected filter
1965
+ */
1966
+ const onStaticFilterSelect = async filterValue => {
1967
+ const selectedFilterStatus = staticFilter.data.map(item => item.selected ? item.value : null).filter(Boolean);
1968
+ const currentSelectedIndex = selectedFilterStatus.indexOf(filterValue);
1969
+ if (currentSelectedIndex === -1) {
1970
+ selectedFilterStatus.push(filterValue);
1971
+ } else {
1972
+ selectedFilterStatus.splice(currentSelectedIndex, 1);
1973
+ }
1974
+ const multiSelectValue = [...selectedFilterStatus];
1975
+ dispatch({
1976
+ type: _layoutReducer.actionTypes.SET_STATIC_FILTER_SELECTION,
1977
+ payload: filterValue,
1978
+ source: "click"
1979
+ });
1980
+
1981
+ // Call the handler if provided
1982
+ if (handleTableChange) {
1983
+ var _state$dropdownSearch11, _state$inputSearch11, _state$tabs18, _tables$pagination15, _tables$sorting27, _tables$sorting28, _header$subHeading31, _header$subHeading32, _customDrawer$applied10, _state$misc27;
1984
+ dispatch({
1985
+ type: _layoutReducer.actionTypes.SET_LOADING,
1986
+ payload: true
1987
+ });
1988
+ const {
1989
+ error,
1990
+ data
1991
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch11 = state.dropdownSearch) === null || _state$dropdownSearch11 === void 0 || (_state$dropdownSearch11 = _state$dropdownSearch11.value) === null || _state$dropdownSearch11 === void 0 ? void 0 : _state$dropdownSearch11.trim()) && {
1992
+ searchedValue: state.dropdownSearch.value,
1993
+ selectedOption: state.dropdownSearch.selectedOption
1994
+ }), (state === null || state === void 0 || (_state$inputSearch11 = state.inputSearch) === null || _state$inputSearch11 === void 0 || (_state$inputSearch11 = _state$inputSearch11.value) === null || _state$inputSearch11 === void 0 ? void 0 : _state$inputSearch11.trim()) && {
1995
+ searchedValue: state.inputSearch.value
1996
+ }), {}, {
1997
+ selectedTab: state === null || state === void 0 || (_state$tabs18 = state.tabs) === null || _state$tabs18 === void 0 ? void 0 : _state$tabs18.active,
1998
+ current: 1,
1999
+ pageSize: tables === null || tables === void 0 || (_tables$pagination15 = tables.pagination) === null || _tables$pagination15 === void 0 ? void 0 : _tables$pagination15.pageSize,
2000
+ filterStatus: filterValue,
2001
+ field: tables === null || tables === void 0 || (_tables$sorting27 = tables.sorting) === null || _tables$sorting27 === void 0 ? void 0 : _tables$sorting27.sortBy,
2002
+ order: tables === null || tables === void 0 || (_tables$sorting28 = tables.sorting) === null || _tables$sorting28 === void 0 ? void 0 : _tables$sorting28.sortDirection
2003
+ }, (header === null || header === void 0 || (_header$subHeading31 = header.subHeading) === null || _header$subHeading31 === void 0 || (_header$subHeading31 = _header$subHeading31.jsxConfig) === null || _header$subHeading31 === void 0 ? void 0 : _header$subHeading31.type) == "select" ? {
2004
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading32 = header.subHeading) === null || _header$subHeading32 === void 0 || (_header$subHeading32 = _header$subHeading32.jsxConfig) === null || _header$subHeading32 === void 0 ? void 0 : _header$subHeading32.value
2005
+ } : {}), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied10 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied10 !== void 0 ? _customDrawer$applied10 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (_state$misc27 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc27 !== void 0 ? _state$misc27 : {}), {}, {
2006
+ staticFilter: filterValue,
2007
+ // Pass static filter value
2008
+ multiSelectValue: multiSelectValue
2009
+ }));
2010
+ if (error) {
2011
+ showErrorNotification(error);
2012
+ dispatch({
2013
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
2014
+ });
2015
+ } else {
2016
+ var _tables$pagination16;
2017
+ dispatch({
2018
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
2019
+ payload: data
2020
+ });
2021
+ // Reset pagination to first page
2022
+ dispatch({
2023
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
2024
+ payload: {
2025
+ current: 1,
2026
+ pageSize: tables === null || tables === void 0 || (_tables$pagination16 = tables.pagination) === null || _tables$pagination16 === void 0 ? void 0 : _tables$pagination16.pageSize
2027
+ }
2028
+ });
2029
+ }
2030
+ dispatch({
2031
+ type: _layoutReducer.actionTypes.SET_LOADING,
2032
+ payload: false
2033
+ });
2034
+ }
2035
+ };
2036
+ const onMobilePageChange = async _ref5 => {
2037
+ let {
2038
+ current,
2039
+ pageSize
2040
+ } = _ref5;
2041
+ dispatch({
2042
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
2043
+ payload: {
2044
+ current,
2045
+ pageSize
2046
+ }
2047
+ });
2048
+ if (handleTableChange) {
2049
+ var _state$dropdownSearch12, _state$inputSearch12, _state$tabs19, _tables$filter12, _tables$sorting29, _tables$sorting30, _header$subHeading33, _header$subHeading34, _staticFilter$data13, _customDrawer$applied11, _state$misc28, _state$staticFilter$m13, _state$staticFilter13;
2050
+ const {
2051
+ error,
2052
+ data
2053
+ } = await handleTableChange(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (state === null || state === void 0 || (_state$dropdownSearch12 = state.dropdownSearch) === null || _state$dropdownSearch12 === void 0 || (_state$dropdownSearch12 = _state$dropdownSearch12.value) === null || _state$dropdownSearch12 === void 0 ? void 0 : _state$dropdownSearch12.trim()) && {
2054
+ searchedValue: state.dropdownSearch.value,
2055
+ selectedOption: state.dropdownSearch.selectedOption
2056
+ }), (state === null || state === void 0 || (_state$inputSearch12 = state.inputSearch) === null || _state$inputSearch12 === void 0 || (_state$inputSearch12 = _state$inputSearch12.value) === null || _state$inputSearch12 === void 0 ? void 0 : _state$inputSearch12.trim()) && {
2057
+ searchedValue: state.inputSearch.value
2058
+ }), {}, {
2059
+ selectedTab: state === null || state === void 0 || (_state$tabs19 = state.tabs) === null || _state$tabs19 === void 0 ? void 0 : _state$tabs19.active,
2060
+ current,
2061
+ pageSize,
2062
+ columnFilterStatus: tables === null || tables === void 0 || (_tables$filter12 = tables.filter) === null || _tables$filter12 === void 0 ? void 0 : _tables$filter12.value,
2063
+ field: tables === null || tables === void 0 || (_tables$sorting29 = tables.sorting) === null || _tables$sorting29 === void 0 ? void 0 : _tables$sorting29.sortBy,
2064
+ order: tables === null || tables === void 0 || (_tables$sorting30 = tables.sorting) === null || _tables$sorting30 === void 0 ? void 0 : _tables$sorting30.sortDirection
2065
+ }, (header === null || header === void 0 || (_header$subHeading33 = header.subHeading) === null || _header$subHeading33 === void 0 || (_header$subHeading33 = _header$subHeading33.jsxConfig) === null || _header$subHeading33 === void 0 ? void 0 : _header$subHeading33.type) == "select" ? {
2066
+ subHeadingSelectVal: header === null || header === void 0 || (_header$subHeading34 = header.subHeading) === null || _header$subHeading34 === void 0 || (_header$subHeading34 = _header$subHeading34.jsxConfig) === null || _header$subHeading34 === void 0 ? void 0 : _header$subHeading34.value
2067
+ } : {}), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data13 = staticFilter.data) === null || _staticFilter$data13 === void 0 || (_staticFilter$data13 = _staticFilter$data13.find(item => item.selected)) === null || _staticFilter$data13 === void 0 ? void 0 : _staticFilter$data13.value) && {
2068
+ staticFilter: staticFilter.data.find(item => item.selected).value
2069
+ }), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && Object.keys((_customDrawer$applied11 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) !== null && _customDrawer$applied11 !== void 0 ? _customDrawer$applied11 : {}).length > 0 && _objectSpread({}, customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters)), (_state$misc28 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc28 !== void 0 ? _state$misc28 : {}), {}, {
2070
+ multiSelectValue: (_state$staticFilter$m13 = state === null || state === void 0 || (_state$staticFilter13 = state.staticFilter) === null || _state$staticFilter13 === void 0 ? void 0 : _state$staticFilter13.multiSelectValue) !== null && _state$staticFilter$m13 !== void 0 ? _state$staticFilter$m13 : []
2071
+ }));
2072
+ if (error) {
2073
+ showErrorNotification(error);
2074
+ dispatch({
2075
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
2076
+ });
2077
+ } else {
2078
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
2079
+ setStaticFilterData(data);
2080
+ }
2081
+ dispatch({
2082
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
2083
+ payload: data
2084
+ });
2085
+ }
2086
+ }
2087
+ };
2088
+ function isFiltersEmpty() {
2089
+ let filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2090
+ const filtersKeyLength = Object.keys(filters).length;
2091
+ if (filtersKeyLength === 0) return true;
2092
+ if (filtersKeyLength === 2) {
2093
+ return (filters === null || filters === void 0 ? void 0 : filters.drawerKey) && (filters === null || filters === void 0 ? void 0 : filters.type);
2094
+ }
2095
+ return false;
2096
+ }
2097
+ console.log(state, "GenricLayOutstate");
2098
+ return /*#__PURE__*/_react.default.createElement(_styles.OapageWithDataStyle, {
2099
+ marginBottom: infoPanel !== null && infoPanel !== void 0 && infoPanel.bottomMarginRequired ? "18px" : "0",
2100
+ className: (state === null || state === void 0 || (_state$misc29 = state.misc) === null || _state$misc29 === void 0 ? void 0 : _state$misc29.flow) === "hubAutomation" ? "hubAutomationContainer" : ""
2101
+ }, /*#__PURE__*/_react.default.createElement(_styles.DrawerWithOutFooter, null), /*#__PURE__*/_react.default.createElement("div", {
2102
+ className: "fullPageLayout"
2103
+ }, /*#__PURE__*/_react.default.createElement(_GlobalCss.default, null, (sidebar === null || sidebar === void 0 ? void 0 : sidebar.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2104
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2105
+ active: true,
2106
+ style: {
2107
+ width: 300
2108
+ }
2109
+ }, /*#__PURE__*/_react.default.createElement(_SidebarWidget.default, _extends({}, sidebar, {
2110
+ handleFooterClick: handleFooterClick,
2111
+ profileData: profileData
2112
+ }))), /*#__PURE__*/_react.default.createElement("div", {
2113
+ className: "oaRightLayouts"
2114
+ }, /*#__PURE__*/_react.default.createElement("div", {
2115
+ className: "oaTopHeaderAndBtnSec "
2116
+ }, /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2117
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2118
+ active: true
2119
+ }, /*#__PURE__*/_react.default.createElement("div", {
2120
+ className: "headerContent"
2121
+ }, /*#__PURE__*/_react.default.createElement("div", {
2122
+ className: "headerLeft"
2123
+ }, (header === null || header === void 0 ? void 0 : header.visible) && /*#__PURE__*/_react.default.createElement(_Header.default, _extends({}, header, {
2124
+ onSubHeadingClick: onSubHeadingClick,
2125
+ handleSubHeadingSelect: handleSubHeadingSelect
2126
+ }))), /*#__PURE__*/_react.default.createElement("div", {
2127
+ className: "headerRight"
2128
+ }, /*#__PURE__*/_react.default.createElement("div", {
2129
+ className: (sidebar === null || sidebar === void 0 || (_sidebar$mobileMenuIt = sidebar.mobileMenuItems) === null || _sidebar$mobileMenuIt === void 0 || (_sidebar$mobileMenuIt = _sidebar$mobileMenuIt.items) === null || _sidebar$mobileMenuIt === void 0 ? void 0 : _sidebar$mobileMenuIt.length) > 0 ? "hideProfileOnMobile" : ""
2130
+ }, /*#__PURE__*/_react.default.createElement(_ProfileSection.default, {
2131
+ profileData: profileData,
2132
+ onProfileClick: () => {
2133
+ handleProfileReroute();
2134
+ }
2135
+ })))))), /*#__PURE__*/_react.default.createElement("div", {
2136
+ className: "layoutHeadingAndSearch"
2137
+ }, (imageViewer === null || imageViewer === void 0 ? void 0 : imageViewer.visible) && /*#__PURE__*/_react.default.createElement(_CustomViewer.default, {
2138
+ open: true,
2139
+ previewFile: imageViewer === null || imageViewer === void 0 || (_imageViewer$content = imageViewer.content) === null || _imageViewer$content === void 0 ? void 0 : _imageViewer$content.url,
2140
+ title: imageViewer === null || imageViewer === void 0 || (_imageViewer$content2 = imageViewer.content) === null || _imageViewer$content2 === void 0 ? void 0 : _imageViewer$content2.name,
2141
+ onCancel: () => dispatch({
2142
+ type: _layoutReducer.actionTypes.TOGGLE_IMAGE_VIEW
2143
+ }),
2144
+ downloadCallback: () => {
2145
+ var _imageViewer$content3;
2146
+ return downloadFileOnS3({
2147
+ url: imageViewer === null || imageViewer === void 0 || (_imageViewer$content3 = imageViewer.content) === null || _imageViewer$content3 === void 0 ? void 0 : _imageViewer$content3.url
2148
+ });
2149
+ }
2150
+ }), (cards === null || cards === void 0 ? void 0 : cards.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2151
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2152
+ active: true,
2153
+ paragraph: {
2154
+ rows: 1
2155
+ }
2156
+ }, /*#__PURE__*/_react.default.createElement(_CardList.default, {
2157
+ cards: cards === null || cards === void 0 ? void 0 : cards.data
2158
+ })), (dropdownSearch === null || dropdownSearch === void 0 ? void 0 : dropdownSearch.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2159
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2160
+ active: true,
2161
+ paragraph: {
2162
+ rows: 1
2163
+ }
2164
+ }, /*#__PURE__*/_react.default.createElement("div", {
2165
+ className: "oaheaderSearchAndFilter"
2166
+ }, /*#__PURE__*/_react.default.createElement(_DropdownSearch.default, _extends({}, dropdownSearch, {
2167
+ selectedOption: dropdownSearch === null || dropdownSearch === void 0 ? void 0 : dropdownSearch.selectedOption,
2168
+ onInputChange: onDropdownSearchInputChange,
2169
+ onPressEnter: onDropdownSearchPressEnter,
2170
+ onOptionChange: onDropdownSearchOptionChange,
2171
+ allowClear: dropdownSearch === null || dropdownSearch === void 0 ? void 0 : dropdownSearch.allowClear,
2172
+ onClear: onDropdownSearchClear,
2173
+ onBlur: onDropdownSearchBlur
2174
+ })), /*#__PURE__*/_react.default.createElement("div", {
2175
+ className: "oaheaderButtons"
2176
+ }, (leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.visible) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, _extends({
2177
+ label: leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.label,
2178
+ onClick: leftHeaderFirstButtonClick,
2179
+ type: leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.type,
2180
+ size: leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.size
2181
+ }, (leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 ? void 0 : leftHeaderFirstButton.iconConfig) && {
2182
+ iconConfig: {
2183
+ icon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
2184
+ icon: leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 || (_leftHeaderFirstButto = leftHeaderFirstButton.iconConfig) === null || _leftHeaderFirstButto === void 0 ? void 0 : _leftHeaderFirstButto.icon,
2185
+ size: 24,
2186
+ color: "primary"
2187
+ }),
2188
+ position: leftHeaderFirstButton === null || leftHeaderFirstButton === void 0 || (_leftHeaderFirstButto2 = leftHeaderFirstButton.iconConfig) === null || _leftHeaderFirstButto2 === void 0 ? void 0 : _leftHeaderFirstButto2.position
2189
+ }
2190
+ })), /*#__PURE__*/_react.default.createElement("div", {
2191
+ className: "oaheaderButtonsRight"
2192
+ }, (rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.visible) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
2193
+ label: rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.label,
2194
+ onClick: rightHeaderSecondButtonClick,
2195
+ type: rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.type,
2196
+ size: rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.size
2197
+ }), (rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.visible) && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
2198
+ label: rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.label,
2199
+ onClick: rightHeaderFirstButtonClick,
2200
+ type: rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.type,
2201
+ size: rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.size,
2202
+ iconConfig: _objectSpread({}, (rightHeaderFirstButton === null || rightHeaderFirstButton === void 0 ? void 0 : rightHeaderFirstButton.showIcon) === false ? {} : {
2203
+ icon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
2204
+ icon: _FilterListRounded.default,
2205
+ size: 24,
2206
+ color: "primary"
2207
+ }),
2208
+ position: "left"
2209
+ })
2210
+ }), !isFiltersEmpty(customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.appliedFilters) && /*#__PURE__*/_react.default.createElement("span", {
2211
+ className: "notifyDot"
2212
+ })))))), (inputSearch === null || inputSearch === void 0 ? void 0 : inputSearch.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2213
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2214
+ active: true,
2215
+ paragraph: {
2216
+ rows: 1
2217
+ }
2218
+ }, /*#__PURE__*/_react.default.createElement(_Search.default, _extends({}, inputSearch, {
2219
+ onInputChange: onSearchInputChange,
2220
+ onPressEnter: onSearchPressEnter,
2221
+ allowClear: true,
2222
+ onClear: onInputSearchClear,
2223
+ onBlur: onInputSearchBlur
2224
+ }))), (infoPanel === null || infoPanel === void 0 ? void 0 : infoPanel.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2225
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2226
+ active: true,
2227
+ paragraph: {
2228
+ rows: 1
2229
+ }
2230
+ }, /*#__PURE__*/_react.default.createElement("div", {
2231
+ className: "margin-bottom-12"
2232
+ }, /*#__PURE__*/_react.default.createElement(_CustomInfo.default, {
2233
+ description: infoPanel === null || infoPanel === void 0 || (_infoPanel$data = infoPanel.data) === null || _infoPanel$data === void 0 ? void 0 : _infoPanel$data.description,
2234
+ color: infoPanel === null || infoPanel === void 0 || (_infoPanel$data2 = infoPanel.data) === null || _infoPanel$data2 === void 0 ? void 0 : _infoPanel$data2.color,
2235
+ iconConfig: {
2236
+ icon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
2237
+ color: (infoPanel === null || infoPanel === void 0 || (_infoPanel$data3 = infoPanel.data) === null || _infoPanel$data3 === void 0 || (_infoPanel$data3 = _infoPanel$data3.iconConfig) === null || _infoPanel$data3 === void 0 ? void 0 : _infoPanel$data3.color) || "warning",
2238
+ icon: infoPanel === null || infoPanel === void 0 || (_infoPanel$data4 = infoPanel.data) === null || _infoPanel$data4 === void 0 || (_infoPanel$data4 = _infoPanel$data4.iconConfig) === null || _infoPanel$data4 === void 0 ? void 0 : _infoPanel$data4.icon
2239
+ }),
2240
+ position: (infoPanel === null || infoPanel === void 0 || (_infoPanel$data5 = infoPanel.data) === null || _infoPanel$data5 === void 0 || (_infoPanel$data5 = _infoPanel$data5.iconConfig) === null || _infoPanel$data5 === void 0 ? void 0 : _infoPanel$data5.position) || "left"
2241
+ }
2242
+ }))), Object.keys((state === null || state === void 0 || (_state$customDrawer3 = state.customDrawer) === null || _state$customDrawer3 === void 0 ? void 0 : _state$customDrawer3.appliedFilters) || {}).length > 0 && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2243
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2244
+ active: true,
2245
+ paragraph: {
2246
+ rows: 1
2247
+ }
2248
+ }, /*#__PURE__*/_react.default.createElement(_AppliedFilters.default, {
2249
+ appliedFilters: state === null || state === void 0 || (_state$customDrawer4 = state.customDrawer) === null || _state$customDrawer4 === void 0 ? void 0 : _state$customDrawer4.appliedFilters,
2250
+ filterConfig: customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.data,
2251
+ onRemoveFilter: onRemoveAppliedFilter,
2252
+ onClearAll: onClearAllAppliedFilters,
2253
+ filterDrawerData: state === null || state === void 0 ? void 0 : state.customDrawer
2254
+ })), (tabs === null || tabs === void 0 ? void 0 : tabs.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2255
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2256
+ active: true,
2257
+ paragraph: {
2258
+ rows: 1
2259
+ }
2260
+ }, /*#__PURE__*/_react.default.createElement("div", {
2261
+ className: "oaTabs"
2262
+ }, /*#__PURE__*/_react.default.createElement(_CustomTabs.default, {
2263
+ data: {
2264
+ tabs: tabs === null || tabs === void 0 || (_tabs$list = tabs.list) === null || _tabs$list === void 0 ? void 0 : _tabs$list.map(tab => _objectSpread(_objectSpread({}, tab), {}, {
2265
+ label: "".concat(tab === null || tab === void 0 ? void 0 : tab.label, " (").concat((tab === null || tab === void 0 ? void 0 : tab.value) || 0, ")")
2266
+ }))
2267
+ },
2268
+ activeKey: tabs === null || tabs === void 0 ? void 0 : tabs.active,
2269
+ onTabClick: onTabClick
2270
+ }))), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2271
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2272
+ active: true,
2273
+ paragraph: {
2274
+ rows: 1
2275
+ }
2276
+ }, /*#__PURE__*/_react.default.createElement(_StaticFilter.default, {
2277
+ staticFilter: staticFilter,
2278
+ onFilterSelect: onStaticFilterSelect
2279
+ })), (tables === null || tables === void 0 ? void 0 : tables.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2280
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2281
+ active: true,
2282
+ paragraph: {
2283
+ rows: 5
2284
+ }
2285
+ }, /*#__PURE__*/_react.default.createElement(_styles.TableDataStyle, null, /*#__PURE__*/_react.default.createElement("div", {
2286
+ className: "tableContainerList"
2287
+ }, /*#__PURE__*/_react.default.createElement(_CustomTableV.default, {
2288
+ columns: (_tables$columns3 = tables === null || tables === void 0 || (_tables$columns4 = tables.columns) === null || _tables$columns4 === void 0 ? void 0 : _tables$columns4[(_tabs$active3 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active3 !== void 0 ? _tabs$active3 : "default"]) !== null && _tables$columns3 !== void 0 ? _tables$columns3 : [],
2289
+ dataSource: Array.isArray(tables === null || tables === void 0 ? void 0 : tables.data) ? tables === null || tables === void 0 ? void 0 : tables.data : [],
2290
+ onChange: onTableChange,
2291
+ customTableChange: customTableChange,
2292
+ pagination: tables === null || tables === void 0 ? void 0 : tables.pagination,
2293
+ selectedRows: (state === null || state === void 0 || (_state$tables4 = state.tables) === null || _state$tables4 === void 0 ? void 0 : _state$tables4.selectedRowKeys) || [],
2294
+ rowSelection: (tables === null || tables === void 0 || (_tables$selectionType = tables.selectionType) === null || _tables$selectionType === void 0 ? void 0 : _tables$selectionType[(_tabs$active4 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active4 !== void 0 ? _tabs$active4 : "default"]) && Object.assign({
2295
+ type: tables === null || tables === void 0 || (_tables$selectionType2 = tables.selectionType) === null || _tables$selectionType2 === void 0 ? void 0 : _tables$selectionType2[tabs === null || tabs === void 0 ? void 0 : tabs.active]
2296
+ }, rowSelection),
2297
+ locale: {
2298
+ emptyText: emptyTableState
2299
+ },
2300
+ emptyStateCard: emptyTableState,
2301
+ onMobilePageChange: tables !== null && tables !== void 0 && (_tables$pagination17 = tables.pagination) !== null && _tables$pagination17 !== void 0 && _tables$pagination17.mwebPagination ? onMobilePageChange : undefined
2302
+ })))), (drawer === null || drawer === void 0 ? void 0 : drawer.visible) && /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
2303
+ className: "oaDrawer",
2304
+ title: drawer === null || drawer === void 0 || (_drawer$data = drawer.data) === null || _drawer$data === void 0 || (_drawer$data = _drawer$data[(_tabs$active5 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active5 !== void 0 ? _tabs$active5 : "default"]) === null || _drawer$data === void 0 || (_drawer$data = _drawer$data[drawer === null || drawer === void 0 ? void 0 : drawer.active]) === null || _drawer$data === void 0 ? void 0 : _drawer$data.title,
2305
+ onClose: () => dispatch({
2306
+ type: _layoutReducer.actionTypes.CLOSE_DRAWER
2307
+ }),
2308
+ footer: null,
2309
+ destroyOnClose: true,
2310
+ zIndex: 1000
2311
+ }, /*#__PURE__*/_react.default.createElement(_DetailDataLayout.default, _extends({}, (_drawer$data$drawer$a = drawer === null || drawer === void 0 || (_drawer$data2 = drawer.data) === null || _drawer$data2 === void 0 || (_drawer$data2 = _drawer$data2[(_tabs$active6 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active6 !== void 0 ? _tabs$active6 : "default"]) === null || _drawer$data2 === void 0 ? void 0 : _drawer$data2[drawer === null || drawer === void 0 ? void 0 : drawer.active]) !== null && _drawer$data$drawer$a !== void 0 ? _drawer$data$drawer$a : {}, {
2312
+ activeTab: (_tabs$active7 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active7 !== void 0 ? _tabs$active7 : "default",
2313
+ handleDrawerFormOnFinish: drawerFormOnFinish,
2314
+ generateS3Url: generateS3Url,
2315
+ downloadFileOnS3: downloadFileOnS3,
2316
+ uploadOnS3: uploadOnS3,
2317
+ onSelectHandlers: updateStateData,
2318
+ handleCollapsibleKeyData: handleCollapsibleKeyData
2319
+ }))), (nestedDrawer === null || nestedDrawer === void 0 ? void 0 : nestedDrawer.visible) && /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
2320
+ className: "oaDrawer",
2321
+ title: nestedDrawer === null || nestedDrawer === void 0 || (_nestedDrawer$data = nestedDrawer.data) === null || _nestedDrawer$data === void 0 || (_nestedDrawer$data = _nestedDrawer$data.cancelOrder) === null || _nestedDrawer$data === void 0 ? void 0 : _nestedDrawer$data.title,
2322
+ onClose: () => dispatch({
2323
+ type: _layoutReducer.actionTypes.NESTED_DRAWER_CLOSED
2324
+ }),
2325
+ footer: null,
2326
+ destroyOnClose: true,
2327
+ zIndex: 1000
2328
+ }, /*#__PURE__*/_react.default.createElement(_DetailDataLayout.default, _extends({}, (_nestedDrawer$data$ca = nestedDrawer === null || nestedDrawer === void 0 || (_nestedDrawer$data2 = nestedDrawer.data) === null || _nestedDrawer$data2 === void 0 ? void 0 : _nestedDrawer$data2.cancelOrder) !== null && _nestedDrawer$data$ca !== void 0 ? _nestedDrawer$data$ca : {}, {
2329
+ handleDrawerFormOnFinish: drawerFormOnFinish
2330
+ }))), (customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.visible) && /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
2331
+ className: "oaDrawer",
2332
+ title: customDrawer === null || customDrawer === void 0 || (_customDrawer$data = customDrawer.data) === null || _customDrawer$data === void 0 ? void 0 : _customDrawer$data.title,
2333
+ onClose: () => dispatch({
2334
+ type: _layoutReducer.actionTypes.CUSTOM_DRAWER_CLOSED
2335
+ }),
2336
+ footer: null,
2337
+ destroyOnClose: true,
2338
+ zIndex: 1000
2339
+ }, /*#__PURE__*/_react.default.createElement(_DetailDataLayout.default, _extends({}, (_customDrawer$data2 = customDrawer === null || customDrawer === void 0 ? void 0 : customDrawer.data) !== null && _customDrawer$data2 !== void 0 ? _customDrawer$data2 : {}, {
2340
+ handleDrawerFormOnFinish: filterFormOnFinish
2341
+ }))), (contentPanel === null || contentPanel === void 0 ? void 0 : contentPanel.visible) && Array.isArray(contentPanel === null || contentPanel === void 0 ? void 0 : contentPanel.dataSource) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2342
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2343
+ active: true,
2344
+ paragraph: {
2345
+ rows: 2
2346
+ }
2347
+ }, contentPanel === null || contentPanel === void 0 || (_contentPanel$dataSou = contentPanel.dataSource) === null || _contentPanel$dataSou === void 0 ? void 0 : _contentPanel$dataSou.map((item, i) => /*#__PURE__*/_react.default.createElement(_ContentPanel.default, _extends({
2348
+ key: i
2349
+ }, item)))), (tables === null || tables === void 0 || (_tables$tableFooter = tables.tableFooter) === null || _tables$tableFooter === void 0 ? void 0 : _tables$tableFooter.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2350
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2351
+ active: true,
2352
+ paragraph: {
2353
+ rows: 1
2354
+ }
2355
+ }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2356
+ className: "bottomSelectedSecion"
2357
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
2358
+ color: "secondary-content",
2359
+ typography: "type-button-500"
2360
+ }, /*#__PURE__*/_react.default.createElement("span", null, "".concat(tables === null || tables === void 0 || (_tables$selectedRowKe = tables.selectedRowKeys) === null || _tables$selectedRowKe === void 0 ? void 0 : _tables$selectedRowKe.length, " ").concat(tables === null || tables === void 0 || (_tables$tableFooter2 = tables.tableFooter) === null || _tables$tableFooter2 === void 0 ? void 0 : _tables$tableFooter2.text))), /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
2361
+ type: tables === null || tables === void 0 || (_tables$tableFooter3 = tables.tableFooter) === null || _tables$tableFooter3 === void 0 || (_tables$tableFooter3 = _tables$tableFooter3.jsxConfig) === null || _tables$tableFooter3 === void 0 ? void 0 : _tables$tableFooter3.buttonType,
2362
+ onClick: () => {
2363
+ var _tables$tableFooter4;
2364
+ return customTableSelectFooterClick(tables === null || tables === void 0 || (_tables$tableFooter4 = tables.tableFooter) === null || _tables$tableFooter4 === void 0 ? void 0 : _tables$tableFooter4.jsxConfig);
2365
+ },
2366
+ label: tables === null || tables === void 0 || (_tables$tableFooter5 = tables.tableFooter) === null || _tables$tableFooter5 === void 0 || (_tables$tableFooter5 = _tables$tableFooter5.jsxConfig) === null || _tables$tableFooter5 === void 0 ? void 0 : _tables$tableFooter5.label
2367
+ })))), (modal === null || modal === void 0 ? void 0 : modal.visible) && /*#__PURE__*/_react.default.createElement(_Modal.default, {
2368
+ modal: modal,
2369
+ onCancel: () => dispatch({
2370
+ type: _layoutReducer.actionTypes.TOGGLE_MODAL,
2371
+ payload: false
2372
+ }),
2373
+ onFooterAction: onClickModalFooter,
2374
+ handleSwitchSelectItem: handleSwitchSelectItem
2375
+ }))), /*#__PURE__*/_react.default.createElement(_CustomNotification.default, {
2376
+ ref: notificationRef
2377
+ }))));
2378
+ }
2379
+ GenricLayOut.propTypes = {};
2380
+ GenricLayOut.defaultProps = {};
2381
+ var _default = exports.default = GenricLayOut;