@bigbinary/neeto-payments-frontend 3.0.23 → 3.0.24

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.
@@ -40,6 +40,7 @@
40
40
  "paymentAmount": "Payment amount",
41
41
  "transferredAmount": "Transferred amount",
42
42
  "search": "Search",
43
+ "takeAction": "Take action",
43
44
  "createdAt": "Created at",
44
45
  "country": "Country",
45
46
  "email": "Email",
@@ -411,7 +412,11 @@
411
412
  "netAmountHelpTitle": "What is the net amount?",
412
413
  "platformShareHelpTitle": "What is the platform share?",
413
414
  "netAmountDescription": "The net amount is the final payment you receive after deducting the payment provider's fees.",
414
- "platformShareDescription": "The platform share is the amount that will be deposited into your bank account after subtracting all service provider shares. (net amount - transferred amount)"
415
+ "platformShareDescription": "The platform share is the amount that will be deposited into your bank account after subtracting all service provider shares. (net amount - transferred amount)",
416
+ "selectAll": "Select all {{count}} pending split transfers",
417
+ "selectedSplitTransfers": "All {{selectedCount}} pending split transfers on this page are selected",
418
+ "recordWithCount_one": "{{count}} split transfer selected of <span>{{recordsCount}}</span>",
419
+ "recordWithCount_other": "{{count}} split transfers selected of <span>{{recordsCount}}</span>"
415
420
  }
416
421
  }
417
422
  }
@@ -6,20 +6,21 @@ import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-
6
6
  import { currencyFormat, getQueryParams, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
7
7
  import { buildFiltersFromURL } from '@bigbinary/neeto-filters-frontend/utils';
8
8
  import Spinner from '@bigbinary/neetoui/Spinner';
9
- import { mergeLeft, curry, mergeDeepWith, concat, reject, isNil, map, prop, sortBy, isEmpty, modify } from 'ramda';
9
+ import { mergeLeft, curry, mergeDeepWith, concat, reject, isNil, map, prop, sortBy, isEmpty, modify, pluck } from 'ramda';
10
10
  import { useHistory } from 'react-router-dom';
11
11
  import { E as ExportModal } from './ExportModal-C6-IwFlZ.js';
12
12
  import { useQuery } from '@tanstack/react-query';
13
+ import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
13
14
  import axios from 'axios';
14
15
  import { B as BASE_URL, k as preProcessStatus, l as getTagStyle, f as formatAmount, d as formatCurrency, m as PAYMENT_KIND, p as processDataIndex, S as SORT_DIRECTIONS, D as DEFAULT_SORT_PROPERTIES, s as shouldTabsVisible, U as UN_HIDEABLE_COLUMNS, h as DEFAULT_PAGE_VALUES, i as DASHBOARD_KIND } from './index-lD18ClWH.js';
15
16
  import { Q as QUERY_KEYS } from './queryConstants-BCx5cEmf.js';
16
17
  import { t } from 'i18next';
17
- import { isNotPresent, isPresent, removeBy, camelToSnakeCase } from '@bigbinary/neeto-cist';
18
+ import { isNotPresent, isPresent, removeBy, camelToSnakeCase, isNotEmpty } from '@bigbinary/neeto-cist';
18
19
  import { useHiddenColumns } from '@bigbinary/neeto-molecules/Columns';
19
20
  import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
20
21
  import Table from '@bigbinary/neetoui/Table';
21
22
  import NoData from '@bigbinary/neetoui/NoData';
22
- import { useTranslation } from 'react-i18next';
23
+ import { useTranslation, Trans } from 'react-i18next';
23
24
  import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
24
25
  import Pane from '@bigbinary/neetoui/Pane';
25
26
  import Typography from '@bigbinary/neetoui/Typography';
@@ -33,6 +34,7 @@ import FiltersBar from '@bigbinary/neeto-filters-frontend/Bar';
33
34
  import Header from '@bigbinary/neeto-molecules/Header';
34
35
  import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
35
36
  import Tab from '@bigbinary/neetoui/Tab';
37
+ import Dropdown from '@bigbinary/neetoui/Dropdown';
36
38
  import '@bigbinary/neeto-icons/Download';
37
39
  import '@bigbinary/neetoui/Modal';
38
40
  import './exportChannel-CViICC6x.js';
@@ -46,9 +48,15 @@ var list = function list(payload) {
46
48
  var show = function show(id) {
47
49
  return axios.get("".concat(BASE_URL, "/api/v1/split_transfers/").concat(id));
48
50
  };
51
+ var bulkCancellation = function bulkCancellation(payload) {
52
+ return axios.post("".concat(BASE_URL, "/api/v1/split_transfers/bulk_cancellation"), {
53
+ splitTransfer: payload
54
+ });
55
+ };
49
56
  var splitTransfersApi = {
50
57
  list: list,
51
- show: show
58
+ show: show,
59
+ bulkCancellation: bulkCancellation
52
60
  };
53
61
 
54
62
  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; }
@@ -71,6 +79,11 @@ var useShowSplitTransfers = function useShowSplitTransfers(id, options) {
71
79
  }
72
80
  }, options));
