@bigbinary/neeto-approvals-frontend 1.0.1 → 1.2.0
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.
- package/dist/Approvals.js +1086 -0
- package/dist/Approvals.js.map +1 -0
- package/dist/Form.js +219 -0
- package/dist/Form.js.map +1 -0
- package/dist/Public.js +174 -0
- package/dist/Public.js.map +1 -0
- package/dist/RequestDetailsPane.js +26 -0
- package/dist/RequestDetailsPane.js.map +1 -0
- package/dist/cjs/Approvals.js +1134 -0
- package/dist/cjs/Approvals.js.map +1 -0
- package/dist/cjs/Form.js +231 -0
- package/dist/cjs/Form.js.map +1 -0
- package/dist/cjs/Public.js +188 -0
- package/dist/cjs/Public.js.map +1 -0
- package/dist/cjs/RequestDetailsPane.js +32 -0
- package/dist/cjs/RequestDetailsPane.js.map +1 -0
- package/dist/cjs/index.js +62 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/constants-752da2ba.js +158 -0
- package/dist/constants-752da2ba.js.map +1 -0
- package/dist/constants-d561fb6c.js +194 -0
- package/dist/constants-d561fb6c.js.map +1 -0
- package/dist/index-458211fe.js +271 -0
- package/dist/index-458211fe.js.map +1 -0
- package/dist/index-c6f5a782.js +290 -0
- package/dist/index-c6f5a782.js.map +1 -0
- package/dist/index.js +50 -1921
- package/dist/index.js.map +1 -1
- package/dist/useTemplatesApi-5d82bdca.js +107 -0
- package/dist/useTemplatesApi-5d82bdca.js.map +1 -0
- package/dist/useTemplatesApi-dc60dcdd.js +97 -0
- package/dist/useTemplatesApi-dc60dcdd.js.map +1 -0
- package/package.json +23 -11
- package/dist/index.cjs.js +0 -1982
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants$1 = require('../constants-d561fb6c.js');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
6
|
+
var Container = require('@bigbinary/neeto-molecules/Container');
|
|
7
|
+
var reactRouterDom = require('react-router-dom');
|
|
8
|
+
var i18next = require('i18next');
|
|
9
|
+
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
10
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
11
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
12
|
+
var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
|
|
13
|
+
var Table$1 = require('@bigbinary/neetoui/Table');
|
|
14
|
+
var NoData = require('@bigbinary/neetoui/NoData');
|
|
15
|
+
var ramda = require('ramda');
|
|
16
|
+
var reactI18next = require('react-i18next');
|
|
17
|
+
var RequestDetailsPane = require('../index-c6f5a782.js');
|
|
18
|
+
var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
|
|
19
|
+
var Tag = require('@bigbinary/neetoui/Tag');
|
|
20
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
21
|
+
var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
|
|
22
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
23
|
+
var useTemplatesApi = require('../useTemplatesApi-5d82bdca.js');
|
|
24
|
+
var Pane = require('@bigbinary/neetoui/Pane');
|
|
25
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
26
|
+
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
27
|
+
var FormikForm = require('@bigbinary/neetoui/formik/Form');
|
|
28
|
+
var utils = require('@bigbinary/neeto-editor/utils');
|
|
29
|
+
var yup = require('yup');
|
|
30
|
+
var formik = require('formik');
|
|
31
|
+
var ToggleFeatureCard = require('@bigbinary/neeto-molecules/ToggleFeatureCard');
|
|
32
|
+
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
33
|
+
var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
34
|
+
var FormikEditor = require('@bigbinary/neeto-editor/FormikEditor');
|
|
35
|
+
var EditorContent = require('@bigbinary/neeto-editor/EditorContent');
|
|
36
|
+
var Label = require('@bigbinary/neetoui/Label');
|
|
37
|
+
var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
38
|
+
var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
|
|
39
|
+
var NeetoUITab = require('@bigbinary/neetoui/Tab');
|
|
40
|
+
var reactQuery = require('@tanstack/react-query');
|
|
41
|
+
var axios = require('axios');
|
|
42
|
+
require('@bigbinary/neeto-commons-frontend/utils');
|
|
43
|
+
require('@bigbinary/neetoui/Textarea');
|
|
44
|
+
require('dayjs');
|
|
45
|
+
require('dayjs/plugin/timezone');
|
|
46
|
+
require('dayjs/plugin/utc');
|
|
47
|
+
require('@bigbinary/neeto-commons-frontend/initializers');
|
|
48
|
+
|
|
49
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
50
|
+
|
|
51
|
+
function _interopNamespace(e) {
|
|
52
|
+
if (e && e.__esModule) return e;
|
|
53
|
+
var n = Object.create(null);
|
|
54
|
+
if (e) {
|
|
55
|
+
Object.keys(e).forEach(function (k) {
|
|
56
|
+
if (k !== 'default') {
|
|
57
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
58
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return e[k]; }
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
n["default"] = e;
|
|
66
|
+
return Object.freeze(n);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
70
|
+
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
71
|
+
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
72
|
+
var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
|
|
73
|
+
var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table$1);
|
|
74
|
+
var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
|
|
75
|
+
var DateFormat__default = /*#__PURE__*/_interopDefaultLegacy(DateFormat);
|
|
76
|
+
var Tag__default = /*#__PURE__*/_interopDefaultLegacy(Tag);
|
|
77
|
+
var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
78
|
+
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
79
|
+
var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
|
|
80
|
+
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
81
|
+
var ActionBlock__default = /*#__PURE__*/_interopDefaultLegacy(ActionBlock);
|
|
82
|
+
var FormikForm__default = /*#__PURE__*/_interopDefaultLegacy(FormikForm);
|
|
83
|
+
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
84
|
+
var ToggleFeatureCard__default = /*#__PURE__*/_interopDefaultLegacy(ToggleFeatureCard);
|
|
85
|
+
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
86
|
+
var Textarea__default = /*#__PURE__*/_interopDefaultLegacy(Textarea);
|
|
87
|
+
var FormikEditor__default = /*#__PURE__*/_interopDefaultLegacy(FormikEditor);
|
|
88
|
+
var EditorContent__default = /*#__PURE__*/_interopDefaultLegacy(EditorContent);
|
|
89
|
+
var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
|
|
90
|
+
var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
|
|
91
|
+
var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
|
|
92
|
+
var NeetoUITab__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUITab);
|
|
93
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
94
|
+
|
|
95
|
+
var routes = {
|
|
96
|
+
home: "/",
|
|
97
|
+
approvals: "/approvals/",
|
|
98
|
+
pending: "pending",
|
|
99
|
+
history: "history",
|
|
100
|
+
templates: {
|
|
101
|
+
index: "templates",
|
|
102
|
+
"new": "templates/new",
|
|
103
|
+
edit: "templates/:id/edit"
|
|
104
|
+
},
|
|
105
|
+
"public": "approvals/public/request/:id"
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageChange) {
|
|
109
|
+
if (ramda.isEmpty(data) && pageProperties.page !== 1) {
|
|
110
|
+
handlePageChange(pageProperties.page - 1, pageProperties.pageSize);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var usePaginate = function usePaginate() {
|
|
115
|
+
var _useState = react.useState({
|
|
116
|
+
page: constants.DEFAULT_PAGE_INDEX,
|
|
117
|
+
pageSize: constants.DEFAULT_PAGE_SIZE
|
|
118
|
+
}),
|
|
119
|
+
_useState2 = constants$1._slicedToArray(_useState, 2),
|
|
120
|
+
pageProperties = _useState2[0],
|
|
121
|
+
setPageProperties = _useState2[1];
|
|
122
|
+
var resetPageProperties = function resetPageProperties() {
|
|
123
|
+
return setPageProperties({
|
|
124
|
+
page: constants.DEFAULT_PAGE_INDEX,
|
|
125
|
+
pageSize: constants.DEFAULT_PAGE_SIZE
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
var handlePageChange = function handlePageChange(page, pageSize) {
|
|
129
|
+
setPageProperties({
|
|
130
|
+
page: page,
|
|
131
|
+
pageSize: pageSize
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
pageProperties: pageProperties,
|
|
136
|
+
resetPageProperties: resetPageProperties,
|
|
137
|
+
handlePageChange: handlePageChange
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var HISTORY_TABLE_COLUMNS = [{
|
|
142
|
+
dataIndex: "approvalLabel",
|
|
143
|
+
key: "approvalLabel",
|
|
144
|
+
sorter: true,
|
|
145
|
+
width: "25%",
|
|
146
|
+
title: i18next.t("neetoApprovals.common.id"),
|
|
147
|
+
render: function render(approvalLabel, _ref) {
|
|
148
|
+
var requestableUrl = _ref.requestableUrl;
|
|
149
|
+
var url = new URL(requestableUrl || window.location.origin);
|
|
150
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
151
|
+
label: approvalLabel,
|
|
152
|
+
style: "link",
|
|
153
|
+
to: url.pathname
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
dataIndex: "title",
|
|
158
|
+
key: "title",
|
|
159
|
+
sorter: true,
|
|
160
|
+
width: "25%",
|
|
161
|
+
title: i18next.t("neetoApprovals.common.title")
|
|
162
|
+
}, {
|
|
163
|
+
dataIndex: "status",
|
|
164
|
+
key: "status",
|
|
165
|
+
sorter: true,
|
|
166
|
+
width: "25%",
|
|
167
|
+
title: i18next.t("neetoApprovals.common.status"),
|
|
168
|
+
render: function render(status) {
|
|
169
|
+
return /*#__PURE__*/jsxRuntime.jsx(Tag__default["default"], {
|
|
170
|
+
label: neetoCist.capitalize(status),
|
|
171
|
+
style: constants$1.STATUS_TAG_STYLE[status]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
dataIndex: "createdAt",
|
|
176
|
+
key: "createdAt",
|
|
177
|
+
sorter: true,
|
|
178
|
+
width: "25%",
|
|
179
|
+
title: i18next.t("neetoApprovals.common.created"),
|
|
180
|
+
render: function render(createdAt) {
|
|
181
|
+
return /*#__PURE__*/jsxRuntime.jsx(DateFormat__default["default"].FromNow, {
|
|
182
|
+
date: createdAt,
|
|
183
|
+
typographyProps: {
|
|
184
|
+
style: "body2"
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}];
|
|
189
|
+
|
|
190
|
+
function ownKeys$7(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; }
|
|
191
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
192
|
+
var History = function History(_ref) {
|
|
193
|
+
var helpDocUrl = _ref.helpDocUrl,
|
|
194
|
+
requestUrl = _ref.requestUrl;
|
|
195
|
+
var _useState = react.useState(constants$1.DEFAULT_FILTER_VALUES),
|
|
196
|
+
_useState2 = constants$1._slicedToArray(_useState, 2),
|
|
197
|
+
filters = _useState2[0],
|
|
198
|
+
setFilters = _useState2[1];
|
|
199
|
+
var debouncedSearchTerm = reactUtils.useDebounce(filters.searchTerm, constants$1.SEARCH_DELAY);
|
|
200
|
+
var _usePaginate = usePaginate(),
|
|
201
|
+
pageProperties = _usePaginate.pageProperties,
|
|
202
|
+
handlePageChange = _usePaginate.handlePageChange;
|
|
203
|
+
var _useState3 = react.useState({}),
|
|
204
|
+
_useState4 = constants$1._slicedToArray(_useState3, 2),
|
|
205
|
+
approvalDetails = _useState4[0],
|
|
206
|
+
setApprovalDetails = _useState4[1];
|
|
207
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
208
|
+
t = _useTranslation.t;
|
|
209
|
+
var _useFetchRequests = RequestDetailsPane.useFetchRequests({
|
|
210
|
+
params: _objectSpread$7(_objectSpread$7(_objectSpread$7({}, pageProperties), filters), {}, {
|
|
211
|
+
searchTerm: debouncedSearchTerm.trim(),
|
|
212
|
+
status: [constants$1.STATUSES.approved, constants$1.STATUSES.rejected, constants$1.STATUSES.cancelled]
|
|
213
|
+
}),
|
|
214
|
+
requestUrl: requestUrl
|
|
215
|
+
}),
|
|
216
|
+
data = _useFetchRequests.data;
|
|
217
|
+
var _ref2 = data || {},
|
|
218
|
+
_ref2$requests = _ref2.requests,
|
|
219
|
+
approvalHistories = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
220
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
221
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
222
|
+
react.useEffect(function () {
|
|
223
|
+
if (!data) return;
|
|
224
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
225
|
+
setApprovalDetails(function (approvalDetails) {
|
|
226
|
+
return RequestDetailsPane.updateApprovalDetails({
|
|
227
|
+
requestsData: data === null || data === void 0 ? void 0 : data.requests,
|
|
228
|
+
approvalDetails: approvalDetails
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}, [data]);
|
|
232
|
+
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
233
|
+
setFilters(_objectSpread$7(_objectSpread$7({}, filters), {}, {
|
|
234
|
+
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
235
|
+
orderBy: constants$1.SORT_ORDER[sorter.order]
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
238
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
239
|
+
children: [!ramda.isEmpty(approvalHistories) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
240
|
+
className: "mt-6",
|
|
241
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
242
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
243
|
+
handlePageChange: handlePageChange,
|
|
244
|
+
totalCount: totalCount,
|
|
245
|
+
allowRowClick: true,
|
|
246
|
+
fixedHeight: true,
|
|
247
|
+
columnData: HISTORY_TABLE_COLUMNS,
|
|
248
|
+
currentPageNumber: pageProperties.page,
|
|
249
|
+
defaultPageSize: pageProperties.pageSize,
|
|
250
|
+
rowData: approvalHistories,
|
|
251
|
+
paginationProps: {
|
|
252
|
+
hideOnSinglePage: (approvalHistories === null || approvalHistories === void 0 ? void 0 : approvalHistories.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
253
|
+
},
|
|
254
|
+
onChange: handleTableChange,
|
|
255
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
256
|
+
return setApprovalDetails(approvalDetails);
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
260
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
261
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], {
|
|
262
|
+
helpText: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
263
|
+
i18nKey: "neetoApprovals.common.noDataHelpTextLearnMore",
|
|
264
|
+
style: "link",
|
|
265
|
+
values: {
|
|
266
|
+
entity: t("neetoApprovals.common.history")
|
|
267
|
+
},
|
|
268
|
+
components: {
|
|
269
|
+
a: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
270
|
+
style: "link",
|
|
271
|
+
target: "_blank",
|
|
272
|
+
to: {
|
|
273
|
+
pathname: helpDocUrl
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
}),
|
|
278
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
279
|
+
what: t("neetoApprovals.common.record", constants.PLURAL)
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
}), /*#__PURE__*/jsxRuntime.jsx(RequestDetailsPane.RequestDetailsPane, {
|
|
283
|
+
approvalDetails: approvalDetails,
|
|
284
|
+
isOpen: neetoCist.isPresent(approvalDetails),
|
|
285
|
+
onClose: function onClose() {
|
|
286
|
+
return setApprovalDetails({});
|
|
287
|
+
}
|
|
288
|
+
})]
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
var PENDING_TABLE_COLUMNS = neetoCist.removeBy({
|
|
293
|
+
key: "status"
|
|
294
|
+
}, HISTORY_TABLE_COLUMNS);
|
|
295
|
+
|
|
296
|
+
function ownKeys$6(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; }
|
|
297
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
298
|
+
var PendingRequests = function PendingRequests(_ref) {
|
|
299
|
+
var helpDocUrl = _ref.helpDocUrl,
|
|
300
|
+
requestUrl = _ref.requestUrl;
|
|
301
|
+
var _useState = react.useState(constants$1.DEFAULT_FILTER_VALUES),
|
|
302
|
+
_useState2 = constants$1._slicedToArray(_useState, 2),
|
|
303
|
+
filters = _useState2[0],
|
|
304
|
+
setFilters = _useState2[1];
|
|
305
|
+
var _useState3 = react.useState({}),
|
|
306
|
+
_useState4 = constants$1._slicedToArray(_useState3, 2),
|
|
307
|
+
approvalDetails = _useState4[0],
|
|
308
|
+
setApprovalDetails = _useState4[1];
|
|
309
|
+
var debouncedSearchTerm = reactUtils.useDebounce(filters.searchTerm, constants$1.SEARCH_DELAY);
|
|
310
|
+
var _usePaginate = usePaginate(),
|
|
311
|
+
pageProperties = _usePaginate.pageProperties,
|
|
312
|
+
handlePageChange = _usePaginate.handlePageChange;
|
|
313
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
314
|
+
t = _useTranslation.t;
|
|
315
|
+
var _useFetchRequests = RequestDetailsPane.useFetchRequests({
|
|
316
|
+
params: _objectSpread$6(_objectSpread$6(_objectSpread$6({}, pageProperties), filters), {}, {
|
|
317
|
+
searchTerm: debouncedSearchTerm.trim(),
|
|
318
|
+
status: [constants$1.STATUSES.pending]
|
|
319
|
+
}),
|
|
320
|
+
requestUrl: requestUrl
|
|
321
|
+
}),
|
|
322
|
+
data = _useFetchRequests.data;
|
|
323
|
+
var _ref2 = data || {},
|
|
324
|
+
_ref2$requests = _ref2.requests,
|
|
325
|
+
pendingRequests = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
326
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
327
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
328
|
+
react.useEffect(function () {
|
|
329
|
+
if (!data) return;
|
|
330
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
331
|
+
}, [data]);
|
|
332
|
+
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
333
|
+
setFilters(_objectSpread$6(_objectSpread$6({}, filters), {}, {
|
|
334
|
+
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
335
|
+
orderBy: constants$1.SORT_ORDER[sorter.order]
|
|
336
|
+
}));
|
|
337
|
+
};
|
|
338
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
339
|
+
children: [!ramda.isEmpty(pendingRequests) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
340
|
+
className: "mt-6",
|
|
341
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
342
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
343
|
+
handlePageChange: handlePageChange,
|
|
344
|
+
totalCount: totalCount,
|
|
345
|
+
allowRowClick: true,
|
|
346
|
+
fixedHeight: true,
|
|
347
|
+
columnData: PENDING_TABLE_COLUMNS,
|
|
348
|
+
currentPageNumber: pageProperties.page,
|
|
349
|
+
defaultPageSize: pageProperties.pageSize,
|
|
350
|
+
rowData: pendingRequests,
|
|
351
|
+
paginationProps: {
|
|
352
|
+
hideOnSinglePage: (pendingRequests === null || pendingRequests === void 0 ? void 0 : pendingRequests.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
353
|
+
},
|
|
354
|
+
onChange: handleTableChange,
|
|
355
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
356
|
+
return setApprovalDetails(approvalDetails);
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
360
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
361
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], {
|
|
362
|
+
helpText: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
363
|
+
i18nKey: "neetoApprovals.common.noDataHelpTextLearnMore",
|
|
364
|
+
style: "link",
|
|
365
|
+
components: {
|
|
366
|
+
a: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
367
|
+
style: "link",
|
|
368
|
+
target: "_blank",
|
|
369
|
+
to: {
|
|
370
|
+
pathname: helpDocUrl
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
},
|
|
374
|
+
values: {
|
|
375
|
+
entity: t("neetoApprovals.common.pendingApproval", constants.PLURAL)
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
379
|
+
what: t("neetoApprovals.common.pendingApproval", constants.PLURAL)
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
}), /*#__PURE__*/jsxRuntime.jsx(RequestDetailsPane.RequestDetailsPane, {
|
|
383
|
+
approvalDetails: approvalDetails,
|
|
384
|
+
isPending: true,
|
|
385
|
+
isOpen: neetoCist.isPresent(approvalDetails),
|
|
386
|
+
onClose: function onClose() {
|
|
387
|
+
return setApprovalDetails({});
|
|
388
|
+
}
|
|
389
|
+
})]
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
394
|
+
if (source == null) return {};
|
|
395
|
+
var target = {};
|
|
396
|
+
var sourceKeys = Object.keys(source);
|
|
397
|
+
var key, i;
|
|
398
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
399
|
+
key = sourceKeys[i];
|
|
400
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
401
|
+
target[key] = source[key];
|
|
402
|
+
}
|
|
403
|
+
return target;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function _objectWithoutProperties(source, excluded) {
|
|
407
|
+
if (source == null) return {};
|
|
408
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
409
|
+
var key, i;
|
|
410
|
+
if (Object.getOwnPropertySymbols) {
|
|
411
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
412
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
413
|
+
key = sourceSymbolKeys[i];
|
|
414
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
415
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
416
|
+
target[key] = source[key];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return target;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
var TEMPLATE_FORM_INITIAL_VALUES = {
|
|
423
|
+
name: "",
|
|
424
|
+
description: "",
|
|
425
|
+
message: ""
|
|
426
|
+
};
|
|
427
|
+
var TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
428
|
+
name: yup__namespace.string().trim().required(i18next.t("neetoApprovals.validations.required", {
|
|
429
|
+
what: i18next.t("neetoApprovals.common.name")
|
|
430
|
+
})),
|
|
431
|
+
message: yup__namespace.string().test("message", i18next.t("neetoApprovals.validations.required", {
|
|
432
|
+
what: i18next.t("neetoApprovals.inputs.labels.message")
|
|
433
|
+
}), function (content) {
|
|
434
|
+
return !utils.isEditorEmpty(content);
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
var MessageEditor = reactUtils.withT(function (_ref) {
|
|
439
|
+
var t = _ref.t,
|
|
440
|
+
_ref$placeholders = _ref.placeholders,
|
|
441
|
+
placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
|
|
442
|
+
_ref$initialValue = _ref.initialValue,
|
|
443
|
+
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
444
|
+
return /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], {
|
|
445
|
+
initialValue: initialValue,
|
|
446
|
+
required: true,
|
|
447
|
+
label: t("neetoApprovals.inputs.labels.message"),
|
|
448
|
+
name: "message",
|
|
449
|
+
rows: 3,
|
|
450
|
+
variables: placeholders,
|
|
451
|
+
placeholder: t("neetoApprovals.inputs.placeholders.enter_", {
|
|
452
|
+
what: t("neetoApprovals.inputs.labels.message")
|
|
453
|
+
})
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
var TemplateForm = function TemplateForm(_ref) {
|
|
458
|
+
var placeholders = _ref.placeholders,
|
|
459
|
+
initialData = _ref.initialData;
|
|
460
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
461
|
+
t = _useTranslation.t;
|
|
462
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
463
|
+
values = _useFormikContext.values,
|
|
464
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
465
|
+
var handleDescriptionToggle = function handleDescriptionToggle(_ref2) {
|
|
466
|
+
var checked = _ref2.target.checked;
|
|
467
|
+
setFieldValue("descriptionEnabled", checked);
|
|
468
|
+
if (!checked) {
|
|
469
|
+
setFieldValue("description", "");
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
473
|
+
className: "flex w-full flex-col space-y-6",
|
|
474
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
|
|
475
|
+
autoFocus: true,
|
|
476
|
+
required: true,
|
|
477
|
+
label: t("neetoApprovals.common.name"),
|
|
478
|
+
name: "name",
|
|
479
|
+
placeholder: t("neetoApprovals.inputs.placeholders.name")
|
|
480
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ToggleFeatureCard__default["default"], {
|
|
481
|
+
switchName: "descriptionEnabled",
|
|
482
|
+
title: t("neetoApprovals.inputs.labels.description"),
|
|
483
|
+
switchProps: {
|
|
484
|
+
onChange: handleDescriptionToggle,
|
|
485
|
+
tooltipProps: {
|
|
486
|
+
enabledSwitchText: t("neetoApprovals.templates.descriptionToggle.enable"),
|
|
487
|
+
disabledSwitchText: t("neetoApprovals.templates.descriptionToggle.disable")
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
children: values.descriptionEnabled && /*#__PURE__*/jsxRuntime.jsx(Textarea__default["default"], {
|
|
491
|
+
className: "w-full",
|
|
492
|
+
name: "description",
|
|
493
|
+
placeholder: t("neetoApprovals.inputs.placeholders.description")
|
|
494
|
+
})
|
|
495
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MessageEditor, {
|
|
496
|
+
placeholders: placeholders,
|
|
497
|
+
initialValue: initialData.message
|
|
498
|
+
})]
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
var Form = function Form(_ref) {
|
|
503
|
+
var isOpen = _ref.isOpen,
|
|
504
|
+
onClose = _ref.onClose,
|
|
505
|
+
_ref$initialData = _ref.initialData,
|
|
506
|
+
initialData = _ref$initialData === void 0 ? {} : _ref$initialData,
|
|
507
|
+
_ref$onSubmit = _ref.onSubmit,
|
|
508
|
+
onSubmit = _ref$onSubmit === void 0 ? neetoCist.noop : _ref$onSubmit,
|
|
509
|
+
_ref$isLoading = _ref.isLoading,
|
|
510
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
511
|
+
placeholders = _ref.placeholders;
|
|
512
|
+
var inputReference = react.useRef(null);
|
|
513
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
514
|
+
t = _useTranslation.t;
|
|
515
|
+
var header = ramda.isEmpty(initialData) ? t("neetoApprovals.common.addNew_", {
|
|
516
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
517
|
+
}) : t("neetoApprovals.common.edit_", {
|
|
518
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
519
|
+
});
|
|
520
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
521
|
+
isOpen: isOpen,
|
|
522
|
+
onClose: onClose,
|
|
523
|
+
initialFocusRef: inputReference,
|
|
524
|
+
size: "large",
|
|
525
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
526
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
527
|
+
style: "h2",
|
|
528
|
+
children: header
|
|
529
|
+
})
|
|
530
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(FormikForm__default["default"], {
|
|
531
|
+
formikProps: {
|
|
532
|
+
enableReinitialize: true,
|
|
533
|
+
initialValues: neetoCist.isPresent(initialData) ? initialData : TEMPLATE_FORM_INITIAL_VALUES,
|
|
534
|
+
validationSchema: TEMPLATE_FORM_VALIDATION_SCHEMA,
|
|
535
|
+
onSubmit: onSubmit
|
|
536
|
+
},
|
|
537
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
|
|
538
|
+
children: /*#__PURE__*/jsxRuntime.jsx(TemplateForm, {
|
|
539
|
+
initialData: initialData,
|
|
540
|
+
placeholders: placeholders
|
|
541
|
+
})
|
|
542
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
|
|
543
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
|
|
544
|
+
isSubmitting: isLoading,
|
|
545
|
+
cancelButtonProps: {
|
|
546
|
+
"data-cy": "neeto-approvals-templates-close-template-form-btn",
|
|
547
|
+
onClick: onClose
|
|
548
|
+
},
|
|
549
|
+
submitButtonProps: {
|
|
550
|
+
"data-cy": "neeto-approvals-templates-save-template-btn"
|
|
551
|
+
}
|
|
552
|
+
})
|
|
553
|
+
})]
|
|
554
|
+
})]
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
var Create = function Create(_ref) {
|
|
559
|
+
var templateUrl = _ref.templateUrl,
|
|
560
|
+
isOpen = _ref.isOpen,
|
|
561
|
+
onClose = _ref.onClose,
|
|
562
|
+
templatePlaceholders = _ref.templatePlaceholders;
|
|
563
|
+
var _useCreateTemplate = useTemplatesApi.useCreateTemplate(),
|
|
564
|
+
createTemplate = _useCreateTemplate.mutate,
|
|
565
|
+
isPending = _useCreateTemplate.isPending;
|
|
566
|
+
var onSubmit = function onSubmit(template) {
|
|
567
|
+
var payload = {
|
|
568
|
+
template: template
|
|
569
|
+
};
|
|
570
|
+
createTemplate({
|
|
571
|
+
url: templateUrl,
|
|
572
|
+
payload: payload
|
|
573
|
+
}, {
|
|
574
|
+
onSuccess: onClose
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form, {
|
|
578
|
+
isOpen: isOpen,
|
|
579
|
+
onClose: onClose,
|
|
580
|
+
onSubmit: onSubmit,
|
|
581
|
+
isLoading: isPending,
|
|
582
|
+
placeholders: templatePlaceholders
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
function ownKeys$5(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; }
|
|
587
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
588
|
+
var Edit = function Edit(_ref) {
|
|
589
|
+
var templateUrl = _ref.templateUrl,
|
|
590
|
+
template = _ref.template,
|
|
591
|
+
setTemplate = _ref.setTemplate,
|
|
592
|
+
isOpen = _ref.isOpen,
|
|
593
|
+
onClose = _ref.onClose,
|
|
594
|
+
templatePlaceholders = _ref.templatePlaceholders;
|
|
595
|
+
var _useUpdateTemplate = useTemplatesApi.useUpdateTemplate({
|
|
596
|
+
onSuccess: function onSuccess() {
|
|
597
|
+
return setTemplate({});
|
|
598
|
+
}
|
|
599
|
+
}),
|
|
600
|
+
updateTemplate = _useUpdateTemplate.mutate,
|
|
601
|
+
isUpdating = _useUpdateTemplate.isPending;
|
|
602
|
+
var onSubmit = function onSubmit(template) {
|
|
603
|
+
var payload = {
|
|
604
|
+
template: template
|
|
605
|
+
};
|
|
606
|
+
updateTemplate({
|
|
607
|
+
id: template.id,
|
|
608
|
+
payload: payload,
|
|
609
|
+
url: templateUrl
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
var initialData = _objectSpread$5(_objectSpread$5({}, template), {}, {
|
|
613
|
+
descriptionEnabled: !!template.description
|
|
614
|
+
});
|
|
615
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form, {
|
|
616
|
+
initialData: initialData,
|
|
617
|
+
isOpen: isOpen,
|
|
618
|
+
onClose: onClose,
|
|
619
|
+
onSubmit: onSubmit,
|
|
620
|
+
isLoading: isUpdating,
|
|
621
|
+
placeholders: templatePlaceholders
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
var Field = function Field(_ref) {
|
|
626
|
+
var label = _ref.label,
|
|
627
|
+
value = _ref.value;
|
|
628
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
629
|
+
className: "flex flex-col items-start justify-center",
|
|
630
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
631
|
+
className: "mb-1 font-normal",
|
|
632
|
+
children: label
|
|
633
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
634
|
+
style: "body1",
|
|
635
|
+
weight: "medium",
|
|
636
|
+
children: value
|
|
637
|
+
})]
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
var Field$1 = /*#__PURE__*/react.memo(Field);
|
|
641
|
+
|
|
642
|
+
var MemoizedEditorContent = /*#__PURE__*/react.memo(EditorContent__default["default"]);
|
|
643
|
+
var TemplateDetails = function TemplateDetails(_ref) {
|
|
644
|
+
var isOpen = _ref.isOpen,
|
|
645
|
+
onClose = _ref.onClose,
|
|
646
|
+
template = _ref.template;
|
|
647
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
648
|
+
t = _useTranslation.t;
|
|
649
|
+
var name = template.name,
|
|
650
|
+
description = template.description,
|
|
651
|
+
message = template.message;
|
|
652
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
653
|
+
isOpen: isOpen,
|
|
654
|
+
onClose: onClose,
|
|
655
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
656
|
+
className: "space-y-2",
|
|
657
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
658
|
+
style: "h2",
|
|
659
|
+
children: t("neetoApprovals.common.templateDetails")
|
|
660
|
+
})
|
|
661
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Body, {
|
|
662
|
+
className: "space-y-6",
|
|
663
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Field$1, {
|
|
664
|
+
label: t("neetoApprovals.common.name"),
|
|
665
|
+
value: name
|
|
666
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Field$1, {
|
|
667
|
+
label: t("neetoApprovals.inputs.labels.description"),
|
|
668
|
+
value: description
|
|
669
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
670
|
+
className: "flex w-full flex-col space-y-4",
|
|
671
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
672
|
+
className: "mb-1 font-normal",
|
|
673
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
674
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedEditorContent, {
|
|
675
|
+
className: "neeto-ui-bg-gray-100 neeto-ui-rounded-lg p-3",
|
|
676
|
+
content: message
|
|
677
|
+
})]
|
|
678
|
+
})]
|
|
679
|
+
})]
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
|
|
684
|
+
var entity = _ref.entity,
|
|
685
|
+
url = _ref.url;
|
|
686
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
687
|
+
i18nKey: "neetoApprovals.common.noDataHelpText",
|
|
688
|
+
style: "link",
|
|
689
|
+
values: {
|
|
690
|
+
entity: entity.toLocaleLowerCase()
|
|
691
|
+
},
|
|
692
|
+
components: {
|
|
693
|
+
a: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
694
|
+
style: "link",
|
|
695
|
+
target: "_blank",
|
|
696
|
+
to: {
|
|
697
|
+
pathname: url
|
|
698
|
+
}
|
|
699
|
+
})
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
var _excluded$1 = ["entity", "columnData", "rowData", "totalCount", "filters", "setFilters", "setIsPaneOpen", "helpDocUrl", "onEditClick", "onDeleteClick", "pageProperties"];
|
|
705
|
+
function ownKeys$4(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; }
|
|
706
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
707
|
+
var Table = function Table(_ref) {
|
|
708
|
+
var entity = _ref.entity,
|
|
709
|
+
columnData = _ref.columnData,
|
|
710
|
+
rowData = _ref.rowData,
|
|
711
|
+
totalCount = _ref.totalCount,
|
|
712
|
+
filters = _ref.filters,
|
|
713
|
+
setFilters = _ref.setFilters,
|
|
714
|
+
setIsPaneOpen = _ref.setIsPaneOpen,
|
|
715
|
+
helpDocUrl = _ref.helpDocUrl,
|
|
716
|
+
onEditClick = _ref.onEditClick,
|
|
717
|
+
onDeleteClick = _ref.onDeleteClick,
|
|
718
|
+
pageProperties = _ref.pageProperties,
|
|
719
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
720
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
721
|
+
t = _useTranslation.t;
|
|
722
|
+
var columns = columnData({
|
|
723
|
+
onEditClick: onEditClick,
|
|
724
|
+
onDeleteClick: onDeleteClick
|
|
725
|
+
});
|
|
726
|
+
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
727
|
+
setFilters(_objectSpread$4(_objectSpread$4({}, filters), {}, {
|
|
728
|
+
sortBy: sorter.field,
|
|
729
|
+
orderBy: constants$1.SORT_ORDER[sorter.order]
|
|
730
|
+
}));
|
|
731
|
+
};
|
|
732
|
+
var noDataProps = {
|
|
733
|
+
primaryButtonProps: {
|
|
734
|
+
label: t("neetoApprovals.common.addNew_", {
|
|
735
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
736
|
+
}),
|
|
737
|
+
onClick: function onClick() {
|
|
738
|
+
return setIsPaneOpen(true);
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
helpText: renderNoDataHelpText({
|
|
742
|
+
entity: entity,
|
|
743
|
+
url: helpDocUrl
|
|
744
|
+
})
|
|
745
|
+
};
|
|
746
|
+
if (ramda.isEmpty(rowData)) {
|
|
747
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
748
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
749
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$4({
|
|
750
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
751
|
+
what: entity
|
|
752
|
+
})
|
|
753
|
+
}, !filters.searchTerm && noDataProps))
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
757
|
+
className: "mt-6",
|
|
758
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
759
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], _objectSpread$4({
|
|
760
|
+
fixedHeight: true,
|
|
761
|
+
columnData: columns,
|
|
762
|
+
currentPageNumber: pageProperties.page,
|
|
763
|
+
defaultPageSize: pageProperties.pageSize,
|
|
764
|
+
scroll: {
|
|
765
|
+
x: 0
|
|
766
|
+
},
|
|
767
|
+
tableLayout: "fixed",
|
|
768
|
+
paginationProps: {
|
|
769
|
+
hideOnSinglePage: (rowData === null || rowData === void 0 ? void 0 : rowData.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
770
|
+
},
|
|
771
|
+
onChange: handleTableChange
|
|
772
|
+
}, _objectSpread$4({
|
|
773
|
+
rowData: rowData,
|
|
774
|
+
totalCount: totalCount
|
|
775
|
+
}, otherProps)))
|
|
776
|
+
});
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
var columnData = function columnData(_ref) {
|
|
780
|
+
var onEditClick = _ref.onEditClick,
|
|
781
|
+
onDeleteClick = _ref.onDeleteClick;
|
|
782
|
+
return [{
|
|
783
|
+
dataIndex: "name",
|
|
784
|
+
key: "name",
|
|
785
|
+
sorter: true,
|
|
786
|
+
title: i18next__default["default"].t("neetoApprovals.common.name"),
|
|
787
|
+
ellipsis: true,
|
|
788
|
+
render: function render(_, template) {
|
|
789
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
790
|
+
className: "flex items-center justify-between gap-x-3",
|
|
791
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
792
|
+
className: "truncate",
|
|
793
|
+
style: "body2",
|
|
794
|
+
children: template.name
|
|
795
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
|
|
796
|
+
dropdownProps: {
|
|
797
|
+
strategy: "fixed",
|
|
798
|
+
onClick: function onClick(e) {
|
|
799
|
+
return e.stopPropagation();
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
menuItems: [constants$1._defineProperty({
|
|
803
|
+
key: "edit",
|
|
804
|
+
label: i18next__default["default"].t("neetoApprovals.common.edit"),
|
|
805
|
+
onClick: function onClick(event) {
|
|
806
|
+
return onEditClick(event, template);
|
|
807
|
+
}
|
|
808
|
+
}, constants$1.DATA_CY_KEY, "neeto-approvals-templates-edit-template-btn"), constants$1._defineProperty({
|
|
809
|
+
key: "delete",
|
|
810
|
+
label: i18next__default["default"].t("neetoApprovals.common.delete"),
|
|
811
|
+
onClick: function onClick(event) {
|
|
812
|
+
return onDeleteClick(event, template);
|
|
813
|
+
}
|
|
814
|
+
}, constants$1.DATA_CY_KEY, "neeto-approvals-templates-delete-template-btn")]
|
|
815
|
+
})]
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}, {
|
|
819
|
+
dataIndex: "description",
|
|
820
|
+
key: "description",
|
|
821
|
+
title: i18next__default["default"].t("neetoApprovals.inputs.labels.description")
|
|
822
|
+
}];
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpen", "helpDocUrl"];
|
|
826
|
+
function ownKeys$3(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; }
|
|
827
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
828
|
+
var Templates = function Templates(_ref) {
|
|
829
|
+
var searchTerm = _ref.searchTerm,
|
|
830
|
+
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
831
|
+
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
|
|
832
|
+
helpDocUrl = _ref.helpDocUrl,
|
|
833
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
834
|
+
var _useState = react.useState(constants$1.DEFAULT_FILTER_VALUES),
|
|
835
|
+
_useState2 = constants$1._slicedToArray(_useState, 2),
|
|
836
|
+
filters = _useState2[0],
|
|
837
|
+
setFilters = _useState2[1];
|
|
838
|
+
var _useState3 = react.useState({}),
|
|
839
|
+
_useState4 = constants$1._slicedToArray(_useState3, 2),
|
|
840
|
+
selectedTemplate = _useState4[0],
|
|
841
|
+
setSelectedTemplate = _useState4[1];
|
|
842
|
+
var _useState5 = react.useState(false),
|
|
843
|
+
_useState6 = constants$1._slicedToArray(_useState5, 2),
|
|
844
|
+
isDeleteAlertOpen = _useState6[0],
|
|
845
|
+
setIsDeleteAlertOpen = _useState6[1];
|
|
846
|
+
var _useState7 = react.useState(false),
|
|
847
|
+
_useState8 = constants$1._slicedToArray(_useState7, 2),
|
|
848
|
+
isEditPaneOpen = _useState8[0],
|
|
849
|
+
setIsEditPaneOpen = _useState8[1];
|
|
850
|
+
var _useState9 = react.useState(false),
|
|
851
|
+
_useState10 = constants$1._slicedToArray(_useState9, 2),
|
|
852
|
+
isShowPaneOpen = _useState10[0],
|
|
853
|
+
setIsShowPaneOpen = _useState10[1];
|
|
854
|
+
var _usePaginate = usePaginate(),
|
|
855
|
+
pageProperties = _usePaginate.pageProperties,
|
|
856
|
+
handlePageChange = _usePaginate.handlePageChange,
|
|
857
|
+
resetPageProperties = _usePaginate.resetPageProperties;
|
|
858
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
859
|
+
t = _useTranslation.t;
|
|
860
|
+
var debouncedSearchTerm = reactUtils.useDebounce(searchTerm, constants$1.SEARCH_DELAY);
|
|
861
|
+
react.useEffect(function () {
|
|
862
|
+
resetPageProperties();
|
|
863
|
+
}, [searchTerm]);
|
|
864
|
+
var _useFetchTemplates = useTemplatesApi.useFetchTemplates(_objectSpread$3(_objectSpread$3(_objectSpread$3({}, pageProperties), filters), {}, {
|
|
865
|
+
searchTerm: debouncedSearchTerm.trim()
|
|
866
|
+
})),
|
|
867
|
+
data = _useFetchTemplates.data,
|
|
868
|
+
isTemplateLoading = _useFetchTemplates.isLoading;
|
|
869
|
+
var _ref2 = data || {},
|
|
870
|
+
_ref2$templates = _ref2.templates,
|
|
871
|
+
templates = _ref2$templates === void 0 ? [] : _ref2$templates,
|
|
872
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
873
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
874
|
+
react.useEffect(function () {
|
|
875
|
+
if (data) {
|
|
876
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.templates, pageProperties, handlePageChange);
|
|
877
|
+
}
|
|
878
|
+
}, [data]);
|
|
879
|
+
var _useDeleteTemplate = useTemplatesApi.useDeleteTemplate(),
|
|
880
|
+
deleteTemplate = _useDeleteTemplate.mutate,
|
|
881
|
+
isDeleting = _useDeleteTemplate.isPending;
|
|
882
|
+
react.useEffect(function () {
|
|
883
|
+
if (!ramda.isEmpty(selectedTemplate)) return;
|
|
884
|
+
setIsDeleteAlertOpen(false);
|
|
885
|
+
setIsEditPaneOpen(false);
|
|
886
|
+
setIsShowPaneOpen(false);
|
|
887
|
+
}, [selectedTemplate]);
|
|
888
|
+
var onEditClick = function onEditClick(event, template) {
|
|
889
|
+
event.stopPropagation();
|
|
890
|
+
setSelectedTemplate(template);
|
|
891
|
+
setIsEditPaneOpen(true);
|
|
892
|
+
};
|
|
893
|
+
var onRowClick = function onRowClick(_, templateDetails) {
|
|
894
|
+
setSelectedTemplate(templateDetails);
|
|
895
|
+
setIsShowPaneOpen(true);
|
|
896
|
+
};
|
|
897
|
+
var onDeleteClick = function onDeleteClick(event, template) {
|
|
898
|
+
event.stopPropagation();
|
|
899
|
+
setSelectedTemplate(template);
|
|
900
|
+
setIsDeleteAlertOpen(true);
|
|
901
|
+
};
|
|
902
|
+
var handleDelete = function handleDelete(templateId) {
|
|
903
|
+
deleteTemplate({
|
|
904
|
+
templateId: templateId
|
|
905
|
+
});
|
|
906
|
+
setSelectedTemplate({});
|
|
907
|
+
};
|
|
908
|
+
var entity = t("neetoApprovals.common.template", constants.PLURAL);
|
|
909
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
910
|
+
children: [isTemplateLoading ? /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {}) : /*#__PURE__*/jsxRuntime.jsx(Table, {
|
|
911
|
+
columnData: columnData,
|
|
912
|
+
entity: entity,
|
|
913
|
+
filters: filters,
|
|
914
|
+
handlePageChange: handlePageChange,
|
|
915
|
+
helpDocUrl: helpDocUrl,
|
|
916
|
+
onDeleteClick: onDeleteClick,
|
|
917
|
+
onEditClick: onEditClick,
|
|
918
|
+
onRowClick: onRowClick,
|
|
919
|
+
pageProperties: pageProperties,
|
|
920
|
+
searchTerm: searchTerm,
|
|
921
|
+
setFilters: setFilters,
|
|
922
|
+
totalCount: totalCount,
|
|
923
|
+
rowData: templates,
|
|
924
|
+
setIsPaneOpen: setIsNewTemplatePaneOpen
|
|
925
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Create, _objectSpread$3({
|
|
926
|
+
isOpen: isNewTemplatePaneOpen,
|
|
927
|
+
onClose: function onClose() {
|
|
928
|
+
return setIsNewTemplatePaneOpen(false);
|
|
929
|
+
}
|
|
930
|
+
}, otherProps)), /*#__PURE__*/jsxRuntime.jsx(Edit, _objectSpread$3(_objectSpread$3({
|
|
931
|
+
isOpen: isEditPaneOpen,
|
|
932
|
+
setTemplate: setSelectedTemplate,
|
|
933
|
+
template: selectedTemplate
|
|
934
|
+
}, otherProps), {}, {
|
|
935
|
+
onClose: function onClose() {
|
|
936
|
+
return setIsEditPaneOpen(false);
|
|
937
|
+
}
|
|
938
|
+
})), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
|
|
939
|
+
isOpen: isDeleteAlertOpen,
|
|
940
|
+
isSubmitting: isDeleting,
|
|
941
|
+
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
942
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
943
|
+
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
944
|
+
values: {
|
|
945
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR),
|
|
946
|
+
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
947
|
+
}
|
|
948
|
+
}),
|
|
949
|
+
title: t("neetoApprovals.common.delete_", {
|
|
950
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
951
|
+
}),
|
|
952
|
+
onClose: function onClose() {
|
|
953
|
+
return setSelectedTemplate({});
|
|
954
|
+
},
|
|
955
|
+
onSubmit: function onSubmit() {
|
|
956
|
+
return handleDelete(selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.id);
|
|
957
|
+
}
|
|
958
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TemplateDetails, {
|
|
959
|
+
isOpen: isShowPaneOpen,
|
|
960
|
+
template: selectedTemplate,
|
|
961
|
+
onClose: function onClose() {
|
|
962
|
+
return setSelectedTemplate({});
|
|
963
|
+
}
|
|
964
|
+
})]
|
|
965
|
+
});
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
function ownKeys$2(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; }
|
|
969
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
970
|
+
var createRoutes = function createRoutes(_ref) {
|
|
971
|
+
var config = _ref.config,
|
|
972
|
+
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
973
|
+
searchTerm = _ref.searchTerm,
|
|
974
|
+
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
|
|
975
|
+
return [{
|
|
976
|
+
component: function component() {
|
|
977
|
+
return /*#__PURE__*/jsxRuntime.jsx(Templates, _objectSpread$2({}, _objectSpread$2({
|
|
978
|
+
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
979
|
+
searchTerm: searchTerm,
|
|
980
|
+
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
981
|
+
}, config)));
|
|
982
|
+
},
|
|
983
|
+
path: "".concat(config.approvalsPath).concat(routes.templates.index),
|
|
984
|
+
actionBlock: function actionBlock() {
|
|
985
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
986
|
+
"data-cy": "neeto-approvals-templates-add-new-button",
|
|
987
|
+
label: i18next.t("neetoApprovals.common.addNew_", {
|
|
988
|
+
what: i18next.t("neetoApprovals.common.template", constants.SINGULAR)
|
|
989
|
+
}),
|
|
990
|
+
onClick: function onClick() {
|
|
991
|
+
return setIsNewTemplatePaneOpen(true);
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
},
|
|
995
|
+
searchPlaceholder: i18next.t("neetoApprovals.inputs.placeholders.search_", {
|
|
996
|
+
what: i18next.t("neetoApprovals.common.template", constants.PLURAL)
|
|
997
|
+
})
|
|
998
|
+
}, {
|
|
999
|
+
component: function component() {
|
|
1000
|
+
return /*#__PURE__*/jsxRuntime.jsx(PendingRequests, _objectSpread$2({}, config));
|
|
1001
|
+
},
|
|
1002
|
+
path: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1003
|
+
}, {
|
|
1004
|
+
component: function component() {
|
|
1005
|
+
return /*#__PURE__*/jsxRuntime.jsx(History, _objectSpread$2({}, config));
|
|
1006
|
+
},
|
|
1007
|
+
path: "".concat(config.approvalsPath).concat(routes.history)
|
|
1008
|
+
}];
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
var Header = function Header(_ref) {
|
|
1012
|
+
var _currentTab$actionBlo;
|
|
1013
|
+
var appRoutes = _ref.appRoutes,
|
|
1014
|
+
breadcrumbs = _ref.breadcrumbs;
|
|
1015
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1016
|
+
t = _useTranslation.t;
|
|
1017
|
+
var _useLocation = reactRouterDom.useLocation(),
|
|
1018
|
+
pathname = _useLocation.pathname;
|
|
1019
|
+
var currentTab = neetoCist.findBy({
|
|
1020
|
+
path: pathname
|
|
1021
|
+
}, appRoutes);
|
|
1022
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
|
|
1023
|
+
breadcrumbs: breadcrumbs,
|
|
1024
|
+
actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
|
|
1025
|
+
title: t("neetoApprovals.common.approval", constants.PLURAL),
|
|
1026
|
+
searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
|
|
1027
|
+
placeholder: currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
var fetch = function fetch() {
|
|
1033
|
+
return axios__default["default"].get("".concat(constants$1.BASE_URL, "/views"));
|
|
1034
|
+
};
|
|
1035
|
+
var viewsApi = {
|
|
1036
|
+
fetch: fetch
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
function ownKeys$1(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; }
|
|
1040
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { constants$1._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1041
|
+
var useFetchViews = function useFetchViews() {
|
|
1042
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1043
|
+
return reactQuery.useQuery(_objectSpread$1({
|
|
1044
|
+
queryKey: [constants$1.QUERY_KEYS.VIEWS],
|
|
1045
|
+
queryFn: viewsApi.fetch,
|
|
1046
|
+
select: function select(response) {
|
|
1047
|
+
return response.data || response;
|
|
1048
|
+
}
|
|
1049
|
+
}, options));
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
var Tab = function Tab(_ref) {
|
|
1053
|
+
var _pathname$split$;
|
|
1054
|
+
var approvalsPath = _ref.approvalsPath;
|
|
1055
|
+
var _useLocation = reactRouterDom.useLocation(),
|
|
1056
|
+
pathname = _useLocation.pathname;
|
|
1057
|
+
var history = reactRouterDom.useHistory();
|
|
1058
|
+
var approvalFilter = RequestDetailsPane.getApprovalFilter();
|
|
1059
|
+
var approvalFilterKeys = ramda.keys(approvalFilter);
|
|
1060
|
+
var category = (_pathname$split$ = pathname.split(routes.approvals)[1]) === null || _pathname$split$ === void 0 ? void 0 : _pathname$split$.toLocaleUpperCase();
|
|
1061
|
+
var isActive = function isActive(filter) {
|
|
1062
|
+
return category.includes(filter);
|
|
1063
|
+
};
|
|
1064
|
+
var getRoute = function getRoute(filter) {
|
|
1065
|
+
return "".concat(approvalsPath).concat(filter.toLowerCase());
|
|
1066
|
+
};
|
|
1067
|
+
var _useFetchViews = useFetchViews(),
|
|
1068
|
+
_useFetchViews$data = _useFetchViews.data,
|
|
1069
|
+
_useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
|
|
1070
|
+
_useFetchViews$data2$ = _useFetchViews$data2.views,
|
|
1071
|
+
views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
|
|
1072
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoUITab__default["default"], {
|
|
1073
|
+
children: approvalFilterKeys.map(function (filter) {
|
|
1074
|
+
return /*#__PURE__*/jsxRuntime.jsxs(NeetoUITab__default["default"].Item, {
|
|
1075
|
+
active: isActive(filter),
|
|
1076
|
+
count: views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()],
|
|
1077
|
+
label: approvalFilter[filter].label,
|
|
1078
|
+
onClick: function onClick() {
|
|
1079
|
+
return history.push(getRoute(filter));
|
|
1080
|
+
},
|
|
1081
|
+
children: [approvalFilter[filter].label, " (", views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()] || 0, ")"]
|
|
1082
|
+
}, filter);
|
|
1083
|
+
})
|
|
1084
|
+
});
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
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; }
|
|
1088
|
+
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) { constants$1._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; }
|
|
1089
|
+
var Approvals = function Approvals(_ref) {
|
|
1090
|
+
var config = _ref.config;
|
|
1091
|
+
var _useQueryParams = reactUtils.useQueryParams(),
|
|
1092
|
+
_useQueryParams$searc = _useQueryParams.searchTerm,
|
|
1093
|
+
searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
|
|
1094
|
+
var _useState = react.useState(false),
|
|
1095
|
+
_useState2 = constants$1._slicedToArray(_useState, 2),
|
|
1096
|
+
isNewTemplatePaneOpen = _useState2[0],
|
|
1097
|
+
setIsNewTemplatePaneOpen = _useState2[1];
|
|
1098
|
+
var appRoutes = createRoutes({
|
|
1099
|
+
config: config,
|
|
1100
|
+
searchTerm: searchTerm,
|
|
1101
|
+
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1102
|
+
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1103
|
+
});
|
|
1104
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1105
|
+
className: "w-full overflow-y-auto",
|
|
1106
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
|
|
1107
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, _objectSpread({}, _objectSpread({
|
|
1108
|
+
appRoutes: appRoutes
|
|
1109
|
+
}, config))), /*#__PURE__*/jsxRuntime.jsx(Tab, {
|
|
1110
|
+
approvalsPath: config.approvalsPath
|
|
1111
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(reactRouterDom.Switch, {
|
|
1112
|
+
children: [appRoutes.map(function (_ref2) {
|
|
1113
|
+
var path = _ref2.path,
|
|
1114
|
+
component = _ref2.component;
|
|
1115
|
+
return /*#__PURE__*/react.createElement(reactRouterDom.Route, {
|
|
1116
|
+
component: component,
|
|
1117
|
+
path: path,
|
|
1118
|
+
exact: true,
|
|
1119
|
+
key: path
|
|
1120
|
+
});
|
|
1121
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Redirect, {
|
|
1122
|
+
exact: true,
|
|
1123
|
+
from: config.approvalsPath
|
|
1124
|
+
// eslint-disable-next-line @bigbinary/neeto/use-common-routes
|
|
1125
|
+
,
|
|
1126
|
+
to: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1127
|
+
})]
|
|
1128
|
+
})]
|
|
1129
|
+
})
|
|
1130
|
+
});
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
module.exports = Approvals;
|
|
1134
|
+
//# sourceMappingURL=Approvals.js.map
|