@bigbinary/neeto-payments-frontend 6.1.11 → 6.1.13

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.
Files changed (221) hide show
  1. package/dist/AccountsDashboard.js +473 -0
  2. package/dist/AccountsDashboard.js.map +1 -0
  3. package/dist/AdminCancelRecurringPaymentButton.js +65 -0
  4. package/dist/AdminCancelRecurringPaymentButton.js.map +1 -0
  5. package/dist/CashPaymentButton.js +58 -0
  6. package/dist/CashPaymentButton.js.map +1 -0
  7. package/dist/ConfirmCashPaymentButton.js +98 -0
  8. package/dist/ConfirmCashPaymentButton.js.map +1 -0
  9. package/dist/CopyButtonWrapper-Bp5IVO76.js +26 -0
  10. package/dist/CopyButtonWrapper-Bp5IVO76.js.map +1 -0
  11. package/dist/CustomerCancelRecurringPaymentForm.js +103 -0
  12. package/dist/CustomerCancelRecurringPaymentForm.js.map +1 -0
  13. package/dist/ExportModal-DyRGg_4o.js +120 -0
  14. package/dist/ExportModal-DyRGg_4o.js.map +1 -0
  15. package/dist/ManualUpiConnect.js +228 -0
  16. package/dist/ManualUpiConnect.js.map +1 -0
  17. package/dist/ManualUpiPayment.js +125 -0
  18. package/dist/ManualUpiPayment.js.map +1 -0
  19. package/dist/ManualUpiPaymentConfirmButton.js +155 -0
  20. package/dist/ManualUpiPaymentConfirmButton.js.map +1 -0
  21. package/dist/ManualUpiPaymentRejectButton.js +126 -0
  22. package/dist/ManualUpiPaymentRejectButton.js.map +1 -0
  23. package/dist/PaymentKindRestrictionAlert.js +31 -0
  24. package/dist/PaymentKindRestrictionAlert.js.map +1 -0
  25. package/dist/PaymentsDashboard.js +555 -0
  26. package/dist/PaymentsDashboard.js.map +1 -0
  27. package/dist/PayoutsDashboard.js +510 -0
  28. package/dist/PayoutsDashboard.js.map +1 -0
  29. package/dist/PayoutsPage.js +158 -0
  30. package/dist/PayoutsPage.js.map +1 -0
  31. package/dist/RazorpayConnect.js +115 -0
  32. package/dist/RazorpayConnect.js.map +1 -0
  33. package/dist/RazorpayLinkedAccountForm.js +201 -0
  34. package/dist/RazorpayLinkedAccountForm.js.map +1 -0
  35. package/dist/RazorpayPaymentButton.js +127 -0
  36. package/dist/RazorpayPaymentButton.js.map +1 -0
  37. package/dist/RecurringPaymentSettings.js +119 -0
  38. package/dist/RecurringPaymentSettings.js.map +1 -0
  39. package/dist/RefundsDashboard.js +484 -0
  40. package/dist/RefundsDashboard.js.map +1 -0
  41. package/dist/SplitTransfersDashboard.js +1042 -0
  42. package/dist/SplitTransfersDashboard.js.map +1 -0
  43. package/dist/StripeCheckoutSetting.js +82 -0
  44. package/dist/StripeCheckoutSetting.js.map +1 -0
  45. package/dist/StripeConnect.js +376 -0
  46. package/dist/StripeConnect.js.map +1 -0
  47. package/dist/StripeManage.js +46 -0
  48. package/dist/StripeManage.js.map +1 -0
  49. package/dist/TaxesDashboard.js +355 -0
  50. package/dist/TaxesDashboard.js.map +1 -0
  51. package/dist/buildStripeTransactionLink.js +12 -0
  52. package/dist/buildStripeTransactionLink.js.map +1 -0
  53. package/dist/cjs/AccountsDashboard.js +475 -0
  54. package/dist/cjs/AccountsDashboard.js.map +1 -0
  55. package/dist/cjs/AdminCancelRecurringPaymentButton.js +67 -0
  56. package/dist/cjs/AdminCancelRecurringPaymentButton.js.map +1 -0
  57. package/dist/cjs/CashPaymentButton.js +60 -0
  58. package/dist/cjs/CashPaymentButton.js.map +1 -0
  59. package/dist/cjs/ConfirmCashPaymentButton.js +100 -0
  60. package/dist/cjs/ConfirmCashPaymentButton.js.map +1 -0
  61. package/dist/cjs/CopyButtonWrapper-I-kdKiiB.js +29 -0
  62. package/dist/cjs/CopyButtonWrapper-I-kdKiiB.js.map +1 -0
  63. package/dist/cjs/CustomerCancelRecurringPaymentForm.js +105 -0
  64. package/dist/cjs/CustomerCancelRecurringPaymentForm.js.map +1 -0
  65. package/dist/cjs/ExportModal-DE-VcN1X.js +122 -0
  66. package/dist/cjs/ExportModal-DE-VcN1X.js.map +1 -0
  67. package/dist/cjs/ManualUpiConnect.js +249 -0
  68. package/dist/cjs/ManualUpiConnect.js.map +1 -0
  69. package/dist/cjs/ManualUpiPayment.js +146 -0
  70. package/dist/cjs/ManualUpiPayment.js.map +1 -0
  71. package/dist/cjs/ManualUpiPaymentConfirmButton.js +176 -0
  72. package/dist/cjs/ManualUpiPaymentConfirmButton.js.map +1 -0
  73. package/dist/cjs/ManualUpiPaymentRejectButton.js +128 -0
  74. package/dist/cjs/ManualUpiPaymentRejectButton.js.map +1 -0
  75. package/dist/cjs/PaymentKindRestrictionAlert.js +33 -0
  76. package/dist/cjs/PaymentKindRestrictionAlert.js.map +1 -0
  77. package/dist/cjs/PaymentsDashboard.js +557 -0
  78. package/dist/cjs/PaymentsDashboard.js.map +1 -0
  79. package/dist/cjs/PayoutsDashboard.js +512 -0
  80. package/dist/cjs/PayoutsDashboard.js.map +1 -0
  81. package/dist/cjs/PayoutsPage.js +160 -0
  82. package/dist/cjs/PayoutsPage.js.map +1 -0
  83. package/dist/cjs/RazorpayConnect.js +117 -0
  84. package/dist/cjs/RazorpayConnect.js.map +1 -0
  85. package/dist/cjs/RazorpayLinkedAccountForm.js +203 -0
  86. package/dist/cjs/RazorpayLinkedAccountForm.js.map +1 -0
  87. package/dist/cjs/RazorpayPaymentButton.js +129 -0
  88. package/dist/cjs/RazorpayPaymentButton.js.map +1 -0
  89. package/dist/cjs/RecurringPaymentSettings.js +140 -0
  90. package/dist/cjs/RecurringPaymentSettings.js.map +1 -0
  91. package/dist/cjs/RefundsDashboard.js +486 -0
  92. package/dist/cjs/RefundsDashboard.js.map +1 -0
  93. package/dist/cjs/SplitTransfersDashboard.js +1063 -0
  94. package/dist/cjs/SplitTransfersDashboard.js.map +1 -0
  95. package/dist/cjs/StripeCheckoutSetting.js +84 -0
  96. package/dist/cjs/StripeCheckoutSetting.js.map +1 -0
  97. package/dist/cjs/StripeConnect.js +397 -0
  98. package/dist/cjs/StripeConnect.js.map +1 -0
  99. package/dist/cjs/StripeManage.js +48 -0
  100. package/dist/cjs/StripeManage.js.map +1 -0
  101. package/dist/cjs/TaxesDashboard.js +376 -0
  102. package/dist/cjs/TaxesDashboard.js.map +1 -0
  103. package/dist/cjs/buildStripeTransactionLink.js +14 -0
  104. package/dist/cjs/buildStripeTransactionLink.js.map +1 -0
  105. package/dist/cjs/constants.js +38 -0
  106. package/dist/cjs/constants.js.map +1 -0
  107. package/dist/cjs/dashboard-BiCB2A6S.js +96 -0
  108. package/dist/cjs/dashboard-BiCB2A6S.js.map +1 -0
  109. package/dist/cjs/exportChannel-BL2RGGhP.js +38 -0
  110. package/dist/cjs/exportChannel-BL2RGGhP.js.map +1 -0
  111. package/dist/cjs/getAddressElementOptions.js +14 -0
  112. package/dist/cjs/getAddressElementOptions.js.map +1 -0
  113. package/dist/cjs/getAmountInLargestCurrencyUnit.js +14 -0
  114. package/dist/cjs/getAmountInLargestCurrencyUnit.js.map +1 -0
  115. package/dist/cjs/getAmountInSmallestCurrencyUnit.js +14 -0
  116. package/dist/cjs/getAmountInSmallestCurrencyUnit.js.map +1 -0
  117. package/dist/cjs/getAmountWithAppliedTax.js +14 -0
  118. package/dist/cjs/getAmountWithAppliedTax.js.map +1 -0
  119. package/dist/cjs/getFormattedAmount.js +14 -0
  120. package/dist/cjs/getFormattedAmount.js.map +1 -0
  121. package/dist/cjs/getFormattedDiscountedAmount.js +14 -0
  122. package/dist/cjs/getFormattedDiscountedAmount.js.map +1 -0
  123. package/dist/cjs/getFormattedDiscountedPercentage.js +14 -0
  124. package/dist/cjs/getFormattedDiscountedPercentage.js.map +1 -0
  125. package/dist/cjs/getFormattedTaxAmount.js +14 -0
  126. package/dist/cjs/getFormattedTaxAmount.js.map +1 -0
  127. package/dist/cjs/getFormattedTipAmount.js +14 -0
  128. package/dist/cjs/getFormattedTipAmount.js.map +1 -0
  129. package/dist/cjs/getQrCodeValue.js +14 -0
  130. package/dist/cjs/getQrCodeValue.js.map +1 -0
  131. package/dist/cjs/getTaxAmount.js +14 -0
  132. package/dist/cjs/getTaxAmount.js.map +1 -0
  133. package/dist/cjs/getTipAmount.js +14 -0
  134. package/dist/cjs/getTipAmount.js.map +1 -0
  135. package/dist/cjs/hasAmountToPay.js +14 -0
  136. package/dist/cjs/hasAmountToPay.js.map +1 -0
  137. package/dist/cjs/index-D6V3Vofs.js +855 -0
  138. package/dist/cjs/index-D6V3Vofs.js.map +1 -0
  139. package/dist/cjs/index.js +121 -0
  140. package/dist/cjs/index.js.map +1 -0
  141. package/dist/cjs/queryConstants-Dc6wh21D.js +35 -0
  142. package/dist/cjs/queryConstants-Dc6wh21D.js.map +1 -0
  143. package/dist/cjs/renderFunctions-DhCwlBWw.js +48 -0
  144. package/dist/cjs/renderFunctions-DhCwlBWw.js.map +1 -0
  145. package/dist/cjs/stripe.esm-CrNYjPcC.js +132 -0
  146. package/dist/cjs/stripe.esm-CrNYjPcC.js.map +1 -0
  147. package/dist/cjs/useAccountsApi-B2MZWHMY.js +42 -0
  148. package/dist/cjs/useAccountsApi-B2MZWHMY.js.map +1 -0
  149. package/dist/cjs/useIntegrationsApi-CVlTmLKc.js +20 -0
  150. package/dist/cjs/useIntegrationsApi-CVlTmLKc.js.map +1 -0
  151. package/dist/cjs/usePaymentApi-BCE_Ql18.js +29 -0
  152. package/dist/cjs/usePaymentApi-BCE_Ql18.js.map +1 -0
  153. package/dist/cjs/usePaymentApi-Bl8jWvnG.js +44 -0
  154. package/dist/cjs/usePaymentApi-Bl8jWvnG.js.map +1 -0
  155. package/dist/cjs/usePaymentApi-CiwXBe90.js +29 -0
  156. package/dist/cjs/usePaymentApi-CiwXBe90.js.map +1 -0
  157. package/dist/cjs/usePlatformApi-CcGVG4Qi.js +55 -0
  158. package/dist/cjs/usePlatformApi-CcGVG4Qi.js.map +1 -0
  159. package/dist/cjs/useRazorpayPayment.js +88 -0
  160. package/dist/cjs/useRazorpayPayment.js.map +1 -0
  161. package/dist/cjs/useStripePromise.js +31 -0
  162. package/dist/cjs/useStripePromise.js.map +1 -0
  163. package/dist/constants.js +8 -0
  164. package/dist/constants.js.map +1 -0
  165. package/dist/dashboard-CwvqEeOl.js +90 -0
  166. package/dist/dashboard-CwvqEeOl.js.map +1 -0
  167. package/dist/exportChannel-Db0U5gc1.js +35 -0
  168. package/dist/exportChannel-Db0U5gc1.js.map +1 -0
  169. package/dist/getAddressElementOptions.js +12 -0
  170. package/dist/getAddressElementOptions.js.map +1 -0
  171. package/dist/getAmountInLargestCurrencyUnit.js +12 -0
  172. package/dist/getAmountInLargestCurrencyUnit.js.map +1 -0
  173. package/dist/getAmountInSmallestCurrencyUnit.js +12 -0
  174. package/dist/getAmountInSmallestCurrencyUnit.js.map +1 -0
  175. package/dist/getAmountWithAppliedTax.js +12 -0
  176. package/dist/getAmountWithAppliedTax.js.map +1 -0
  177. package/dist/getFormattedAmount.js +12 -0
  178. package/dist/getFormattedAmount.js.map +1 -0
  179. package/dist/getFormattedDiscountedAmount.js +12 -0
  180. package/dist/getFormattedDiscountedAmount.js.map +1 -0
  181. package/dist/getFormattedDiscountedPercentage.js +12 -0
  182. package/dist/getFormattedDiscountedPercentage.js.map +1 -0
  183. package/dist/getFormattedTaxAmount.js +12 -0
  184. package/dist/getFormattedTaxAmount.js.map +1 -0
  185. package/dist/getFormattedTipAmount.js +12 -0
  186. package/dist/getFormattedTipAmount.js.map +1 -0
  187. package/dist/getQrCodeValue.js +12 -0
  188. package/dist/getQrCodeValue.js.map +1 -0
  189. package/dist/getTaxAmount.js +12 -0
  190. package/dist/getTaxAmount.js.map +1 -0
  191. package/dist/getTipAmount.js +12 -0
  192. package/dist/getTipAmount.js.map +1 -0
  193. package/dist/hasAmountToPay.js +12 -0
  194. package/dist/hasAmountToPay.js.map +1 -0
  195. package/dist/index-CNouM9_z.js +804 -0
  196. package/dist/index-CNouM9_z.js.map +1 -0
  197. package/dist/index.js +78 -0
  198. package/dist/index.js.map +1 -0
  199. package/dist/queryConstants-C7AqdemO.js +33 -0
  200. package/dist/queryConstants-C7AqdemO.js.map +1 -0
  201. package/dist/renderFunctions-Bx5nzyE_.js +44 -0
  202. package/dist/renderFunctions-Bx5nzyE_.js.map +1 -0
  203. package/dist/stripe.esm-DuZ_gsAa.js +130 -0
  204. package/dist/stripe.esm-DuZ_gsAa.js.map +1 -0
  205. package/dist/useAccountsApi-C9_eNmEZ.js +38 -0
  206. package/dist/useAccountsApi-C9_eNmEZ.js.map +1 -0
  207. package/dist/useIntegrationsApi-D9eA_FrB.js +18 -0
  208. package/dist/useIntegrationsApi-D9eA_FrB.js.map +1 -0
  209. package/dist/usePaymentApi-B98qoM7U.js +26 -0
  210. package/dist/usePaymentApi-B98qoM7U.js.map +1 -0
  211. package/dist/usePaymentApi-DMHHdCK1.js +41 -0
  212. package/dist/usePaymentApi-DMHHdCK1.js.map +1 -0
  213. package/dist/usePaymentApi-DSlW_EBq.js +27 -0
  214. package/dist/usePaymentApi-DSlW_EBq.js.map +1 -0
  215. package/dist/usePlatformApi-sJUY6wju.js +50 -0
  216. package/dist/usePlatformApi-sJUY6wju.js.map +1 -0
  217. package/dist/useRazorpayPayment.js +86 -0
  218. package/dist/useRazorpayPayment.js.map +1 -0
  219. package/dist/useStripePromise.js +29 -0
  220. package/dist/useStripePromise.js.map +1 -0
  221. package/package.json +1 -1
