@bigbinary/neeto-payments-frontend 1.5.0-beta1 → 1.6.0-beta2

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 (157) hide show
  1. package/README.md +4 -95
  2. package/app/javascript/src/translations/en.json +0 -15
  3. package/dist/AccountsDashboard.js +477 -0
  4. package/dist/AccountsDashboard.js.map +1 -0
  5. package/dist/Dashboard.js +598 -0
  6. package/dist/Dashboard.js.map +1 -0
  7. package/dist/ExportModal-85725c35.js +645 -0
  8. package/dist/ExportModal-85725c35.js.map +1 -0
  9. package/dist/IdentifierButton-73cadb18.js +20 -0
  10. package/dist/IdentifierButton-73cadb18.js.map +1 -0
  11. package/dist/PaymentKindRestrictionAlert.js +34 -0
  12. package/dist/PaymentKindRestrictionAlert.js.map +1 -0
  13. package/dist/PayoutsDashboard.js +503 -0
  14. package/dist/PayoutsDashboard.js.map +1 -0
  15. package/dist/PayoutsPage.js +185 -0
  16. package/dist/PayoutsPage.js.map +1 -0
  17. package/dist/RazorpayDashboard.js +251 -0
  18. package/dist/RazorpayDashboard.js.map +1 -0
  19. package/dist/RazorpayPaymentButton.js +111 -0
  20. package/dist/RazorpayPaymentButton.js.map +1 -0
  21. package/dist/StripeConnect.js +2071 -0
  22. package/dist/StripeConnect.js.map +1 -0
  23. package/dist/U2TDTBMY-c464dc98.js +12081 -0
  24. package/dist/U2TDTBMY-c464dc98.js.map +1 -0
  25. package/dist/UpiConnect.js +148 -0
  26. package/dist/UpiConnect.js.map +1 -0
  27. package/dist/UpiMarkAsPaidButton.js +42 -0
  28. package/dist/UpiMarkAsPaidButton.js.map +1 -0
  29. package/dist/UpiPayment.js +94 -0
  30. package/dist/UpiPayment.js.map +1 -0
  31. package/dist/V2PaymentsDashboard.js +302 -0
  32. package/dist/V2PaymentsDashboard.js.map +1 -0
  33. package/dist/buildStripeTransactionLink.js +6 -0
  34. package/dist/buildStripeTransactionLink.js.map +1 -0
  35. package/dist/cjs/AccountsDashboard.js +494 -0
  36. package/dist/cjs/AccountsDashboard.js.map +1 -0
  37. package/dist/cjs/Dashboard.js +613 -0
  38. package/dist/cjs/Dashboard.js.map +1 -0
  39. package/dist/cjs/ExportModal-20f368a1.js +669 -0
  40. package/dist/cjs/ExportModal-20f368a1.js.map +1 -0
  41. package/dist/cjs/IdentifierButton-40b5459d.js +27 -0
  42. package/dist/cjs/IdentifierButton-40b5459d.js.map +1 -0
  43. package/dist/cjs/PaymentKindRestrictionAlert.js +41 -0
  44. package/dist/cjs/PaymentKindRestrictionAlert.js.map +1 -0
  45. package/dist/cjs/PayoutsDashboard.js +519 -0
  46. package/dist/cjs/PayoutsDashboard.js.map +1 -0
  47. package/dist/cjs/PayoutsPage.js +194 -0
  48. package/dist/cjs/PayoutsPage.js.map +1 -0
  49. package/dist/cjs/RazorpayDashboard.js +262 -0
  50. package/dist/cjs/RazorpayDashboard.js.map +1 -0
  51. package/dist/cjs/RazorpayPaymentButton.js +118 -0
  52. package/dist/cjs/RazorpayPaymentButton.js.map +1 -0
  53. package/dist/cjs/StripeConnect.js +2106 -0
  54. package/dist/cjs/StripeConnect.js.map +1 -0
  55. package/dist/cjs/U2TDTBMY-e2fad970.js +12083 -0
  56. package/dist/cjs/U2TDTBMY-e2fad970.js.map +1 -0
  57. package/dist/cjs/UpiConnect.js +181 -0
  58. package/dist/cjs/UpiConnect.js.map +1 -0
  59. package/dist/cjs/UpiMarkAsPaidButton.js +49 -0
  60. package/dist/cjs/UpiMarkAsPaidButton.js.map +1 -0
  61. package/dist/cjs/UpiPayment.js +124 -0
  62. package/dist/cjs/UpiPayment.js.map +1 -0
  63. package/dist/cjs/V2PaymentsDashboard.js +313 -0
  64. package/dist/cjs/V2PaymentsDashboard.js.map +1 -0
  65. package/dist/cjs/buildStripeTransactionLink.js +11 -0
  66. package/dist/cjs/buildStripeTransactionLink.js.map +1 -0
  67. package/dist/cjs/constants.js +495 -0
  68. package/dist/cjs/constants.js.map +1 -0
  69. package/dist/cjs/exportChannel-7bd80952.js +39 -0
  70. package/dist/cjs/exportChannel-7bd80952.js.map +1 -0
  71. package/dist/cjs/extends-1b35a664.js +19 -0
  72. package/dist/cjs/extends-1b35a664.js.map +1 -0
  73. package/dist/cjs/index-b097dce8.js +41 -0
  74. package/dist/cjs/index-b097dce8.js.map +1 -0
  75. package/dist/cjs/index-b7badf96.js +88 -0
  76. package/dist/cjs/index-b7badf96.js.map +1 -0
  77. package/dist/cjs/index.js +100 -0
  78. package/dist/cjs/index.js.map +1 -0
  79. package/dist/cjs/mutation-ed7b84fc.js +235 -0
  80. package/dist/cjs/mutation-ed7b84fc.js.map +1 -0
  81. package/dist/cjs/queryConstants-de21eed5.js +944 -0
  82. package/dist/cjs/queryConstants-de21eed5.js.map +1 -0
  83. package/dist/cjs/renderFunctions-398d3fb5.js +3719 -0
  84. package/dist/cjs/renderFunctions-398d3fb5.js.map +1 -0
  85. package/dist/cjs/stripe.esm-4218a1e9.js.map +1 -0
  86. package/dist/cjs/useConnectApi-f0665633.js +2189 -0
  87. package/dist/cjs/useConnectApi-f0665633.js.map +1 -0
  88. package/dist/cjs/useFiltersAndPagination-312c0331.js +277 -0
  89. package/dist/cjs/useFiltersAndPagination-312c0331.js.map +1 -0
  90. package/dist/cjs/useMutation-4c7cdbe1.js +154 -0
  91. package/dist/cjs/useMutation-4c7cdbe1.js.map +1 -0
  92. package/dist/cjs/usePaymentApi-ae70e5df.js +48 -0
  93. package/dist/cjs/usePaymentApi-ae70e5df.js.map +1 -0
  94. package/dist/cjs/usePaymentsApi-815be3da.js +36 -0
  95. package/dist/cjs/usePaymentsApi-815be3da.js.map +1 -0
  96. package/dist/cjs/usePlatformApi-830827fa.js +116 -0
  97. package/dist/cjs/usePlatformApi-830827fa.js.map +1 -0
  98. package/dist/cjs/useRazorpayPayment.js +91 -0
  99. package/dist/cjs/useRazorpayPayment.js.map +1 -0
  100. package/dist/cjs/useStripePromise.js +27 -0
  101. package/dist/cjs/useStripePromise.js.map +1 -0
  102. package/dist/cjs/utils-7eba34a4.js +664 -0
  103. package/dist/cjs/utils-7eba34a4.js.map +1 -0
  104. package/dist/constants.js +480 -0
  105. package/dist/constants.js.map +1 -0
  106. package/dist/exportChannel-250e6f14.js +32 -0
  107. package/dist/exportChannel-250e6f14.js.map +1 -0
  108. package/dist/extends-093996c9.js +17 -0
  109. package/dist/extends-093996c9.js.map +1 -0
  110. package/dist/index-1aedc364.js +80 -0
  111. package/dist/index-1aedc364.js.map +1 -0
  112. package/dist/index-48f8b281.js +32 -0
  113. package/dist/index-48f8b281.js.map +1 -0
  114. package/dist/index.js +77 -12558
  115. package/dist/index.js.map +1 -1
  116. package/dist/mutation-286611ef.js +232 -0
  117. package/dist/mutation-286611ef.js.map +1 -0
  118. package/dist/queryConstants-765c8816.js +920 -0
  119. package/dist/queryConstants-765c8816.js.map +1 -0
  120. package/dist/renderFunctions-97b121a4.js +3633 -0
  121. package/dist/renderFunctions-97b121a4.js.map +1 -0
  122. package/dist/useConnectApi-87335bf6.js +2174 -0
  123. package/dist/useConnectApi-87335bf6.js.map +1 -0
  124. package/dist/useFiltersAndPagination-2ab7bc8f.js +262 -0
  125. package/dist/useFiltersAndPagination-2ab7bc8f.js.map +1 -0
  126. package/dist/useMutation-8d67f853.js +132 -0
  127. package/dist/useMutation-8d67f853.js.map +1 -0
  128. package/dist/usePaymentApi-12737871.js +41 -0
  129. package/dist/usePaymentApi-12737871.js.map +1 -0
  130. package/dist/usePaymentsApi-a801ab15.js +29 -0
  131. package/dist/usePaymentsApi-a801ab15.js.map +1 -0
  132. package/dist/usePlatformApi-8adc2a50.js +104 -0
  133. package/dist/usePlatformApi-8adc2a50.js.map +1 -0
  134. package/dist/useRazorpayPayment.js +89 -0
  135. package/dist/useRazorpayPayment.js.map +1 -0
  136. package/dist/useStripePromise.js +25 -0
  137. package/dist/useStripePromise.js.map +1 -0
  138. package/dist/utils-e29db9c9.js +614 -0
  139. package/dist/utils-e29db9c9.js.map +1 -0
  140. package/package.json +18 -10
  141. package/types/AccountsDashboard.d.ts +3 -0
  142. package/types/Dashboard.d.ts +15 -0
  143. package/types/PaymentKindRestrictionAlert.d.ts +11 -0
  144. package/types/PayoutsDashboard.d.ts +10 -0
  145. package/types/PayoutsPage.d.ts +11 -0
  146. package/types/StripeConnect.d.ts +13 -0
  147. package/types/buildStripeTransactionLink.d.ts +6 -0
  148. package/types/useStripePromise.d.ts +5 -0
  149. package/types.d.ts +8 -75
  150. package/dist/index-042b6907.js +0 -6
  151. package/dist/index-042b6907.js.map +0 -1
  152. package/dist/index-87824935.js +0 -4
  153. package/dist/index-87824935.js.map +0 -1
  154. package/dist/index.cjs.js +0 -12633
  155. package/dist/index.cjs.js.map +0 -1
  156. package/dist/stripe.esm-4218a1e9.js.map +0 -1
  157. /package/dist/{stripe.esm-4218a1e9.js → cjs/stripe.esm-4218a1e9.js} +0 -0
