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

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