@@ -0,0 +1,1042 @@
1
+ import { useState, startTransition, useEffect } from 'react';
2
+ import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from 'neetocommons/constants';
3
+ import { currencyFormat, getQueryParams, buildUrl } from 'neetocommons/utils';
4
+ import { Bar, buildFiltersFromURL } from '@bigbinary/neeto-filters-frontend';
5
+ import { Modal, Typography, Tooltip, Tag, Pane, Spinner, Button, NoData, Table, Tab, Dropdown } from '@bigbinary/neetoui';
6
+ import { mergeLeft, curry, mergeDeepWith, concat, reject, isNil, map, prop, sortBy, isEmpty, modify, pluck } from 'ramda';
7
+ import { useHistory } from 'react-router-dom';
8
+ import { E as ExportModal } from './ExportModal-DyRGg_4o.js';
9
+ import { useQuery } from '@tanstack/react-query';
10
+ import { useMutationWithInvalidation } from 'neetocommons/react-utils';
11
+ import axios from 'axios';
12
+ import { B as BASE_URL, v as preProcessStatus, w as getTagStyle, l as formatAmount, m as formatCurrency, x as PAYMENT_KIND, S as SORT_DIRECTIONS, p as processDataIndex, D as DEFAULT_SORT_PROPERTIES, s as shouldTabsVisible, U as UN_HIDEABLE_COLUMNS, i as DEFAULT_PAGE_VALUES, q as DASHBOARD_KIND } from './index-CNouM9_z.js';
13
+ import { Q as QUERY_KEYS } from './queryConstants-C7AqdemO.js';
14
+ import { Form, Textarea, ActionBlock } from '@bigbinary/neetoui/formik';
15
+ import { useTranslation, Trans } from 'react-i18next';
16
+ import { t } from 'i18next';
17
+ import * as yup from 'yup';
18
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
19
+ import { isNotPresent, humanize, isPresent, removeBy, camelToSnakeCase, isNotEmpty, existsBy } from 'neetocist';
20
+ import { useTableConfigurations } from '@bigbinary/neeto-molecules/Columns';
21
+ import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
22
+ import { T as TABLE_KEYS } from './exportChannel-Db0U5gc1.js';
23
+ import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
24
+ import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
25
+ import { C as CopyButtonWrapper } from './CopyButtonWrapper-Bp5IVO76.js';
26
+ import Header from '@bigbinary/neeto-molecules/Header';
27
+ import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
28
+ import '@bigbinary/neeto-icons';
29
+ import 'decimal.js';
30
+ import '@bigbinary/neeto-molecules/CopyToClipboardButton';
31
+
32
+ const list = payload => axios.get(`${BASE_URL}/api/v1/split_transfers`, {
33
+ params: payload
34
+ });
35
+ const show = id => axios.get(`${BASE_URL}/api/v1/split_transfers/${id}`);
36
+ const bulkUpdate = payload => axios.post(`${BASE_URL}/api/v1/split_transfers/bulk_update`, {
37
+ splitTransfer: payload
38
+ });
39
+ const splitTransfersApi = {
40
+ list,
41
+ show,
42
+ bulkUpdate
43
+ };
44
+
45
+ const useFetchSplitTransfers = (payload = {}, options = {}) => useQuery({
46
+ queryKey: [QUERY_KEYS.SPLIT_TRANSFERS_LIST, payload],
47
+ queryFn: () => splitTransfersApi.list(payload),
48
+ ...options
49
+ });
50
+ const useShowSplitTransfers = (id, options) => useQuery({
51
+ queryKey: [QUERY_KEYS.SPLIT_TRANSFERS_DETAILS, id],
52
+ queryFn: () => splitTransfersApi.show(id),
53
+ ...options
54
+ });
55
+ const useBulkUpdateSplitTransfers = options => useMutationWithInvalidation(splitTransfersApi.bulkUpdate, {
56
+ keysToInvalidate: [QUERY_KEYS.SPLIT_TRANSFERS_LISTw],
57
+ ...options
58
+ });
59
+
60
+ const SPLIT_TRANSFERS_DASHBOARD_TAB = {
61
+ all: "all",
62
+ successful: "successful",
63
+ cancelled: "cancelled",
64
+ pending: "pending"
65
+ };
66
+ const SEARCH_PROPS = {
67
+ node: "identifier,",
68
+ key: "search_term",
69
+ model: "NeetoPaymentsEngine::Payments::Split,"
70
+ };
71
+ const FILTER_COLUMNS = [{
72
+ key: "amount",
73
+ label: t("neetoPayments.common.amount"),
74
+ node: "amount",
75
+ type: "decimal"
76
+ }, {
77
+ key: "payment_at",
78
+ label: t("neetoPayments.common.transferTime"),
79
+ node: "payment_at",
80
+ type: "date"
81
+ }];
82
+ const INITIAL_TRANSFER_DETAILS = {
83
+ id: null,
84
+ isPaneOpen: false
85
+ };
86
+ const VALIDATION_SCHEMA = yup.object().shape({
87
+ reason: yup.string().required(t("neetoPayments.cancelSplitTransfers.reasonRequired"))
88
+ });
89
+
90
+ const CancelModal = ({
91
+ isOpen,
92
+ onClose,
93
+ handleSplitTransfersUpdate
94
+ }) => {
95
+ const {
96
+ t
97
+ } = useTranslation();
98
+ const handleSubmit = ({
99
+ reason
100
+ }) => {
101
+ handleSplitTransfersUpdate("cancelled", reason);
102
+ };
103
+ return /*#__PURE__*/jsxs(Modal, {
104
+ isOpen,
105
+ onClose,
106
+ size: "large",
107
+ children: [/*#__PURE__*/jsx(Modal.Header, {
108
+ children: /*#__PURE__*/jsx(Typography, {
109
+ style: "h2",
110
+ weight: "medium",
111
+ children: t("neetoPayments.cancelSplitTransfers.modal.title")
112
+ })
113
+ }), /*#__PURE__*/jsx(Form, {
114
+ formikProps: {
115
+ initialValues: {
116
+ reason: ""
117
+ },
118
+ validationSchema: VALIDATION_SCHEMA,
119
+ onSubmit: handleSubmit
120
+ },
121
+ children: /*#__PURE__*/jsxs(Fragment, {
122
+ children: [/*#__PURE__*/jsx(Modal.Body, {
123
+ children: /*#__PURE__*/jsx("div", {
124
+ className: "flex flex-col space-y-4",
125
+ children: /*#__PURE__*/jsx(Textarea, {
126
+ required: true,
127
+ label: t("neetoPayments.cancelSplitTransfers.modal.reason"),
128
+ name: "reason"
129
+ })
130
+ })
131
+ }), /*#__PURE__*/jsx(Modal.Footer, {
132
+ children: /*#__PURE__*/jsx(ActionBlock, {
133
+ position: "right",
134
+ cancelButtonProps: {
135
+ onClick: onClose,
136
+ style: "tertiary"
137
+ },
138
+ submitButtonProps: {
139
+ disabled: false,
140
+ label: t("neetoPayments.common.submit")
141
+ }
142
+ })
143
+ })]
144
+ })
145
+ })]
146
+ });
147
+ };
148
+
149
+ const Status = ({
150
+ type,
151
+ status = ""
152
+ }) => {
153
+ const {
154
+ t
155
+ } = useTranslation();
156
+ const processedStatus = preProcessStatus(type, status);
157
+ if (isNotPresent(status)) {
158
+ return /*#__PURE__*/jsx(Typography, {
159
+ style: "body2",
160
+ children: t("neetoPayments.common.notAvailable")
161
+ });
162
+ }
163
+ return /*#__PURE__*/jsx(Tooltip, {
164
+ content: t(`neetoPayments.tooltipContent.${type}.${processedStatus}`),
165
+ position: "top",
166
+ children: /*#__PURE__*/jsx("div", {
167
+ className: "w-fit",
168
+ children: /*#__PURE__*/jsx(Tag, {
169
+ style: getTagStyle(processedStatus),
170
+ label: humanize(t(`neetoPayments.tagLabels.${type}.${processedStatus}`))
171
+ })
172
+ })
173
+ });
174
+ };
175
+
176
+ const Date = ({
177
+ date,
178
+ isTimeVisible = false
179
+ }) => {
180
+ const {
181
+ t
182
+ } = useTranslation();
183
+ if (isNotPresent(date)) {
184
+ return /*#__PURE__*/jsx(Typography, {
185
+ style: "body2",
186
+ children: t("neetoPayments.common.notAvailable")
187
+ });
188
+ }
189
+ if (isTimeVisible) {
190
+ return /*#__PURE__*/jsx("div", {
191
+ className: "flex items-center",
192
+ children: /*#__PURE__*/jsx(DateFormat.DateTime, {
193
+ date
194
+ })
195
+ });
196
+ }
197
+ return /*#__PURE__*/jsx("div", {
198
+ className: "flex items-center",
199
+ children: /*#__PURE__*/jsx(DateFormat.Date, {
200
+ date
201
+ })
202
+ });
203
+ };
204
+
205
+ const DiscountCode = ({
206
+ discountCode,
207
+ currency
208
+ }) => {
209
+ const {
210
+ t
211
+ } = useTranslation();
212
+ const {
213
+ code,
214
+ value,
215
+ kind
216
+ } = discountCode;
217
+ return /*#__PURE__*/jsx(Typography, {
218
+ style: "body2",
219
+ children: kind === "percentage" ? t("neetoPayments.splitTransferDetails.discountCodeOfPercentageApplied", {
220
+ code,
221
+ percentage: value.toFixed(1)
222
+ }) : t("neetoPayments.splitTransferDetails.discountCodeOfAmountApplied", {
223
+ code,
224
+ amount: currencyFormat.withSymbol(value, currency.toUpperCase(), {
225
+ maximumFractionDigits: 2,
226
+ minimumFractionDigits: 2
227
+ })
228
+ })
229
+ });
230
+ };
231
+
232
+ const Details = ({
233
+ selectedTransfer,
234
+ setSelectedTransfer
235
+ }) => {
236
+ const {
237
+ t
238
+ } = useTranslation();
239
+ const {
240
+ isPending,
241
+ data: {
242
+ splitTransfer
243
+ } = {}
244
+ } = useShowSplitTransfers(selectedTransfer["id"], {
245
+ enabled: isPresent(selectedTransfer["id"])
246
+ });
247
+ return /*#__PURE__*/jsxs(Pane, {
248
+ isOpen: selectedTransfer["isPaneOpen"],
249
+ size: "large",
250
+ onClose: () => setSelectedTransfer(mergeLeft({
251
+ isPaneOpen: false
252
+ }, selectedTransfer)),
253
+ children: [/*#__PURE__*/jsx(Pane.Header, {
254
+ children: /*#__PURE__*/jsx(Typography, {
255
+ style: "h2",
256
+ children: t("neetoPayments.splitTransferDetails.title")
257
+ })
258
+ }), /*#__PURE__*/jsx(Pane.Body, {
259
+ children: isPending ? /*#__PURE__*/jsx("div", {
260
+ className: "flex h-full w-full items-center justify-center",
261
+ children: /*#__PURE__*/jsx(Spinner, {})
262
+ }) : /*#__PURE__*/jsxs("div", {
263
+ className: "space-y-4 p-3",
264
+ children: [/*#__PURE__*/jsxs("div", {
265
+ className: "flex grid-cols-2 flex-col gap-3 lg:grid",
266
+ children: [/*#__PURE__*/jsx(Typography, {
267
+ style: "body1",
268
+ weight: "medium",
269
+ children: t("neetoPayments.common.identifier")
270
+ }), /*#__PURE__*/jsx(Button, {
271
+ href: splitTransfer.transferUrl,
272
+ label: splitTransfer.identifier,
273
+ size: "small",
274
+ style: "link",
275
+ target: "_blank"
276
+ }), /*#__PURE__*/jsx(Typography, {
277
+ style: "body1",
278
+ weight: "medium",
279
+ children: t("neetoPayments.common.status")
280
+ }), /*#__PURE__*/jsx(Status, {
281
+ status: splitTransfer.status,
282
+ type: "splitTransfers"
283
+ }), /*#__PURE__*/jsx(Typography, {
284
+ style: "body1",
285
+ weight: "medium",
286
+ children: t("neetoPayments.common.transferTime")
287
+ }), /*#__PURE__*/jsx(Date, {
288
+ isTimeVisible: true,
289
+ date: splitTransfer.paymentAt
290
+ }), /*#__PURE__*/jsx(Typography, {
291
+ style: "body1",
292
+ weight: "medium",
293
+ children: t("neetoPayments.common.paymentAmount")
294
+ }), /*#__PURE__*/jsx(Typography, {
295
+ style: "body2",
296
+ children: currencyFormat.withCode(splitTransfer.sourcePayment?.amount, splitTransfer.currency?.toUpperCase())
297
+ }), isPresent(splitTransfer.discountCode) && /*#__PURE__*/jsxs(Fragment, {
298
+ children: [/*#__PURE__*/jsx(Typography, {
299
+ style: "body1",
300
+ weight: "medium",
301
+ children: t("neetoPayments.common.discountCode")
302
+ }), /*#__PURE__*/jsx(DiscountCode, {
303
+ currency: splitTransfer.currency,
304
+ discountCode: splitTransfer.discountCode
305
+ })]
306
+ }), /*#__PURE__*/jsxs("div", {
307
+ className: "flex items-center space-x-1",
308
+ children: [/*#__PURE__*/jsx(Typography, {
309
+ style: "body1",
310
+ weight: "medium",
311
+ children: t("neetoPayments.common.netAmount")
312
+ }), /*#__PURE__*/jsx(HelpPopover, {
313
+ popoverProps: {
314
+ position: "right"
315
+ },
316
+ description: t("neetoPayments.splitTransferDetails.netAmountDescription"),
317
+ title: t("neetoPayments.splitTransferDetails.netAmountHelpTitle")
318
+ })]
319
+ }), /*#__PURE__*/jsx(Typography, {
320
+ style: "body2",
321
+ children: currencyFormat.withCode(splitTransfer.sourcePayment?.netAmount, splitTransfer.currency?.toUpperCase())
322
+ }), /*#__PURE__*/jsxs("div", {
323
+ className: "flex space-x-1",
324
+ children: [/*#__PURE__*/jsx(Typography, {
325
+ style: "body1",
326
+ weight: "medium",
327
+ children: t("neetoPayments.common.platformShare")
328
+ }), /*#__PURE__*/jsx(HelpPopover, {
329
+ popoverProps: {
330
+ position: "right"
331
+ },
332
+ description: t("neetoPayments.splitTransferDetails.platformShareDescription"),
333
+ title: t("neetoPayments.splitTransferDetails.platformShareHelpTitle")
334
+ })]
335
+ }), /*#__PURE__*/jsx(Typography, {
336
+ style: "body2",
337
+ children: currencyFormat.withCode(splitTransfer.platformShare, splitTransfer.currency?.toUpperCase())
338
+ }), /*#__PURE__*/jsx(Typography, {
339
+ style: "body1",
340
+ weight: "medium",
341
+ children: t("neetoPayments.common.transferredAmount")
342
+ }), /*#__PURE__*/jsx(Typography, {
343
+ style: "body2",
344
+ children: currencyFormat.withCode(splitTransfer.amount, splitTransfer.currency?.toUpperCase())
345
+ })]
346
+ }), /*#__PURE__*/jsx(Typography, {
347
+ style: "h3",
348
+ children: t("neetoPayments.splitTransferDetails.destinationDetails")
349
+ }), /*#__PURE__*/jsxs("div", {
350
+ className: "flex grid-cols-2 flex-col gap-3 lg:grid",
351
+ children: [/*#__PURE__*/jsx(Typography, {
352
+ style: "body1",
353
+ weight: "medium",
354
+ children: t("neetoPayments.common.destinationAccountIdentifier")
355
+ }), /*#__PURE__*/jsx(Button, {
356
+ href: splitTransfer.destinationAccount.dashboardUrl,
357
+ label: splitTransfer.destinationAccount.identifier,
358
+ size: "small",
359
+ style: "link",
360
+ target: "_blank"
361
+ }), /*#__PURE__*/jsx(Typography, {
362
+ style: "body1",
363
+ weight: "medium",
364
+ children: t("neetoPayments.common.destinationAccountName")
365
+ }), /*#__PURE__*/jsx(Typography, {
366
+ style: "body2",
367
+ children: splitTransfer.destinationAccount.userName
368
+ }), /*#__PURE__*/jsx(Typography, {
369
+ style: "body1",
370
+ weight: "medium",
371
+ children: t("neetoPayments.common.destinationAccountEmail")
372
+ }), /*#__PURE__*/jsx(Typography, {
373
+ style: "body2",
374
+ children: splitTransfer.destinationAccount.userEmail
375
+ }), /*#__PURE__*/jsx(Typography, {
376
+ style: "body1",
377
+ weight: "medium",
378
+ children: t("neetoPayments.common.payoutStatus")
379
+ }), /*#__PURE__*/jsx(Status, {
380
+ status: splitTransfer.destinationPayout?.status,
381
+ type: "payout"
382
+ }), /*#__PURE__*/jsx(Typography, {
383
+ style: "body1",
384
+ weight: "medium",
385
+ children: t("neetoPayments.splitTransferDetails.payoutInitiatedDate")
386
+ }), /*#__PURE__*/jsx(Date, {
387
+ date: splitTransfer.destinationPayout?.createdAt
388
+ }), /*#__PURE__*/jsx(Typography, {
389
+ style: "body1",
390
+ weight: "medium",
391
+ children: t("neetoPayments.splitTransferDetails.payoutArrivalDate")
392
+ }), /*#__PURE__*/jsx(Date, {
393
+ date: splitTransfer.destinationPayout?.arrivalDate
394
+ }), /*#__PURE__*/jsx("div", {})]
395
+ })]
396
+ })
397
+ })]
398
+ });
399
+ };
400
+
401
+ const renderIdentifier = curry((setSelectedTransfer, identifier, {
402
+ id
403
+ }) => {
404
+ if (isNotPresent(identifier)) {
405
+ return /*#__PURE__*/jsx(Tooltip, {
406
+ content: t("neetoPayments.tooltipContent.identifierUnavailable"),
407
+ position: "top",
408
+ children: /*#__PURE__*/jsx("div", {
409
+ className: "text-center",
410
+ children: /*#__PURE__*/jsx(Typography, {
411
+ style: "body2",
412
+ children: t("neetoPayments.common.notAvailable")
413
+ })
414
+ })
415
+ });
416
+ }
417
+ return /*#__PURE__*/jsx(CopyButtonWrapper, {
418
+ content: identifier,
419
+ children: /*#__PURE__*/jsx(Button, {
420
+ label: identifier,
421
+ size: "small",
422
+ style: "link",
423
+ onClick: () => setSelectedTransfer({
424
+ id,
425
+ isPaneOpen: true
426
+ })
427
+ })
428
+ });
429
+ });
430
+ const renderPlatformPaymentIdentifier = ({
431
+ identifier,
432
+ receiptUrl,
433
+ kind
434
+ }) => {
435
+ if (kind === PAYMENT_KIND.temporary) {
436
+ return /*#__PURE__*/jsx(CopyButtonWrapper, {
437
+ content: identifier,
438
+ children: identifier
439
+ });
440
+ }
441
+ return /*#__PURE__*/jsx(CopyButtonWrapper, {
442
+ content: identifier,
443
+ children: /*#__PURE__*/jsx(Button, {
444
+ href: receiptUrl,
445
+ label: identifier,
446
+ size: "small",
447
+ style: "link",
448
+ target: "_blank"
449
+ })
450
+ });
451
+ };
452
+ const renderDestinationAccountIdentifier = ({
453
+ identifier,
454
+ dashboardUrl
455
+ }) => /*#__PURE__*/jsx(CopyButtonWrapper, {
456
+ content: identifier,
457
+ children: /*#__PURE__*/jsx(Button, {
458
+ href: dashboardUrl,
459
+ label: identifier,
460
+ size: "small",
461
+ style: "link",
462
+ target: "_blank"
463
+ })
464
+ });
465
+ const renderStatus = curry((type, status) => /*#__PURE__*/jsx(Status, {
466
+ status,
467
+ type
468
+ }));
469
+ const renderDate = date => {
470
+ if (isNotPresent(date)) {
471
+ return /*#__PURE__*/jsx(Tooltip, {
472
+ content: t("neetoPayments.tooltipContent.dateUnavailable"),
473
+ position: "top",
474
+ children: /*#__PURE__*/jsx("div", {
475
+ className: "text-center",
476
+ children: /*#__PURE__*/jsx(Typography, {
477
+ style: "body2",
478
+ children: t("neetoPayments.common.notAvailable")
479
+ })
480
+ })
481
+ });
482
+ }
483
+ return /*#__PURE__*/jsx(DateFormat.DateTime, {
484
+ date
485
+ });
486
+ };
487
+ const renderPlatformShare = amount => {
488
+ if (isNotPresent(amount)) {
489
+ return /*#__PURE__*/jsx(Tooltip, {
490
+ content: t("neetoPayments.tooltipContent.platformShareUnavailable"),
491
+ position: "top",
492
+ children: /*#__PURE__*/jsx(Typography, {
493
+ style: "body2",
494
+ children: t("neetoPayments.common.notCalculated")
495
+ })
496
+ });
497
+ }
498
+ return formatAmount(amount);
499
+ };
500
+ const getDefaultColumns = setSelectedTransfer => [{
501
+ title: t("neetoPayments.common.id"),
502
+ dataIndex: "rowId",
503
+ key: "rowId",
504
+ width: 85,
505
+ position: 0,
506
+ isHidable: false
507
+ }, {
508
+ title: t("neetoPayments.common.identifier"),
509
+ dataIndex: "identifier",
510
+ key: "identifier",
511
+ width: 300,
512
+ render: renderIdentifier(setSelectedTransfer),
513
+ position: 1,
514
+ isHidable: false
515
+ }, {
516
+ title: t("neetoPayments.common.status"),
517
+ dataIndex: "status",
518
+ key: "status",
519
+ width: 150,
520
+ render: renderStatus("splitTransfers"),
521
+ sorter: true,
522
+ position: 2,
523
+ isHidable: false
524
+ }, {
525
+ title: t("neetoPayments.common.amount"),
526
+ dataIndex: "amount",
527
+ key: "amount",
528
+ width: 150,
529
+ sorter: true,
530
+ render: formatAmount,
531
+ position: 3
532
+ }, {
533
+ title: t("neetoPayments.common.currency"),
534
+ dataIndex: "currency",
535
+ key: "currency",
536
+ width: 160,
537
+ sorter: true,
538
+ render: formatCurrency,
539
+ position: 3
540
+ }, {
541
+ title: t("neetoPayments.common.platformShare"),
542
+ dataIndex: "platformShare",
543
+ key: "platformShare",
544
+ width: 205,
545
+ render: renderPlatformShare,
546
+ sorter: true,
547
+ position: 3
548
+ }, {
549
+ title: t("neetoPayments.common.transferTime"),
550
+ dataIndex: "paymentAt",
551
+ key: "paymentAt",
552
+ width: 190,
553
+ render: renderDate,
554
+ sorter: true,
555
+ position: 10
556
+ }, {
557
+ title: t("neetoPayments.common.platformPayment"),
558
+ dataIndex: "sourcePayment",
559
+ key: "sourcePayment",
560
+ render: renderPlatformPaymentIdentifier,
561
+ width: 300,
562
+ position: 19
563
+ }, {
564
+ title: t("neetoPayments.common.accountIdentifier"),
565
+ dataIndex: "destinationAccount",
566
+ key: "destinationAccount",
567
+ render: renderDestinationAccountIdentifier,
568
+ width: 320,
569
+ position: 20
570
+ }];
571
+
572
+ const buildSearchProps = (searchProps, searchTerm) => mergeDeepWith(concat, SEARCH_PROPS, mergeLeft({
573
+ value: searchTerm.trim()
574
+ }, searchProps));
575
+ const buildFilterColumns = (payableEntityColumns = []) => reject(isNil, concat(FILTER_COLUMNS, map(prop("filterProps"), payableEntityColumns)));
576
+ const buildTableColumns = ({
577
+ tab,
578
+ payableEntityColumns = [],
579
+ setSelectedTransfer
580
+ }) => {
581
+ const filteredColumns = sortBy(prop("position"), concat(getDefaultColumns(setSelectedTransfer), payableEntityColumns));
582
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all) return filteredColumns;
583
+ return removeBy({
584
+ key: "status"
585
+ }, filteredColumns);
586
+ };
587
+ const buildRowData = ({
588
+ splitTransfers,
589
+ pageProperties = {}
590
+ }) => splitTransfers?.map((element, index) => ({
591
+ ...element,
592
+ rowId: isEmpty(pageProperties) ? index + 1 : pageProperties.pageSize * (pageProperties.page - 1) + index + 1
593
+ }));
594
+
595
+ const List = ({
596
+ isFetching,
597
+ splitTransfers,
598
+ selectedRows,
599
+ views,
600
+ payableEntityColumns,
601
+ pageProperties,
602
+ onRowSelect,
603
+ setSortProperties,
604
+ handleTablePagination,
605
+ setHasBulkSelectedAllRows
606
+ }) => {
607
+ const [selectedTransfer, setSelectedTransfer] = useState(INITIAL_TRANSFER_DETAILS);
608
+ const {
609
+ t
610
+ } = useTranslation();
611
+ const {
612
+ tab = SPLIT_TRANSFERS_DASHBOARD_TAB.all
613
+ } = getQueryParams();
614
+ const splitTransfersCount = views[tab];
615
+ const getRowSelection = () => {
616
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.successful) return false;
617
+ if (tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all) {
618
+ return {
619
+ getCheckboxProps: record => ({
620
+ disabled: record.status === SPLIT_TRANSFERS_DASHBOARD_TAB.successful
621
+ })
622
+ };
623
+ }
624
+ return true;
625
+ };
626
+ const allColumns = buildTableColumns({
627
+ tab,
628
+ payableEntityColumns,
629
+ setSelectedTransfer
630
+ });
631
+ const {
632
+ isTableConfigurationLoading,
633
+ customizedColumns,
634
+ hideColumn
635
+ } = useTableConfigurations(`${TABLE_KEYS.SPLIT_TRANSFERS_TABLE}-${tab}`, allColumns);
636
+ const handleTableChange = (_, __, sorter) => {
637
+ setSortProperties(isPresent(sorter?.column) ? {
638
+ sortBy: camelToSnakeCase(processDataIndex(sorter.field)),
639
+ orderBy: sorter.order === "ascend" ? "ASC" : "DESC"
640
+ } : DEFAULT_SORT_PROPERTIES);
641
+ };
642
+ if (isNotPresent(splitTransfers)) {
643
+ return /*#__PURE__*/jsx("div", {
644
+ className: "flex h-full w-full items-center justify-center",
645
+ children: /*#__PURE__*/jsx(NoData, {
646
+ title: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.emptyState.splitTransfers") : t("neetoPayments.emptyState.splitTransfersWithStatus", {
647
+ status: tab
648
+ })
649
+ })
650
+ });
651
+ }
652
+ return /*#__PURE__*/jsxs(Fragment, {
653
+ children: [/*#__PURE__*/jsx(TableWrapper, {
654
+ hasPagination: splitTransfersCount > pageProperties?.pageSize,
655
+ children: /*#__PURE__*/jsx(Table, {
656
+ onRowSelect,
657
+ fixedHeight: true,
658
+ allowRowClick: false,
659
+ columnData: customizedColumns,
660
+ currentPageNumber: pageProperties?.page,
661
+ handlePageChange: handleTablePagination,
662
+ loading: isFetching || isTableConfigurationLoading,
663
+ rowData: buildRowData({
664
+ splitTransfers,
665
+ pageProperties,
666
+ tab
667
+ }),
668
+ rowSelection: getRowSelection(),
669
+ selectedRowKeys: selectedRows,
670
+ sortDirections: SORT_DIRECTIONS,
671
+ totalCount: splitTransfersCount,
672
+ bulkSelectAllRowsProps: {
673
+ selectAllRowMessage: t("neetoPayments.splitTransferDetails.selectedSplitTransfers", {
674
+ count: selectedRows.length
675
+ }),
676
+ selectAllRowButtonLabel: t("neetoPayments.splitTransferDetails.selectAll", {
677
+ count: views[SPLIT_TRANSFERS_DASHBOARD_TAB.pending]
678
+ }),
679
+ setBulkSelectedAllRows: setHasBulkSelectedAllRows
680
+ },
681
+ paginationProps: {
682
+ showSizeChanger: true,
683
+ hideOnSinglePage: true,
684
+ pageSize: pageProperties?.pageSize,
685
+ total: splitTransfersCount
686
+ },
687
+ onChange: handleTableChange,
688
+ onColumnHide: ({
689
+ key
690
+ }) => hideColumn(key)
691
+ })
692
+ }), /*#__PURE__*/jsx(Details, {
693
+ selectedTransfer,
694
+ setSelectedTransfer
695
+ })]
696
+ });
697
+ };
698
+
699
+ const ResumeModal = ({
700
+ isOpen,
701
+ onClose,
702
+ handleSplitTransfersUpdate
703
+ }) => {
704
+ const {
705
+ t
706
+ } = useTranslation();
707
+ const handleSubmit = ({
708
+ reason
709
+ }) => {
710
+ handleSplitTransfersUpdate("pending", reason);
711
+ };
712
+ return /*#__PURE__*/jsxs(Modal, {
713
+ isOpen,
714
+ onClose,
715
+ size: "large",
716
+ children: [/*#__PURE__*/jsx(Modal.Header, {
717
+ children: /*#__PURE__*/jsx(Typography, {
718
+ style: "h2",
719
+ weight: "medium",
720
+ children: t("neetoPayments.resumeSplitTransfers.modal.title")
721
+ })
722
+ }), /*#__PURE__*/jsx(Form, {
723
+ formikProps: {
724
+ initialValues: {
725
+ reason: ""
726
+ },
727
+ validationSchema: VALIDATION_SCHEMA,
728
+ onSubmit: handleSubmit
729
+ },
730
+ children: /*#__PURE__*/jsxs(Fragment, {
731
+ children: [/*#__PURE__*/jsx(Modal.Body, {
732
+ children: /*#__PURE__*/jsx("div", {
733
+ className: "flex flex-col space-y-4",
734
+ children: /*#__PURE__*/jsx(Textarea, {
735
+ required: true,
736
+ label: t("neetoPayments.resumeSplitTransfers.modal.reason"),
737
+ name: "reason"
738
+ })
739
+ })
740
+ }), /*#__PURE__*/jsx(Modal.Footer, {
741
+ children: /*#__PURE__*/jsx(ActionBlock, {
742
+ position: "right",
743
+ cancelButtonProps: {
744
+ onClick: onClose,
745
+ style: "tertiary"
746
+ },
747
+ submitButtonProps: {
748
+ disabled: false,
749
+ label: t("neetoPayments.common.submit")
750
+ }
751
+ })
752
+ })]
753
+ })
754
+ })]
755
+ });
756
+ };
757
+
758
+ const {
759
+ Menu,
760
+ MenuItem
761
+ } = Dropdown;
762
+ const TopSection = ({
763
+ views,
764
+ filters,
765
+ setIsCancelModalOpen,
766
+ setIsResumeModalOpen,
767
+ selectedRows,
768
+ selectedRowData,
769
+ setFilters,
770
+ hasBulkSelectedAllRows,
771
+ filterableColumns,
772
+ searchKeywordProps,
773
+ payableEntityColumns,
774
+ setIsExportModalOpen
775
+ }) => {
776
+ const [isFilterPaneOpen, setIsFilterPaneOpen] = useState(false);
777
+ const {
778
+ t
779
+ } = useTranslation();
780
+ const history = useHistory();
781
+ const {
782
+ tab = SPLIT_TRANSFERS_DASHBOARD_TAB.all
783
+ } = getQueryParams();
784
+ const splitTransfersCount = views?.[tab];
785
+ const splitTransfersCountVisible = splitTransfersCount > 0 || splitTransfersCount === 0 && isPresent(filters);
786
+ const isFilterButtonVisible = splitTransfersCount || isPresent(filters);
787
+ const isDropdownVisible = isNotEmpty(selectedRows);
788
+ const isCancelButtonDisabled = existsBy({
789
+ status: SPLIT_TRANSFERS_DASHBOARD_TAB.cancelled
790
+ }, selectedRowData);
791
+ const isResumeButtonDisabled = existsBy({
792
+ status: SPLIT_TRANSFERS_DASHBOARD_TAB.pending
793
+ }, selectedRowData);
794
+ const selectedRecordsCount = hasBulkSelectedAllRows ? splitTransfersCount : selectedRows.length;
795
+ const handleFiltersChange = filters => {
796
+ startTransition(() => {
797
+ setFilters(filters);
798
+ });
799
+ };
800
+ const handleTabChange = tab => {
801
+ const queryParams = getQueryParams({
802
+ toCamelCase: false
803
+ });
804
+ const newParams = {
805
+ tab,
806
+ page: DEFAULT_PAGE_INDEX,
807
+ page_size: DEFAULT_PAGE_SIZE
808
+ };
809
+ history.push(buildUrl(window.location.pathname, mergeLeft(newParams, queryParams)));
810
+ };
811
+ return /*#__PURE__*/jsxs(Fragment, {
812
+ children: [/*#__PURE__*/jsx(Header, {
813
+ title: t("neetoPayments.title.splitTransfers"),
814
+ searchProps: isFilterButtonVisible && {
815
+ placeholder: searchKeywordProps.placeholder,
816
+ className: "w-96"
817
+ }
818
+ }), shouldTabsVisible(views) && /*#__PURE__*/jsx(Tab, {
819
+ children: Object.keys(SPLIT_TRANSFERS_DASHBOARD_TAB).map(item => /*#__PURE__*/jsx(Tab.Item, {
820
+ active: tab === item,
821
+ onClick: () => handleTabChange(item),
822
+ children: t(`neetoPayments.common.${item}`)
823
+ }, item))
824
+ }), /*#__PURE__*/jsx(SubHeader, {
825
+ className: "my-4",
826
+ leftActionBlock: splitTransfersCountVisible && /*#__PURE__*/jsx("div", {
827
+ className: "w-100 flex items-center space-x-3",
828
+ children: isDropdownVisible ? /*#__PURE__*/jsxs(Fragment, {
829
+ children: [/*#__PURE__*/jsx(Typography, {
830
+ className: "neeto-ui-gray-800 me-2 font-semibold",
831
+ component: "h4",
832
+ children: /*#__PURE__*/jsx(Trans, {
833
+ count: selectedRecordsCount,
834
+ i18nKey: "neetoPayments.splitTransferDetails.recordWithCount",
835
+ components: {
836
+ span: /*#__PURE__*/jsx("span", {
837
+ className: "neeto-ui-text-gray-600"
838
+ })
839
+ },
840
+ values: {
841
+ count: selectedRecordsCount,
842
+ recordsCount: splitTransfersCount
843
+ }
844
+ })
845
+ }), /*#__PURE__*/jsxs(Dropdown, {
846
+ buttonStyle: "secondary",
847
+ label: t("neetoPayments.common.takeAction"),
848
+ children: [/*#__PURE__*/jsx(Menu, {
849
+ children: /*#__PURE__*/jsx(MenuItem.Button, {
850
+ isDisabled: isCancelButtonDisabled,
851
+ tooltipProps: isCancelButtonDisabled ? {
852
+ content: t("neetoPayments.tooltipContent.splitTransfers.cancelledRecordsSelected")
853
+ } : "",
854
+ onClick: () => setIsCancelModalOpen(true),
855
+ children: t("neetoPayments.common.cancel")
856
+ })
857
+ }), /*#__PURE__*/jsx(Menu, {
858
+ children: /*#__PURE__*/jsx(MenuItem.Button, {
859
+ isDisabled: isResumeButtonDisabled,
860
+ tooltipProps: isResumeButtonDisabled ? {
861
+ content: t("neetoPayments.tooltipContent.splitTransfers.pendingRecordsSelected")
862
+ } : "",
863
+ onClick: () => setIsResumeModalOpen(true),
864
+ children: t("neetoPayments.common.resume")
865
+ })
866
+ })]
867
+ })]
868
+ }) : /*#__PURE__*/jsx(Typography, {
869
+ className: "neeto-ui-gray-800 me-2 font-semibold",
870
+ component: "h4",
871
+ children: tab === SPLIT_TRANSFERS_DASHBOARD_TAB.all ? t("neetoPayments.countOf.splitTransfer", {
872
+ count: splitTransfersCount
873
+ }) : t("neetoPayments.countOf.splitTransferWithStatus", {
874
+ count: splitTransfersCount,
875
+ status: tab
876
+ })
877
+ })
878
+ }),
879
+ rightActionBlock: isFilterButtonVisible && /*#__PURE__*/jsx(SubHeader.RightBlock, {
880
+ columnsButtonProps: {
881
+ columnData: buildTableColumns({
882
+ tab,
883
+ payableEntityColumns,
884
+ setSelectedTransfer: () => {}
885
+ }).map(modify("dataIndex", processDataIndex)),
886
+ fixedColumns: UN_HIDEABLE_COLUMNS,
887
+ tableKey: `${TABLE_KEYS.SPLIT_TRANSFERS_TABLE}-${tab}`
888
+ },
889
+ downloadButtonProps: {
890
+ onClick: () => setIsExportModalOpen(true)
891
+ },
892
+ filterProps: {
893
+ columns: filterableColumns,
894
+ isOpen: isFilterPaneOpen,
895
+ keyword: searchKeywordProps,
896
+ setIsOpen: setIsFilterPaneOpen,
897
+ onChange: handleFiltersChange
898
+ }
899
+ })
900
+ }), /*#__PURE__*/jsx(Bar, {
901
+ columns: filterableColumns,
902
+ keyword: searchKeywordProps,
903
+ setIsPaneOpen: setIsFilterPaneOpen,
904
+ onChange: handleFiltersChange
905
+ })]
906
+ });
907
+ };
908
+
909
+ const SplitTransfersDashboard = ({
910
+ searchProps,
911
+ payableEntityColumns
912
+ }) => {
913
+ const {
914
+ searchTerm = ""
915
+ } = getQueryParams();
916
+ const filterableColumns = buildFilterColumns(payableEntityColumns);
917
+ const searchKeywordProps = buildSearchProps(searchProps, searchTerm);
918
+ const [selectedRows, setSelectedRows] = useState([]);
919
+ const [selectedRowData, setSelectedRowData] = useState([]);
920
+ const [isExportModalOpen, setIsExportModalOpen] = useState(false);
921
+ const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
922
+ const [isResumeModalOpen, setIsResumeModalOpen] = useState(false);
923
+ const [hasBulkSelectedAllRows, setHasBulkSelectedAllRows] = useState(false);
924
+ const [sortProperties, setSortProperties] = useState(DEFAULT_SORT_PROPERTIES);
925
+ const [pageProperties, setPageProperties] = useState(DEFAULT_PAGE_VALUES);
926
+ const [filters, setFilters] = useState(buildFiltersFromURL([...filterableColumns, searchKeywordProps]));
927
+ const history = useHistory();
928
+ const {
929
+ tab = SPLIT_TRANSFERS_DASHBOARD_TAB.all
930
+ } = getQueryParams();
931
+ const payload = {
932
+ tab,
933
+ filters,
934
+ ...pageProperties,
935
+ ...sortProperties
936
+ };
937
+ const {
938
+ data: {
939
+ splitTransfers,
940
+ views
941
+ } = {},
942
+ isFetching,
943
+ isPending: isSplitTransfersLoading
944
+ } = useFetchSplitTransfers(payload);
945
+ const {
946
+ mutate: updateSplitTransfers,
947
+ isPending: isCancelling
948
+ } = useBulkUpdateSplitTransfers({
949
+ onSuccess: () => {
950
+ setSelectedRowData([]);
951
+ setSelectedRows([]);
952
+ }
953
+ });
954
+ const handleSplitTransfersUpdate = (status, reason) => {
955
+ const ids = pluck("id", selectedRowData);
956
+ updateSplitTransfers({
957
+ ids,
958
+ status,
959
+ reason,
960
+ isApplyChangesToAllRequired: hasBulkSelectedAllRows
961
+ });
962
+ setIsCancelModalOpen(false);
963
+ setIsResumeModalOpen(false);
964
+ };
965
+ const handleTablePagination = (page, pageSize) => {
966
+ const queryParams = getQueryParams({
967
+ toCamelCase: false
968
+ });
969
+ history.push(buildUrl(window.location.pathname, mergeLeft({
970
+ page,
971
+ page_size: pageSize
972
+ }, queryParams)));
973
+ setPageProperties({
974
+ page,
975
+ pageSize
976
+ });
977
+ };
978
+ const handleRowSelect = (keys, rowData) => {
979
+ setSelectedRows(keys);
980
+ setSelectedRowData(rowData);
981
+ };
982
+ useEffect(() => {
983
+ handleTablePagination(DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE);
984
+ setSortProperties(DEFAULT_SORT_PROPERTIES);
985
+ setSelectedRowData([]);
986
+ setSelectedRows([]);
987
+ }, [filters, tab]);
988
+ if (isSplitTransfersLoading || isCancelling) {
989
+ return /*#__PURE__*/jsx("div", {
990
+ className: "flex h-full w-full items-center justify-center",
991
+ children: /*#__PURE__*/jsx(Spinner, {})
992
+ });
993
+ }
994
+ return /*#__PURE__*/jsxs(Fragment, {
995
+ children: [/*#__PURE__*/jsx(TopSection, {
996
+ filterableColumns,
997
+ filters,
998
+ hasBulkSelectedAllRows,
999
+ pageProperties,
1000
+ payableEntityColumns,
1001
+ searchKeywordProps,
1002
+ selectedRowData,
1003
+ selectedRows,
1004
+ setFilters,
1005
+ setIsCancelModalOpen,
1006
+ setIsExportModalOpen,
1007
+ setIsResumeModalOpen,
1008
+ setPageProperties,
1009
+ setSortProperties,
1010
+ views
1011
+ }), /*#__PURE__*/jsx(List, {
1012
+ handleTablePagination,
1013
+ isFetching,
1014
+ pageProperties,
1015
+ payableEntityColumns,
1016
+ selectedRows,
1017
+ setHasBulkSelectedAllRows,
1018
+ setSelectedRows,
1019
+ setSortProperties,
1020
+ splitTransfers,
1021
+ views,
1022
+ onRowSelect: handleRowSelect
1023
+ }), /*#__PURE__*/jsx(ExportModal, {
1024
+ filters,
1025
+ isExportModalOpen,
1026
+ setIsExportModalOpen,
1027
+ sortProperties,
1028
+ dashboardKind: DASHBOARD_KIND.splitTransfers
1029
+ }), /*#__PURE__*/jsx(CancelModal, {
1030
+ handleSplitTransfersUpdate,
1031
+ isOpen: isCancelModalOpen,
1032
+ onClose: () => setIsCancelModalOpen(false)
1033
+ }), /*#__PURE__*/jsx(ResumeModal, {
1034
+ handleSplitTransfersUpdate,
1035
+ isOpen: isResumeModalOpen,
1036
+ onClose: () => setIsResumeModalOpen(false)
1037
+ })]
1038
+ });
1039
+ };
1040
+
1041
+ export { SplitTransfersDashboard as default };
1042
+ //# sourceMappingURL=SplitTransfersDashboard.js.map