package/README.md CHANGED
@@ -110,6 +110,10 @@ The engine is used to manage payments across neeto products.
110
110
  ### Usage
111
111
  You can learn more about setup and usage here:
112
112
  1. [Services](/docs/engine/services.md)
113
+ 2. [Stripe integration](/docs/engine/stripe_integrations.md)
114
+ 2. [Razorpay integration](/docs/engine/razorpay_integrations.md)
115
+ 3. [Stripe payment](/docs/engine/stripe_payment.md)
116
+ 4. [Razorpay payment](/docs/engine/razorpay_payment.md)
113
117
 
114
118
  ## Frontend package
115
119
  ### Installation
@@ -198,42 +202,6 @@ const App = () => {
198
202
  export default App;
199
203
  ```
200
204
 
201
- #### 3. `SquareCard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/SquareCard/index.jsx))
202
-
203
- **Props**
204
- - `card`: The Square card instance.
205
- - `setCard`: Function to set the Square card instance.
206
-
207
- **Optional Props**
208
- - `onChange`: Event handler function triggered on Square card events.
209
- - `id`: ID of the container element for the Square card. Defaults to `square-card-container`.
210
- - `options`: Configuration options for the Square card. Defaults to `{}`.
211
- - `disabled`: Disables pointer events if set to `true`. Defaults to `false`.
212
-
213
- **Usage**
214
- ```jsx
215
- import React, { useState } from "react";
216
- import { SquareCard } from "@bigbinary/neeto-payments-frontend";
217
-
218
- const App = () => {
219
- const [squareCard, setSquareCard] = useState(null);
220
- const handleCardChange = event => {
221
- // Handle Square card events
222
- };
223
-
224
- return (
225
- <SquareCard
226
- card={squareCard}
227
- setCard={setSquareCard}
228
- onChange={handleCardChange}
229
- disabled={false}
230
- />
231
- );
232
- };
233
-
234
- export default App;
235
- ```
236
-
237
205
  #### 4. `PayoutsDashboard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/PayoutsDashboard/index.jsx))
