@bigbinary/neeto-payments-frontend 3.0.23 → 3.0.25

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.
@@ -12,34 +12,59 @@ var ramda = require('ramda');
12
12
  var reactRouterDom = require('react-router-dom');
13
13
  var ExportModal = require('./ExportModal-DaLww9x0.js');
14
14
  var reactQuery = require('@tanstack/react-query');
15
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
15
16
  var axios = require('axios');
16
17
  var constants = require('./index-Br_ibfWm.js');
17
18
  var queryConstants = require('./queryConstants-DjUfvjMz.js');
19
+ var Modal = require('@bigbinary/neetoui/Modal');
20
+ var Typography = require('@bigbinary/neetoui/Typography');
21
+ var Form = require('@bigbinary/neetoui/formik/Form');
22
+ var Textarea = require('@bigbinary/neetoui/formik/Textarea');
23
+ var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
24
+ var reactI18next = require('react-i18next');
18
25
  var i18next = require('i18next');
26
+ var yup = require('yup');
27
+ var jsxRuntime = require('react/jsx-runtime');
19
28
  var neetoCist = require('@bigbinary/neeto-cist');
20
29
  var Columns = require('@bigbinary/neeto-molecules/Columns');
21
30
  var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
22
31
  var Table = require('@bigbinary/neetoui/Table');
23
32
  var NoData = require('@bigbinary/neetoui/NoData');
24
- var reactI18next = require('react-i18next');
25
33
  var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
26
34
  var Pane = require('@bigbinary/neetoui/Pane');
27
- var Typography = require('@bigbinary/neetoui/Typography');
28
35
  var Button = require('@bigbinary/neetoui/Button');
29
36
  var Tag = require('@bigbinary/neetoui/Tag');
30
37
  var Tooltip = require('@bigbinary/neetoui/Tooltip');
31
- var jsxRuntime = require('react/jsx-runtime');
32
38
  var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
33
39
  var CopyButtonWrapper = require('./CopyButtonWrapper-Ds1k64E0.js');
34
40
  var FiltersBar = require('@bigbinary/neeto-filters-frontend/Bar');
35
41
  var Header = require('@bigbinary/neeto-molecules/Header');
36
42
  var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
37
43
  var Tab = require('@bigbinary/neetoui/Tab');
44
+ var Dropdown = require('@bigbinary/neetoui/Dropdown');
38
45
  require('@bigbinary/neeto-icons/Download');
39
- require('@bigbinary/neetoui/Modal');
40
46
  require('./exportChannel-BsZ3fusx.js');
41
47
  require('@bigbinary/neeto-molecules/CopyToClipboardButton');
42
48
 
49
+ function _interopNamespaceDefault(e) {
50
+ var n = Object.create(null);
51
+ if (e) {
52
+ Object.keys(e).forEach(function (k) {
53
+ if (k !== 'default') {
54
+ var d = Object.getOwnPropertyDescriptor(e, k);
55
+ Object.defineProperty(n, k, d.get ? d : {
56
+ enumerable: true,
57
+ get: function () { return e[k]; }
58
+ });
59
+ }
60
+ });
61
+ }
62
+ n.default = e;
63
+ return Object.freeze(n);
64
+ }
65
+
66
+ var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
67
+
43
68
  var list = function list(payload) {
44
69
  return axios.get("".concat(constants.BASE_URL, "/api/v1/split_transfers"), {
45
70
  params: payload
@@ -48,9 +73,15 @@ var list = function list(payload) {
48
73
  var show = function show(id) {
49
74
  return axios.get("".concat(constants.BASE_URL, "/api/v1/split_transfers/").concat(id));
50
75
  };
76
+ var bulkCancellation = function bulkCancellation(payload) {
77
+ return axios.post("".concat(constants.BASE_URL, "/api/v1/split_transfers/bulk_cancellation"), {
78
+ splitTransfer: payload
79
+ });
80
+ };
51
81
  var splitTransfersApi = {
52
82
  list: list,
53
- show: show
83
+ show: show,
84
+ bulkCancellation: bulkCancellation
54
85
  };
55
86
 
56
87
  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; }
@@ -73,6 +104,11 @@ var useShowSplitTransfers = function useShowSplitTransfers(id, options) {
73
104
  }
74
105
  }, options));
75
106
  };
