@bigbinary/neeto-payments-frontend 1.0.1 → 1.0.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.
package/README.md CHANGED
@@ -11,9 +11,9 @@ neetoPayments is the library that manages payments across neeto products.
11
11
  proper functioning of the package. Install all the peer dependencies using
12
12
  the below command:
13
13
 
14
- ```zsh
15
- yarn add @bigbinary/neeto-commons-frontend@2.0.54 @bigbinary/neeto-filters-frontend@2.8.1 @bigbinary/neeto-icons@1.9.22 @bigbinary/neeto-molecules@1.0.9 @bigbinary/neetoui@4.4.10 @honeybadger-io/js@5.1.1 @honeybadger-io/react@5.1.3 axios@1.3.4 classnames@2.3.2 formik@2.2.9 js-logger@1.6.1 mixpanel-browser@2.45.0 ramda@0.28.0 react-helmet@6.1.0 react-query@3.39.3 react-router-dom@5.3.4 react-toastify@8.2.0 yup@1.0.2
16
- ```
14
+ ```zsh
15
+ yarn add @bigbinary/neeto-commons-frontend@2.0.54 @bigbinary/neeto-filters-frontend@2.8.1 @bigbinary/neeto-icons@1.9.22 @bigbinary/neeto-molecules@1.0.9 @bigbinary/neetoui@4.4.10 @honeybadger-io/js@5.1.1 @honeybadger-io/react@5.1.3 axios@1.3.4 classnames@2.3.2 formik@2.2.9 js-logger@1.6.1 mixpanel-browser@2.45.0 ramda@0.28.0 react-helmet@6.1.0 react-query@3.39.3 react-router-dom@5.3.4 react-toastify@8.2.0 yup@1.0.2
16
+ ```
17
17
 
18
18
  2. Now install the latest **neetoPayments** package using the below command:
19
19
 
@@ -21,6 +21,152 @@ neetoPayments is the library that manages payments across neeto products.
21
21
  yarn add @bigbinary/neeto-payments-frontend