238
206
 
239
207
  **Props**
@@ -257,50 +225,6 @@ const App = () => {
257
225
  export default App;
258
226
  ```
259
227
 
260
- #### 5. `SquareDashboard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/SquareDashboard/index.jsx))
261
-
262
- **Props**
263
- - `searchProps`: To specify the search props to be passed to the neetoUI `Header`
264
- component used in the `Dashboard`.
265
-
266
- **Optional Props**
267
- - `holdableId`: To specify the ID of the entity that holds the stripe
268
- account. If the value is not specified, the current
269
- organization ID is taken as the default value while querying for
270
- transactions.
271
- - `payableEntityColumns`: To specify the columns from the payable entity
272
- which need to be additionally displayed. Defaults to `[]`.
273
- - `kind`: To specify the type of payment. Defaults to `squarePayment`.
274
- - `headerProps`: To specify the props to be passed to the neetoUI `Header`
275
- component used in the `Dashboard`. Defaults to `{}`.
276
-
277
- **Usage**
278
- ```jsx
279
- import React from "react";
280
- import { SquareDashboard } from "@bigbinary/neeto-payments-frontend";
281
-
282
- const App = () => {
283
- const searchProps = {
284
- placeholder: "Search...",
285
- };
286
-
287
- const headerProps = {
288
- className: "w-80",
289
- // Your header properties
290
- };
291
- return (
292
- <SquareDashboard
293
- searchProps={searchProps}
294
- headerProps={headerProps}
295
- kind="squarePayment"
296
- payableEntityColumns=[]
297
- />
298
- );
299
- };
300
-
301
- export default App;
302
- ```
303
-
304
228
  ### Hooks
