@bigbinary/neeto-payments-frontend 3.2.1 → 3.2.3

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.
@@ -74,7 +74,8 @@
74
74
  "payoutStatus": "Payout status",
75
75
  "searchByIdentifier": "Search by identifier",
76
76
  "submit": "Submit",
77
- "edit": "Edit"
77
+ "edit": "Edit",
78
+ "resume": "Resume"
78
79
  },
79
80
  "alert": {
80
81
  "stripe": {
@@ -236,7 +237,9 @@
236
237
  "splitTransfers": {
237
238
  "successful": "Successful split",
238
239
  "pending": "Pending split",
239
- "cancelled": "The split transaction is cancelled"
240
+ "cancelled": "The split transaction is cancelled",
241
+ "cancelledRecordsSelected": "You have selected cancelled split transfers.",
242
+ "pendingRecordsSelected": "You have selected pending split transfers."
240
243
  },
241
244
  "payment": {
242
245
  "completed": "The payment is complete",
@@ -398,7 +401,7 @@
398
401
  },
399
402
  "payment": {
400
403
  "transaction": {
401
- "label": "Enter the first 6 digits of your transaction ID",
404
+ "label": "Enter the first 6 digits of your UPI transaction ID",
402
405
  "placeholder": "123456",
403
406
  "required": "Transaction ID is required",
404
407
  "sixCharacters": "Transaction ID should have 6 characters"
@@ -429,11 +432,18 @@
429
432
  "recordWithCount_other": "{{count}} split transfers selected of <span>{{recordsCount}}</span>"
430
433
  },
431
434
  "cancelSplitTransfers": {
432
- "cancellationReasonRequired": "Cancellation reason is required",
435
+ "reasonRequired": "Reason is required",
433
436
  "modal": {
434
437
  "title": "Cancel split transfers?",
435
438
  "message": "You are about to cancel pending split transfers. This can't be undone.",
436
- "cancelReason": "Reason for cancellation"
439
+ "reason": "Reason for cancellation"
440
+ }
441
+ },
442
+ "resumeSplitTransfers": {
443
+ "modal": {
444
+ "title": "Resume split transfers?",
445
+ "message": "You are about to resume cancelled split transfers. This can't be undone.",
446
+ "reason": "Reason for resumption"
437
447
  }
438
448
  },
439
449
  "taxesDashboard": {
@@ -23,7 +23,7 @@ import { useTranslation, Trans } from 'react-i18next';
23
23
  import { t } from 'i18next';
24
24
  import * as yup from 'yup';
25
25
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
26
- import { isNotPresent, isPresent, removeBy, camelToSnakeCase, isNotEmpty } from '@bigbinary/neeto-cist';
26
+ import { isNotPresent, isPresent, removeBy, camelToSnakeCase, isNotEmpty, existsBy } from '@bigbinary/neeto-cist';
27
27
  import { useHiddenColumns } from '@bigbinary/neeto-molecules/Columns';
28
28
  import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
29
29
  import Table from '@bigbinary/neetoui/Table';
@@ -52,15 +52,15 @@ var list = function list(payload) {
52
52
  var show = function show(id) {
53
53
  return axios.get("".concat(BASE_URL, "/api/v1/split_transfers/").concat(id));
54
54
  };
55
- var bulkCancellation = function bulkCancellation(payload) {
56
- return axios.post("".concat(BASE_URL, "/api/v1/split_transfers/bulk_cancellation"), {
55
+ var bulkUpdate = function bulkUpdate(payload) {
56
+ return axios.post("".concat(BASE_URL, "/api/v1/split_transfers/bulk_update"), {
57
57
  splitTransfer: payload
58
58
  });
59
59
  };
60
60
  var splitTransfersApi = {
61
61
  list: list,
62
62
  show: show,
63
- bulkCancellation: bulkCancellation
63
+ bulkUpdate: bulkUpdate
64
64
  };
65
65
 
66
66
  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; }
@@ -83,8 +83,8 @@ var useShowSplitTransfers = function useShowSplitTransfers(id, options) {
83
83
  }
84
84
  }, options));
85
85
  };
86
- var useBulkCancellationSplitTransfers = function useBulkCancellationSplitTransfers(options) {
87
- return useMutationWithInvalidation(splitTransfersApi.bulkCancellation, _objectSpread$2({
86
+ var useBulkUpdateSplitTransfers = function useBulkUpdateSplitTransfers(options) {
87
+ return useMutationWithInvalidation(splitTransfersApi.bulkUpdate, _objectSpread$2({
88
88
  keysToInvalidate: [QUERY_KEYS.SPLIT_TRANSFERS_LISTw]
89
89
  }, options));
90
90
  };
@@ -117,18 +117,18 @@ var INITIAL_TRANSFER_DETAILS = {
117
117
  isPaneOpen: false
118
118
  };
119
119
  var VALIDATION_SCHEMA = yup.object().shape({
120
- cancellationReason: yup.string().required(t("neetoPayments.cancelSplitTransfers.cancellationReasonRequired"))
120
+ reason: yup.string().required(t("neetoPayments.cancelSplitTransfers.reasonRequired"))
121
121
  });
122
122
 
123
123
  var CancelModal = function CancelModal(_ref) {
124
124
  var isOpen = _ref.isOpen,
125
125
  onClose = _ref.onClose,
126
- handleSplitTransfersCancellation = _ref.handleSplitTransfersCancellation;
126
+ handleSplitTransfersUpdate = _ref.handleSplitTransfersUpdate;
127
127
  var _useTranslation = useTranslation(),
128
128
  t = _useTranslation.t;
129
129
  var handleSubmit = function handleSubmit(_ref2) {
130
- var cancellationReason = _ref2.cancellationReason;
131
- handleSplitTransfersCancellation(cancellationReason);
130
+ var reason = _ref2.reason;
131
+ handleSplitTransfersUpdate("cancelled", reason);
132
132
  };
133
133
  return /*#__PURE__*/jsxs(Modal, {
134
134
  isOpen: isOpen,
@@ -143,7 +143,7 @@ var CancelModal = function CancelModal(_ref) {
143
143
  }), /*#__PURE__*/jsx(Form, {
144
144
  formikProps: {
145
145
  initialValues: {
146
- cancellationReason: ""
146
+ reason: ""
147
147
  },
148
148
  validationSchema: VALIDATION_SCHEMA,
149
149
  onSubmit: handleSubmit
@@ -154,8 +154,8 @@ var CancelModal = function CancelModal(_ref) {
154
154
  className: "flex flex-col space-y-4",
155
155
  children: /*#__PURE__*/jsx(Textarea, {
156
156
  required: true,
157
- name: "cancellationReason",
158
- label: t("neetoPayments.cancelSplitTransfers.modal.cancelReason")
157
+ label: t("neetoPayments.cancelSplitTransfers.modal.reason"),
158
+ name: "reason"
159
159
  })
160
160
  })
161
161
  }), /*#__PURE__*/jsx(Modal.Footer, {
@@ -661,17 +661,17 @@ var List = function List(_ref) {
661
661
  hiddenColumns = _useHiddenColumns$hid === void 0 ? [] : _useHiddenColumns$hid;
662
662
  var splitTransfersCount = views[tab];
663
663
  var getRowSelection = function getRowSelection() {
664
- if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.pending) return true;
664
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.successful) return false;
665
665
  if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all) {
666
666
  return {
667
667
  getCheckboxProps: function getCheckboxProps(record) {
668
668
  return {
669
- disabled: record.status !== SPLIT_TRANSFERS_DASHBOARD_TAB.pending
669
+ disabled: record.status === SPLIT_TRANSFERS_DASHBOARD_TAB.successful
670
670
  };
671
671
  }
672
672
  };
673
673
  }
674
- return false;
674
+ return true;
675
675
  };
676
676
  var visibleColumns = buildTableColumns({
677
677
  tab: tab,
@@ -743,13 +743,71 @@ var List = function List(_ref) {
743
743
  });
744
744
  };
745
745
 
746
+ var ResumeModal = function ResumeModal(_ref) {
747
+ var isOpen = _ref.isOpen,
748
+ onClose = _ref.onClose,
749
+ handleSplitTransfersUpdate = _ref.handleSplitTransfersUpdate;
750
+ var _useTranslation = useTranslation(),
751
+ t = _useTranslation.t;
752
+ var handleSubmit = function handleSubmit(_ref2) {
753
+ var reason = _ref2.reason;
754
+ handleSplitTransfersUpdate("pending", reason);
755
+ };
756
+ return /*#__PURE__*/jsxs(Modal, {
757
+ isOpen: isOpen,
758
+ onClose: onClose,
759
+ size: "large",
760
+ children: [/*#__PURE__*/jsx(Modal.Header, {
761
+ children: /*#__PURE__*/jsx(Typography, {
762
+ style: "h2",
763
+ weight: "medium",
764
+ children: t("neetoPayments.resumeSplitTransfers.modal.title")
765
+ })
766
+ }), /*#__PURE__*/jsx(Form, {
767
+ formikProps: {
768
+ initialValues: {
769
+ reason: ""
770
+ },
771
+ validationSchema: VALIDATION_SCHEMA,
772
+ onSubmit: handleSubmit
773
+ },
774
+ children: /*#__PURE__*/jsxs(Fragment, {
775
+ children: [/*#__PURE__*/jsx(Modal.Body, {
776
+ children: /*#__PURE__*/jsx("div", {
777
+ className: "flex flex-col space-y-4",
778
+ children: /*#__PURE__*/jsx(Textarea, {
779
+ required: true,
780
+ label: t("neetoPayments.resumeSplitTransfers.modal.reason"),
781
+ name: "reason"
782
+ })
783
+ })
784
+ }), /*#__PURE__*/jsx(Modal.Footer, {
785
+ children: /*#__PURE__*/jsx(ActionBlock, {
786
+ position: "right",
787
+ cancelButtonProps: {
788
+ onClick: onClose,
789
+ style: "tertiary"
790
+ },
791
+ submitButtonProps: {
792
+ disabled: false,
793
+ label: t("neetoPayments.common.submit")
794
+ }
795
+ })
796
+ })]
797
+ })
798
+ })]
799
+ });
800
+ };
801
+
746
802
  var Menu = Dropdown.Menu,
747
803
  MenuItem = Dropdown.MenuItem;
748
804
  var TopSection = function TopSection(_ref) {
749
805
  var views = _ref.views,
750
806
  filters = _ref.filters,
751
807
  setIsCancelModalOpen = _ref.setIsCancelModalOpen,
808
+ setIsResumeModalOpen = _ref.setIsResumeModalOpen,
752
809
  selectedRows = _ref.selectedRows,
810
+ selectedRowData = _ref.selectedRowData,
753
811
  setFilters = _ref.setFilters,
754
812
  hasBulkSelectedAllRows = _ref.hasBulkSelectedAllRows,
755
813
  filterableColumns = _ref.filterableColumns,
@@ -770,6 +828,12 @@ var TopSection = function TopSection(_ref) {
770
828
  var splitTransfersCountVisible = splitTransfersCount > 0;
771
829
  var isFilterButtonVisible = splitTransfersCount || isPresent(filters);
772
830
  var isDropdownVisible = isNotEmpty(selectedRows);
831
+ var isCancelButtonDisabled = existsBy({
832
+ status: SPLIT_TRANSFERS_DASHBOARD_TAB.cancelled
833
+ }, selectedRowData);
834
+ var isResumeButtonDisabled = existsBy({
835
+ status: SPLIT_TRANSFERS_DASHBOARD_TAB.pending
836
+ }, selectedRowData);
773
837
  var selectedRecordsCount = hasBulkSelectedAllRows ? splitTransfersCount : selectedRows.length;
774
838
  var handleFiltersChange = function handleFiltersChange(filters) {
775
839
  startTransition(function () {
@@ -825,17 +889,32 @@ var TopSection = function TopSection(_ref) {
825
889
  recordsCount: splitTransfersCount
826
890
  }
827
891
  })
828
- }), /*#__PURE__*/jsx(Dropdown, {
892
+ }), /*#__PURE__*/jsxs(Dropdown, {
829
893
  buttonStyle: "secondary",
830
894
  label: t("neetoPayments.common.takeAction"),
831
- children: /*#__PURE__*/jsx(Menu, {
895
+ children: [/*#__PURE__*/jsx(Menu, {
832
896
  children: /*#__PURE__*/jsx(MenuItem.Button, {
897
+ isDisabled: isCancelButtonDisabled,
898
+ tooltipProps: isCancelButtonDisabled ? {
899
+ content: t("neetoPayments.tooltipContent.splitTransfers.cancelledRecordsSelected")
900
+ } : "",
833
901
  onClick: function onClick() {
834
902
  return setIsCancelModalOpen(true);
835
903
  },
836
904
  children: t("neetoPayments.common.cancel")
837
905
  })
838
- })
906
+ }), /*#__PURE__*/jsx(Menu, {
907
+ children: /*#__PURE__*/jsx(MenuItem.Button, {
908
+ isDisabled: isResumeButtonDisabled,
909
+ tooltipProps: isResumeButtonDisabled ? {
910
+ content: t("neetoPayments.tooltipContent.splitTransfers.pendingRecordsSelected")
911
+ } : "",
912
+ onClick: function onClick() {
913
+ return setIsResumeModalOpen(true);
914
+ },
915
+ children: t("neetoPayments.common.resume")
916
+ })
917
+ })]
839
918
  })]
840
919
  }) : /*#__PURE__*/jsx(Typography, {
841
920
  className: "neeto-ui-gray-800 mr-2 font-semibold",
@@ -904,20 +983,24 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
904
983
  setIsCancelModalOpen = _useState8[1];
905
984
  var _useState9 = useState(false),
906
985
  _useState10 = _slicedToArray(_useState9, 2),
907
- hasBulkSelectedAllRows = _useState10[0],
908
- setHasBulkSelectedAllRows = _useState10[1];
909
- var _useState11 = useState(DEFAULT_SORT_PROPERTIES),
986
+ isResumeModalOpen = _useState10[0],
987
+ setIsResumeModalOpen = _useState10[1];
988
+ var _useState11 = useState(false),
910
989
  _useState12 = _slicedToArray(_useState11, 2),
911
- sortProperties = _useState12[0],
912
- setSortProperties = _useState12[1];
913
- var _useState13 = useState(DEFAULT_PAGE_VALUES),
990
+ hasBulkSelectedAllRows = _useState12[0],
991
+ setHasBulkSelectedAllRows = _useState12[1];
992
+ var _useState13 = useState(DEFAULT_SORT_PROPERTIES),
914
993
  _useState14 = _slicedToArray(_useState13, 2),
915
- pageProperties = _useState14[0],
916
- setPageProperties = _useState14[1];
917
- var _useState15 = useState(buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
994
+ sortProperties = _useState14[0],
995
+ setSortProperties = _useState14[1];
996
+ var _useState15 = useState(DEFAULT_PAGE_VALUES),
918
997
  _useState16 = _slicedToArray(_useState15, 2),
919
- filters = _useState16[0],
920
- setFilters = _useState16[1];
998
+ pageProperties = _useState16[0],
999
+ setPageProperties = _useState16[1];
1000
+ var _useState17 = useState(buildFiltersFromURL([].concat(_toConsumableArray(filterableColumns), [searchKeywordProps]))),
1001
+ _useState18 = _slicedToArray(_useState17, 2),
1002
+ filters = _useState18[0],
1003
+ setFilters = _useState18[1];
921
1004
  var history = useHistory();
922
1005
  var _getQueryParams2 = getQueryParams(),
923
1006
  _getQueryParams2$tab = _getQueryParams2.tab,
@@ -933,22 +1016,24 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
933
1016
  views = _useFetchSplitTransfe3.views,
934
1017
  isFetching = _useFetchSplitTransfe.isFetching,
935
1018
  isSplitTransfersLoading = _useFetchSplitTransfe.isPending;
936
- var _useBulkCancellationS = useBulkCancellationSplitTransfers({
1019
+ var _useBulkUpdateSplitTr = useBulkUpdateSplitTransfers({
937
1020
  onSuccess: function onSuccess() {
938
1021
  setSelectedRowData([]);
939
1022
  setSelectedRows([]);
940
1023
  }
941
1024
  }),
942
- cancelSplitTransfers = _useBulkCancellationS.mutate,
943
- isCancelling = _useBulkCancellationS.isPending;
944
- var handleSplitTransfersCancellation = function handleSplitTransfersCancellation(cancellationReason) {
1025
+ updateSplitTransfers = _useBulkUpdateSplitTr.mutate,
1026
+ isCancelling = _useBulkUpdateSplitTr.isPending;
1027
+ var handleSplitTransfersUpdate = function handleSplitTransfersUpdate(status, reason) {
945
1028
  var ids = pluck("id", selectedRowData);
946
- cancelSplitTransfers({
1029
+ updateSplitTransfers({
947
1030
  ids: ids,
948
- cancellationReason: cancellationReason,
1031
+ status: status,
1032
+ reason: reason,
949
1033
  isApplyChangesToAllRequired: hasBulkSelectedAllRows
950
1034
  });
951
1035
  setIsCancelModalOpen(false);
1036
+ setIsResumeModalOpen(false);
952
1037
  };
953
1038
  var handleTablePagination = function handleTablePagination(page, pageSize) {
954
1039
  var queryParams = getQueryParams({
@@ -970,6 +1055,8 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
970
1055
  useEffect(function () {
971
1056
  handleTablePagination(DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE);
972
1057
  setSortProperties(DEFAULT_SORT_PROPERTIES);
1058
+ setSelectedRowData([]);
1059
+ setSelectedRows([]);
973
1060
  }, [filters, tab]);
974
1061
  if (isSplitTransfersLoading || isCancelling) {
975
1062
  return /*#__PURE__*/jsx("div", {
@@ -985,10 +1072,12 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
985
1072
  pageProperties: pageProperties,
986
1073
  payableEntityColumns: payableEntityColumns,
987
1074
  searchKeywordProps: searchKeywordProps,
1075
+ selectedRowData: selectedRowData,
988
1076
  selectedRows: selectedRows,
989
1077
  setFilters: setFilters,
990
1078
  setIsCancelModalOpen: setIsCancelModalOpen,
991
1079
  setIsExportModalOpen: setIsExportModalOpen,
1080
+ setIsResumeModalOpen: setIsResumeModalOpen,
992
1081
  setPageProperties: setPageProperties,
993
1082
  setSortProperties: setSortProperties,
994
1083
  views: views
@@ -1011,11 +1100,17 @@ var SplitTransfersDashboard = function SplitTransfersDashboard(_ref) {
1011
1100
  sortProperties: sortProperties,
1012
1101
  dashboardKind: DASHBOARD_KIND.splitTransfers
1013
1102
  }), /*#__PURE__*/jsx(CancelModal, {
1014
- handleSplitTransfersCancellation: handleSplitTransfersCancellation,
1103
+ handleSplitTransfersUpdate: handleSplitTransfersUpdate,
1015
1104
  isOpen: isCancelModalOpen,
1016
1105
  onClose: function onClose() {
1017
1106
  return setIsCancelModalOpen(false);
1018
1107
  }
1108
+ }), /*#__PURE__*/jsx(ResumeModal, {
1109
+ handleSplitTransfersUpdate: handleSplitTransfersUpdate,
1110
+ isOpen: isResumeModalOpen,
1111
+ onClose: function onClose() {
1112
+ return setIsResumeModalOpen(false);
1113
+ }
1019
1114
  })]
1020
1115
  });
1021
1116
  };