@bigbinary/neeto-approvals-frontend 0.3.11 → 0.4.0-beta2
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/README.md +3 -3
- package/dist/index.cjs.js +694 -626
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +689 -623
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, createElement, useMemo } from 'react';
|
|
2
2
|
import { useMutationWithInvalidation, useDebounce, withT, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
3
3
|
import Container from '@bigbinary/neeto-molecules/Container';
|
|
4
4
|
import { Link, useLocation, useHistory, Switch, Route, Redirect, useParams } from 'react-router-dom';
|
|
5
5
|
import i18next, { t as t$1 } from 'i18next';
|
|
6
6
|
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, PLURAL, SINGULAR } from '@bigbinary/neeto-commons-frontend/constants';
|
|
7
7
|
import Button from '@bigbinary/neetoui/Button';
|
|
8
|
-
import { isEmpty, keys } from 'ramda';
|
|
9
8
|
import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop } from '@bigbinary/neeto-cist';
|
|
10
9
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
11
10
|
import Table$1 from '@bigbinary/neetoui/Table';
|
|
12
11
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
12
|
+
import { isEmpty, keys } from 'ramda';
|
|
13
13
|
import { useTranslation, Trans } from 'react-i18next';
|
|
14
|
-
import { useQuery,
|
|
14
|
+
import { useQuery, keepPreviousData } from '@tanstack/react-query';
|
|
15
15
|
import axios from 'axios';
|
|
16
16
|
import Tag from '@bigbinary/neetoui/Tag';
|
|
17
17
|
import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
|
|
18
|
-
import { isEditorEmpty
|
|
18
|
+
import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
|
|
19
19
|
import * as yup from 'yup';
|
|
20
|
-
import {
|
|
20
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
|
+
import { dateFormat, withEventTargetValue, captureAnalyticsEvent } from '@bigbinary/neeto-commons-frontend/utils';
|
|
22
|
+
import EditorContent from '@bigbinary/neeto-editor/EditorContent';
|
|
21
23
|
import Label from '@bigbinary/neetoui/Label';
|
|
22
24
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
23
25
|
import Textarea from '@bigbinary/neetoui/Textarea';
|
|
@@ -34,6 +36,7 @@ import { useFormikContext } from 'formik';
|
|
|
34
36
|
import ToggleFeatureCard from '@bigbinary/neeto-molecules/ToggleFeatureCard';
|
|
35
37
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
36
38
|
import Textarea$1 from '@bigbinary/neetoui/formik/Textarea';
|
|
39
|
+
import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
|
|
37
40
|
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
38
41
|
import NeetoHeader from '@bigbinary/neeto-molecules/Header';
|
|
39
42
|
import NeetoUITab from '@bigbinary/neetoui/Tab';
|
|
@@ -192,23 +195,20 @@ var useFetchRequests = function useFetchRequests(_ref) {
|
|
|
192
195
|
params = _ref$params === void 0 ? {} : _ref$params,
|
|
193
196
|
_ref$options = _ref.options,
|
|
194
197
|
options = _ref$options === void 0 ? {} : _ref$options;
|
|
195
|
-
return useQuery(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
return useQuery(_objectSpread$b({
|
|
199
|
+
queryKey: [QUERY_KEYS.REQUESTS, params],
|
|
200
|
+
queryFn: function queryFn() {
|
|
201
|
+
return requestsApi.fetch(params, requestUrl);
|
|
202
|
+
},
|
|
198
203
|
select: function select(response) {
|
|
199
204
|
return response.data || response;
|
|
200
205
|
},
|
|
201
|
-
|
|
202
|
-
onSuccess: function onSuccess(_ref2) {
|
|
203
|
-
var _options$onSuccess;
|
|
204
|
-
var requests = _ref2.requests;
|
|
205
|
-
return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, requests);
|
|
206
|
-
}
|
|
206
|
+
placeholderData: keepPreviousData
|
|
207
207
|
}, options));
|
|
208
208
|
};
|
|
209
209
|
var useUpdateRequest = function useUpdateRequest(options) {
|
|
210
210
|
return useMutationWithInvalidation(requestsApi.update, _objectSpread$b({
|
|
211
|
-
keysToInvalidate: [QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
211
|
+
keysToInvalidate: [[QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
212
212
|
}, options));
|
|
213
213
|
};
|
|
214
214
|
|
|
@@ -279,6 +279,9 @@ var REQUEST_FORM_VALIDATION_SCHEMA = yup.object().shape({
|
|
|
279
279
|
}),
|
|
280
280
|
approver: yup.object().required(t$1("neetoApprovals.validations.approver"))
|
|
281
281
|
});
|
|
282
|
+
var EVENTS = {
|
|
283
|
+
APPROVAL_TEMPLATE_CREATED: "approval_template_created"
|
|
284
|
+
};
|
|
282
285
|
|
|
283
286
|
var HISTORY_TABLE_COLUMNS = [{
|
|
284
287
|
dataIndex: "approvalLabel",
|
|
@@ -289,7 +292,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
289
292
|
render: function render(approvalLabel, _ref) {
|
|
290
293
|
var requestableUrl = _ref.requestableUrl;
|
|
291
294
|
var url = new URL(requestableUrl || window.location.origin);
|
|
292
|
-
return /*#__PURE__*/
|
|
295
|
+
return /*#__PURE__*/jsx(Button, {
|
|
293
296
|
label: approvalLabel,
|
|
294
297
|
style: "link",
|
|
295
298
|
to: url.pathname
|
|
@@ -308,7 +311,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
308
311
|
width: "25%",
|
|
309
312
|
title: t$1("neetoApprovals.common.status"),
|
|
310
313
|
render: function render(status) {
|
|
311
|
-
return /*#__PURE__*/
|
|
314
|
+
return /*#__PURE__*/jsx(Tag, {
|
|
312
315
|
label: capitalize(status),
|
|
313
316
|
style: STATUS_TAG_STYLE[status]
|
|
314
317
|
});
|
|
@@ -320,7 +323,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
320
323
|
width: "25%",
|
|
321
324
|
title: t$1("neetoApprovals.common.created"),
|
|
322
325
|
render: function render(createdAt) {
|
|
323
|
-
return /*#__PURE__*/
|
|
326
|
+
return /*#__PURE__*/jsx(DateFormat.FromNow, {
|
|
324
327
|
date: createdAt,
|
|
325
328
|
typographyProps: {
|
|
326
329
|
style: "body2"
|
|
@@ -338,34 +341,36 @@ var Footer = function Footer(_ref) {
|
|
|
338
341
|
t = _useTranslation.t;
|
|
339
342
|
if (!isCurrentUserApprover && !isCurrentUserRequester) return null;
|
|
340
343
|
if (isCurrentUserApprover) {
|
|
341
|
-
return /*#__PURE__*/
|
|
342
|
-
className: "flex gap-x-2"
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
return /*#__PURE__*/jsxs(Pane.Footer, {
|
|
345
|
+
className: "flex gap-x-2",
|
|
346
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
347
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
348
|
+
loading: isLoading,
|
|
349
|
+
type: "submit",
|
|
350
|
+
onClick: function onClick() {
|
|
351
|
+
return handleSubmit(STATUSES.approved);
|
|
352
|
+
}
|
|
353
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
354
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
355
|
+
loading: isLoading,
|
|
356
|
+
style: "text",
|
|
357
|
+
onClick: function onClick() {
|
|
358
|
+
return handleSubmit(STATUSES.rejected);
|
|
359
|
+
}
|
|
360
|
+
})]
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return /*#__PURE__*/jsx(Pane.Footer, {
|
|
364
|
+
className: "flex gap-x-2",
|
|
365
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
366
|
+
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
345
367
|
loading: isLoading,
|
|
346
368
|
type: "submit",
|
|
347
369
|
onClick: function onClick() {
|
|
348
|
-
return handleSubmit(STATUSES.
|
|
370
|
+
return handleSubmit(STATUSES.cancelled);
|
|
349
371
|
}
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
loading: isLoading,
|
|
353
|
-
style: "text",
|
|
354
|
-
onClick: function onClick() {
|
|
355
|
-
return handleSubmit(STATUSES.rejected);
|
|
356
|
-
}
|
|
357
|
-
}));
|
|
358
|
-
}
|
|
359
|
-
return /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
360
|
-
className: "flex gap-x-2"
|
|
361
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
362
|
-
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
363
|
-
loading: isLoading,
|
|
364
|
-
type: "submit",
|
|
365
|
-
onClick: function onClick() {
|
|
366
|
-
return handleSubmit(STATUSES.cancelled);
|
|
367
|
-
}
|
|
368
|
-
}));
|
|
372
|
+
})
|
|
373
|
+
});
|
|
369
374
|
};
|
|
370
375
|
|
|
371
376
|
dayjs.extend(utc);
|
|
@@ -430,7 +435,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
430
435
|
setNote = _useState2[1];
|
|
431
436
|
var _useUpdateRequest = useUpdateRequest(),
|
|
432
437
|
updatePendingRequest = _useUpdateRequest.mutate,
|
|
433
|
-
|
|
438
|
+
isUpdateRequestPending = _useUpdateRequest.isPending;
|
|
434
439
|
useEffect(function () {
|
|
435
440
|
setNote(initialNote);
|
|
436
441
|
}, [initialNote]);
|
|
@@ -458,65 +463,82 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
458
463
|
onSuccess: handleOnClose
|
|
459
464
|
});
|
|
460
465
|
};
|
|
461
|
-
return /*#__PURE__*/
|
|
466
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
462
467
|
isOpen: isOpen,
|
|
463
468
|
size: "large",
|
|
464
|
-
onClose: handleOnClose
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
469
|
+
onClose: handleOnClose,
|
|
470
|
+
children: [/*#__PURE__*/jsxs(Pane.Header, {
|
|
471
|
+
className: "space-y-2",
|
|
472
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
473
|
+
style: "h2",
|
|
474
|
+
children: title
|
|
475
|
+
}), /*#__PURE__*/jsx(Tag, {
|
|
476
|
+
label: capitalize(status),
|
|
477
|
+
style: STATUS_TAG_STYLE[status]
|
|
478
|
+
})]
|
|
479
|
+
}), /*#__PURE__*/jsxs(Pane.Body, {
|
|
480
|
+
className: "space-y-6",
|
|
481
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
482
|
+
className: "w-full divide-y border px-3",
|
|
483
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
484
|
+
className: "flex space-x-3 p-2",
|
|
485
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
486
|
+
className: "font-normal",
|
|
487
|
+
children: getStatusLabel()
|
|
488
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
489
|
+
style: "body2",
|
|
490
|
+
weight: "medium",
|
|
491
|
+
children: requesterOrApproverDetails
|
|
492
|
+
})]
|
|
493
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
494
|
+
className: "flex space-x-3 p-2",
|
|
495
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
496
|
+
className: "font-normal",
|
|
497
|
+
children: t("neetoApprovals.common.created")
|
|
498
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
499
|
+
style: "body2",
|
|
500
|
+
weight: "medium",
|
|
501
|
+
children: dateFormat.defaultWithTime(timeInZone(createdAt))
|
|
502
|
+
})]
|
|
503
|
+
})]
|
|
504
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
505
|
+
className: "w-full space-y-2",
|
|
506
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
507
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
508
|
+
}), /*#__PURE__*/jsx(MemoizedEditorContent$1, {
|
|
509
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
510
|
+
content: message
|
|
511
|
+
})]
|
|
512
|
+
}), isPending && isCurrentUserApprover && /*#__PURE__*/jsx(Textarea, {
|
|
513
|
+
className: "w-full",
|
|
514
|
+
disabled: !isPending,
|
|
515
|
+
label: t("neetoApprovals.common.note"),
|
|
516
|
+
value: note,
|
|
517
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
518
|
+
what: t("neetoApprovals.common.note")
|
|
519
|
+
}),
|
|
520
|
+
onChange: withEventTargetValue(setNote)
|
|
521
|
+
}), !isPending && note && /*#__PURE__*/jsxs("div", {
|
|
522
|
+
className: "w-full space-y-2",
|
|
523
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
524
|
+
children: t("neetoApprovals.common.note")
|
|
525
|
+
}), /*#__PURE__*/jsx("div", {
|
|
526
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
527
|
+
children: note
|
|
528
|
+
})]
|
|
529
|
+
})]
|
|
530
|
+
}), isPending && /*#__PURE__*/jsx(Footer, {
|
|
531
|
+
handleSubmit: handleSubmit,
|
|
532
|
+
isCurrentUserApprover: isCurrentUserApprover,
|
|
533
|
+
isCurrentUserRequester: isCurrentUserRequester,
|
|
534
|
+
isLoading: isUpdateRequestPending
|
|
535
|
+
})]
|
|
536
|
+
});
|
|
514
537
|
};
|
|
515
538
|
|
|
516
539
|
function ownKeys$a(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; }
|
|
517
540
|
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
518
541
|
var History = function History(_ref) {
|
|
519
|
-
var _t;
|
|
520
542
|
var requestUrl = _ref.requestUrl;
|
|
521
543
|
var _useState = useState(DEFAULT_FILTER_VALUES),
|
|
522
544
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -537,64 +559,66 @@ var History = function History(_ref) {
|
|
|
537
559
|
searchTerm: debouncedSearchTerm.trim(),
|
|
538
560
|
status: [STATUSES.approved, STATUSES.rejected, STATUSES.cancelled]
|
|
539
561
|
}),
|
|
540
|
-
options: {
|
|
541
|
-
onSuccess: function onSuccess(_ref2) {
|
|
542
|
-
var requests = _ref2.requests;
|
|
543
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
544
|
-
setApprovalDetails(function (approvalDetails) {
|
|
545
|
-
return updateApprovalDetails({
|
|
546
|
-
requestsData: requests,
|
|
547
|
-
approvalDetails: approvalDetails
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
},
|
|
552
562
|
requestUrl: requestUrl
|
|
553
563
|
}),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
approvalHistories =
|
|
558
|
-
|
|
559
|
-
totalCount =
|
|
564
|
+
data = _useFetchRequests.data;
|
|
565
|
+
var _ref2 = data || {},
|
|
566
|
+
_ref2$requests = _ref2.requests,
|
|
567
|
+
approvalHistories = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
568
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
569
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
570
|
+
useEffect(function () {
|
|
571
|
+
if (!data) return;
|
|
572
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
573
|
+
setApprovalDetails(function (approvalDetails) {
|
|
574
|
+
return updateApprovalDetails({
|
|
575
|
+
requestsData: data === null || data === void 0 ? void 0 : data.requests,
|
|
576
|
+
approvalDetails: approvalDetails
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}, [data]);
|
|
560
580
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
561
581
|
setFilters(_objectSpread$a(_objectSpread$a({}, filters), {}, {
|
|
562
582
|
sortBy: camelToSnakeCase(sorter.field || ""),
|
|
563
583
|
orderBy: SORT_ORDER[sorter.order]
|
|
564
584
|
}));
|
|
565
585
|
};
|
|
566
|
-
return /*#__PURE__*/
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
586
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
587
|
+
children: [!isEmpty(approvalHistories) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
588
|
+
className: "mt-6",
|
|
589
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
590
|
+
children: /*#__PURE__*/jsx(Table$1, {
|
|
591
|
+
handlePageChange: handlePageChange,
|
|
592
|
+
totalCount: totalCount,
|
|
593
|
+
allowRowClick: true,
|
|
594
|
+
fixedHeight: true,
|
|
595
|
+
columnData: HISTORY_TABLE_COLUMNS,
|
|
596
|
+
currentPageNumber: pageProperties.page,
|
|
597
|
+
defaultPageSize: pageProperties.pageSize,
|
|
598
|
+
rowData: approvalHistories,
|
|
599
|
+
paginationProps: {
|
|
600
|
+
hideOnSinglePage: (approvalHistories === null || approvalHistories === void 0 ? void 0 : approvalHistories.length) < DEFAULT_PAGE_SIZE + 1
|
|
601
|
+
},
|
|
602
|
+
onChange: handleTableChange,
|
|
603
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
604
|
+
return setApprovalDetails(approvalDetails);
|
|
605
|
+
}
|
|
606
|
+
})
|
|
607
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
608
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
609
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
610
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
611
|
+
what: t("neetoApprovals.common.record", PLURAL)
|
|
612
|
+
})
|
|
613
|
+
})
|
|
614
|
+
}), /*#__PURE__*/jsx(RequestDetailsPane, {
|
|
615
|
+
approvalDetails: approvalDetails,
|
|
616
|
+
isOpen: isPresent(approvalDetails),
|
|
617
|
+
onClose: function onClose() {
|
|
618
|
+
return setApprovalDetails({});
|
|
619
|
+
}
|
|
620
|
+
})]
|
|
621
|
+
});
|
|
598
622
|
};
|
|
599
623
|
|
|
600
624
|
var PENDING_TABLE_COLUMNS = removeBy({
|
|
@@ -604,7 +628,6 @@ var PENDING_TABLE_COLUMNS = removeBy({
|
|
|
604
628
|
function ownKeys$9(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; }
|
|
605
629
|
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
606
630
|
var PendingRequests = function PendingRequests(_ref) {
|
|
607
|
-
var _t;
|
|
608
631
|
var requestUrl = _ref.requestUrl;
|
|
609
632
|
var _useState = useState(DEFAULT_FILTER_VALUES),
|
|
610
633
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -625,75 +648,62 @@ var PendingRequests = function PendingRequests(_ref) {
|
|
|
625
648
|
searchTerm: debouncedSearchTerm.trim(),
|
|
626
649
|
status: [STATUSES.pending]
|
|
627
650
|
}),
|
|
628
|
-
options: {
|
|
629
|
-
onSuccess: function onSuccess(_ref2) {
|
|
630
|
-
var requests = _ref2.requests;
|
|
631
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
651
|
requestUrl: requestUrl
|
|
635
652
|
}),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
pendingRequests =
|
|
640
|
-
|
|
641
|
-
totalCount =
|
|
653
|
+
data = _useFetchRequests.data;
|
|
654
|
+
var _ref2 = data || {},
|
|
655
|
+
_ref2$requests = _ref2.requests,
|
|
656
|
+
pendingRequests = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
657
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
658
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
659
|
+
useEffect(function () {
|
|
660
|
+
if (!data) return;
|
|
661
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
662
|
+
}, [data]);
|
|
642
663
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
643
664
|
setFilters(_objectSpread$9(_objectSpread$9({}, filters), {}, {
|
|
644
665
|
sortBy: camelToSnakeCase(sorter.field || ""),
|
|
645
666
|
orderBy: SORT_ORDER[sorter.order]
|
|
646
667
|
}));
|
|
647
668
|
};
|
|
648
|
-
return /*#__PURE__*/
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
668
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
669
|
-
}, /*#__PURE__*/React.createElement(NoData, {
|
|
670
|
-
title: t("neetoApprovals.common.notFound_", {
|
|
671
|
-
what: (_t = t("neetoApprovals.common.pendingApproval", PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
672
|
-
})
|
|
673
|
-
})), /*#__PURE__*/React.createElement(RequestDetailsPane, {
|
|
674
|
-
isPending: true,
|
|
675
|
-
approvalDetails: approvalDetails,
|
|
676
|
-
isOpen: isPresent(approvalDetails),
|
|
677
|
-
onClose: function onClose() {
|
|
678
|
-
return setApprovalDetails({});
|
|
679
|
-
}
|
|
680
|
-
}));
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
function _extends() {
|
|
684
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
685
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
686
|
-
var source = arguments[i];
|
|
687
|
-
for (var key in source) {
|
|
688
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
689
|
-
target[key] = source[key];
|
|
669
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
670
|
+
children: [!isEmpty(pendingRequests) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
671
|
+
className: "mt-6",
|
|
672
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
673
|
+
children: /*#__PURE__*/jsx(Table$1, {
|
|
674
|
+
handlePageChange: handlePageChange,
|
|
675
|
+
totalCount: totalCount,
|
|
676
|
+
allowRowClick: true,
|
|
677
|
+
fixedHeight: true,
|
|
678
|
+
columnData: PENDING_TABLE_COLUMNS,
|
|
679
|
+
currentPageNumber: pageProperties.page,
|
|
680
|
+
defaultPageSize: pageProperties.pageSize,
|
|
681
|
+
rowData: pendingRequests,
|
|
682
|
+
paginationProps: {
|
|
683
|
+
hideOnSinglePage: (pendingRequests === null || pendingRequests === void 0 ? void 0 : pendingRequests.length) < DEFAULT_PAGE_SIZE + 1
|
|
684
|
+
},
|
|
685
|
+
onChange: handleTableChange,
|
|
686
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
687
|
+
return setApprovalDetails(approvalDetails);
|
|
690
688
|
}
|
|
689
|
+
})
|
|
690
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
691
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
692
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
693
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
694
|
+
what: t("neetoApprovals.common.pendingApproval", PLURAL)
|
|
695
|
+
})
|
|
696
|
+
})
|
|
697
|
+
}), /*#__PURE__*/jsx(RequestDetailsPane, {
|
|
698
|
+
approvalDetails: approvalDetails,
|
|
699
|
+
isPending: true,
|
|
700
|
+
isOpen: isPresent(approvalDetails),
|
|
701
|
+
onClose: function onClose() {
|
|
702
|
+
return setApprovalDetails({});
|
|
691
703
|
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return _extends.apply(this, arguments);
|
|
696
|
-
}
|
|
704
|
+
})]
|
|
705
|
+
});
|
|
706
|
+
};
|
|
697
707
|
|
|
698
708
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
699
709
|
if (source == null) return {};
|
|
@@ -766,48 +776,50 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
766
776
|
var useFetchTemplates = function useFetchTemplates() {
|
|
767
777
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
768
778
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
769
|
-
return useQuery(
|
|
770
|
-
|
|
771
|
-
|
|
779
|
+
return useQuery(_objectSpread$8({
|
|
780
|
+
queryKey: [QUERY_KEYS.TEMPLATES, params],
|
|
781
|
+
queryFn: function queryFn() {
|
|
782
|
+
return templatesApi.fetch(params);
|
|
783
|
+
},
|
|
772
784
|
select: function select(response) {
|
|
773
785
|
return response.data || response;
|
|
774
786
|
},
|
|
775
|
-
|
|
776
|
-
onSuccess: function onSuccess(_ref) {
|
|
777
|
-
var _params$onSuccess;
|
|
778
|
-
var templates = _ref.templates;
|
|
779
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, templates);
|
|
780
|
-
}
|
|
787
|
+
placeholderData: keepPreviousData
|
|
781
788
|
}, options));
|
|
782
789
|
};
|
|
783
|
-
var useFetchTemplate = function useFetchTemplate(
|
|
784
|
-
var id =
|
|
785
|
-
params =
|
|
786
|
-
return useQuery(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
790
|
+
var useFetchTemplate = function useFetchTemplate(_ref) {
|
|
791
|
+
var id = _ref.id,
|
|
792
|
+
params = _ref.params;
|
|
793
|
+
return useQuery({
|
|
794
|
+
queryKey: [QUERY_KEYS.SHOW_TEMPLATE, id, params],
|
|
795
|
+
queryFn: function queryFn() {
|
|
796
|
+
return templatesApi.show({
|
|
797
|
+
id: id,
|
|
798
|
+
params: params
|
|
799
|
+
});
|
|
800
|
+
},
|
|
792
801
|
enabled: !!id
|
|
793
802
|
});
|
|
794
803
|
};
|
|
795
|
-
var useCreateTemplate = function useCreateTemplate(
|
|
796
|
-
return useMutationWithInvalidation(templatesApi.create,
|
|
797
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
798
|
-
|
|
804
|
+
var useCreateTemplate = function useCreateTemplate() {
|
|
805
|
+
return useMutationWithInvalidation(templatesApi.create, {
|
|
806
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]],
|
|
807
|
+
onSuccess: function onSuccess() {
|
|
808
|
+
return captureAnalyticsEvent(EVENTS.APPROVAL_TEMPLATE_CREATED);
|
|
809
|
+
}
|
|
810
|
+
});
|
|
799
811
|
};
|
|
800
812
|
var useUpdateTemplate = function useUpdateTemplate(options) {
|
|
801
813
|
return useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
|
|
802
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, function (_,
|
|
803
|
-
var id =
|
|
814
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], function (_, _ref2) {
|
|
815
|
+
var id = _ref2.id;
|
|
804
816
|
return [QUERY_KEYS.SHOW_TEMPLATE, id];
|
|
805
817
|
}]
|
|
806
818
|
}, options));
|
|
807
819
|
};
|
|
808
820
|
var useDeleteTemplate = function useDeleteTemplate(options) {
|
|
809
821
|
return useMutationWithInvalidation(templatesApi.destroy, _objectSpread$8({
|
|
810
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
822
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
811
823
|
}, options));
|
|
812
824
|
};
|
|
813
825
|
|
|
@@ -833,7 +845,7 @@ var MessageEditor = withT(function (_ref) {
|
|
|
833
845
|
placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
|
|
834
846
|
_ref$initialValue = _ref.initialValue,
|
|
835
847
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
836
|
-
return /*#__PURE__*/
|
|
848
|
+
return /*#__PURE__*/jsx(FormikEditor, {
|
|
837
849
|
initialValue: initialValue,
|
|
838
850
|
required: true,
|
|
839
851
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
@@ -861,32 +873,34 @@ var TemplateForm = function TemplateForm(_ref) {
|
|
|
861
873
|
setFieldValue("description", "");
|
|
862
874
|
}
|
|
863
875
|
};
|
|
864
|
-
return /*#__PURE__*/
|
|
865
|
-
className: "flex w-full flex-col space-y-6"
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
876
|
+
return /*#__PURE__*/jsxs("div", {
|
|
877
|
+
className: "flex w-full flex-col space-y-6",
|
|
878
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
879
|
+
autoFocus: true,
|
|
880
|
+
required: true,
|
|
881
|
+
label: t("neetoApprovals.common.name"),
|
|
882
|
+
name: "name",
|
|
883
|
+
placeholder: t("neetoApprovals.inputs.placeholders.name")
|
|
884
|
+
}), /*#__PURE__*/jsx(ToggleFeatureCard, {
|
|
885
|
+
switchName: "descriptionEnabled",
|
|
886
|
+
title: t("neetoApprovals.inputs.labels.description"),
|
|
887
|
+
switchProps: {
|
|
888
|
+
onChange: handleDescriptionToggle,
|
|
889
|
+
tooltipProps: {
|
|
890
|
+
enabledSwitchText: t("neetoApprovals.templates.descriptionToggle.enable"),
|
|
891
|
+
disabledSwitchText: t("neetoApprovals.templates.descriptionToggle.disable")
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
children: values.descriptionEnabled && /*#__PURE__*/jsx(Textarea$1, {
|
|
895
|
+
className: "w-full",
|
|
896
|
+
name: "description",
|
|
897
|
+
placeholder: t("neetoApprovals.inputs.placeholders.description")
|
|
898
|
+
})
|
|
899
|
+
}), /*#__PURE__*/jsx(MessageEditor, {
|
|
900
|
+
placeholders: placeholders,
|
|
901
|
+
initialValue: initialData.message
|
|
902
|
+
})]
|
|
903
|
+
});
|
|
890
904
|
};
|
|
891
905
|
|
|
892
906
|
var Form$2 = function Form(_ref) {
|
|
@@ -907,33 +921,42 @@ var Form$2 = function Form(_ref) {
|
|
|
907
921
|
}) : t("neetoApprovals.common.edit_", {
|
|
908
922
|
what: t("neetoApprovals.common.template", SINGULAR)
|
|
909
923
|
});
|
|
910
|
-
return /*#__PURE__*/
|
|
924
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
911
925
|
isOpen: isOpen,
|
|
912
926
|
onClose: onClose,
|
|
913
927
|
initialFocusRef: inputReference,
|
|
914
|
-
size: "large"
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
928
|
+
size: "large",
|
|
929
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
930
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
931
|
+
style: "h2",
|
|
932
|
+
children: header
|
|
933
|
+
})
|
|
934
|
+
}), /*#__PURE__*/jsxs(FormikForm, {
|
|
935
|
+
formikProps: {
|
|
936
|
+
enableReinitialize: true,
|
|
937
|
+
initialValues: isPresent(initialData) ? initialData : TEMPLATE_FORM_INITIAL_VALUES,
|
|
938
|
+
validationSchema: TEMPLATE_FORM_VALIDATION_SCHEMA,
|
|
939
|
+
onSubmit: onSubmit
|
|
940
|
+
},
|
|
941
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
942
|
+
children: /*#__PURE__*/jsx(TemplateForm, {
|
|
943
|
+
initialData: initialData,
|
|
944
|
+
placeholders: placeholders
|
|
945
|
+
})
|
|
946
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
947
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
948
|
+
isSubmitting: isLoading,
|
|
949
|
+
cancelButtonProps: {
|
|
950
|
+
"data-cy": "neeto-approvals-templates-close-template-form-btn",
|
|
951
|
+
onClick: onClose
|
|
952
|
+
},
|
|
953
|
+
submitButtonProps: {
|
|
954
|
+
"data-cy": "neeto-approvals-templates-save-template-btn"
|
|
955
|
+
}
|
|
956
|
+
})
|
|
957
|
+
})]
|
|
958
|
+
})]
|
|
959
|
+
});
|
|
937
960
|
};
|
|
938
961
|
|
|
939
962
|
var Create = function Create(_ref) {
|
|
@@ -943,7 +966,7 @@ var Create = function Create(_ref) {
|
|
|
943
966
|
templatePlaceholders = _ref.templatePlaceholders;
|
|
944
967
|
var _useCreateTemplate = useCreateTemplate(),
|
|
945
968
|
createTemplate = _useCreateTemplate.mutate,
|
|
946
|
-
|
|
969
|
+
isPending = _useCreateTemplate.isPending;
|
|
947
970
|
var onSubmit = function onSubmit(template) {
|
|
948
971
|
var payload = {
|
|
949
972
|
template: template
|
|
@@ -955,11 +978,11 @@ var Create = function Create(_ref) {
|
|
|
955
978
|
onSuccess: onClose
|
|
956
979
|
});
|
|
957
980
|
};
|
|
958
|
-
return /*#__PURE__*/
|
|
959
|
-
isLoading: isLoading,
|
|
981
|
+
return /*#__PURE__*/jsx(Form$2, {
|
|
960
982
|
isOpen: isOpen,
|
|
961
983
|
onClose: onClose,
|
|
962
984
|
onSubmit: onSubmit,
|
|
985
|
+
isLoading: isPending,
|
|
963
986
|
placeholders: templatePlaceholders
|
|
964
987
|
});
|
|
965
988
|
};
|
|
@@ -979,7 +1002,7 @@ var Edit = function Edit(_ref) {
|
|
|
979
1002
|
}
|
|
980
1003
|
}),
|
|
981
1004
|
updateTemplate = _useUpdateTemplate.mutate,
|
|
982
|
-
isUpdating = _useUpdateTemplate.
|
|
1005
|
+
isUpdating = _useUpdateTemplate.isPending;
|
|
983
1006
|
var onSubmit = function onSubmit(template) {
|
|
984
1007
|
var payload = {
|
|
985
1008
|
template: template
|
|
@@ -993,7 +1016,7 @@ var Edit = function Edit(_ref) {
|
|
|
993
1016
|
var initialData = _objectSpread$7(_objectSpread$7({}, template), {}, {
|
|
994
1017
|
descriptionEnabled: !!template.description
|
|
995
1018
|
});
|
|
996
|
-
return /*#__PURE__*/
|
|
1019
|
+
return /*#__PURE__*/jsx(Form$2, {
|
|
997
1020
|
initialData: initialData,
|
|
998
1021
|
isOpen: isOpen,
|
|
999
1022
|
onClose: onClose,
|
|
@@ -1006,14 +1029,17 @@ var Edit = function Edit(_ref) {
|
|
|
1006
1029
|
var Field = function Field(_ref) {
|
|
1007
1030
|
var label = _ref.label,
|
|
1008
1031
|
value = _ref.value;
|
|
1009
|
-
return /*#__PURE__*/
|
|
1010
|
-
className: "flex flex-col items-start justify-center"
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1032
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1033
|
+
className: "flex flex-col items-start justify-center",
|
|
1034
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1035
|
+
className: "mb-1 font-normal",
|
|
1036
|
+
children: label
|
|
1037
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1038
|
+
style: "body1",
|
|
1039
|
+
weight: "medium",
|
|
1040
|
+
children: value
|
|
1041
|
+
})]
|
|
1042
|
+
});
|
|
1017
1043
|
};
|
|
1018
1044
|
var Field$1 = /*#__PURE__*/React.memo(Field);
|
|
1019
1045
|
|
|
@@ -1027,41 +1053,47 @@ var TemplateDetails = function TemplateDetails(_ref) {
|
|
|
1027
1053
|
var name = template.name,
|
|
1028
1054
|
description = template.description,
|
|
1029
1055
|
message = template.message;
|
|
1030
|
-
return /*#__PURE__*/
|
|
1056
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1031
1057
|
isOpen: isOpen,
|
|
1032
|
-
onClose: onClose
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1058
|
+
onClose: onClose,
|
|
1059
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1060
|
+
className: "space-y-2",
|
|
1061
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1062
|
+
style: "h2",
|
|
1063
|
+
children: t("neetoApprovals.common.templateDetails")
|
|
1064
|
+
})
|
|
1065
|
+
}), /*#__PURE__*/jsxs(Pane.Body, {
|
|
1066
|
+
className: "space-y-6",
|
|
1067
|
+
children: [/*#__PURE__*/jsx(Field$1, {
|
|
1068
|
+
label: t("neetoApprovals.common.name"),
|
|
1069
|
+
value: name
|
|
1070
|
+
}), /*#__PURE__*/jsx(Field$1, {
|
|
1071
|
+
label: t("neetoApprovals.inputs.labels.description"),
|
|
1072
|
+
value: description
|
|
1073
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1074
|
+
className: "flex w-full flex-col space-y-4",
|
|
1075
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1076
|
+
className: "mb-1 font-normal",
|
|
1077
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
1078
|
+
}), /*#__PURE__*/jsx(MemoizedEditorContent, {
|
|
1079
|
+
className: "neeto-ui-bg-gray-100 neeto-ui-rounded-lg p-3",
|
|
1080
|
+
content: message
|
|
1081
|
+
})]
|
|
1082
|
+
})]
|
|
1083
|
+
})]
|
|
1084
|
+
});
|
|
1053
1085
|
};
|
|
1054
1086
|
|
|
1055
1087
|
var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
|
|
1056
1088
|
var entity = _ref.entity,
|
|
1057
1089
|
url = _ref.url;
|
|
1058
|
-
return /*#__PURE__*/
|
|
1090
|
+
return /*#__PURE__*/jsx(Trans, {
|
|
1059
1091
|
i18nKey: "neetoApprovals.common.noDataHelpText",
|
|
1060
1092
|
values: {
|
|
1061
1093
|
entity: entity
|
|
1062
1094
|
},
|
|
1063
1095
|
components: {
|
|
1064
|
-
a: /*#__PURE__*/
|
|
1096
|
+
a: /*#__PURE__*/jsx(Link, {
|
|
1065
1097
|
className: "neeto-ui-text-primary-600 underline",
|
|
1066
1098
|
target: "_blank",
|
|
1067
1099
|
to: {
|
|
@@ -1116,34 +1148,36 @@ var Table = function Table(_ref) {
|
|
|
1116
1148
|
})
|
|
1117
1149
|
};
|
|
1118
1150
|
if (isEmpty(rowData)) {
|
|
1119
|
-
return /*#__PURE__*/
|
|
1120
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1151
|
+
return /*#__PURE__*/jsx("div", {
|
|
1152
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
1153
|
+
children: /*#__PURE__*/jsx(NoData, _objectSpread$6({
|
|
1154
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
1155
|
+
what: entity
|
|
1156
|
+
})
|
|
1157
|
+
}, !filters.searchTerm && noDataProps))
|
|
1158
|
+
});
|
|
1126
1159
|
}
|
|
1127
|
-
return /*#__PURE__*/
|
|
1160
|
+
return /*#__PURE__*/jsx(TableWrapper, {
|
|
1128
1161
|
className: "mt-6",
|
|
1129
|
-
hasPagination: totalCount > pageProperties.pageSize
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1162
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
1163
|
+
children: /*#__PURE__*/jsx(Table$1, _objectSpread$6({
|
|
1164
|
+
fixedHeight: true,
|
|
1165
|
+
columnData: columns,
|
|
1166
|
+
currentPageNumber: pageProperties.page,
|
|
1167
|
+
defaultPageSize: pageProperties.pageSize,
|
|
1168
|
+
scroll: {
|
|
1169
|
+
x: 0
|
|
1170
|
+
},
|
|
1171
|
+
tableLayout: "fixed",
|
|
1172
|
+
paginationProps: {
|
|
1173
|
+
hideOnSinglePage: (rowData === null || rowData === void 0 ? void 0 : rowData.length) < DEFAULT_PAGE_SIZE + 1
|
|
1174
|
+
},
|
|
1175
|
+
onChange: handleTableChange
|
|
1176
|
+
}, _objectSpread$6({
|
|
1177
|
+
rowData: rowData,
|
|
1178
|
+
totalCount: totalCount
|
|
1179
|
+
}, otherProps)))
|
|
1180
|
+
});
|
|
1147
1181
|
};
|
|
1148
1182
|
|
|
1149
1183
|
var columnData = function columnData(_ref) {
|
|
@@ -1156,32 +1190,34 @@ var columnData = function columnData(_ref) {
|
|
|
1156
1190
|
title: i18next.t("neetoApprovals.common.name"),
|
|
1157
1191
|
ellipsis: true,
|
|
1158
1192
|
render: function render(_, template) {
|
|
1159
|
-
return /*#__PURE__*/
|
|
1160
|
-
className: "flex items-center justify-between gap-x-3"
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1193
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1194
|
+
className: "flex items-center justify-between gap-x-3",
|
|
1195
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1196
|
+
className: "truncate",
|
|
1197
|
+
style: "body2",
|
|
1198
|
+
children: template.name
|
|
1199
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
1200
|
+
dropdownProps: {
|
|
1201
|
+
strategy: "fixed",
|
|
1202
|
+
onClick: function onClick(e) {
|
|
1203
|
+
return e.stopPropagation();
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
menuItems: [_defineProperty({
|
|
1207
|
+
key: "edit",
|
|
1208
|
+
label: i18next.t("neetoApprovals.common.edit"),
|
|
1209
|
+
onClick: function onClick(event) {
|
|
1210
|
+
return onEditClick(event, template);
|
|
1211
|
+
}
|
|
1212
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-edit-template-btn"), _defineProperty({
|
|
1213
|
+
key: "delete",
|
|
1214
|
+
label: i18next.t("neetoApprovals.common.delete"),
|
|
1215
|
+
onClick: function onClick(event) {
|
|
1216
|
+
return onDeleteClick(event, template);
|
|
1217
|
+
}
|
|
1218
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-delete-template-btn")]
|
|
1219
|
+
})]
|
|
1220
|
+
});
|
|
1185
1221
|
}
|
|
1186
1222
|
}, {
|
|
1187
1223
|
dataIndex: "description",
|
|
@@ -1194,7 +1230,6 @@ var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpe
|
|
|
1194
1230
|
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; }
|
|
1195
1231
|
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) { _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; }
|
|
1196
1232
|
var Templates = function Templates(_ref) {
|
|
1197
|
-
var _t, _t2, _t3;
|
|
1198
1233
|
var searchTerm = _ref.searchTerm,
|
|
1199
1234
|
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
1200
1235
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
|
|
@@ -1232,28 +1267,27 @@ var Templates = function Templates(_ref) {
|
|
|
1232
1267
|
}, [searchTerm]);
|
|
1233
1268
|
var _useFetchTemplates = useFetchTemplates(_objectSpread$5(_objectSpread$5(_objectSpread$5({}, pageProperties), filters), {}, {
|
|
1234
1269
|
searchTerm: debouncedSearchTerm.trim()
|
|
1235
|
-
}),
|
|
1236
|
-
|
|
1237
|
-
var templates = _ref2.templates;
|
|
1238
|
-
handleEmptyPage(templates, pageProperties, handlePageChange);
|
|
1239
|
-
}
|
|
1240
|
-
}),
|
|
1241
|
-
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1242
|
-
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1243
|
-
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1244
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
1245
|
-
_useFetchTemplates$da4 = _useFetchTemplates$da2.totalCount,
|
|
1246
|
-
totalCount = _useFetchTemplates$da4 === void 0 ? 0 : _useFetchTemplates$da4,
|
|
1270
|
+
})),
|
|
1271
|
+
data = _useFetchTemplates.data,
|
|
1247
1272
|
isTemplateLoading = _useFetchTemplates.isLoading;
|
|
1273
|
+
var _ref2 = data || {},
|
|
1274
|
+
_ref2$templates = _ref2.templates,
|
|
1275
|
+
templates = _ref2$templates === void 0 ? [] : _ref2$templates,
|
|
1276
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
1277
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
1278
|
+
useEffect(function () {
|
|
1279
|
+
if (data) {
|
|
1280
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.templates, pageProperties, handlePageChange);
|
|
1281
|
+
}
|
|
1282
|
+
}, [data]);
|
|
1248
1283
|
var _useDeleteTemplate = useDeleteTemplate(),
|
|
1249
1284
|
deleteTemplate = _useDeleteTemplate.mutate,
|
|
1250
|
-
isDeleting = _useDeleteTemplate.
|
|
1285
|
+
isDeleting = _useDeleteTemplate.isPending;
|
|
1251
1286
|
useEffect(function () {
|
|
1252
|
-
if (isEmpty(selectedTemplate))
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
}
|
|
1287
|
+
if (!isEmpty(selectedTemplate)) return;
|
|
1288
|
+
setIsDeleteAlertOpen(false);
|
|
1289
|
+
setIsEditPaneOpen(false);
|
|
1290
|
+
setIsShowPaneOpen(false);
|
|
1257
1291
|
}, [selectedTemplate]);
|
|
1258
1292
|
var onEditClick = function onEditClick(event, template) {
|
|
1259
1293
|
event.stopPropagation();
|
|
@@ -1275,62 +1309,64 @@ var Templates = function Templates(_ref) {
|
|
|
1275
1309
|
});
|
|
1276
1310
|
setSelectedTemplate({});
|
|
1277
1311
|
};
|
|
1278
|
-
var entity =
|
|
1279
|
-
return /*#__PURE__*/
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}, otherProps)), /*#__PURE__*/React.createElement(Edit, _extends({
|
|
1300
|
-
isOpen: isEditPaneOpen,
|
|
1301
|
-
setTemplate: setSelectedTemplate,
|
|
1302
|
-
template: selectedTemplate
|
|
1303
|
-
}, otherProps, {
|
|
1304
|
-
onClose: function onClose() {
|
|
1305
|
-
return setIsEditPaneOpen(false);
|
|
1306
|
-
}
|
|
1307
|
-
})), /*#__PURE__*/React.createElement(Alert, {
|
|
1308
|
-
isOpen: isDeleteAlertOpen,
|
|
1309
|
-
isSubmitting: isDeleting,
|
|
1310
|
-
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
1311
|
-
message: /*#__PURE__*/React.createElement(Trans, {
|
|
1312
|
-
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
1313
|
-
values: {
|
|
1314
|
-
what: (_t2 = t("neetoApprovals.common.template", SINGULAR)) === null || _t2 === void 0 ? void 0 : _t2.toLocaleLowerCase(),
|
|
1315
|
-
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
1312
|
+
var entity = t("neetoApprovals.common.template", PLURAL);
|
|
1313
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1314
|
+
children: [isTemplateLoading ? /*#__PURE__*/jsx(PageLoader, {}) : /*#__PURE__*/jsx(Table, {
|
|
1315
|
+
columnData: columnData,
|
|
1316
|
+
entity: entity,
|
|
1317
|
+
filters: filters,
|
|
1318
|
+
handlePageChange: handlePageChange,
|
|
1319
|
+
helpDocUrl: helpDocUrl,
|
|
1320
|
+
onDeleteClick: onDeleteClick,
|
|
1321
|
+
onEditClick: onEditClick,
|
|
1322
|
+
onRowClick: onRowClick,
|
|
1323
|
+
pageProperties: pageProperties,
|
|
1324
|
+
searchTerm: searchTerm,
|
|
1325
|
+
setFilters: setFilters,
|
|
1326
|
+
totalCount: totalCount,
|
|
1327
|
+
rowData: templates,
|
|
1328
|
+
setIsPaneOpen: setIsNewTemplatePaneOpen
|
|
1329
|
+
}), /*#__PURE__*/jsx(Create, _objectSpread$5({
|
|
1330
|
+
isOpen: isNewTemplatePaneOpen,
|
|
1331
|
+
onClose: function onClose() {
|
|
1332
|
+
return setIsNewTemplatePaneOpen(false);
|
|
1316
1333
|
}
|
|
1317
|
-
}),
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
+
}, otherProps)), /*#__PURE__*/jsx(Edit, _objectSpread$5(_objectSpread$5({
|
|
1335
|
+
isOpen: isEditPaneOpen,
|
|
1336
|
+
setTemplate: setSelectedTemplate,
|
|
1337
|
+
template: selectedTemplate
|
|
1338
|
+
}, otherProps), {}, {
|
|
1339
|
+
onClose: function onClose() {
|
|
1340
|
+
return setIsEditPaneOpen(false);
|
|
1341
|
+
}
|
|
1342
|
+
})), /*#__PURE__*/jsx(Alert, {
|
|
1343
|
+
isOpen: isDeleteAlertOpen,
|
|
1344
|
+
isSubmitting: isDeleting,
|
|
1345
|
+
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
1346
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
1347
|
+
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
1348
|
+
values: {
|
|
1349
|
+
what: t("neetoApprovals.common.template", SINGULAR),
|
|
1350
|
+
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
1351
|
+
}
|
|
1352
|
+
}),
|
|
1353
|
+
title: t("neetoApprovals.common.delete_", {
|
|
1354
|
+
what: t("neetoApprovals.common.template", SINGULAR)
|
|
1355
|
+
}),
|
|
1356
|
+
onClose: function onClose() {
|
|
1357
|
+
return setSelectedTemplate({});
|
|
1358
|
+
},
|
|
1359
|
+
onSubmit: function onSubmit() {
|
|
1360
|
+
return handleDelete(selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.id);
|
|
1361
|
+
}
|
|
1362
|
+
}), /*#__PURE__*/jsx(TemplateDetails, {
|
|
1363
|
+
isOpen: isShowPaneOpen,
|
|
1364
|
+
template: selectedTemplate,
|
|
1365
|
+
onClose: function onClose() {
|
|
1366
|
+
return setSelectedTemplate({});
|
|
1367
|
+
}
|
|
1368
|
+
})]
|
|
1369
|
+
});
|
|
1334
1370
|
};
|
|
1335
1371
|
|
|
1336
1372
|
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; }
|
|
@@ -1342,16 +1378,16 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1342
1378
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
|
|
1343
1379
|
return [{
|
|
1344
1380
|
component: function component() {
|
|
1345
|
-
return /*#__PURE__*/
|
|
1381
|
+
return /*#__PURE__*/jsx(Templates, _objectSpread$4({}, _objectSpread$4({
|
|
1346
1382
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1347
1383
|
searchTerm: searchTerm,
|
|
1348
1384
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1349
|
-
}, config));
|
|
1385
|
+
}, config)));
|
|
1350
1386
|
},
|
|
1351
1387
|
path: "".concat(config.approvalsPath).concat(routes.templates.index),
|
|
1352
1388
|
actionBlock: function actionBlock() {
|
|
1353
1389
|
var _t;
|
|
1354
|
-
return /*#__PURE__*/
|
|
1390
|
+
return /*#__PURE__*/jsx(Button, {
|
|
1355
1391
|
"data-cy": "neeto-approvals-templates-add-new-button",
|
|
1356
1392
|
label: t$1("neetoApprovals.common.addNew_", {
|
|
1357
1393
|
what: (_t = t$1("neetoApprovals.common.template", SINGULAR)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
@@ -1366,12 +1402,12 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1366
1402
|
})
|
|
1367
1403
|
}, {
|
|
1368
1404
|
component: function component() {
|
|
1369
|
-
return /*#__PURE__*/
|
|
1405
|
+
return /*#__PURE__*/jsx(PendingRequests, _objectSpread$4({}, config));
|
|
1370
1406
|
},
|
|
1371
1407
|
path: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1372
1408
|
}, {
|
|
1373
1409
|
component: function component() {
|
|
1374
|
-
return /*#__PURE__*/
|
|
1410
|
+
return /*#__PURE__*/jsx(History, _objectSpread$4({}, config));
|
|
1375
1411
|
},
|
|
1376
1412
|
path: "".concat(config.approvalsPath).concat(routes.history)
|
|
1377
1413
|
}];
|
|
@@ -1388,7 +1424,7 @@ var Header = function Header(_ref) {
|
|
|
1388
1424
|
var currentTab = findBy({
|
|
1389
1425
|
path: pathname
|
|
1390
1426
|
}, appRoutes);
|
|
1391
|
-
return /*#__PURE__*/
|
|
1427
|
+
return /*#__PURE__*/jsx(NeetoHeader, {
|
|
1392
1428
|
actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
|
|
1393
1429
|
title: t("neetoApprovals.common.approval", PLURAL),
|
|
1394
1430
|
searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
|
|
@@ -1409,9 +1445,9 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
|
|
|
1409
1445
|
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) { _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; }
|
|
1410
1446
|
var useFetchViews = function useFetchViews() {
|
|
1411
1447
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1412
|
-
return useQuery(
|
|
1413
|
-
|
|
1414
|
-
|
|
1448
|
+
return useQuery(_objectSpread$3({
|
|
1449
|
+
queryKey: [QUERY_KEYS.VIEWS],
|
|
1450
|
+
queryFn: viewsApi.fetch,
|
|
1415
1451
|
select: function select(response) {
|
|
1416
1452
|
return response.data || response;
|
|
1417
1453
|
}
|
|
@@ -1438,17 +1474,19 @@ var Tab = function Tab(_ref) {
|
|
|
1438
1474
|
_useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
|
|
1439
1475
|
_useFetchViews$data2$ = _useFetchViews$data2.views,
|
|
1440
1476
|
views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
|
|
1441
|
-
return /*#__PURE__*/
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1477
|
+
return /*#__PURE__*/jsx(NeetoUITab, {
|
|
1478
|
+
children: approvalFilterKeys.map(function (filter) {
|
|
1479
|
+
return /*#__PURE__*/jsxs(NeetoUITab.Item, {
|
|
1480
|
+
active: isActive(filter),
|
|
1481
|
+
count: views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()],
|
|
1482
|
+
label: approvalFilter[filter].label,
|
|
1483
|
+
onClick: function onClick() {
|
|
1484
|
+
return history.push(getRoute(filter));
|
|
1485
|
+
},
|
|
1486
|
+
children: [approvalFilter[filter].label, " (", views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()] || 0, ")"]
|
|
1487
|
+
}, filter);
|
|
1488
|
+
})
|
|
1489
|
+
});
|
|
1452
1490
|
};
|
|
1453
1491
|
|
|
1454
1492
|
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; }
|
|
@@ -1468,28 +1506,33 @@ var Approvals = function Approvals(_ref) {
|
|
|
1468
1506
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1469
1507
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1470
1508
|
});
|
|
1471
|
-
return /*#__PURE__*/
|
|
1472
|
-
className: "w-full overflow-y-auto"
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1509
|
+
return /*#__PURE__*/jsx("div", {
|
|
1510
|
+
className: "w-full overflow-y-auto",
|
|
1511
|
+
children: /*#__PURE__*/jsxs(Container, {
|
|
1512
|
+
children: [/*#__PURE__*/jsx(Header, _objectSpread$2({}, _objectSpread$2({
|
|
1513
|
+
appRoutes: appRoutes
|
|
1514
|
+
}, config))), /*#__PURE__*/jsx(Tab, {
|
|
1515
|
+
approvalsPath: config.approvalsPath
|
|
1516
|
+
}), /*#__PURE__*/jsxs(Switch, {
|
|
1517
|
+
children: [appRoutes.map(function (_ref2) {
|
|
1518
|
+
var path = _ref2.path,
|
|
1519
|
+
component = _ref2.component;
|
|
1520
|
+
return /*#__PURE__*/createElement(Route, {
|
|
1521
|
+
exact: true,
|
|
1522
|
+
component: component,
|
|
1523
|
+
path: path,
|
|
1524
|
+
key: path
|
|
1525
|
+
});
|
|
1526
|
+
}), /*#__PURE__*/jsx(Redirect, {
|
|
1527
|
+
exact: true,
|
|
1528
|
+
from: config.approvalsPath
|
|
1529
|
+
// eslint-disable-next-line @bigbinary/neeto/use-common-routes
|
|
1530
|
+
,
|
|
1531
|
+
to: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1532
|
+
})]
|
|
1533
|
+
})]
|
|
1534
|
+
})
|
|
1535
|
+
});
|
|
1493
1536
|
};
|
|
1494
1537
|
|
|
1495
1538
|
var fetch = function fetch(params) {
|
|
@@ -1506,17 +1549,13 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
1506
1549
|
var useFetchApprovers = function useFetchApprovers() {
|
|
1507
1550
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1508
1551
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1509
|
-
return useQuery(
|
|
1510
|
-
|
|
1511
|
-
|
|
1552
|
+
return useQuery(_objectSpread$1({
|
|
1553
|
+
queryKey: [QUERY_KEYS.APPROVERS, params],
|
|
1554
|
+
queryFn: function queryFn() {
|
|
1555
|
+
return approversApi.fetch(params);
|
|
1556
|
+
},
|
|
1512
1557
|
select: function select(response) {
|
|
1513
1558
|
return response.data || response;
|
|
1514
|
-
},
|
|
1515
|
-
keepPreviousData: true,
|
|
1516
|
-
onSuccess: function onSuccess(_ref) {
|
|
1517
|
-
var _params$onSuccess;
|
|
1518
|
-
var approvers = _ref.approvers;
|
|
1519
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, approvers);
|
|
1520
1559
|
}
|
|
1521
1560
|
}, options));
|
|
1522
1561
|
};
|
|
@@ -1595,37 +1634,42 @@ var Form$1 = function Form(_ref) {
|
|
|
1595
1634
|
setSelectedTemplateData(template);
|
|
1596
1635
|
updateMessage();
|
|
1597
1636
|
}, [template]);
|
|
1598
|
-
return /*#__PURE__*/
|
|
1599
|
-
className: "w-full space-y-6"
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1637
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1638
|
+
className: "w-full space-y-6",
|
|
1639
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
1640
|
+
label: t("neetoApprovals.select.approval"),
|
|
1641
|
+
options: templateOptions,
|
|
1642
|
+
onChange: function onChange(selectedTemplate) {
|
|
1643
|
+
return handleTemplateChange(selectedTemplate);
|
|
1644
|
+
}
|
|
1645
|
+
}), (selectedTemplateData === null || selectedTemplateData === void 0 ? void 0 : selectedTemplateData.message) && /*#__PURE__*/jsxs(Fragment, {
|
|
1646
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1647
|
+
className: "flex space-x-6",
|
|
1648
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
1649
|
+
required: true,
|
|
1650
|
+
label: t("neetoApprovals.inputs.labels.approver"),
|
|
1651
|
+
name: "approver",
|
|
1652
|
+
options: approverOptions,
|
|
1653
|
+
placeholder: t("neetoApprovals.inputs.placeholders.select_", {
|
|
1654
|
+
what: t("neetoApprovals.common.approver", SINGULAR)
|
|
1655
|
+
}),
|
|
1656
|
+
onChange: handleApproverChange
|
|
1657
|
+
})
|
|
1658
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1659
|
+
className: "space-y-2",
|
|
1660
|
+
children: /*#__PURE__*/jsx(FormikEditor, {
|
|
1661
|
+
required: true,
|
|
1662
|
+
label: t("neetoApprovals.inputs.labels.message"),
|
|
1663
|
+
name: "message",
|
|
1664
|
+
ref: inputRef,
|
|
1665
|
+
rows: 3,
|
|
1666
|
+
placeholder: t("neetoApprovals.inputs.placeholders.enter_", {
|
|
1667
|
+
what: t("neetoApprovals.inputs.labels.message")
|
|
1668
|
+
})
|
|
1669
|
+
})
|
|
1670
|
+
})]
|
|
1671
|
+
})]
|
|
1672
|
+
});
|
|
1629
1673
|
};
|
|
1630
1674
|
|
|
1631
1675
|
var Form = function Form(_ref) {
|
|
@@ -1651,29 +1695,38 @@ var Form = function Form(_ref) {
|
|
|
1651
1695
|
approverId: values.approver.value
|
|
1652
1696
|
}, selectedTemplateData, onClose);
|
|
1653
1697
|
};
|
|
1654
|
-
return /*#__PURE__*/
|
|
1698
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1655
1699
|
isOpen: isOpen,
|
|
1656
|
-
onClose: onClose
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1700
|
+
onClose: onClose,
|
|
1701
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1702
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1703
|
+
style: "h2",
|
|
1704
|
+
children: t("neetoApprovals.common.add_", {
|
|
1705
|
+
what: t("neetoApprovals.common.approval", SINGULAR)
|
|
1706
|
+
})
|
|
1707
|
+
})
|
|
1708
|
+
}), /*#__PURE__*/jsxs(FormikForm, {
|
|
1709
|
+
formikProps: {
|
|
1710
|
+
onSubmit: handleSubmit,
|
|
1711
|
+
initialValues: APPROVAL_REQUEST_FORM_INITIAL_VALUES,
|
|
1712
|
+
validationSchema: REQUEST_FORM_VALIDATION_SCHEMA
|
|
1713
|
+
},
|
|
1714
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
1715
|
+
children: /*#__PURE__*/jsx(Form$1, {
|
|
1716
|
+
requestableId: requestableId,
|
|
1717
|
+
selectedTemplateData: selectedTemplateData,
|
|
1718
|
+
setSelectedTemplateData: setSelectedTemplateData
|
|
1719
|
+
})
|
|
1720
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1721
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1722
|
+
cancelButtonProps: {
|
|
1723
|
+
onClick: onClose
|
|
1724
|
+
},
|
|
1725
|
+
isSubmitting: isLoading
|
|
1726
|
+
})
|
|
1727
|
+
})]
|
|
1728
|
+
})]
|
|
1729
|
+
});
|
|
1677
1730
|
};
|
|
1678
1731
|
|
|
1679
1732
|
var show = function show(id) {
|
|
@@ -1703,20 +1756,21 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
1703
1756
|
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; }
|
|
1704
1757
|
var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
|
|
1705
1758
|
var requestId = _ref.requestId;
|
|
1706
|
-
return useQuery(
|
|
1707
|
-
|
|
1708
|
-
|
|
1759
|
+
return useQuery(_objectSpread({
|
|
1760
|
+
queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
|
|
1761
|
+
queryFn: function queryFn() {
|
|
1762
|
+
return publicRequestsApi.show(requestId);
|
|
1763
|
+
}
|
|
1764
|
+
}, options));
|
|
1709
1765
|
};
|
|
1710
1766
|
var useAcceptPendingRequest = function useAcceptPendingRequest(options) {
|
|
1711
|
-
useQueryClient();
|
|
1712
1767
|
return useMutationWithInvalidation(publicRequestsApi.accept, _objectSpread({
|
|
1713
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
1768
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1714
1769
|
}, options));
|
|
1715
1770
|
};
|
|
1716
1771
|
var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
|
|
1717
|
-
useQueryClient();
|
|
1718
1772
|
return useMutationWithInvalidation(publicRequestsApi.decline, _objectSpread({
|
|
1719
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
1773
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1720
1774
|
}, options));
|
|
1721
1775
|
};
|
|
1722
1776
|
|
|
@@ -1732,84 +1786,96 @@ var Public = function Public() {
|
|
|
1732
1786
|
t = _useTranslation.t;
|
|
1733
1787
|
var _useFetchPublicReques = useFetchPublicRequest({
|
|
1734
1788
|
requestId: id
|
|
1735
|
-
}, {
|
|
1736
|
-
onSuccess: function onSuccess(_ref) {
|
|
1737
|
-
var note = _ref.approvalRequest.note;
|
|
1738
|
-
note && setNote(note);
|
|
1739
|
-
}
|
|
1740
1789
|
}),
|
|
1741
|
-
|
|
1742
|
-
_useFetchPublicReques3 = _useFetchPublicReques2 === void 0 ? {} : _useFetchPublicReques2,
|
|
1743
|
-
_useFetchPublicReques4 = _useFetchPublicReques3.approvalRequest,
|
|
1744
|
-
approvalRequest = _useFetchPublicReques4 === void 0 ? {} : _useFetchPublicReques4,
|
|
1790
|
+
data = _useFetchPublicReques.data,
|
|
1745
1791
|
isLoading = _useFetchPublicReques.isLoading;
|
|
1792
|
+
var _ref = data || {},
|
|
1793
|
+
_ref$approvalRequest = _ref.approvalRequest,
|
|
1794
|
+
approvalRequest = _ref$approvalRequest === void 0 ? {} : _ref$approvalRequest;
|
|
1795
|
+
useEffect(function () {
|
|
1796
|
+
var _data$approvalRequest;
|
|
1797
|
+
if (data !== null && data !== void 0 && (_data$approvalRequest = data.approvalRequest) !== null && _data$approvalRequest !== void 0 && _data$approvalRequest.note) {
|
|
1798
|
+
setNote(data.approvalRequest.note);
|
|
1799
|
+
}
|
|
1800
|
+
}, [data]);
|
|
1746
1801
|
var _useAcceptPendingRequ = useAcceptPendingRequest(),
|
|
1747
1802
|
acceptPendingRequest = _useAcceptPendingRequ.mutate,
|
|
1748
|
-
isAccepting = _useAcceptPendingRequ.
|
|
1803
|
+
isAccepting = _useAcceptPendingRequ.isPending;
|
|
1749
1804
|
var _useDeclinePendingReq = useDeclinePendingRequest(),
|
|
1750
1805
|
declinePendingRequest = _useDeclinePendingReq.mutate,
|
|
1751
|
-
isDeclining = _useDeclinePendingReq.
|
|
1806
|
+
isDeclining = _useDeclinePendingReq.isPending;
|
|
1752
1807
|
var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
|
|
1753
1808
|
var hideTextArea = approvalRequest.status !== STATUSES.pending && isEmpty(note);
|
|
1754
1809
|
if (isLoading) {
|
|
1755
|
-
return /*#__PURE__*/
|
|
1756
|
-
className: "h-screen items-center justify-center"
|
|
1757
|
-
|
|
1810
|
+
return /*#__PURE__*/jsx("div", {
|
|
1811
|
+
className: "h-screen items-center justify-center",
|
|
1812
|
+
children: /*#__PURE__*/jsx(PageLoader, {})
|
|
1813
|
+
});
|
|
1758
1814
|
}
|
|
1759
|
-
return /*#__PURE__*/
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1815
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
1816
|
+
children: [/*#__PURE__*/jsx(NeetoHeader, {
|
|
1817
|
+
title: t("neetoApprovals.common.approval", PLURAL)
|
|
1818
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1819
|
+
className: "flex h-screen w-full flex-col items-center",
|
|
1820
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1821
|
+
className: "neeto-ui-shadow-s w-2/5 rounded border p-6",
|
|
1822
|
+
children: approvalRequest ? /*#__PURE__*/jsxs("div", {
|
|
1823
|
+
className: "flex w-full flex-col space-y-6",
|
|
1824
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1825
|
+
style: "h2",
|
|
1826
|
+
children: approvalRequest.title
|
|
1827
|
+
}), /*#__PURE__*/jsx(EditorContent, {
|
|
1828
|
+
content: approvalRequest.message
|
|
1829
|
+
}), !hideTextArea && /*#__PURE__*/jsx(Textarea, {
|
|
1830
|
+
label: t("neetoApprovals.common.note"),
|
|
1831
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
1832
|
+
what: (_t = t("neetoApprovals.common.note")) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
1833
|
+
}),
|
|
1834
|
+
value: note,
|
|
1835
|
+
disabled: approvalRequest.status !== STATUSES.pending,
|
|
1836
|
+
onChange: withEventTargetValue(setNote)
|
|
1837
|
+
}), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/jsxs("div", {
|
|
1838
|
+
className: "mx-auto mt-8 flex space-x-6",
|
|
1839
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1840
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
1841
|
+
onClick: function onClick() {
|
|
1842
|
+
return acceptPendingRequest({
|
|
1843
|
+
id: approvalRequest.id,
|
|
1844
|
+
note: note
|
|
1845
|
+
});
|
|
1846
|
+
},
|
|
1847
|
+
loading: isAccepting
|
|
1848
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1849
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
1850
|
+
onClick: function onClick() {
|
|
1851
|
+
return declinePendingRequest({
|
|
1852
|
+
id: approvalRequest.id,
|
|
1853
|
+
note: note
|
|
1854
|
+
});
|
|
1855
|
+
},
|
|
1856
|
+
style: "secondary",
|
|
1857
|
+
loading: isDeclining
|
|
1858
|
+
})]
|
|
1859
|
+
}) : /*#__PURE__*/jsx(Callout, {
|
|
1860
|
+
style: calloutStyle,
|
|
1861
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1862
|
+
style: "body1",
|
|
1863
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
1864
|
+
i18nKey: "neetoApprovals.typography.approvalRequest",
|
|
1865
|
+
values: {
|
|
1866
|
+
status: approvalRequest.status
|
|
1867
|
+
}
|
|
1868
|
+
})
|
|
1869
|
+
})
|
|
1870
|
+
})]
|
|
1871
|
+
}) : /*#__PURE__*/jsx(Typography, {
|
|
1872
|
+
style: "h4",
|
|
1873
|
+
className: "text-center",
|
|
1874
|
+
children: t("neetoApprovals.common.notFound")
|
|
1875
|
+
})
|
|
1876
|
+
})
|
|
1877
|
+
})]
|
|
1878
|
+
});
|
|
1813
1879
|
};
|
|
1814
1880
|
|
|
1815
1881
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|