22
22
  ```
23
23
 
24
+ ## Usage
25
+
26
+ neeto-payments-frontend exports:
27
+
28
+ - `Dashboard` component
29
+ - `buildStripeTransactionLink()` function
30
+
31
+ ### 1. `Dashboard` component
32
+
33
+ #### Props
34
+
35
+ 1. **holdableId**: To specify the ID of the entity that holds the stripe
36
+ account. This is an optional prop. If the value is not specified, the current
37
+ organization ID is taken as the default value while querying for
38
+ transactions.
39
+
40
+ 2. **payableEntityColumns**: To specify the columns from the payable entity
41
+ which need to be additionally displayed. It is an optional prop that defaults
42
+ to `[]` if not specified.
43
+
44
+ 3. **searchProps**: To specify the properties of the search bar in `Dashboard`.
45
+
46
+ 4. **shouldFetchFilterOptions**: To specify whether or not to fetch the options
47
+ for columns with filter type as `single_option` or `multi_option`. Its value
48
+ is `false` by default.
49
+
50
+ 5. **tabs**: To specify the tabs to be displayed in the payments dashboard. It is an optional parameter.
51
+
52
+ **More about `payableEntityColumns`**
53
+
54
+ Here is an example of `payableEntityColumns` prop:
55
+
56
+ ```js
57
+ const payableEntityColumns = [
58
+ {
59
+ title: t("entity.meeting"),
60
+ dataIndex: "payable",
61
+ key: "meeting",
62
+ ellipsis: true,
63
+ width: 150,
64
+ render: renderMeeting,
65
+ isFilterable: true,
66
+ filterProps: {
67
+ key: "meeting",
68
+ label: "Meeting",
69
+ node: "bookings:payable.meeting.name",
70
+ type: "multi_option",
71
+ model: "Meeting",
72
+ },
73
+ },
74
+ {
75
+ title: t("common.host"),
76
+ dataIndex: ["payable", "host"],
77
+ key: "host",
78
+ ellipsis: true,
79
+ width: 150,
80
+ isFilterable: true,
81
+ filterProps: {
82
+ key: "host",
83
+ label: "Host",
84
+ node: "bookings:payable.user.first_name,last_name",
85
+ model: "User",
86
+ type: "multi_option",
87
+ },
88
+ },
89
+ ];
90
+ ```
91
+
92
+ The `payableEntityColumns` is similar to `columnData` prop used in `Table`
93
+ component in **NeetoUI**. The prop can be modified accordingly to customize the
94
+ columns in the table. For more customizations, refer
95
+ [NeetoUI docs](https://neeto-ui.neeto.com/?path=/docs/components-table--default).
96
+
97
+ The additional keys are `isFilterable` and `filterProps`. `filterProps` is used
98
+ to build the list of columns to be represented in the filters pane. The
99
+ `isFilterable` key must be `true` for `filterProps` to be considered.
100
+
101
+ > :memo: **Note:** The data about the payable entity is in the format
102
+ > `{ payable: {...} }`. So the `dataIndex` key must be used accordingly. Refer
103
+ > the example above.
104
+
105
+ > In the case of columns with filter type as `single_option` or `multi_option`,
106
+ > `values` key can be passed along with `filterProps`. Alternatively it be
107
+ > automated using `Dashboard` component. To know more on this, refer "More about
108
+ > shouldFetchFilterOptions prop" section below.
109
+
110
+ **More about `searchProps` prop**
111
+
112
+ Here is an example of `searchProps` prop:
113
+
114
+ ```js
115
+ const searchProps = {
116
+ key: "keyword",
117
+ node: "bookings:payable.meeting.name,bookings:payable.user.first_name,last_name,bookings:payable.name",
118
+ model: "Meeting,User,Booking",
119
+ placeholder: "Search by meeting name, user name or booking name",
120
+ };
121
+ ```
122
+
123
+ This is passed to the `FiltersBar` and `FiltersPane` components from
124
+ `neeto-filters-frontend`. This is similar to the `keyword` prop used in
125
+ `neeto-filters-frontend` with an additional `placeholder` key which is used as
126
+ the placeholder in the search bar.
127
+
128
+ To know more about the working of `node` and `model` keys, refer the
129
+ [`neeto-filters-frontend` documentation](https://github.com/bigbinary/neeto-filters-frontend/blob/main/README.md).
130
+
131
+ **More about `shouldFetchFilterOptions` prop**
132
+
133
+ `shouldFetchFilterOptions` decides whether or not to fetch the data to be set as
134
+ the `values` key in `filterProp`. For this to work,
135
+ `api/v1/payments/filter_options` endpoint must be defined and it must return the
136
+ filter options.
137
+
138
+ An example of desired response from the endpoint is:
139
+
140
+ `{ filterOptions: { host: [...], meeting: [...]}}`
141
+
142
+ > :memo: **Note:** For the above method to work, the keys inside the
143
+ > `filterOptions` object must match the `key` property in `payableEntityColumns`
144
+
145
+ **More about `tabs` prop**
146
+
147
+ `tabs` is an array of strings. It has default value as this: `["all", "successful", "pending", "declined", "refunded"]`.It should only be a subset of the array above. Preferably it shouldn't be an empty array.
148
+
149
+
150
+ ### 2. `buildStripeTransactionLink` function
151
+
152
+ This function is used to generate the stripe transaction link from a payment
153
+ identifier.
154
+
155
+ The arguments are:
156
+
157
+ 1. `identifier`: The payment identifier
158
+ 2. `isLive`: Specifying whether or not the environment is live. It defaults to
159
+ `true`.
160
+
161
+ Example usage
162
+
163
+ ```js
164
+ const transactionLink = buildStripeTransactionLink(
165
+ "pi_3MqWX92fKivMPpZ11EPmOBBR",
166
+ false
167
+ );
168
+ ```
169
+
24
170
  ## Other References
25
171
 
26
172
  - [Development instructions](./docs/general/development-instructions.md)