oa-componentbook 1.0.1-stage.40 → 1.0.1-stage.401

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