73
81
  };
82
+ var useBulkCancellationSplitTransfers = function useBulkCancellationSplitTransfers(options) {
83
+ return useMutationWithInvalidation(splitTransfersApi.bulkCancellation, _objectSpread$2({
84
+ keysToInvalidate: [QUERY_KEYS.SPLIT_TRANSFERS_LISTw]
85
+ }, options));
86
+ };
74
87
 
75
88
  var COLUMNS_STORAGE_KEY = "splitTransfersDashboard";
76
89
  var SPLIT_TRANSFERS_DASHBOARD_TAB = {
@@ -562,11 +575,14 @@ var buildRowData = function buildRowData(_ref3) {
562
575
  var List = function List(_ref) {
563
576
  var isFetching = _ref.isFetching,
564
577
  splitTransfers = _ref.splitTransfers,
578
+ selectedRows = _ref.selectedRows,
565
579
  views = _ref.views,
566
580
  payableEntityColumns = _ref.payableEntityColumns,
567
- setSortProperties = _ref.setSortProperties,
568
581
  pageProperties = _ref.pageProperties,
569
- handleTablePagination = _ref.handleTablePagination;
582
+ onRowSelect = _ref.onRowSelect,
583
+ setSortProperties = _ref.setSortProperties,
584
+ handleTablePagination = _ref.handleTablePagination,
585
+ setHasBulkSelectedAllRows = _ref.setHasBulkSelectedAllRows;
570
586
  var _useState = useState(INITIAL_TRANSFER_DETAILS),
571
587
  _useState2 = _slicedToArray(_useState, 2),
572
588
  selectedTransfer = _useState2[0],
@@ -581,6 +597,19 @@ var List = function List(_ref) {
581
597
  _useHiddenColumns$hid = _useHiddenColumns.hiddenColumns,
582
598
  hiddenColumns = _useHiddenColumns$hid === void 0 ? [] : _useHiddenColumns$hid;
583
599
  var splitTransfersCount = views[tab];
600
+ var getRowSelection = function getRowSelection() {
601
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.pending) return true;
602
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all) {
603
+ return {
604
+ getCheckboxProps: function getCheckboxProps(record) {
605
+ return {
606
+ disabled: record.status !== SPLIT_TRANSFERS_DASHBOARD_TAB.pending
607
+ };
608
+ }
609
+ };
610
+ }
611
+ return false;
612
+ };
584
613
  var visibleColumns = buildTableColumns({
585
614
  tab: tab,
586
615
  hiddenColumns: hiddenColumns,
@@ -610,6 +639,7 @@ var List = function List(_ref) {
610
639
  children: [/*#__PURE__*/jsx(TableWrapper, {
611
640
  hasPagination: splitTransfersCount > (pageProperties === null || pageProperties === void 0 ? void 0 : pageProperties.pageSize),
612
641
  children: /*#__PURE__*/jsx(Table, {
642
+ onRowSelect: onRowSelect,
613
643
  fixedHeight: true,
614
644
  allowRowClick: false,
615
645
  columnData: visibleColumns,
@@ -621,9 +651,19 @@ var List = function List(_ref) {
621
651
  pageProperties: pageProperties,
622
652
  tab: tab
623
653
  }),
624
- rowSelection: false,
654
+ rowSelection: getRowSelection(),
655
+ selectedRowKeys: selectedRows,
625
656
  sortDirections: SORT_DIRECTIONS,
626
657
  totalCount: splitTransfersCount,
658
+ bulkSelectAllRowsProps: {
659
+ selectAllRowMessage: t("neetoPayments.splitTransferDetails.selectedSplitTransfers", {
660
+ count: selectedRows.length
661
+ }),
662
+ selectAllRowButtonLabel: t("neetoPayments.splitTransferDetails.selectAll", {
663
+ count: views[SPLIT_TRANSFERS_DASHBOARD_TAB.pending]
664
+ }),
665
+ setBulkSelectedAllRows: setHasBulkSelectedAllRows
666
+ },
627
667
  paginationProps: {
628
668
  showSizeChanger: true,
629
669
  hideOnSinglePage: true,
@@ -640,10 +680,15 @@ var List = function List(_ref) {
640
680
  });
641
681
  };
642
682
 
683
+ var Menu = Dropdown.Menu,
684
+ MenuItem = Dropdown.MenuItem;
643
685
  var TopSection = function TopSection(_ref) {
644
686
  var views = _ref.views,
645
687
  filters = _ref.filters,
688
+ handleSplitTransfersCancellation = _ref.handleSplitTransfersCancellation,
689
+ selectedRows = _ref.selectedRows,
646
690
  setFilters = _ref.setFilters,
691
+ hasBulkSelectedAllRows = _ref.hasBulkSelectedAllRows,
647
692
  filterableColumns = _ref.filterableColumns,
648
693
  searchKeywordProps = _ref.searchKeywordProps,
649
694
  payableEntityColumns = _ref.payableEntityColumns,
@@ -661,6 +706,8 @@ var TopSection = function TopSection(_ref) {
661
706
  var splitTransfersCount = views[tab];
662
707
  var splitTransfersCountVisible = splitTransfersCount > 0;
663
708
  var isFilterButtonVisible = splitTransfersCount || isPresent(filters);
709
+ var isDropdownVisible = isNotEmpty(selectedRows);
710
+ var selectedRecordsCount = hasBulkSelectedAllRows ? splitTransfersCount : selectedRows.length;
664
711
  var handleFiltersChange = function handleFiltersChange(filters) {
665
712
  startTransition(function () {
666
713
  setFilters(filters);
@@ -696,14 +743,44 @@ var TopSection = function TopSection(_ref) {
696
743
  })
697
744
  }), /*#__PURE__*/jsx(SubHeader, {
698
745
  className: "mt-4",
699
- leftActionBlock: splitTransfersCountVisible && /*#__PURE__*/jsx(Typography, {
700
- className: "neeto-ui-gray-800 mr-2 font-semibold",
701
- component: "h4",
702
- children: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.countOf.splitTransfer", {
703
- count: splitTransfersCount
704
- }) : t("neetoPayments.countOf.splitTransferWithStatus", {
705
- count: splitTransfersCount,
706
- status: tab
746
+ leftActionBlock: splitTransfersCountVisible && /*#__PURE__*/jsx("div", {
747
+ className: "w-100 flex items-center space-x-3",
748
+ children: isDropdownVisible ? /*#__PURE__*/jsxs(Fragment, {
749
+ children: [/*#__PURE__*/jsx(Typography, {
750
+ className: "neeto-ui-gray-800 mr-2 font-semibold",
751
+ component: "h4",
752
+ children: /*#__PURE__*/jsx(Trans, {
753
+ count: selectedRecordsCount,
754
+ i18nKey: "neetoPayments.splitTransferDetails.recordWithCount",
755
+ components: {
756
+ span: /*#__PURE__*/jsx("span", {
757
+ className: "neeto-ui-text-gray-600"
758
+ })
759
+ },
760
+ values: {
761
+ count: selectedRecordsCount,
762
+ recordsCount: splitTransfersCount
763
+ }
764
+ })
765
+ }), /*#__PURE__*/jsx(Dropdown, {
766
+ buttonStyle: "secondary",
767
+ label: t("neetoPayments.common.takeAction"),
768
+ children: /*#__PURE__*/jsx(Menu, {
769
+ children: /*#__PURE__*/jsx(MenuItem.Button, {
770
+ onClick: handleSplitTransfersCancellation,
771
+ children: t("neetoPayments.common.cancel")
772
+ })
773
+ })
774
+ })]
775
+ }) : /*#__PURE__*/jsx(Typography, {
776
+ className: "neeto-ui-gray-800 mr-2 font-semibold",
777
+ component: "h4",
778
+ children: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.countOf.splitTransfer", {
779
+ count: splitTransfersCount
780
+ }) : t("neetoPayments.countOf.splitTransferWithStatus", {
781
+ count: splitTransfersCount,
782
+ status: tab
783
+ })
707
784
  })
708
785
  }),
709
786
  rightActionBlock: /*#__PURE__*/jsxs(Fragment, {
@@ -746,22 +823,34 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
746
823
  searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
747
824
  var filterableColumns = buildFilterColumns(payableEntityColumns);
748
825
  var searchKeywordProps = buildSearchProps(searchProps, searchTerm);
749
- var _useState = useState(DEFAULT_SORT_PROPERTIES),
826
+ var _useState = useState([]),
750
827
  _useState2 = _slicedToArray(_useState, 2),
751
- sortProperties = _useState2[0],
752
- setSortProperties = _useState2[1];
753
- var _useState3 = useState(DEFAULT_PAGE_VALUES),
828
+ selectedRows = _useState2[0],
829
+ setSelectedRows = _useState2[1];
830
+ var _useState3 = useState([]),
754
831
  _useState4 = _slicedToArray(_useState3, 2),
755
- pageProperties = _useState4[0],
756
- setPageProperties = _useState4[1];
832
+ selectedRowData = _useState4[0],
833
+ setSelectedRowData = _useState4[1];
757
834
  var _useState5 = useState(false),
758
835
  _useState6 = _slicedToArray(_useState5, 2),
759
836
  isExportModalOpen = _useState6[0],
760
837
  setIsExportModalOpen = _useState6[1];
761
- var _useState7 = useState(buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
838
+ var _useState7 = useState(false),
762
839
  _useState8 = _slicedToArray(_useState7, 2),
763
- filters = _useState8[0],
764
- setFilters = _useState8[1];
840
+ hasBulkSelectedAllRows = _useState8[0],
841
+ setHasBulkSelectedAllRows = _useState8[1];
842
+ var _useState9 = useState(DEFAULT_SORT_PROPERTIES),
843
+ _useState10 = _slicedToArray(_useState9, 2),
844
+ sortProperties = _useState10[0],
845
+ setSortProperties = _useState10[1];
846
+ var _useState11 = useState(DEFAULT_PAGE_VALUES),
847
+ _useState12 = _slicedToArray(_useState11, 2),
848
+ pageProperties = _useState12[0],
849
+ setPageProperties = _useState12[1];
850
+ var _useState13 = useState(buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
851
+ _useState14 = _slicedToArray(_useState13, 2),
852
+ filters = _useState14[0],
853
+ setFilters = _useState14[1];
765
854
  var history = useHistory();
766
855
  var _getQueryParams2 = getQueryParams(),
767
856
  _getQueryParams2$tab = _getQueryParams2.tab,
@@ -777,6 +866,21 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
777
866
  views = _useFetchSplitTransfe3.views,
778
867
  isFetching = _useFetchSplitTransfe.isFetching,
779
868
  isSplitTransfersLoading = _useFetchSplitTransfe.isPending;
869
+ var _useBulkCancellationS = useBulkCancellationSplitTransfers({
870
+ onSuccess: function onSuccess() {
871
+ setSelectedRowData([]);
872
+ setSelectedRows([]);
873
+ }
874
+ }),
875
+ cancelSplitTransfers = _useBulkCancellationS.mutate,
876
+ isCancelling = _useBulkCancellationS.isPending;
877
+ var handleSplitTransfersCancellation = function handleSplitTransfersCancellation() {
878
+ var ids = pluck("id", selectedRowData);
879
+ cancelSplitTransfers({
880
+ ids: ids,
881
+ isApplyChangesToAllRequired: hasBulkSelectedAllRows
882
+ });
883
+ };
780
884
  var handleTablePagination = function handleTablePagination(page, pageSize) {
781
885
  var queryParams = getQueryParams({
782
886
  toCamelCase: false
@@ -790,11 +894,15 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
790
894
  pageSize: pageSize
791
895
  });
792
896
  };
897
+ var handleRowSelect = function handleRowSelect(keys, rowData) {
898
+ setSelectedRows(keys);
899
+ setSelectedRowData(rowData);
900
+ };
793
901
  useEffect(function () {
794
902
  handleTablePagination(DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE);
795
903
  setSortProperties(DEFAULT_SORT_PROPERTIES);
796
904
  }, [filters, tab]);
797
- if (isSplitTransfersLoading) {
905
+ if (isSplitTransfersLoading || isCancelling) {
798
906
  return /*#__PURE__*/jsx("div", {
799
907
  className: "flex h-full w-full items-center justify-center",
800
908
  children: /*#__PURE__*/jsx(Spinner, {})
@@ -804,9 +912,12 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
804
912
  children: [/*#__PURE__*/jsx(TopSection, {
805
913
  filterableColumns: filterableColumns,
806
914
  filters: filters,
915
+ handleSplitTransfersCancellation: handleSplitTransfersCancellation,
916
+ hasBulkSelectedAllRows: hasBulkSelectedAllRows,
807
917
  pageProperties: pageProperties,
808
918
  payableEntityColumns: payableEntityColumns,
809
919
  searchKeywordProps: searchKeywordProps,
920
+ selectedRows: selectedRows,
810
921
  setFilters: setFilters,
811
922
  setIsExportModalOpen: setIsExportModalOpen,
812
923
  setPageProperties: setPageProperties,
@@ -817,9 +928,13 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
817
928
  isFetching: isFetching,
818
929
  pageProperties: pageProperties,
819
930
  payableEntityColumns: payableEntityColumns,
931
+ selectedRows: selectedRows,
932
+ setHasBulkSelectedAllRows: setHasBulkSelectedAllRows,
933
+ setSelectedRows: setSelectedRows,
820
934
  setSortProperties: setSortProperties,
821
935
  splitTransfers: splitTransfers,
822
- views: views
936
+ views: views,
937
+ onRowSelect: handleRowSelect
823
938
  }), /*#__PURE__*/jsx(ExportModal, {
824
939
  filters: filters,
825
940
  isExportModalOpen: isExportModalOpen,