react-native-unit-components 1.2.1 → 1.4.0
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 +0 -255
- package/ios/Camera/Camera.swift +22 -0
- package/ios/Camera/CameraExportModule.m +7 -0
- package/ios/UNAppInfo/UNAppInfo.swift +19 -0
- package/ios/UNAppInfo/UNAppInfoExportModule.m +7 -0
- package/ios/UnitReactNativeComponentsViewManager.swift +7 -7
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +28 -3
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +11 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +32 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +8 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +7 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +37 -3
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +9 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCheckDepositComponent/UNCheckDepositComponent.js +97 -0
- package/lib/commonjs/components/UNCheckDepositComponent/UNCheckDepositComponent.js.map +1 -0
- package/lib/commonjs/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.js +45 -0
- package/lib/commonjs/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.js.map +1 -0
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/hooks/listenerToBus.js +4 -1
- package/lib/commonjs/hooks/listenerToBus.js.map +1 -1
- package/lib/commonjs/messages/webMessages/activityMessage.js +12 -0
- package/lib/commonjs/messages/webMessages/activityMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/cardMessage.js +1 -0
- package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/checkMessage.js +13 -0
- package/lib/commonjs/messages/webMessages/checkMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/index.js.map +1 -1
- package/lib/commonjs/messages/webMessages/onLoadMessage.js +17 -0
- package/lib/commonjs/messages/webMessages/onLoadMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +42 -1
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/account.types.js +8 -1
- package/lib/commonjs/sharedTypes/account.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/activity.types.js +6 -0
- package/lib/commonjs/sharedTypes/activity.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/authorization.types.js +2 -0
- package/lib/commonjs/sharedTypes/authorization.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/card.types.js +15 -0
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/checkDeposit.types.js +22 -0
- package/lib/commonjs/sharedTypes/checkDeposit.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/index.js +11 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js +0 -4
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/transactions.types.js +52 -0
- package/lib/commonjs/sharedTypes/transactions.types.js.map +1 -0
- package/lib/commonjs/webComponent/WebComponent.js +35 -2
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +14 -1
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +30 -5
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +8 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +6 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +7 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +39 -5
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +6 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/components/UNCheckDepositComponent/UNCheckDepositComponent.js +88 -0
- package/lib/module/components/UNCheckDepositComponent/UNCheckDepositComponent.js.map +1 -0
- package/lib/module/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.js +37 -0
- package/lib/module/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/hooks/listenerToBus.js +4 -1
- package/lib/module/hooks/listenerToBus.js.map +1 -1
- package/lib/module/messages/webMessages/activityMessage.js +5 -0
- package/lib/module/messages/webMessages/activityMessage.js.map +1 -0
- package/lib/module/messages/webMessages/cardMessage.js +1 -0
- package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/module/messages/webMessages/checkMessage.js +6 -0
- package/lib/module/messages/webMessages/checkMessage.js.map +1 -0
- package/lib/module/messages/webMessages/index.js.map +1 -1
- package/lib/module/messages/webMessages/onLoadMessage.js +10 -0
- package/lib/module/messages/webMessages/onLoadMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +37 -0
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/account.types.js +6 -0
- package/lib/module/sharedTypes/account.types.js.map +1 -1
- package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/module/sharedTypes/activity.types.js +2 -0
- package/lib/module/sharedTypes/activity.types.js.map +1 -0
- package/lib/module/sharedTypes/authorization.types.js +2 -0
- package/lib/module/sharedTypes/authorization.types.js.map +1 -0
- package/lib/module/sharedTypes/card.types.js +13 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/checkDeposit.types.js +15 -0
- package/lib/module/sharedTypes/checkDeposit.types.js.map +1 -0
- package/lib/module/sharedTypes/index.js +2 -1
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/module/sharedTypes/transactions.types.js +44 -0
- package/lib/module/sharedTypes/transactions.types.js.map +1 -0
- package/lib/module/webComponent/WebComponent.js +34 -2
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +15 -2
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +2 -2
- package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +2 -2
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +11 -3
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +3 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +5 -2
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +1 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +9 -3
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +3 -0
- package/lib/typescript/components/UNCheckDepositComponent/UNCheckDepositComponent.d.ts +12 -0
- package/lib/typescript/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.d.ts +3 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/messages/webMessages/activityMessage.d.ts +5 -0
- package/lib/typescript/messages/webMessages/cardMessage.d.ts +5 -1
- package/lib/typescript/messages/webMessages/checkMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/index.d.ts +4 -2
- package/lib/typescript/messages/webMessages/onLoadMessage.d.ts +30 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
- package/lib/typescript/scripts/html/bodyScript.d.ts +6 -0
- package/lib/typescript/sharedTypes/account.types.d.ts +18 -4
- package/lib/typescript/sharedTypes/achCredit.types.d.ts +6 -0
- package/lib/typescript/sharedTypes/activity.types.d.ts +7 -0
- package/lib/typescript/sharedTypes/authorization.types.d.ts +20 -0
- package/lib/typescript/sharedTypes/card.types.d.ts +12 -0
- package/lib/typescript/sharedTypes/checkDeposit.types.d.ts +46 -0
- package/lib/typescript/sharedTypes/index.d.ts +2 -1
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +12 -16
- package/lib/typescript/sharedTypes/transactions.types.d.ts +80 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +1 -0
- package/package.json +3 -3
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +30 -3
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +30 -3
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +52 -9
- package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +11 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +45 -4
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +7 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +24 -3
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +8 -1
- package/src/components/UNCardComponent/UNCardComponent.tsx +51 -7
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +9 -0
- package/src/components/UNCheckDepositComponent/UNCheckDepositComponent.tsx +112 -0
- package/src/components/UNCheckDepositComponent/UNCheckDepositComponent.utils.ts +40 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/listenerToBus.ts +4 -1
- package/src/messages/webMessages/activityMessage.ts +8 -0
- package/src/messages/webMessages/cardMessage.ts +6 -0
- package/src/messages/webMessages/checkMessage.ts +14 -0
- package/src/messages/webMessages/index.ts +6 -0
- package/src/messages/webMessages/onLoadMessage.ts +45 -0
- package/src/messages/webMessages/unitMessages.ts +2 -2
- package/src/scripts/html/bodyScript.ts +42 -1
- package/src/sharedTypes/account.types.ts +33 -19
- package/src/sharedTypes/achCredit.types.ts +7 -0
- package/src/sharedTypes/activity.types.ts +8 -0
- package/src/sharedTypes/authorization.types.ts +22 -0
- package/src/sharedTypes/card.types.ts +13 -0
- package/src/sharedTypes/checkDeposit.types.ts +50 -0
- package/src/sharedTypes/index.ts +2 -1
- package/src/sharedTypes/onLoadResponse.types.ts +15 -23
- package/src/sharedTypes/transactions.types.ts +84 -0
- package/src/webComponent/WebComponent.tsx +36 -2
- package/src/webComponent/html.ts +15 -2
- package/android/src/main/res/values/themes.xml +0 -16
- package/android/src/main/res/values-night/themes.xml +0 -16
package/README.md
CHANGED
|
@@ -69,258 +69,3 @@ export default function YourRootComponent() {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
```
|
|
72
|
-
|
|
73
|
-
### Components
|
|
74
|
-
|
|
75
|
-
#### Card Component
|
|
76
|
-
|
|
77
|
-
##### UNCardComponent props:
|
|
78
|
-
| Name | Type | Required | Description |
|
|
79
|
-
| ---------------------- | ---------------------------- | --------- | -------------------------------------------------------- |
|
|
80
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
81
|
-
| cardId | string | YES | Unit card id. |
|
|
82
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
83
|
-
| hide-actions-menu-button | boolean | No | Hide menu button in case value is true |
|
|
84
|
-
| hide-card-title | boolean | No | Hide card title in case value is true |
|
|
85
|
-
| hide-sensitive-data-button | boolean | No | Hide sensitive data button in case value is true |
|
|
86
|
-
| onStatusChanged | (card: UNCardData) => void | No | Callback for card status changes. |
|
|
87
|
-
| pushProvisioningModule | typeof NativeModules | No | A Native Module that implements Visa's push provisioning |
|
|
88
|
-
|
|
89
|
-
##### Example:
|
|
90
|
-
```js
|
|
91
|
-
import React from 'react';
|
|
92
|
-
import { UNCardComponent, UNCardData } from 'react-native-unit-components';
|
|
93
|
-
import { NativeModules } from 'react-native';
|
|
94
|
-
const { PushProvisioningModule } = NativeModules;
|
|
95
|
-
|
|
96
|
-
export default function YourComponent() {
|
|
97
|
-
return (
|
|
98
|
-
<UNCardComponent
|
|
99
|
-
cardId={'632197'}
|
|
100
|
-
customerToken={''}
|
|
101
|
-
onStatusChanged={(card: UNCardData) => { console.log(card) }}
|
|
102
|
-
pushProvisioningModule={PushProvisioningModule}
|
|
103
|
-
/>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
##### Add card to wallet capability - Optional
|
|
109
|
-
|
|
110
|
-
[Complete the add to wallet guide for React Native](https://guides.unit.co/add-to-mobile-wallet#react-native), skipping the [last module access from javascript](https://guides.unit.co/add-to-mobile-wallet#module-access-from-javascript-1), to use this capability.
|
|
111
|
-
|
|
112
|
-
Call `UnitSDK.setSignedNonce` with the signedNonce response you obtained from the `launchInitialize` method of the `PushProvisioningModule` in Javascript.
|
|
113
|
-
|
|
114
|
-
Then pass the `PushProvisioningModule` as a prop to [Unit's Card Component](#card-component). This will let the SDK get wallets and start card provisioning for you once the native add to wallet button was pressed.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
###### Input:
|
|
118
|
-
| Name | Type | Required | Description |
|
|
119
|
-
| --------------- | ---------------------------- | --------- | -------------------------------------------- |
|
|
120
|
-
| signedNonce | string | YES | A signed nonce obtained from Visa. |
|
|
121
|
-
|
|
122
|
-
###### Example:
|
|
123
|
-
```js
|
|
124
|
-
import React from "react";
|
|
125
|
-
import { UnitSDK } from "react-native-unit-components";
|
|
126
|
-
import { NativeModules } from 'react-native';
|
|
127
|
-
const { PushProvisioningModule } = NativeModules;
|
|
128
|
-
|
|
129
|
-
export default function YourRootComponent() {
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
const launchInitialize = async () => {
|
|
132
|
-
try {
|
|
133
|
-
// To call the module method to use SDK method initialize
|
|
134
|
-
const response = await PushProvisioningModule.launchInitialize();
|
|
135
|
-
const signedNonce = JSON.parse(response).signedNonce;
|
|
136
|
-
UnitSDK.setSignedNonce(signedNonce);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
// Manage errors
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
launchInitialize();
|
|
143
|
-
}, []);
|
|
144
|
-
};
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Book Payment Component
|
|
148
|
-
|
|
149
|
-
##### UNBookPaymentComponent props:
|
|
150
|
-
| Name | Type | Required | Description |
|
|
151
|
-
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
152
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
153
|
-
| accountId | string | YES | Unit account id. The account from which money is being sent. |
|
|
154
|
-
| counterPartyAccountId | string | YES | Unit account id. The account which will receive money. |
|
|
155
|
-
| counterPartyName | string | YES | Name of the counterparty. This is the name that will be displayed in the Book Payment UI during the transfer.|
|
|
156
|
-
| isSameCustomer | boolean | NO | Stating whether both accounts belong to the same customer. Allows fetching additional information about the counterparty account. Default "false" |
|
|
157
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
158
|
-
| onPaymentCreated | (bookPayment: UNBookPaymentData) => void | NO | Callback for the created bookPayment. |
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
##### Example:
|
|
163
|
-
```js
|
|
164
|
-
import React from 'react';
|
|
165
|
-
import { UNBookPaymentComponent, UNBookPaymentData } from 'react-native-unit-components';
|
|
166
|
-
|
|
167
|
-
export default function YourComponent() {
|
|
168
|
-
return (
|
|
169
|
-
<UNBookPaymentComponent
|
|
170
|
-
customerToken={''}
|
|
171
|
-
accountId={'1105561'}
|
|
172
|
-
counterPartyAccountId={'1105562'}
|
|
173
|
-
counterPartyName={'Peter Parker"'}
|
|
174
|
-
isSameCustomer={true}
|
|
175
|
-
onPaymentCreated={(bookPayment: UNBookPaymentData) => { console.log(bookPayment) }}
|
|
176
|
-
/>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
#### Activity Component
|
|
182
|
-
|
|
183
|
-
##### UNActivityComponent props:
|
|
184
|
-
| Name | Type | Required | Description |
|
|
185
|
-
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
186
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
187
|
-
| accountId | string | No | Unit account id. The account for which the activity will be shown. If not specified: the activity of the customer (all accounts) will be shown |
|
|
188
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
##### Example:
|
|
192
|
-
```js
|
|
193
|
-
import React from 'react';
|
|
194
|
-
import { UNActivityComponent } from 'react-native-unit-components';
|
|
195
|
-
|
|
196
|
-
export default function YourComponent() {
|
|
197
|
-
return (
|
|
198
|
-
<UNActivityComponent
|
|
199
|
-
customerToken={''}
|
|
200
|
-
accountId={'1105561'}
|
|
201
|
-
/>
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
#### Account Component
|
|
207
|
-
|
|
208
|
-
##### UNAccountComponent props:
|
|
209
|
-
| Name | Type | Required | Description |
|
|
210
|
-
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
211
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
212
|
-
| accountId | string | No | Unit account id. The account to show, when not provided, one of the customer's accounts will be shown. |
|
|
213
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
##### Example:
|
|
217
|
-
```js
|
|
218
|
-
import React from 'react';
|
|
219
|
-
import { UNAccountComponent } from 'react-native-unit-components';
|
|
220
|
-
|
|
221
|
-
export default function YourComponent() {
|
|
222
|
-
return (
|
|
223
|
-
<UNAccountComponent
|
|
224
|
-
customerToken={''}
|
|
225
|
-
accountId={'1105561'}
|
|
226
|
-
/>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### ACH Credit Payment Component
|
|
232
|
-
|
|
233
|
-
##### UNACHCreditComponent props:
|
|
234
|
-
| Name | Type | Required | Description |
|
|
235
|
-
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
236
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
237
|
-
| accountId | string | YES | Unit account id. The account from which money is being sent. |
|
|
238
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
239
|
-
| fee | number | NO | Bill your counterparty for his activity. |
|
|
240
|
-
| is-auto-focus | boolean | NO | Auto-focus the 'add new recipient' button once the component is mounted. Default "false" |
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
##### Example:
|
|
244
|
-
```js
|
|
245
|
-
import React from 'react';
|
|
246
|
-
import { UNACHCreditComponent, UNACHData } from 'react-native-unit-components';
|
|
247
|
-
export default function YourComponent() {
|
|
248
|
-
return (
|
|
249
|
-
<UNACHCreditComponent
|
|
250
|
-
customerToken={''}
|
|
251
|
-
accountId={'1105561'}
|
|
252
|
-
onPaymentCreated={(payment: UNACHData) => { console.log(payment) }}
|
|
253
|
-
/>
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
#### ACH Debit Payment Component
|
|
259
|
-
|
|
260
|
-
##### Prerequirements
|
|
261
|
-
|
|
262
|
-
###### Installation of the SDK
|
|
263
|
-
In your project directory, run:
|
|
264
|
-
|
|
265
|
-
With npm:
|
|
266
|
-
|
|
267
|
-
```
|
|
268
|
-
npm install --save react-native-plaid-link-sdk
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
With yarn:
|
|
272
|
-
|
|
273
|
-
```
|
|
274
|
-
yarn add react-native-plaid-link-sdk
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
###### Installation for iOS
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
Add Plaid to your project’s Podfile as follows (likely located at ios/Podfile).
|
|
281
|
-
|
|
282
|
-
```
|
|
283
|
-
pod 'Plaid', '~> <insert latest version>'
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Then install your CocoaPods dependencies:
|
|
287
|
-
|
|
288
|
-
```
|
|
289
|
-
(cd ios && pod install)
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
###### Installation for Android
|
|
293
|
-
|
|
294
|
-
Register your app id with Plaid:
|
|
295
|
-
|
|
296
|
-
- Log in to the [Plaid dashboard](https://dashboard.plaid.com/signin) and go to Team Settings -> API.
|
|
297
|
-
|
|
298
|
-
- Next to Allowed Android package names, click Configure, then Add New Android Package Name.
|
|
299
|
-
|
|
300
|
-
- Enter your package name, for example com.plaid.example.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
##### UNACHDebitComponent props:
|
|
304
|
-
| Name | Type | Required | Description |
|
|
305
|
-
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
306
|
-
| customerToken | string | YES | A Unit Customer token. |
|
|
307
|
-
| accountId | string | YES | Unit account id. The account from which money is being sent. |
|
|
308
|
-
| theme | string | No | A URL that specifies the UI configuration. |
|
|
309
|
-
| fee | number | NO | Bill your counterparty for his activity. |
|
|
310
|
-
| is-auto-focus | boolean | NO | Auto-focus the 'add new recipient' button once the component is mounted. Default "false" |
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
##### Example:
|
|
314
|
-
```js
|
|
315
|
-
import React from 'react';
|
|
316
|
-
import { UNACHDebitComponent, UNACHData } from 'react-native-unit-components';
|
|
317
|
-
export default function YourComponent() {
|
|
318
|
-
return (
|
|
319
|
-
<UNACHDebitComponent
|
|
320
|
-
customerToken={''}
|
|
321
|
-
accountId={'1105561'}
|
|
322
|
-
onPaymentCreated={(payment: UNACHData) => { console.log(payment) }}
|
|
323
|
-
/>
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// CameraAccess.swift
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import AVFoundation
|
|
5
|
+
|
|
6
|
+
@objc(Camera)
|
|
7
|
+
class Camera: NSObject {
|
|
8
|
+
|
|
9
|
+
@objc static func requiresMainQueueSetup() -> Bool {
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc func requestAccess(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
14
|
+
AVCaptureDevice.requestAccess(for: .video) { (granted: Bool) in
|
|
15
|
+
if granted {
|
|
16
|
+
resolve("Camera access granted")
|
|
17
|
+
} else {
|
|
18
|
+
reject("ERROR", "Camera access denied", nil)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// AppInfo.swift
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
@objc(UNAppInfo)
|
|
6
|
+
class UNAppInfo: NSObject {
|
|
7
|
+
|
|
8
|
+
@objc static func requiresMainQueueSetup() -> Bool {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc func getBundleName(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
13
|
+
if let bundleName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String {
|
|
14
|
+
resolve(bundleName)
|
|
15
|
+
} else {
|
|
16
|
+
reject("ERROR", "Could not get bundle name", nil)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -15,17 +15,17 @@ class UnitAddToWalletButtonViewManager: RCTViewManager {
|
|
|
15
15
|
|
|
16
16
|
class UnitAddToWalletButtonView : UIView {
|
|
17
17
|
@objc var onAddToWalletClicked: RCTDirectEventBlock?
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
override init(frame: CGRect) {
|
|
20
20
|
super.init(frame: frame)
|
|
21
21
|
self.addSubview(addPassButton)
|
|
22
22
|
center(addPassButton: addPassButton)
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
required init?(coder: NSCoder) {
|
|
26
26
|
super.init(coder: coder)
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
lazy var addPassButton: PKAddPassButton = {
|
|
30
30
|
let button = PKAddPassButton(addPassButtonStyle: PKAddPassButtonStyle.black)
|
|
31
31
|
button.addTarget(
|
|
@@ -35,7 +35,7 @@ class UnitAddToWalletButtonView : UIView {
|
|
|
35
35
|
|
|
36
36
|
return button
|
|
37
37
|
}()
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
func center(addPassButton: PKAddPassButton) {
|
|
40
40
|
addPassButton.translatesAutoresizingMaskIntoConstraints = false
|
|
41
41
|
NSLayoutConstraint.activate([
|
|
@@ -45,9 +45,9 @@ class UnitAddToWalletButtonView : UIView {
|
|
|
45
45
|
addPassButton.bottomAnchor.constraint(equalTo: self.bottomAnchor)
|
|
46
46
|
])
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
51
|
@objc func sendUpdate(_ sender: UITapGestureRecognizer? = nil) {
|
|
52
52
|
self.onAddToWalletClicked?(nil)
|
|
53
53
|
}
|
|
@@ -12,11 +12,34 @@ var _reactNative = require("react-native");
|
|
|
12
12
|
var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
13
13
|
var _UNACHCreditComponent = require("./UNACHCreditComponent.utils");
|
|
14
14
|
var _paymentsMessage = require("../../messages/webMessages/paymentsMessage");
|
|
15
|
+
var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
|
|
15
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
18
|
const UNACHCreditComponent = props => {
|
|
18
19
|
const [height, setHeight] = (0, _react.useState)(0);
|
|
19
20
|
const [presentationMode, setPresentationMode] = (0, _react.useState)(_bodyHtml.PresentationMode.Inherit);
|
|
21
|
+
const handleUnitOnLoad = response => {
|
|
22
|
+
if (!props.onLoad) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
|
|
26
|
+
props.onLoad(response);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (_onLoadMessage.RESPONSE_KEYS.account in response && _onLoadMessage.RESPONSE_KEYS.counterpartyAccount in response) {
|
|
30
|
+
// ACHOnLoadResponse;
|
|
31
|
+
const achOnload = {
|
|
32
|
+
data: {
|
|
33
|
+
[_onLoadMessage.RESPONSE_KEYS.account]: response[_onLoadMessage.RESPONSE_KEYS.account].data,
|
|
34
|
+
[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount]: response[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount].data
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
props.onLoad(achOnload);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.error('On Load Error: unexpected response type');
|
|
41
|
+
return;
|
|
42
|
+
};
|
|
20
43
|
const handleWebViewMessage = message => {
|
|
21
44
|
if (!message || !message.details) return;
|
|
22
45
|
switch (message.type) {
|
|
@@ -27,7 +50,7 @@ const UNACHCreditComponent = props => {
|
|
|
27
50
|
break;
|
|
28
51
|
}
|
|
29
52
|
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
30
|
-
|
|
53
|
+
handleUnitOnLoad(message.details);
|
|
31
54
|
break;
|
|
32
55
|
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
33
56
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHCreditComponent","_paymentsMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHCreditComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achCreditEvent","onPaymentCreated","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHCreditComponent","_paymentsMessage","_onLoadMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHCreditComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","account","counterpartyAccount","achOnload","data","console","error","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achCreditEvent","onPaymentCreated","UnitMessage","UNIT_ON_LOAD","PageMessage","PAGE_HEIGHT","currentHeight","Default","renderACHCreditWebView","createElement","WebComponent","WebComponentType","achCreditPayment","params","getACHCreditParams","script","getACHCreditScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHCreditComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNOnLoadResponse, UNACHData, UNACHOnLoadData, UNError, UNOnLoadResponseData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHCreditParams, getACHCreditScript } from './UNACHCreditComponent.utils';\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\n\nexport interface UNACHCreditComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;\n}\n\nexport const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {\n // ACHOnLoadResponse;\n const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {\n data: {\n [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,\n [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,\n }\n };\n props.onLoad(achOnload);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achCreditEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achCreditEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n }\n };\n\n const renderACHCreditWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.achCreditPayment}\n presentationMode={presentationMode}\n params={getACHCreditParams(props)}\n script={getACHCreditScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHCreditWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHCreditWebView()}\n </View>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAEA,IAAAQ,cAAA,GAAAR,OAAA;AAAkG,SAAAS,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,i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ACC,0BAAgB,CAAC0B,OAAO,CAAC;UAC/C;UACA;QACF;IAAC;EAEL,CAAC;EAED,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;IACnC,oBACEnE,MAAA,CAAAkB,OAAA,CAAAkD,aAAA,CAACjE,aAAA,CAAAkE,YAAY;MACXb,IAAI,EAAEc,8BAAgB,CAACC,gBAAiB;MACxCjC,gBAAgB,EAAEA,gBAAiB;MACnCkC,MAAM,EAAE,IAAAC,wCAAkB,EAACvC,KAAK,CAAE;MAClCwC,MAAM,EAAE,IAAAC,wCAAkB,GAAG;MAC7BC,SAAS,EAAGtB,OAAuB,IAAKD,oBAAoB,CAACC,OAAO,CAAE;MACtEuB,YAAY,EAAE,KAAM;MACpBC,KAAK,EAAE5C,KAAK,CAAC4C;IAAM,EACnB;EAEN,CAAC;EAED,IAAIxC,gBAAgB,KAAKE,0BAAgB,CAACC,OAAO,EAAE;IACjD,OAAO0B,sBAAsB,EAAE;EACjC;EAEA,oBACEnE,MAAA,CAAAkB,OAAA,CAAAkD,aAAA,CAAC9D,YAAA,CAAAyE,IAAI;IAACC,KAAK,EAAE;MAAE7C,MAAM,EAAEA;IAAO;EAAE,GAC7BgC,sBAAsB,EAAE,CACpB;AAEX,CAAC;AAACc,OAAA,CAAAhD,oBAAA,GAAAA,oBAAA"}
|
|
@@ -13,6 +13,7 @@ var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
|
13
13
|
var _UNACHDebitComponent = require("./UNACHDebitComponent.utils");
|
|
14
14
|
var _reactNativePlaidLinkSdk = require("react-native-plaid-link-sdk");
|
|
15
15
|
var _paymentsMessage = require("../../messages/webMessages/paymentsMessage");
|
|
16
|
+
var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
19
|
const UNACHDebitComponent = props => {
|
|
@@ -33,6 +34,28 @@ const UNACHDebitComponent = props => {
|
|
|
33
34
|
const dispatchUnitPlaidResponse = success => {
|
|
34
35
|
(0, _UNACHDebitComponent.injectUnitPlaidResponse)(webRef.current, success);
|
|
35
36
|
};
|
|
37
|
+
const handleUnitOnLoad = response => {
|
|
38
|
+
if (!props.onLoad) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
|
|
42
|
+
props.onLoad(response);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (_onLoadMessage.RESPONSE_KEYS.account in response && _onLoadMessage.RESPONSE_KEYS.counterpartyAccount in response) {
|
|
46
|
+
// ACHOnLoadResponse;
|
|
47
|
+
const achOnload = {
|
|
48
|
+
data: {
|
|
49
|
+
[_onLoadMessage.RESPONSE_KEYS.account]: response[_onLoadMessage.RESPONSE_KEYS.account].data,
|
|
50
|
+
[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount]: response[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount].data
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
props.onLoad(achOnload);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.error('On Load Error: unexpected response type');
|
|
57
|
+
return;
|
|
58
|
+
};
|
|
36
59
|
const handleWebViewMessage = message => {
|
|
37
60
|
if (!message || !message.details) return;
|
|
38
61
|
switch (message.type) {
|
|
@@ -43,7 +66,7 @@ const UNACHDebitComponent = props => {
|
|
|
43
66
|
break;
|
|
44
67
|
}
|
|
45
68
|
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
46
|
-
|
|
69
|
+
handleUnitOnLoad(message.details);
|
|
47
70
|
break;
|
|
48
71
|
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
49
72
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHDebitComponent","_reactNativePlaidLinkSdk","_paymentsMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHDebitComponent","props","height","setHeight","useState","appPackageName","setAppPackageName","linkToken","setLinkToken","webRef","useRef","presentationMode","setPresentationMode","PresentationMode","Inherit","useEffect","setPackageNameForAndroid","Platform","OS","packageName","getAndroidPackageName","dispatchUnitPlaidResponse","success","injectUnitPlaidResponse","current","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achDebitEvent","onPaymentCreated","data","UnitMessage","UNIT_ON_LOAD","onLoad","PageMessage","PAGE_HEIGHT","currentHeight","Default","UNIT_PLAID_TOKEN_CREATED","linkTokenEvent","linkTokenData","attributes","UNIT_REQUEST_EXTERNAL_SDK","externalSdkType","openLink","tokenConfig","noLoadingState","token","onSuccess","onExit","exit","console","log","catch","e","error","renderACHDebitWebView","createElement","WebComponent","ref","WebComponentType","achDebitPayment","params","getACHDebitParams","script","getACHDebitScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHDebitComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { Platform, View } from 'react-native';\nimport { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHDebitParams, getACHDebitScript, getAndroidPackageName, injectUnitPlaidResponse } from './UNACHDebitComponent.utils';\n\nimport { LinkSuccess, openLink } from 'react-native-plaid-link-sdk';\nimport type WebView from 'react-native-webview';\n\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\n\nexport interface UNACHDebitComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNResponseUnitOnLoadEvent) => void;\n}\n\nexport const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [appPackageName, setAppPackageName] = useState<string>('');\n const [linkToken, setLinkToken] = useState<string>('');\n const webRef = useRef<WebView>(null);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n useEffect(() => {\n const setPackageNameForAndroid = async () => {\n if (Platform.OS === 'android') {\n const packageName = await getAndroidPackageName();\n setAppPackageName(packageName);\n }\n };\n setPackageNameForAndroid();\n }, []);\n\n const dispatchUnitPlaidResponse = (success: LinkSuccess) => {\n injectUnitPlaidResponse(webRef.current, success);\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achDebitEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achDebitEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n case UnitMessage.UNIT_PLAID_TOKEN_CREATED: {\n const linkTokenEvent = message.details as PlaidTokenCreatedEvent;\n const linkTokenData = linkTokenEvent.linkToken as PlaidLinkTokenData;\n setLinkToken(linkTokenData.attributes.linkToken);\n break;\n }\n\n case UnitMessage.UNIT_REQUEST_EXTERNAL_SDK: {\n const externalSdkType = (message.details as RequestExternalSdkEvent).type;\n if (externalSdkType !== 'plaid') return;\n linkToken && openLink({\n tokenConfig: { noLoadingState: false, token: linkToken},\n onSuccess: (success) => {\n dispatchUnitPlaidResponse(success);\n },\n onExit: exit => { console.log(exit); }\n }).catch(e => {\n console.error(e);\n });\n break;\n }\n }\n };\n\n const renderACHDebitWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.achDebitPayment}\n presentationMode={presentationMode}\n params={getACHDebitParams(props)}\n script={getACHDebitScript(appPackageName)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHDebitWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHDebitWebView()}\n </View>\n\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,O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YAAY;MACXC,GAAG,EAAErD,MAAO;MACZmB,IAAI,EAAEmC,8BAAgB,CAACC,eAAgB;MACvCrD,gBAAgB,EAAEA,gBAAiB;MACnCsD,MAAM,EAAE,IAAAC,sCAAiB,EAACjE,KAAK,CAAE;MACjCkE,MAAM,EAAE,IAAAC,sCAAiB,EAAC/D,cAAc,CAAE;MAC1CgE,SAAS,EAAG3C,OAAuB,IAAKD,oBAAoB,CAACC,OAAO,CAAE;MACtE4C,YAAY,EAAE,KAAM;MACpBC,KAAK,EAAEtE,KAAK,CAACsE;IAAM,EACnB;EAEN,CAAC;EAED,IAAI5D,gBAAgB,KAAKE,0BAAgB,CAACC,OAAO,EAAE;IACjD,OAAO6C,qBAAqB,EAAE;EAChC;EAEA,oBACE5F,MAAA,CAAAkB,OAAA,CAAA2E,aAAA,CAACvF,YAAA,CAAAmG,IAAI;IAACC,KAAK,EAAE;MAAEvE,MAAM,EAAEA;IAAO;EAAE,GAC7ByD,qBAAqB,EAAE,CACnB;AAGX,CAAC;AAACe,OAAA,CAAA1E,mBAAA,GAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHDebitComponent","_reactNativePlaidLinkSdk","_paymentsMessage","_onLoadMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHDebitComponent","props","height","setHeight","useState","appPackageName","setAppPackageName","linkToken","setLinkToken","webRef","useRef","presentationMode","setPresentationMode","PresentationMode","Inherit","useEffect","setPackageNameForAndroid","Platform","OS","packageName","getAndroidPackageName","dispatchUnitPlaidResponse","success","injectUnitPlaidResponse","current","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","account","counterpartyAccount","achOnload","data","console","error","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achDebitEvent","onPaymentCreated","UnitMessage","UNIT_ON_LOAD","PageMessage","PAGE_HEIGHT","currentHeight","Default","UNIT_PLAID_TOKEN_CREATED","linkTokenEvent","linkTokenData","attributes","UNIT_REQUEST_EXTERNAL_SDK","externalSdkType","openLink","tokenConfig","noLoadingState","token","onSuccess","onExit","exit","log","catch","e","renderACHDebitWebView","createElement","WebComponent","ref","WebComponentType","achDebitPayment","params","getACHDebitParams","script","getACHDebitScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHDebitComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNOnLoadResponse, UNACHData, UNError, UNOnLoadResponseData, UNACHOnLoadData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { Platform, View } from 'react-native';\nimport { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHDebitParams, getACHDebitScript, getAndroidPackageName, injectUnitPlaidResponse } from './UNACHDebitComponent.utils';\n\nimport { LinkSuccess, openLink } from 'react-native-plaid-link-sdk';\nimport type WebView from 'react-native-webview';\n\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\n\nexport interface UNACHDebitComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;\n}\n\nexport const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [appPackageName, setAppPackageName] = useState<string>('');\n const [linkToken, setLinkToken] = useState<string>('');\n const webRef = useRef<WebView>(null);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n useEffect(() => {\n const setPackageNameForAndroid = async () => {\n if (Platform.OS === 'android') {\n const packageName = await getAndroidPackageName();\n setAppPackageName(packageName);\n }\n };\n setPackageNameForAndroid();\n }, []);\n\n const dispatchUnitPlaidResponse = (success: LinkSuccess) => {\n injectUnitPlaidResponse(webRef.current, success);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {\n // ACHOnLoadResponse;\n const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {\n data: {\n [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,\n [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,\n }\n };\n props.onLoad(achOnload);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achDebitEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achDebitEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n case UnitMessage.UNIT_PLAID_TOKEN_CREATED: {\n const linkTokenEvent = message.details as PlaidTokenCreatedEvent;\n const linkTokenData = linkTokenEvent.linkToken as PlaidLinkTokenData;\n setLinkToken(linkTokenData.attributes.linkToken);\n break;\n }\n\n case UnitMessage.UNIT_REQUEST_EXTERNAL_SDK: {\n const externalSdkType = (message.details as RequestExternalSdkEvent).type;\n if (externalSdkType !== 'plaid') return;\n linkToken && openLink({\n tokenConfig: { noLoadingState: false, token: linkToken},\n onSuccess: (success) => {\n dispatchUnitPlaidResponse(success);\n },\n onExit: exit => { console.log(exit); }\n }).catch(e => {\n console.error(e);\n });\n break;\n }\n }\n };\n\n const renderACHDebitWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.achDebitPayment}\n presentationMode={presentationMode}\n params={getACHDebitParams(props)}\n script={getACHDebitScript(appPackageName)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHDebitWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHDebitWebView()}\n </View>\n\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AAEA,IAAAO,wBAAA,GAAAP,OAAA;AAGA,IAAAQ,gBAAA,GAAAR,OAAA;AAEA,IAAAS,cAAA,GAAAT,OAAA;AAAkG,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAZ,wBAAAgB,GAAA,EAAAJ,WAAA,SAAAA,WAAA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AI,CAAC;YAAE;UACvC,CAAC,CAAC,CAACE,KAAK,CAACC,CAAC,IAAI;YACZ/B,OAAO,CAACC,KAAK,CAAC8B,CAAC,CAAC;UAClB,CAAC,CAAC;UACF;QACF;IAAC;EAEL,CAAC;EAED,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;IAClC,oBACEpG,MAAA,CAAAmB,OAAA,CAAAkF,aAAA,CAAClG,aAAA,CAAAmG,YAAY;MACXC,GAAG,EAAE5D,MAAO;MACZ8B,IAAI,EAAE+B,8BAAgB,CAACC,eAAgB;MACvC5D,gBAAgB,EAAEA,gBAAiB;MACnC6D,MAAM,EAAE,IAAAC,sCAAiB,EAACxE,KAAK,CAAE;MACjCyE,MAAM,EAAE,IAAAC,sCAAiB,EAACtE,cAAc,CAAE;MAC1CuE,SAAS,EAAGvC,OAAuB,IAAKD,oBAAoB,CAACC,OAAO,CAAE;MACtEwC,YAAY,EAAE,KAAM;MACpBC,KAAK,EAAE7E,KAAK,CAAC6E;IAAM,EACnB;EAEN,CAAC;EAED,IAAInE,gBAAgB,KAAKE,0BAAgB,CAACC,OAAO,EAAE;IACjD,OAAOoD,qBAAqB,EAAE;EAChC;EAEA,oBACEpG,MAAA,CAAAmB,OAAA,CAAAkF,aAAA,CAAC/F,YAAA,CAAA2G,IAAI;IAACC,KAAK,EAAE;MAAE9E,MAAM,EAAEA;IAAO;EAAE,GAC7BgE,qBAAqB,EAAE,CACnB;AAGX,CAAC;AAACe,OAAA,CAAAjF,mBAAA,GAAAA,mBAAA"}
|
|
@@ -14,6 +14,7 @@ var _UNAccountComponent = require("./UNAccountComponent.utils");
|
|
|
14
14
|
var _bodyHtml = require("../../scripts/html/bodyHtml");
|
|
15
15
|
var _listenerToBus = require("../../hooks/listenerToBus");
|
|
16
16
|
var _accountMessage = require("../../messages/webMessages/accountMessage");
|
|
17
|
+
var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -23,7 +24,7 @@ exports.AccountAction = AccountAction;
|
|
|
23
24
|
AccountAction["List"] = "account-list";
|
|
24
25
|
AccountAction["Menu"] = "account-menu";
|
|
25
26
|
})(AccountAction || (exports.AccountAction = AccountAction = {}));
|
|
26
|
-
const UNAccountComponent = props
|
|
27
|
+
const UNAccountComponent = /*#__PURE__*/_react.default.forwardRef(function UNAccountComponent(props, accountRef) {
|
|
27
28
|
const [height, setHeight] = (0, _react.useState)(0);
|
|
28
29
|
const windowWidth = _reactNative.Dimensions.get('window').width;
|
|
29
30
|
const [requestRefreshEvent, setRequestRefreshEvent] = (0, _react.useState)(null);
|
|
@@ -34,6 +35,22 @@ const UNAccountComponent = props => {
|
|
|
34
35
|
const requestRefresh = data => {
|
|
35
36
|
setRequestRefreshEvent(data);
|
|
36
37
|
};
|
|
38
|
+
const handleUnitOnLoad = response => {
|
|
39
|
+
if (!props.onLoad) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
|
|
43
|
+
props.onLoad(response);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (_onLoadMessage.RESPONSE_KEYS.account in response) {
|
|
47
|
+
// AccountsOnLoadResponse;
|
|
48
|
+
props.onLoad(response[_onLoadMessage.RESPONSE_KEYS.account]);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
console.error('On Load Error: unexpected response type.');
|
|
52
|
+
return;
|
|
53
|
+
};
|
|
37
54
|
(0, _listenerToBus.useListenerToBus)({
|
|
38
55
|
busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_REFRESH,
|
|
39
56
|
action: requestRefresh
|
|
@@ -45,10 +62,18 @@ const UNAccountComponent = props => {
|
|
|
45
62
|
(0, _react.useEffect)(() => {
|
|
46
63
|
(0, _UNAccountComponent.injectRefreshEventIfNeeded)(webRef.current, requestRefreshEvent);
|
|
47
64
|
}, [requestRefreshEvent]);
|
|
65
|
+
(0, _react.useImperativeHandle)(accountRef, () => ({
|
|
66
|
+
openActionsMenu() {
|
|
67
|
+
(0, _UNAccountComponent.injectOpenActionsMenuScript)(webRef.current);
|
|
68
|
+
},
|
|
69
|
+
openAction(action) {
|
|
70
|
+
(0, _UNAccountComponent.injectRequestAccountActionScript)(webRef.current, action);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
48
73
|
const handleMessage = message => {
|
|
49
74
|
switch (message.type) {
|
|
50
75
|
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
51
|
-
|
|
76
|
+
handleUnitOnLoad(message.details);
|
|
52
77
|
break;
|
|
53
78
|
case _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING:
|
|
54
79
|
{
|
|
@@ -80,6 +105,6 @@ const UNAccountComponent = props => {
|
|
|
80
105
|
width: windowWidth,
|
|
81
106
|
isScrollable: false
|
|
82
107
|
}));
|
|
83
|
-
};
|
|
108
|
+
});
|
|
84
109
|
exports.UNAccountComponent = UNAccountComponent;
|
|
85
110
|
//# sourceMappingURL=UNAccountComponent.js.map
|