305
229
  #### 1. `useStripePromise` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useStripePromise.js))
306
230
 
@@ -322,21 +246,6 @@ identifier as input and returns a `Promise`.
322
246
  </Elements>
323
247
  ```
324
248
 
325
- #### 2. `useSquareCard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useSquareCard.js))
326
-
327
- - This hook manages the state and functionality related to the Square card instance, providing methods for setting the card, accessing the current card instance, and tokenizing the card.
328
- - Usage in [neetoInvoice](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useSquareCard.js).
329
-
330
- **Returns**
331
- - `card`: The Square card instance.
332
- - `setCard`: Function to set the Square card instance.
333
- - `tokenizeCard`: Asynchronous function to tokenize the Square card instance. It returns a Promise that resolves to the tokenized card. If no card instance is found, a warning is logged, and an empty string is returned. If tokenization is successful, the token is returned. In case of errors during tokenization, an error is logged, and an empty string is returned.
334
-
335
- **Usage**
336
- ```jsx
337
- const { card, setCard, tokenizeCard } = useSquareCard();
338
- ```
339
-
340
249
  ### Functions
341
250
  #### 1. `buildStripeTransactionLink` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/utils/index.js#L3))
342
251
 
@@ -26,7 +26,6 @@
26
26
  "paymentIdentifier": "Payment identifier",
27
27
  "notAvailable": "-",
28
28
  "rejected": "Rejected",
29
- "squarePayments": "Square Payments",
30
29
  "razorpayPayments": "Razorpay payments",
31
30
  "upiPayments": "UPI payments",
32
31
  "completed": "Completed",
@@ -75,8 +74,6 @@
75
74
  "split": "Stripe split transfers",
76
75
  "transfer": "Stripe standard transactions",
77
76
  "refund": "Stripe refunds",
78
- "squarePayment": "Square payments",
79
- "squareRefund": "Square refunds",
80
77
  "account": "Standard accounts",
81
78
  "payouts": "Stripe payouts"
82
79
  },
@@ -93,10 +90,6 @@
93
90
  "refundWithStatus": "There are no {{status}} refunds.",
94
91
  "account": "There are no standard accounts.",
95
92
  "accountWithStatus": "There are no {{status}} standard accounts.",
96
- "squarePayment": "There are no payments.",
97
- "squarePaymentWithStatus": "There are no {{status}} payments.",
98
- "squareRefund": "There are no refunds.",
99
- "squareRefundWithStatus": "There are no {{status}} refunds.",
100
93
  "razorpayPayment": "There are no payments.",
101
94
  "razorpayPaymentWithStatus": "There are no {{status}} payments.",
102
95
  "upiPayment": "There are no payments.",
@@ -263,14 +256,6 @@
263
256
  "refund_other": "{{count}} refunds",
264
257
  "refundWithStatus": "{{count}} {{status}} refund",
265
258
  "refundWithStatus_other": "{{count}} {{status}} refunds",
266
- "squarePayment": "{{count}} payment",
267
- "squarePayment_other": "{{count}} payments",
268
- "squarePaymentWithStatus": "{{count}} {{status}} payment",
269
- "squarePaymentWithStatus_other": "{{count}} {{status}} payments",
270
- "squareRefund": "{{count}} refund",
271
- "squareRefund_other": "{{count}} refunds",
272
- "squareRefundWithStatus": "{{count}} {{status}} refund",
273
- "squareRefundWithStatus_other": "{{count}} {{status}} refunds",
274
259
  "account": "{{count}} standard account",
275
260
  "account_other": "{{count}} standard accounts",
276
261
  "accountWithStatus": "{{count}} {{status}} standard account",
