@bigbinary/neeto-approvals-frontend 0.2.15 → 0.3.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/README.md +4 -0
- package/dist/index.cjs.js +60 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/package.json +14 -13
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ 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, Tag, Pane, Typography, Label, Textarea, Table as Table$1, NoData, Alert, Tab as Tab$1, Select, Callout } from '@bigbinary/neetoui';
|
|
8
8
|
import { isEmpty, keys } from 'ramda';
|
|
9
|
-
import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop
|
|
9
|
+
import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop } from '@bigbinary/neeto-cist';
|
|
10
10
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
11
11
|
import { useTranslation, Trans } from 'react-i18next';
|
|
12
12
|
import { useQuery, useQueryClient } from 'react-query';
|
|
@@ -428,7 +428,7 @@ var getApprovalFilter = function getApprovalFilter() {
|
|
|
428
428
|
|
|
429
429
|
var MemoizedEditorContent$1 = /*#__PURE__*/React.memo(EditorContent);
|
|
430
430
|
var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
431
|
-
var _window$globalProps, _window$globalProps2
|
|
431
|
+
var _window$globalProps, _window$globalProps2;
|
|
432
432
|
var isOpen = _ref.isOpen,
|
|
433
433
|
onClose = _ref.onClose,
|
|
434
434
|
approvalDetails = _ref.approvalDetails,
|
|
@@ -521,7 +521,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
521
521
|
label: t("neetoApprovals.common.note"),
|
|
522
522
|
value: note,
|
|
523
523
|
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
524
|
-
what:
|
|
524
|
+
what: t("neetoApprovals.common.note")
|
|
525
525
|
}),
|
|
526
526
|
onChange: withEventTargetValue(setNote)
|
|
527
527
|
}), !isPending && note && /*#__PURE__*/React.createElement("div", {
|
|
@@ -752,24 +752,28 @@ var fetch$2 = function fetch(params) {
|
|
|
752
752
|
params: params
|
|
753
753
|
});
|
|
754
754
|
};
|
|
755
|
-
var show$1 = function show(
|
|
756
|
-
|
|
755
|
+
var show$1 = function show(_ref) {
|
|
756
|
+
var id = _ref.id,
|
|
757
|
+
params = _ref.params;
|
|
758
|
+
return axios.get("".concat(TEMPLATE_URL, "/").concat(id), {
|
|
759
|
+
params: params
|
|
760
|
+
});
|
|
757
761
|
};
|
|
758
|
-
var create = function create(
|
|
759
|
-
var
|
|
760
|
-
url =
|
|
761
|
-
payload =
|
|
762
|
+
var create = function create(_ref2) {
|
|
763
|
+
var _ref2$url = _ref2.url,
|
|
764
|
+
url = _ref2$url === void 0 ? TEMPLATE_URL : _ref2$url,
|
|
765
|
+
payload = _ref2.payload;
|
|
762
766
|
return axios.post(url, payload);
|
|
763
767
|
};
|
|
764
|
-
var update = function update(
|
|
765
|
-
var id =
|
|
766
|
-
payload =
|
|
767
|
-
|
|
768
|
-
url =
|
|
768
|
+
var update = function update(_ref3) {
|
|
769
|
+
var id = _ref3.id,
|
|
770
|
+
payload = _ref3.payload,
|
|
771
|
+
_ref3$url = _ref3.url,
|
|
772
|
+
url = _ref3$url === void 0 ? BASE_URL : _ref3$url;
|
|
769
773
|
return axios.put("".concat(url, "/").concat(id), payload);
|
|
770
774
|
};
|
|
771
|
-
var destroy = function destroy(
|
|
772
|
-
var templateId =
|
|
775
|
+
var destroy = function destroy(_ref4) {
|
|
776
|
+
var templateId = _ref4.templateId;
|
|
773
777
|
return axios["delete"]("".concat(TEMPLATE_URL, "/").concat(templateId));
|
|
774
778
|
};
|
|
775
779
|
var templatesApi = {
|
|
@@ -799,6 +803,18 @@ var useFetchTemplates = function useFetchTemplates() {
|
|
|
799
803
|
}
|
|
800
804
|
}, options));
|
|
801
805
|
};
|
|
806
|
+
var useFetchTemplate = function useFetchTemplate(_ref2) {
|
|
807
|
+
var id = _ref2.id,
|
|
808
|
+
params = _ref2.params;
|
|
809
|
+
return useQuery([QUERY_KEYS.SHOW_TEMPLATE, id, params], function () {
|
|
810
|
+
return templatesApi.show({
|
|
811
|
+
id: id,
|
|
812
|
+
params: params
|
|
813
|
+
});
|
|
814
|
+
}, {
|
|
815
|
+
enabled: !!id
|
|
816
|
+
});
|
|
817
|
+
};
|
|
802
818
|
var useCreateTemplate = function useCreateTemplate(options) {
|
|
803
819
|
return useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
|
|
804
820
|
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
@@ -841,8 +857,8 @@ var MessageEditor = withT(function (_ref) {
|
|
|
841
857
|
_ref$initialValue = _ref.initialValue,
|
|
842
858
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
843
859
|
return /*#__PURE__*/React.createElement(FormikEditor, {
|
|
844
|
-
required: true,
|
|
845
860
|
initialValue: initialValue,
|
|
861
|
+
required: true,
|
|
846
862
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
847
863
|
name: "message",
|
|
848
864
|
rows: 3,
|
|
@@ -911,10 +927,10 @@ var Form$2 = function Form(_ref) {
|
|
|
911
927
|
what: t("neetoApprovals.common.template", SINGULAR)
|
|
912
928
|
});
|
|
913
929
|
return /*#__PURE__*/React.createElement(Pane, {
|
|
914
|
-
initialFocusRef: inputReference,
|
|
915
|
-
size: "large",
|
|
916
930
|
isOpen: isOpen,
|
|
917
|
-
onClose: onClose
|
|
931
|
+
onClose: onClose,
|
|
932
|
+
initialFocusRef: inputReference,
|
|
933
|
+
size: "large"
|
|
918
934
|
}, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
919
935
|
style: "h2"
|
|
920
936
|
}, header)), /*#__PURE__*/React.createElement(Form$3, {
|
|
@@ -962,11 +978,11 @@ var Create = function Create(_ref) {
|
|
|
962
978
|
});
|
|
963
979
|
};
|
|
964
980
|
return /*#__PURE__*/React.createElement(Form$2, {
|
|
965
|
-
placeholders: templatePlaceholders,
|
|
966
981
|
isLoading: isLoading,
|
|
967
982
|
isOpen: isOpen,
|
|
968
983
|
onClose: onClose,
|
|
969
|
-
onSubmit: onSubmit
|
|
984
|
+
onSubmit: onSubmit,
|
|
985
|
+
placeholders: templatePlaceholders
|
|
970
986
|
});
|
|
971
987
|
};
|
|
972
988
|
|
|
@@ -1000,12 +1016,12 @@ var Edit = function Edit(_ref) {
|
|
|
1000
1016
|
descriptionEnabled: !!template.description
|
|
1001
1017
|
});
|
|
1002
1018
|
return /*#__PURE__*/React.createElement(Form$2, {
|
|
1003
|
-
|
|
1004
|
-
placeholders: templatePlaceholders,
|
|
1019
|
+
initialData: initialData,
|
|
1005
1020
|
isOpen: isOpen,
|
|
1006
1021
|
onClose: onClose,
|
|
1007
1022
|
onSubmit: onSubmit,
|
|
1008
|
-
|
|
1023
|
+
isLoading: isUpdating,
|
|
1024
|
+
placeholders: templatePlaceholders
|
|
1009
1025
|
});
|
|
1010
1026
|
};
|
|
1011
1027
|
|
|
@@ -1536,23 +1552,34 @@ var Form$1 = function Form(_ref) {
|
|
|
1536
1552
|
var _useTranslation = useTranslation(),
|
|
1537
1553
|
t = _useTranslation.t;
|
|
1538
1554
|
var _useFormikContext = useFormikContext(),
|
|
1539
|
-
resetForm = _useFormikContext.resetForm,
|
|
1540
1555
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
1541
1556
|
var inputRef = useRef(null);
|
|
1542
1557
|
var _useState = useState(null),
|
|
1543
1558
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1544
1559
|
approverId = _useState2[0],
|
|
1545
1560
|
setApproverId = _useState2[1];
|
|
1546
|
-
var
|
|
1561
|
+
var _useState3 = useState(null),
|
|
1562
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1563
|
+
templateId = _useState4[0],
|
|
1564
|
+
setTemplateId = _useState4[1];
|
|
1565
|
+
var params = {
|
|
1547
1566
|
requestableId: requestableId,
|
|
1548
1567
|
approverId: approverId,
|
|
1549
1568
|
approvalRequestorId: (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id
|
|
1550
1569
|
};
|
|
1551
|
-
var _useFetchTemplates = useFetchTemplates(
|
|
1570
|
+
var _useFetchTemplates = useFetchTemplates(),
|
|
1552
1571
|
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1553
1572
|
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1554
1573
|
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1555
1574
|
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3;
|
|
1575
|
+
var _useFetchTemplate = useFetchTemplate({
|
|
1576
|
+
id: templateId,
|
|
1577
|
+
params: params
|
|
1578
|
+
}),
|
|
1579
|
+
_useFetchTemplate$dat = _useFetchTemplate.data,
|
|
1580
|
+
_useFetchTemplate$dat2 = _useFetchTemplate$dat === void 0 ? {} : _useFetchTemplate$dat,
|
|
1581
|
+
_useFetchTemplate$dat3 = _useFetchTemplate$dat2.template,
|
|
1582
|
+
template = _useFetchTemplate$dat3 === void 0 ? {} : _useFetchTemplate$dat3;
|
|
1556
1583
|
var _useFetchApprovers = useFetchApprovers(),
|
|
1557
1584
|
_useFetchApprovers$da = _useFetchApprovers.data,
|
|
1558
1585
|
_useFetchApprovers$da2 = _useFetchApprovers$da === void 0 ? {} : _useFetchApprovers$da,
|
|
@@ -1572,27 +1599,24 @@ var Form$1 = function Form(_ref) {
|
|
|
1572
1599
|
value: template.id
|
|
1573
1600
|
};
|
|
1574
1601
|
});
|
|
1575
|
-
var updateMessage = function updateMessage(
|
|
1602
|
+
var updateMessage = function updateMessage() {
|
|
1576
1603
|
var _inputRef$current;
|
|
1577
1604
|
var message = template.parsedMessage || template.message;
|
|
1578
1605
|
setFieldValue("message", message);
|
|
1579
1606
|
inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.editor) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.commands) === null || _inputRef$current === void 0 || _inputRef$current.setContent(message);
|
|
1580
1607
|
};
|
|
1581
1608
|
var handleTemplateChange = function handleTemplateChange(selectedTemplate) {
|
|
1582
|
-
|
|
1583
|
-
var template = findById(selectedTemplate.value, templates);
|
|
1584
|
-
setSelectedTemplateData(template);
|
|
1585
|
-
updateMessage(template);
|
|
1609
|
+
setTemplateId(selectedTemplate.value);
|
|
1586
1610
|
};
|
|
1587
1611
|
var handleApproverChange = function handleApproverChange(approver) {
|
|
1588
1612
|
setApproverId(approver.value);
|
|
1589
1613
|
setFieldValue("approver", approver);
|
|
1590
1614
|
};
|
|
1591
1615
|
useEffect(function () {
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1594
|
-
updateMessage(
|
|
1595
|
-
}, [
|
|
1616
|
+
if (isEmpty(template)) return;
|
|
1617
|
+
setSelectedTemplateData(template);
|
|
1618
|
+
updateMessage();
|
|
1619
|
+
}, [template]);
|
|
1596
1620
|
return /*#__PURE__*/React.createElement("div", {
|
|
1597
1621
|
className: "w-full space-y-6"
|
|
1598
1622
|
}, /*#__PURE__*/React.createElement(Select, {
|