@bigbinary/neeto-payments-frontend 1.0.1 → 1.0.2

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,145 @@ 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
+ **More about `payableEntityColumns`**
51
+
52
+ Here is an example of `payableEntityColumns` prop:
53
+
54
+ ```js
55
+ const payableEntityColumns = [
56
+ {
57
+ title: t("entity.meeting"),
58
+ dataIndex: "payable",
59
+ key: "meeting",
60
+ ellipsis: true,
61
+ width: 150,
62
+ render: renderMeeting,
63
+ isFilterable: true,
64
+ filterProps: {
65
+ key: "meeting",
66
+ label: "Meeting",
67
+ node: "bookings:payable.meeting.name",
68
+ type: "multi_option",
69
+ model: "Meeting",
70
+ },
71
+ },
72
+ {
73
+ title: t("common.host"),
74
+ dataIndex: ["payable", "host"],
75
+ key: "host",
76
+ ellipsis: true,
77
+ width: 150,
78
+ isFilterable: true,
79
+ filterProps: {
80
+ key: "host",
81
+ label: "Host",
82
+ node: "bookings:payable.user.first_name,last_name",
83
+ model: "User",
84
+ type: "multi_option",
85
+ },
86
+ },
87
+ ];
88
+ ```
89
+
90
+ The `payableEntityColumns` is similar to `columnData` prop used in `Table`
91
+ component in **NeetoUI**. The prop can be modified accordingly to customize the
92
+ columns in the table. For more customizations, refer
93
+ [NeetoUI docs](https://neeto-ui.neeto.com/?path=/docs/components-table--default).
94
+
95
+ The additional keys are `isFilterable` and `filterProps`. `filterProps` is used
96
+ to build the list of columns to be represented in the filters pane. The
97
+ `isFilterable` key must be `true` for `filterProps` to be considered.
98
+
99
+ > :memo: **Note:** The data about the payable entity is in the format
100
+ > `{ payable: {...} }`. So the `dataIndex` key must be used accordingly. Refer
101
+ > the example above.
102
+
103
+ > In the case of columns with filter type as `single_option` or `multi_option`,
104
+ > `values` key can be passed along with `filterProps`. Alternatively it be
105
+ > automated using `Dashboard` component. To know more on this, refer "More about
106
+ > shouldFetchFilterOptions prop" section below.
107
+
108
+ **More about `searchProps` prop**
109
+
110
+ Here is an example of `searchProps` prop:
111
+
112
+ ```js
113
+ const searchProps = {
114
+ key: "keyword",
115
+ node: "bookings:payable.meeting.name,bookings:payable.user.first_name,last_name,bookings:payable.name",
116
+ model: "Meeting,User,Booking",
117
+ placeholder: "Search by meeting name, user name or booking name",
118
+ };
119
+ ```
120
+
121
+ This is passed to the `FiltersBar` and `FiltersPane` components from
122
+ `neeto-filters-frontend`. This is similar to the `keyword` prop used in
123
+ `neeto-filters-frontend` with an additional `placeholder` key which is used as
124
+ the placeholder in the search bar.
125
+
126
+ To know more about the working of `node` and `model` keys, refer the
127
+ [`neeto-filters-frontend` documentation](https://github.com/bigbinary/neeto-filters-frontend/blob/main/README.md).
128
+
129
+ **More about `shouldFetchFilterOptions` prop**
130
+
131
+ `shouldFetchFilterOptions` decides whether or not to fetch the data to be set as
132
+ the `values` key in `filterProp`. For this to work,
133
+ `api/v1/payments/filter_options` endpoint must be defined and it must return the
134
+ filter options.
135
+
136
+ An example of desired response from the endpoint is:
137
+
138
+ `{ filterOptions: { host: [...], meeting: [...]}}`
139
+
140
+ > :memo: **Note:** For the above method to work, the keys inside the
141
+ > `filterOptions` object must match the `key` property in `payableEntityColumns`
142
+
143
+ ### 2. `buildStripeTransactionLink` function
144
+
145
+ This function is used to generate the stripe transaction link from a payment
146
+ identifier.
147
+
148
+ The arguments are:
149
+
150
+ 1. `identifier`: The payment identifier
151
+ 2. `isLive`: Specifying whether or not the environment is live. It defaults to
152
+ `true`.
153
+
154
+ Example usage
155
+
156
+ ```js
157
+ const transactionLink = buildStripeTransactionLink(
158
+ "pi_3MqWX92fKivMPpZ11EPmOBBR",
159
+ false
160
+ );
161
+ ```
162
+
24
163
  ## Other References
25
164
 
26
165
  - [Development instructions](./docs/general/development-instructions.md)