@@ -0,0 +1,477 @@
1
+ import React__default, { useState, useMemo, useEffect, useTransition } from 'react';
2
+ import { t } from 'i18next';
3
+ import { capitalize, removeBy, isPresent, camelToSnakeCase } from '@bigbinary/neeto-cist';
4
+ import { useQueryParams, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
5
+ import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
6
+ import Header from '@bigbinary/neeto-molecules/Header';
7
+ import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
8
+ import Tab from '@bigbinary/neetoui/Tab';
9
+ import Typography from '@bigbinary/neetoui/Typography';
10
+ import { useTranslation } from 'react-i18next';
11
+ import { C as CopyButtonWrapper, r as renderStatus, a as renderFullName, b as renderEmail, c as renderDate, d as buildDefaultPageProperties, e as buildPayload, f as buildRowData, w as withReactQuery } from './renderFunctions-97b121a4.js';
12
+ import { Download } from '@bigbinary/neeto-icons';
13
+ import Button from '@bigbinary/neetoui/Button';
14
+ import Modal from '@bigbinary/neetoui/Modal';
15
+ import { u as useExportData, e as exportChannel } from './exportChannel-250e6f14.js';
16
+ import { u as uuidV4, b as buildStripeAccountLink } from './index-48f8b281.js';
17
+ import { getQueryParams, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
18
+ import { pipe, split, map, join, mergeLeft, assoc } from 'ramda';
19
+ import { useHistory } from 'react-router-dom';
20
+ import { DEFAULT_SORT_PROPERTIES, BASE_URL, SORT_DIRECTIONS } from './constants.js';
21
+ import { I as IdentifierButton } from './IdentifierButton-73cadb18.js';
22
+ import { DEFAULT_PAGE_SIZE, DEFAULT_PAGE_INDEX } from '@bigbinary/neeto-commons-frontend/constants';
23
+ import { useHiddenColumns } from '@bigbinary/neeto-molecules/Columns';
24
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
25
+ import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
26
+ import Table from '@bigbinary/neetoui/Table';
27
+ import NoData from '@bigbinary/neetoui/NoData';
28
+ import { u as useQuery, Q as QUERY_KEYS } from './queryConstants-765c8816.js';
29
+ import axios from 'axios';
30
+ import './utils-e29db9c9.js';
31
+ import 'react/jsx-runtime';
32
+ import './mutation-286611ef.js';
33
+ import '@bigbinary/neeto-molecules/DateFormat';
34
+ import '@bigbinary/neetoui/Tag';
35
+ import '@bigbinary/neetoui/Tooltip';
36
+ import '@bigbinary/neeto-molecules/CopyToClipboardButton';
37
+ import './useMutation-8d67f853.js';
38
+
39
+ const TAB = {
40
+ all: "all",
41
+ connected: "connected",
42
+ disconnected: "disconnected",
43
+ incomplete: "incomplete"
44
+ };
45
+ const TABS = Object.values(TAB);
46
+ const SEARCH_PROPS = {
47
+ key: "keyword",
48
+ node: "identifier,user.first_name,last_name,email",
49
+ model: "NeetoPaymentsEngine::Stripe::Account,User"
50
+ };
51
+ const DASHBOARD_MANDATORY_COLUMNS = ["id", "status", "identifier"];
52
+ const FILTER_COLUMNS = [{
53
+ key: "created_at",
54
+ label: t("neetoPayments.common.createdAt"),
55
+ node: "created_at",
56
+ type: "date",
57
+ showRuleSelector: true
58
+ }];
59
+ const STRIPE_ACCOUNTS_TABLE_HIDDEN_COLUMNS_STORAGE_KEY = "stripeAccountsDashboard";
60
+
61
+ const ExportModal = _ref => {
62
+ let {
63
+ showExportModal,
64
+ setShowExportModal,
65
+ tab,
66
+ filters,
67
+ sortProperties = {}
68
+ } = _ref;
69
+ const {
70
+ t
71
+ } = useTranslation();
72
+ const [downloadUrl, setDownloadUrl] = useState("");
73
+ const [isGenerating, setIsGenerating] = useState(false);
74
+ const {
75
+ mutate: exportCsv,
76
+ isLoading
77
+ } = useExportData();
78
+ const isFileLoading = isLoading || isGenerating;
79
+ const token = useMemo(() => `account-report-${uuidV4()}`, []);
80
+ const receivedCallback = data => {
81
+ if (!data.download_url) return;
82
+ setDownloadUrl(data.download_url);
83
+ setIsGenerating(false);
84
+ };
85
+ const handleGenerateClick = () => {
86
+ const payload = {
87
+ kind: "account",
88
+ token,
89
+ filters,
90
+ tab,
91
+ ...sortProperties
92
+ };
93
+ exportCsv(payload, {
94
+ onSuccess: () => {
95
+ setDownloadUrl("");
96
+ setIsGenerating(true);
97
+ }
98
+ });
99
+ };
100
+ useEffect(() => {
101
+ if (showExportModal) {
102
+ const channel = exportChannel(token, receivedCallback);
103
+ setDownloadUrl("");
104
+ setIsGenerating(false);
105
+ return () => {
106
+ channel.disconnected();
107
+ };
108
+ }
109
+ return undefined;
110
+ }, [showExportModal, token]);
111
+ const onClose = () => setShowExportModal(false);
112
+ return /*#__PURE__*/React__default.createElement(Modal, {
113
+ onClose,
114
+ isOpen: showExportModal
115
+ }, /*#__PURE__*/React__default.createElement(Modal.Header, null, /*#__PURE__*/React__default.createElement(Typography, {
116
+ style: "h2"
117
+ }, t("neetoPayments.export.title.account"))), /*#__PURE__*/React__default.createElement(Modal.Body, null, isFileLoading ? /*#__PURE__*/React__default.createElement(Typography, {
118
+ style: "body2"
119
+ }, t("neetoPayments.export.pleaseWait")) : /*#__PURE__*/React__default.createElement(Typography, {
120
+ style: "body2"
121
+ }, downloadUrl ? t("neetoPayments.export.fileReady") : t("neetoPayments.export.download.account"))), /*#__PURE__*/React__default.createElement(Modal.Footer, {
122
+ className: "space-x-2"
123
+ }, downloadUrl ? /*#__PURE__*/React__default.createElement(Button, {
124
+ href: downloadUrl,
125
+ icon: Download,
126
+ label: t("neetoPayments.common.download"),
127
+ onClick: onClose
128
+ }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
129
+ disabled: isFileLoading,
130
+ label: t("neetoPayments.common.cancel"),
131
+ style: "tertiary",
132
+ onClick: onClose
133
+ }), /*#__PURE__*/React__default.createElement(Button, {
134
+ disabled: isFileLoading,
135
+ label: t("neetoPayments.common.export"),
136
+ loading: isFileLoading,
137
+ onClick: handleGenerateClick
138
+ }))));
139
+ };
140
+
141
+ const renderIdentifier = function () {
142
+ let {
143
+ identifier = "",
144
+ live: isLive = false
145
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
146
+ return /*#__PURE__*/React__default.createElement(CopyButtonWrapper, {
147
+ content: identifier
148
+ }, /*#__PURE__*/React__default.createElement(IdentifierButton, {
149
+ href: buildStripeAccountLink(identifier, isLive),
150
+ label: identifier
151
+ }));
152
+ };
153
+ const renderCountry = pipe(split("_"), map(capitalize), join(" "));
154
+
155
+ const COLUMNS = [{
156
+ title: t("neetoPayments.common.id"),
157
+ dataIndex: "id",
158
+ key: "id",
159
+ width: "72px",
160
+ isHidable: false
161
+ }, {
162
+ title: t("neetoPayments.common.identifier"),
163
+ dataIndex: "identifier",
164
+ key: "identifier",
165
+ width: "300px",
166
+ render: renderIdentifier,
167
+ isHidable: false
168
+ }, {
169
+ title: t("neetoPayments.common.status"),
170
+ dataIndex: "status",
171
+ key: "status",
172
+ width: "150px",
173
+ render: renderStatus("account"),
174
+ sorter: true,
175
+ isHidable: false
176
+ }, {
177
+ title: t("neetoPayments.common.name"),
178
+ dataIndex: "first_name",
179
+ key: "first_name",
180
+ width: "300px",
181
+ sorter: true,
182
+ render: renderFullName
183
+ }, {
184
+ title: t("neetoPayments.common.email"),
185
+ dataIndex: "email",
186
+ key: "email",
187
+ width: "300px",
188
+ sorter: true,
189
+ render: renderEmail
190
+ }, {
191
+ title: t("neetoPayments.common.country"),
192
+ dataIndex: "country",
193
+ key: "country",
194
+ width: "150px",
195
+ render: renderCountry,
196
+ sorter: true
197
+ }, {
198
+ title: t("neetoPayments.common.createdAt"),
199
+ dataIndex: "createdAt",
200
+ key: "createdAt",
201
+ width: "220px",
202
+ render: renderDate,
203
+ sorter: true
204
+ }];
205
+
206
+ const useFiltersAndPagination = () => {
207
+ const history = useHistory();
208
+ const [isFilterButtonVisible, setIsFilterButtonVisible] = useState(false);
209
+ const [isFilterPaneOpen, setIsFilterPaneOpen] = useState(false);
210
+ const [pageProperties, setPageProperties] = useState(buildDefaultPageProperties(TABS));
211
+ const [sortProperties, setSortProperties] = useState(DEFAULT_SORT_PROPERTIES);
212
+ const {
213
+ tab = TAB.all
214
+ } = useQueryParams();
215
+ const {
216
+ searchTerm = ""
217
+ } = getQueryParams();
218
+ const searchKeywordProps = {
219
+ ...SEARCH_PROPS,
220
+ key: "search_term",
221
+ value: searchTerm.trim()
222
+ };
223
+ const [filters, setFilters] = useState(buildFiltersFromURL([...FILTER_COLUMNS, searchKeywordProps]));
224
+ const [dataSize, setDataSize] = useState(null);
225
+ const columnData = tab !== TAB.all ? removeBy({
226
+ key: "status"
227
+ }, COLUMNS) : COLUMNS;
228
+ const handleTabChange = tab => {
229
+ setDataSize(null);
230
+ const queryParams = getQueryParams({
231
+ toCamelCase: false
232
+ });
233
+ const newParams = {
234
+ tab,
235
+ page: pageProperties[tab]?.page,
236
+ page_size: pageProperties[tab]?.pageSize
237
+ };
238
+ history.push(buildUrl(window.location.pathname, mergeLeft(newParams, queryParams)));
239
+ };
240
+ return {
241
+ isFilterButtonVisible,
242
+ isFilterPaneOpen,
243
+ pageProperties,
244
+ filters,
245
+ searchKeywordProps,
246
+ tab,
247
+ sortProperties,
248
+ columnData,
249
+ dataSize,
250
+ setDataSize,
251
+ setIsFilterButtonVisible,
252
+ setIsFilterPaneOpen,
253
+ setPageProperties,
254
+ setFilters,
255
+ handleTabChange,
256
+ setSortProperties
257
+ };
258
+ };
259
+
260
+ const list = payload => axios.get(`${BASE_URL}/api/v1/stripe/accounts`, {
261
+ params: payload
262
+ });
263
+ const accountsApi = {
264
+ list
265
+ };
266
+
267
+ const useFetchConnectedAccounts = function () {
268
+ let payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
269
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
270
+ return useQuery({
271
+ queryKey: [QUERY_KEYS.STRIPE_ACCOUNTS_LIST, payload],
272
+ queryFn: () => accountsApi.list(payload),
273
+ ...options
274
+ });
275
+ };
276
+
277
+ const List = _ref => {
278
+ let {
279
+ columnData,
280
+ filters,
281
+ pageProperties,
282
+ setDataSize,
283
+ setIsFilterButtonVisible,
284
+ setPageProperties,
285
+ setSortProperties,
286
+ sortProperties,
287
+ tab
288
+ } = _ref;
289
+ const history = useHistory();
290
+ const {
291
+ t
292
+ } = useTranslation();
293
+ const {
294
+ hideColumn,
295
+ getVisibleColumnData
296
+ } = useHiddenColumns(STRIPE_ACCOUNTS_TABLE_HIDDEN_COLUMNS_STORAGE_KEY);
297
+ const {
298
+ data: {
299
+ accounts = [],
300
+ views = {}
301
+ } = {},
302
+ isLoading,
303
+ isFetching
304
+ } = useFetchConnectedAccounts(buildPayload({
305
+ filters,
306
+ pageProperties,
307
+ sortProperties,
308
+ tab
309
+ }));
310
+ const dataSize = views[tab];
311
+ useEffect(() => {
312
+ setIsFilterButtonVisible(isPresent(accounts) || isPresent(filters));
313
+ setDataSize(dataSize);
314
+ }, [accounts]);
315
+ const handleTablePagination = (page, pageSize) => {
316
+ const queryParams = getQueryParams({
317
+ toCamelCase: false
318
+ });
319
+ history.push(buildUrl(window.location.pathname, mergeLeft({
320
+ page,
321
+ page_size: pageSize
322
+ }, queryParams)));
323
+ setPageProperties(assoc(tab, {
324
+ page,
325
+ pageSize
326
+ }));
327
+ };
328
+ useEffect(() => {
329
+ handleTablePagination(DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE);
330
+ setSortProperties(DEFAULT_SORT_PROPERTIES);
331
+ }, [filters, tab]);
332
+ const handleTableChange = (_, __, sorter) => {
333
+ setSortProperties(isPresent(sorter?.column) ? {
334
+ sortBy: camelToSnakeCase(sorter.field),
335
+ orderBy: sorter.order === "ascend" ? "ASC" : "DESC"
336
+ } : DEFAULT_SORT_PROPERTIES);
337
+ };
338
+ if (isLoading) {
339
+ return /*#__PURE__*/React__default.createElement(PageLoader, null);
340
+ }
341
+ if (dataSize <= 0 || !isPresent(accounts)) {
342
+ return /*#__PURE__*/React__default.createElement("div", {
343
+ className: "flex h-full w-full items-center justify-center"
344
+ }, /*#__PURE__*/React__default.createElement(NoData, {
345
+ title: tab === TAB.all ? t("neetoPayments.emptyState.account") : t("neetoPayments.emptyState.accountWithStatus", {
346
+ status: tab
347
+ })
348
+ }));
349
+ }
350
+ return /*#__PURE__*/React__default.createElement(TableWrapper, {
351
+ hasPagination: dataSize > pageProperties[tab]?.pageSize
352
+ }, /*#__PURE__*/React__default.createElement(Table, {
353
+ fixedHeight: true,
354
+ allowRowClick: false,
355
+ columnData: getVisibleColumnData(columnData),
356
+ currentPageNumber: pageProperties[tab]?.page,
357
+ handlePageChange: handleTablePagination,
358
+ loading: isFetching,
359
+ rowData: buildRowData({
360
+ data: accounts,
361
+ pageProperties,
362
+ tab
363
+ }),
364
+ rowSelection: false,
365
+ sortDirections: SORT_DIRECTIONS,
366
+ totalCount: dataSize,
367
+ paginationProps: {
368
+ showSizeChanger: true,
369
+ hideOnSinglePage: true,
370
+ pageSize: pageProperties[tab]?.pageSize,
371
+ total: dataSize
372
+ },
373
+ onChange: handleTableChange,
374
+ onColumnHide: _ref2 => {
375
+ let {
376
+ dataIndex
377
+ } = _ref2;
378
+ return hideColumn(dataIndex);
379
+ }
380
+ }));
381
+ };
382
+
383
+ const AccountsDashboard = () => {
384
+ const [_, startTransition] = useTransition();
385
+ const {
386
+ t
387
+ } = useTranslation();
388
+ const [showExportModal, setShowExportModal] = useState(false);
389
+ const {
390
+ isFilterButtonVisible,
391
+ isFilterPaneOpen,
392
+ pageProperties,
393
+ filters,
394
+ searchKeywordProps,
395
+ tab,
396
+ sortProperties,
397
+ columnData,
398
+ dataSize,
399
+ setDataSize,
400
+ setIsFilterButtonVisible,
401
+ setIsFilterPaneOpen,
402
+ setPageProperties,
403
+ setFilters,
404
+ handleTabChange,
405
+ setSortProperties
406
+ } = useFiltersAndPagination();
407
+ const isTabsVisible = isFilterButtonVisible || tab !== "all";
408
+ const handleFiltersChange = filters => {
409
+ startTransition(() => {
410
+ setFilters(filters);
411
+ });
412
+ };
413
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Header, {
414
+ title: t("neetoPayments.title.account"),
415
+ searchProps: isFilterButtonVisible && {
416
+ placeholder: t("neetoPayments.common.search"),
417
+ className: "w-80"
418
+ }
419
+ }), isTabsVisible && /*#__PURE__*/React__default.createElement(Tab, null, TABS.map(item => /*#__PURE__*/React__default.createElement(Tab.Item, {
420
+ active: tab === item,
421
+ key: item,
422
+ onClick: () => handleTabChange(item)
423
+ }, t(`neetoPayments.common.${item}`)))), /*#__PURE__*/React__default.createElement(SubHeader, {
424
+ className: "mt-4",
425
+ leftActionBlock: isPresent(dataSize) && /*#__PURE__*/React__default.createElement(Typography, {
426
+ className: "neeto-ui-gray-800 mr-2 font-semibold",
427
+ component: "h4"
428
+ }, tab === TAB.all ? t("neetoPayments.countOf.account", {
429
+ count: dataSize
430
+ }) : t("neetoPayments.countOf.accountWithStatus", {
431
+ count: dataSize,
432
+ status: tab
433
+ })),
434
+ rightActionBlock: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Bar, {
435
+ columns: FILTER_COLUMNS,
436
+ keyword: searchKeywordProps,
437
+ setIsPaneOpen: setIsFilterPaneOpen,
438
+ onChange: handleFiltersChange
439
+ }), isFilterButtonVisible && /*#__PURE__*/React__default.createElement(SubHeader.RightBlock, {
440
+ columnsButtonProps: {
441
+ columnData,
442
+ fixedColumns: DASHBOARD_MANDATORY_COLUMNS,
443
+ localStorageKey: STRIPE_ACCOUNTS_TABLE_HIDDEN_COLUMNS_STORAGE_KEY
444
+ },
445
+ downloadButtonProps: {
446
+ onClick: () => setShowExportModal(true)
447
+ },
448
+ filterProps: {
449
+ columns: FILTER_COLUMNS,
450
+ isOpen: isFilterPaneOpen,
451
+ keyword: searchKeywordProps,
452
+ setIsOpen: setIsFilterPaneOpen,
453
+ onChange: handleFiltersChange
454
+ }
455
+ }))
456
+ }), /*#__PURE__*/React__default.createElement(List, {
457
+ columnData,
458
+ filters,
459
+ pageProperties,
460
+ setDataSize,
461
+ setIsFilterButtonVisible,
462
+ setPageProperties,
463
+ setSortProperties,
464
+ sortProperties,
465
+ tab
466
+ }), /*#__PURE__*/React__default.createElement(ExportModal, {
467
+ filters,
468
+ setShowExportModal,
469
+ showExportModal,
470
+ sortProperties,
471
+ tab
472
+ }));
473
+ };
474
+ var index = withTitle(withReactQuery(AccountsDashboard), t("neetoPayments.title.account"));
475
+
476
+ export { index as default };
477
+ //# sourceMappingURL=AccountsDashboard.js.map