oa-componentbook 1.0.1-stage.35 → 1.0.1-stage.351

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