107
+ var useBulkCancellationSplitTransfers = function useBulkCancellationSplitTransfers(options) {
108
+ return reactUtils.useMutationWithInvalidation(splitTransfersApi.bulkCancellation, _objectSpread$2({
109
+ keysToInvalidate: [queryConstants.QUERY_KEYS.SPLIT_TRANSFERS_LISTw]
110
+ }, options));
111
+ };
76
112
 
77
113
  var COLUMNS_STORAGE_KEY = "splitTransfersDashboard";
78
114
  var SPLIT_TRANSFERS_DASHBOARD_TAB = {
@@ -101,6 +137,65 @@ var INITIAL_TRANSFER_DETAILS = {
101
137
  id: null,
102
138
  isPaneOpen: false
103
139
  };
140
+ var VALIDATION_SCHEMA = yup__namespace.object().shape({
141
+ cancellationReason: yup__namespace.string().required(i18next.t("neetoPayments.cancelSplitTransfers.cancellationReasonRequired"))
142
+ });
143
+
144
+ var CancelModal = function CancelModal(_ref) {
145
+ var isOpen = _ref.isOpen,
146
+ onClose = _ref.onClose,
147
+ handleSplitTransfersCancellation = _ref.handleSplitTransfersCancellation;
148
+ var _useTranslation = reactI18next.useTranslation(),
149
+ t = _useTranslation.t;
150
+ var handleSubmit = function handleSubmit(_ref2) {
151
+ var cancellationReason = _ref2.cancellationReason;
152
+ handleSplitTransfersCancellation(cancellationReason);
153
+ };
154
+ return /*#__PURE__*/jsxRuntime.jsxs(Modal, {
155
+ isOpen: isOpen,
156
+ onClose: onClose,
157
+ size: "large",
158
+ children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
159
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
160
+ style: "h2",
161
+ weight: "medium",
162
+ children: t("neetoPayments.cancelSplitTransfers.modal.title")
163
+ })
164
+ }), /*#__PURE__*/jsxRuntime.jsx(Form, {
165
+ formikProps: {
166
+ initialValues: {
167
+ cancellationReason: ""
168
+ },
169
+ validationSchema: VALIDATION_SCHEMA,
170
+ onSubmit: handleSubmit
171
+ },
172
+ children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
173
+ children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
174
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
175
+ className: "flex flex-col space-y-4",
176
+ children: /*#__PURE__*/jsxRuntime.jsx(Textarea, {
177
+ required: true,
178
+ name: "cancellationReason",
179
+ label: t("neetoPayments.cancelSplitTransfers.modal.cancelReason")
180
+ })
181
+ })
182
+ }), /*#__PURE__*/jsxRuntime.jsx(Modal.Footer, {
183
+ children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
184
+ position: "right",
185
+ cancelButtonProps: {
186
+ onClick: onClose,
187
+ style: "tertiary"
188
+ },
189
+ submitButtonProps: {
190
+ disabled: false,
191
+ label: t("neetoPayments.common.submit")
192
+ }
193
+ })
194
+ })]
195
+ })
196
+ })]
197
+ });
198
+ };
104
199
 
