oa-componentbook 1.0.1-stage.46 → 1.0.1-stage.461

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