105
200
  var Status = function Status(_ref) {
106
201
  var type = _ref.type,
@@ -564,11 +659,14 @@ var buildRowData = function buildRowData(_ref3) {
564
659
  var List = function List(_ref) {
565
660
  var isFetching = _ref.isFetching,
566
661
  splitTransfers = _ref.splitTransfers,
662
+ selectedRows = _ref.selectedRows,
567
663
  views = _ref.views,
568
664
  payableEntityColumns = _ref.payableEntityColumns,
569
- setSortProperties = _ref.setSortProperties,
570
665
  pageProperties = _ref.pageProperties,
571
- handleTablePagination = _ref.handleTablePagination;
666
+ onRowSelect = _ref.onRowSelect,
667
+ setSortProperties = _ref.setSortProperties,
668
+ handleTablePagination = _ref.handleTablePagination,
669
+ setHasBulkSelectedAllRows = _ref.setHasBulkSelectedAllRows;
572
670
  var _useState = React.useState(INITIAL_TRANSFER_DETAILS),
573
671
  _useState2 = _slicedToArray(_useState, 2),
574
672
  selectedTransfer = _useState2[0],
@@ -583,6 +681,19 @@ var List = function List(_ref) {
583
681
  _useHiddenColumns$hid = _useHiddenColumns.hiddenColumns,
584
682
  hiddenColumns = _useHiddenColumns$hid === void 0 ? [] : _useHiddenColumns$hid;
585
683
  var splitTransfersCount = views[tab];
684
+ var getRowSelection = function getRowSelection() {
685
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.pending) return true;
686
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all) {
687
+ return {
688
+ getCheckboxProps: function getCheckboxProps(record) {
689
+ return {
690
+ disabled: record.status !== SPLIT_TRANSFERS_DASHBOARD_TAB.pending
691
+ };
692
+ }
693
+ };
694
+ }
695
+ return false;
696
+ };
586
697
  var visibleColumns = buildTableColumns({
587
698
  tab: tab,
588
699
  hiddenColumns: hiddenColumns,
@@ -612,6 +723,7 @@ var List = function List(_ref) {
612
723
  children: [/*#__PURE__*/jsxRuntime.jsx(TableWrapper, {
613
724
  hasPagination: splitTransfersCount > (pageProperties === null || pageProperties === void 0 ? void 0 : pageProperties.pageSize),
614
725
  children: /*#__PURE__*/jsxRuntime.jsx(Table, {
726
+ onRowSelect: onRowSelect,
615
727
  fixedHeight: true,
616
728
  allowRowClick: false,
617
729
  columnData: visibleColumns,
@@ -623,9 +735,19 @@ var List = function List(_ref) {
623
735
  pageProperties: pageProperties,
624
736
  tab: tab
625
737
  }),
626
- rowSelection: false,
738
+ rowSelection: getRowSelection(),
739
+ selectedRowKeys: selectedRows,
627
740
  sortDirections: constants.SORT_DIRECTIONS,
628
741
  totalCount: splitTransfersCount,
742
+ bulkSelectAllRowsProps: {
743
+ selectAllRowMessage: t("neetoPayments.splitTransferDetails.selectedSplitTransfers", {
744
+ count: selectedRows.length
745
+ }),
746
+ selectAllRowButtonLabel: t("neetoPayments.splitTransferDetails.selectAll", {
747
+ count: views[SPLIT_TRANSFERS_DASHBOARD_TAB.pending]
748
+ }),
749
+ setBulkSelectedAllRows: setHasBulkSelectedAllRows
750
+ },
629
751
  paginationProps: {
630
752
  showSizeChanger: true,
631
753
  hideOnSinglePage: true,
@@ -642,10 +764,15 @@ var List = function List(_ref) {
642
764
  });
643
765
  };
644
766
 
767
+ var Menu = Dropdown.Menu,
768
+ MenuItem = Dropdown.MenuItem;
645
769
  var TopSection = function TopSection(_ref) {
646
770
  var views = _ref.views,
647
771
  filters = _ref.filters,
772
+ setIsCancelModalOpen = _ref.setIsCancelModalOpen,
773
+ selectedRows = _ref.selectedRows,
648
774
  setFilters = _ref.setFilters,
775
+ hasBulkSelectedAllRows = _ref.hasBulkSelectedAllRows,
649
776
  filterableColumns = _ref.filterableColumns,
650
777
  searchKeywordProps = _ref.searchKeywordProps,
651
778
  payableEntityColumns = _ref.payableEntityColumns,
@@ -663,6 +790,8 @@ var TopSection = function TopSection(_ref) {
663
790
  var splitTransfersCount = views[tab];
664
791
  var splitTransfersCountVisible = splitTransfersCount > 0;
665
792
  var isFilterButtonVisible = splitTransfersCount || neetoCist.isPresent(filters);
793
+ var isDropdownVisible = neetoCist.isNotEmpty(selectedRows);
794
+ var selectedRecordsCount = hasBulkSelectedAllRows ? splitTransfersCount : selectedRows.length;
666
795
  var handleFiltersChange = function handleFiltersChange(filters) {
667
796
  React.startTransition(function () {
668
797
  setFilters(filters);
@@ -698,14 +827,46 @@ var TopSection = function TopSection(_ref) {
698
827
  })
699
828
  }), /*#__PURE__*/jsxRuntime.jsx(SubHeader, {
700
829
  className: "mt-4",
701
- leftActionBlock: splitTransfersCountVisible && /*#__PURE__*/jsxRuntime.jsx(Typography, {
702
- className: "neeto-ui-gray-800 mr-2 font-semibold",
703
- component: "h4",
704
- children: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.countOf.splitTransfer", {
705
- count: splitTransfersCount
706
- }) : t("neetoPayments.countOf.splitTransferWithStatus", {
707
- count: splitTransfersCount,
708
- status: tab
830
+ leftActionBlock: splitTransfersCountVisible && /*#__PURE__*/jsxRuntime.jsx("div", {
831
+ className: "w-100 flex items-center space-x-3",
832
+ children: isDropdownVisible ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
833
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
834
+ className: "neeto-ui-gray-800 mr-2 font-semibold",
835
+ component: "h4",
836
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
837
+ count: selectedRecordsCount,
838
+ i18nKey: "neetoPayments.splitTransferDetails.recordWithCount",
839
+ components: {
840
+ span: /*#__PURE__*/jsxRuntime.jsx("span", {
841
+ className: "neeto-ui-text-gray-600"
842
+ })
843
+ },
844
+ values: {
845
+ count: selectedRecordsCount,
846
+ recordsCount: splitTransfersCount
847
+ }
848
+ })
849
+ }), /*#__PURE__*/jsxRuntime.jsx(Dropdown, {
850
+ buttonStyle: "secondary",
851
+ label: t("neetoPayments.common.takeAction"),
852
+ children: /*#__PURE__*/jsxRuntime.jsx(Menu, {
853
+ children: /*#__PURE__*/jsxRuntime.jsx(MenuItem.Button, {
854
+ onClick: function onClick() {
855
+ return setIsCancelModalOpen(true);
856
+ },
857
+ children: t("neetoPayments.common.cancel")
858
+ })
859
+ })
860
+ })]
861
+ }) : /*#__PURE__*/jsxRuntime.jsx(Typography, {
862
+ className: "neeto-ui-gray-800 mr-2 font-semibold",
863
+ component: "h4",
864
+ children: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.countOf.splitTransfer", {
865
+ count: splitTransfersCount
866
+ }) : t("neetoPayments.countOf.splitTransferWithStatus", {
867
+ count: splitTransfersCount,
868
+ status: tab
869
+ })
709
870
  })
710
871
  }),
711
872
  rightActionBlock: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -748,22 +909,38 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
748
909
  searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
749
910
  var filterableColumns = buildFilterColumns(payableEntityColumns);
750
911
  var searchKeywordProps = buildSearchProps(searchProps, searchTerm);
751
- var _useState = React.useState(constants.DEFAULT_SORT_PROPERTIES),
912
+ var _useState = React.useState([]),
752
913
  _useState2 = _slicedToArray(_useState, 2),
753
- sortProperties = _useState2[0],
754
- setSortProperties = _useState2[1];
755
- var _useState3 = React.useState(constants.DEFAULT_PAGE_VALUES),
914
+ selectedRows = _useState2[0],
915
+ setSelectedRows = _useState2[1];
916
+ var _useState3 = React.useState([]),
756
917
  _useState4 = _slicedToArray(_useState3, 2),
757
- pageProperties = _useState4[0],
758
- setPageProperties = _useState4[1];
918
+ selectedRowData = _useState4[0],
919
+ setSelectedRowData = _useState4[1];
759
920
  var _useState5 = React.useState(false),
760
921
  _useState6 = _slicedToArray(_useState5, 2),
761
922
  isExportModalOpen = _useState6[0],
762
923
  setIsExportModalOpen = _useState6[1];
763
- var _useState7 = React.useState(utils$1.buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
924
+ var _useState7 = React.useState(false),
764
925
  _useState8 = _slicedToArray(_useState7, 2),
765
- filters = _useState8[0],
766
- setFilters = _useState8[1];
926
+ isCancelModalOpen = _useState8[0],
927
+ setIsCancelModalOpen = _useState8[1];
928
+ var _useState9 = React.useState(false),
929
+ _useState10 = _slicedToArray(_useState9, 2),
930
+ hasBulkSelectedAllRows = _useState10[0],
931
+ setHasBulkSelectedAllRows = _useState10[1];
932
+ var _useState11 = React.useState(constants.DEFAULT_SORT_PROPERTIES),
933
+ _useState12 = _slicedToArray(_useState11, 2),
934
+ sortProperties = _useState12[0],
935
+ setSortProperties = _useState12[1];
936
+ var _useState13 = React.useState(constants.DEFAULT_PAGE_VALUES),
937
+ _useState14 = _slicedToArray(_useState13, 2),
938
+ pageProperties = _useState14[0],
939
+ setPageProperties = _useState14[1];
940
+ var _useState15 = React.useState(utils$1.buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
941
+ _useState16 = _slicedToArray(_useState15, 2),
942
+ filters = _useState16[0],
943
+ setFilters = _useState16[1];
767
944
  var history = reactRouterDom.useHistory();
768
945
  var _getQueryParams2 = utils.getQueryParams(),
769
946
  _getQueryParams2$tab = _getQueryParams2.tab,
@@ -779,6 +956,23 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
779
956
  views = _useFetchSplitTransfe3.views,
780
957
  isFetching = _useFetchSplitTransfe.isFetching,
781
958
  isSplitTransfersLoading = _useFetchSplitTransfe.isPending;
959
+ var _useBulkCancellationS = useBulkCancellationSplitTransfers({
960
+ onSuccess: function onSuccess() {
961
+ setSelectedRowData([]);
962
+ setSelectedRows([]);
963
+ }
964
+ }),
965
+ cancelSplitTransfers = _useBulkCancellationS.mutate,
966
+ isCancelling = _useBulkCancellationS.isPending;
967
+ var handleSplitTransfersCancellation = function handleSplitTransfersCancellation(cancellationReason) {
968
+ var ids = ramda.pluck("id", selectedRowData);
969
+ cancelSplitTransfers({
970
+ ids: ids,
971
+ cancellationReason: cancellationReason,
972
+ isApplyChangesToAllRequired: hasBulkSelectedAllRows
973
+ });
974
+ setIsCancelModalOpen(false);
975
+ };
782
976
  var handleTablePagination = function handleTablePagination(page, pageSize) {
783
977
  var queryParams = utils.getQueryParams({
784
978
  toCamelCase: false
@@ -792,11 +986,15 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
792
986
  pageSize: pageSize
793
987
  });
794
988
  };
989
+ var handleRowSelect = function handleRowSelect(keys, rowData) {
990
+ setSelectedRows(keys);
991
+ setSelectedRowData(rowData);
992
+ };
795
993
  React.useEffect(function () {
796
994
  handleTablePagination(constants$1.DEFAULT_PAGE_INDEX, constants$1.DEFAULT_PAGE_SIZE);
797
995
  setSortProperties(constants.DEFAULT_SORT_PROPERTIES);
798
996
  }, [filters, tab]);
799
- if (isSplitTransfersLoading) {
997
+ if (isSplitTransfersLoading || isCancelling) {
800
998
  return /*#__PURE__*/jsxRuntime.jsx("div", {
801
999
  className: "flex h-full w-full items-center justify-center",
802
1000
  children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
@@ -806,10 +1004,13 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
806
1004
  children: [/*#__PURE__*/jsxRuntime.jsx(TopSection, {
807
1005
  filterableColumns: filterableColumns,
808
1006
  filters: filters,
1007
+ hasBulkSelectedAllRows: hasBulkSelectedAllRows,
809
1008
  pageProperties: pageProperties,
810
1009
  payableEntityColumns: payableEntityColumns,
811
1010
  searchKeywordProps: searchKeywordProps,
1011
+ selectedRows: selectedRows,
812
1012
  setFilters: setFilters,
1013
+ setIsCancelModalOpen: setIsCancelModalOpen,
813
1014
  setIsExportModalOpen: setIsExportModalOpen,
814
1015
  setPageProperties: setPageProperties,
815
1016
  setSortProperties: setSortProperties,
@@ -819,15 +1020,25 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
819
1020
  isFetching: isFetching,
820
1021
  pageProperties: pageProperties,
821
1022
  payableEntityColumns: payableEntityColumns,
1023
+ selectedRows: selectedRows,
1024
+ setHasBulkSelectedAllRows: setHasBulkSelectedAllRows,
1025
+ setSelectedRows: setSelectedRows,
822
1026
  setSortProperties: setSortProperties,
823
1027
  splitTransfers: splitTransfers,
824
- views: views
1028
+ views: views,
1029
+ onRowSelect: handleRowSelect
825
1030
  }), /*#__PURE__*/jsxRuntime.jsx(ExportModal.ExportModal, {
826
1031
  filters: filters,
827
1032
  isExportModalOpen: isExportModalOpen,
828
1033
  setIsExportModalOpen: setIsExportModalOpen,
829
1034
  sortProperties: sortProperties,
830
1035
  dashboardKind: constants.DASHBOARD_KIND.splitTransfers
1036
+ }), /*#__PURE__*/jsxRuntime.jsx(CancelModal, {
1037
+ handleSplitTransfersCancellation: handleSplitTransfersCancellation,
1038
+ isOpen: isCancelModalOpen,
1039
+ onClose: function onClose() {
1040
+ return setIsCancelModalOpen(false);
1041
+ }
831
1042
  })]
832
1043
  });
833
1044
  };