react-native-unit-components 1.1.0 → 1.2.1
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 +70 -1
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +8 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +12 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +6 -5
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/cardMessage.js +1 -13
- package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/accountMessage.js +12 -0
- package/lib/commonjs/messages/webMessages/accountMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/index.js.map +1 -1
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +14 -3
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/account.types.js +31 -0
- package/lib/commonjs/sharedTypes/account.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js +11 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/payments.types.js +6 -6
- package/lib/commonjs/sharedTypes/payments.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/types.js.map +1 -1
- package/lib/commonjs/sharedTypes/wallet.types.js +13 -1
- package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +2 -1
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +2 -0
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +8 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +11 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +7 -6
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/messages/nativeMessages/cardMessage.js +0 -11
- package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -1
- package/lib/module/messages/webMessages/accountMessage.js +5 -0
- package/lib/module/messages/webMessages/accountMessage.js.map +1 -0
- package/lib/module/messages/webMessages/index.js.map +1 -1
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +14 -3
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/account.types.js +23 -0
- package/lib/module/sharedTypes/account.types.js.map +1 -0
- package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +1 -0
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/module/sharedTypes/payments.types.js +4 -4
- package/lib/module/sharedTypes/payments.types.js.map +1 -1
- package/lib/module/sharedTypes/types.js.map +1 -1
- package/lib/module/sharedTypes/wallet.types.js +11 -0
- package/lib/module/sharedTypes/wallet.types.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +2 -1
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +2 -0
- 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 +4 -2
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -2
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +2 -2
- package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +4 -13
- package/lib/typescript/messages/webMessages/accountMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/index.d.ts +3 -2
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
- package/lib/typescript/scripts/html/bodyScript.d.ts +1 -0
- package/lib/typescript/sharedTypes/account.types.d.ts +114 -0
- package/lib/typescript/sharedTypes/achCredit.types.d.ts +13 -13
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +11 -11
- package/lib/typescript/sharedTypes/card.types.d.ts +18 -18
- package/lib/typescript/sharedTypes/index.d.ts +1 -0
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +3 -3
- package/lib/typescript/sharedTypes/payments.types.d.ts +5 -5
- package/lib/typescript/sharedTypes/types.d.ts +7 -7
- package/lib/typescript/sharedTypes/wallet.types.d.ts +11 -2
- package/package.json +1 -1
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +3 -3
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +3 -3
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +11 -3
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +15 -4
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +3 -3
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +11 -1
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +8 -7
- package/src/components/UNCardComponent/UNCardComponent.tsx +5 -5
- package/src/messages/nativeMessages/cardMessage.ts +5 -15
- package/src/messages/webMessages/accountMessage.ts +12 -0
- package/src/messages/webMessages/index.ts +3 -0
- package/src/messages/webMessages/unitMessages.ts +2 -2
- package/src/scripts/html/bodyScript.ts +14 -2
- package/src/sharedTypes/account.types.ts +117 -0
- package/src/sharedTypes/achCredit.types.ts +13 -13
- package/src/sharedTypes/bookPayment.types.ts +11 -11
- package/src/sharedTypes/card.types.ts +18 -18
- package/src/sharedTypes/index.ts +1 -0
- package/src/sharedTypes/onLoadResponse.types.ts +5 -5
- package/src/sharedTypes/payments.types.ts +5 -5
- package/src/sharedTypes/types.ts +8 -8
- package/src/sharedTypes/wallet.types.ts +13 -3
- package/src/webComponent/WebComponent.tsx +1 -1
- package/src/webComponent/html.ts +2 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { UNCardData } from '../sharedTypes';
|
|
2
|
-
export type
|
|
2
|
+
export type UNSuccessResponseUnitOnLoad = {
|
|
3
3
|
data: UNCardData | Object;
|
|
4
4
|
included: [Object];
|
|
5
5
|
errors: null;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type UNErrorResponseUnitOnLoad = {
|
|
8
8
|
errors: [
|
|
9
9
|
{
|
|
10
10
|
status: string;
|
|
@@ -15,4 +15,4 @@ export type ErrorResponseUnitOnLoad = {
|
|
|
15
15
|
}
|
|
16
16
|
];
|
|
17
17
|
};
|
|
18
|
-
export type
|
|
18
|
+
export type UNResponseUnitOnLoadEvent = UNSuccessResponseUnitOnLoad | UNErrorResponseUnitOnLoad;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
1
|
+
export type UNPaymentStatus = 'Sent' | 'Rejected';
|
|
2
|
+
export type UNAchCounterparty = {
|
|
3
3
|
name: string;
|
|
4
4
|
accountNumber: string;
|
|
5
5
|
routingNumber: string;
|
|
6
|
-
accountType:
|
|
6
|
+
accountType: UNAccountType;
|
|
7
7
|
};
|
|
8
|
-
type
|
|
9
|
-
export declare enum
|
|
8
|
+
type UNAccountType = 'Savings' | 'Checking';
|
|
9
|
+
export declare enum UNCounterpartyVerificationMethod {
|
|
10
10
|
Plaid = "Plaid"
|
|
11
11
|
}
|
|
12
12
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type UNAddress = {
|
|
2
2
|
street: string;
|
|
3
3
|
street2?: string;
|
|
4
4
|
city: string;
|
|
@@ -6,22 +6,22 @@ export type Address = {
|
|
|
6
6
|
postalCode: string;
|
|
7
7
|
country: string;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type UNLimits = {
|
|
10
10
|
dailyWithdrawal?: string | number;
|
|
11
11
|
dailyPurchase?: string | number;
|
|
12
12
|
monthlyWithdrawal?: string | number;
|
|
13
13
|
monthlyPurchase?: string | number;
|
|
14
14
|
};
|
|
15
|
-
type
|
|
15
|
+
type UNData = {
|
|
16
16
|
type: string;
|
|
17
17
|
id: string;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
20
|
-
data: null | [] |
|
|
19
|
+
export type UNRelationship = {
|
|
20
|
+
data: null | [] | UNData | UNData[];
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
22
|
+
export type UNFullName = {
|
|
23
23
|
first: string;
|
|
24
24
|
last: string;
|
|
25
25
|
};
|
|
26
|
-
export type
|
|
26
|
+
export type UNTags = Record<string, string>;
|
|
27
27
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CardAddToWalletStatus } from 'src/messages/nativeMessages/cardMessage';
|
|
2
1
|
export declare enum UNWalletCode {
|
|
3
2
|
Apple = "ApplePayPushProvision",
|
|
4
3
|
Google = "GooglePayPushProvision"
|
|
@@ -10,5 +9,15 @@ export declare enum UNWalletName {
|
|
|
10
9
|
export interface UNWallet {
|
|
11
10
|
name: string;
|
|
12
11
|
code: string;
|
|
13
|
-
status:
|
|
12
|
+
status: UNCardAddToWalletStatus;
|
|
13
|
+
}
|
|
14
|
+
export declare enum UNCardAddToWalletStatus {
|
|
15
|
+
pending = 0,
|
|
16
|
+
readyToProvisioning = "ReadyToProvision",
|
|
17
|
+
addedToWallet = "AlreadyProvisioned",
|
|
18
|
+
iosProvisionedInCurrentDevice = "ProvisionedInCurrentDevice",
|
|
19
|
+
iosProvisionedInPairedDevice = "ProvisionedInPairedDevice",
|
|
20
|
+
androidNotInstalled = "NotInstalled",
|
|
21
|
+
androidWalletSetupNotCompleted = "WalletSetupNotCompleted",
|
|
22
|
+
androidWalletAppUpdateAvailable = "WalletAppUpdateAvailable"
|
|
14
23
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
3
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
4
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
5
|
-
import type {
|
|
5
|
+
import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
|
|
6
6
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
7
|
import { View } from 'react-native';
|
|
8
8
|
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
@@ -17,7 +17,7 @@ export interface UNACHCreditComponentProps {
|
|
|
17
17
|
isAutoFocus?: boolean;
|
|
18
18
|
fee?: number;
|
|
19
19
|
onPaymentCreated?: (data: UNACHData) => void;
|
|
20
|
-
onLoad?: (response:
|
|
20
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {
|
|
@@ -34,7 +34,7 @@ export const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {
|
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
36
|
case UnitMessage.UNIT_ON_LOAD:
|
|
37
|
-
props.onLoad && props.onLoad(message.details as
|
|
37
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
38
38
|
break;
|
|
39
39
|
case PageMessage.PAGE_HEIGHT: {
|
|
40
40
|
const currentHeight = (message.details as HeightEvent).height;
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
3
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
4
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
5
|
-
import type {
|
|
5
|
+
import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
|
|
6
6
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
7
|
import { Platform, View } from 'react-native';
|
|
8
8
|
import { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
@@ -21,7 +21,7 @@ export interface UNACHDebitComponentProps {
|
|
|
21
21
|
isAutoFocus?: boolean;
|
|
22
22
|
fee?: number;
|
|
23
23
|
onPaymentCreated?: (data: UNACHData) => void;
|
|
24
|
-
onLoad?: (response:
|
|
24
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
|
|
@@ -55,7 +55,7 @@ export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
|
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
57
|
case UnitMessage.UNIT_ON_LOAD:
|
|
58
|
-
props.onLoad && props.onLoad(message.details as
|
|
58
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
59
59
|
break;
|
|
60
60
|
case PageMessage.PAGE_HEIGHT: {
|
|
61
61
|
const currentHeight = (message.details as HeightEvent).height;
|
|
@@ -9,14 +9,17 @@ import type { WebViewMessage } from '../../messages/webMessages';
|
|
|
9
9
|
import { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';
|
|
10
10
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
11
11
|
import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
|
|
12
|
-
import type {
|
|
12
|
+
import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
|
|
13
13
|
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
14
|
+
import type { UNAccountData } from '../../sharedTypes/account.types';
|
|
15
|
+
import { AccountMessage } from '../../messages/webMessages/accountMessage';
|
|
14
16
|
|
|
15
17
|
export interface UNAccountComponentProps {
|
|
16
18
|
accountId?: string;
|
|
17
19
|
customerToken: string;
|
|
18
20
|
theme?: string;
|
|
19
|
-
onLoad?: (response:
|
|
21
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
22
|
+
onAccountChanged?: (account: UNAccountData) => void;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export enum AccountAction {
|
|
@@ -32,11 +35,16 @@ export const UNAccountComponent = (props: UNAccountComponentProps) => {
|
|
|
32
35
|
|
|
33
36
|
const webRef = useRef<WebView>(null);
|
|
34
37
|
|
|
38
|
+
const handleAccountChanged = (account: UNAccountData) => {
|
|
39
|
+
props.onAccountChanged && props.onAccountChanged(account)
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
const requestRefresh = (data: RequestRefreshEvent) => {
|
|
36
43
|
setRequestRefreshEvent(data);
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });
|
|
47
|
+
useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });
|
|
40
48
|
|
|
41
49
|
useEffect(() => {
|
|
42
50
|
injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);
|
|
@@ -45,7 +53,7 @@ export const UNAccountComponent = (props: UNAccountComponentProps) => {
|
|
|
45
53
|
const handleMessage = (message: WebViewMessage) => {
|
|
46
54
|
switch (message.type) {
|
|
47
55
|
case UnitMessage.UNIT_ON_LOAD:
|
|
48
|
-
props.onLoad && props.onLoad(message.details as
|
|
56
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
49
57
|
break;
|
|
50
58
|
case UnitMessage.UNIT_REQUEST_RENDERING: {
|
|
51
59
|
const event: BottomSheetSlotData = {
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react';
|
|
2
2
|
import { Dimensions, View } from 'react-native';
|
|
3
|
-
import { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
3
|
+
import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
4
4
|
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
5
5
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
6
6
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
7
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
8
|
-
import type {
|
|
8
|
+
import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
|
|
9
9
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
10
10
|
import { getActivityParams, getActivityScript, injectRefreshEventIfNeeded } from './UNActivityComponent.utils';
|
|
11
11
|
import type WebView from 'react-native-webview';
|
|
12
|
+
import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
|
|
13
|
+
import EventBus from '../../helpers/EventBus';
|
|
12
14
|
|
|
13
15
|
const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
|
|
14
16
|
export interface UNActivityComponentProps {
|
|
15
17
|
accountId: string;
|
|
16
18
|
customerToken: string;
|
|
17
19
|
theme?: string;
|
|
18
|
-
onLoad?: (response:
|
|
20
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export const UNActivityComponent = (props: UNActivityComponentProps) => {
|
|
@@ -30,8 +32,17 @@ export const UNActivityComponent = (props: UNActivityComponentProps) => {
|
|
|
30
32
|
|
|
31
33
|
const handleWebViewMessage = (message: WebViewMessage) => {
|
|
32
34
|
switch (message.type) {
|
|
35
|
+
case UnitMessage.UNIT_REQUEST_RENDERING: {
|
|
36
|
+
const event: BottomSheetSlotData = {
|
|
37
|
+
componentName: WebComponentType.activity,
|
|
38
|
+
componentResourceId: props.accountId,
|
|
39
|
+
requestRenderingEvent: message.details as RequestRenderingEvent
|
|
40
|
+
};
|
|
41
|
+
EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
33
44
|
case UnitMessage.UNIT_ON_LOAD:
|
|
34
|
-
props.onLoad && props.onLoad(message.details as
|
|
45
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
35
46
|
break;
|
|
36
47
|
case PageMessage.PAGE_HEIGHT: {
|
|
37
48
|
const currentHeight = (message.details as HeightEvent).height;
|
|
@@ -3,7 +3,7 @@ import { WebComponent, WebComponentType } from '../../webComponent/WebComponent'
|
|
|
3
3
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
4
|
import { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';
|
|
5
5
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
6
|
-
import type {
|
|
6
|
+
import type { UNResponseUnitOnLoadEvent, UNBookPaymentData } from '../../sharedTypes';
|
|
7
7
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
8
8
|
import { View } from 'react-native';
|
|
9
9
|
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
@@ -18,7 +18,7 @@ export interface UNBookPaymentComponentProps {
|
|
|
18
18
|
counterPartyName: string;
|
|
19
19
|
theme?: string;
|
|
20
20
|
onPaymentCreated?: (data: UNBookPaymentData) => void;
|
|
21
|
-
onLoad?: (response:
|
|
21
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {
|
|
@@ -33,7 +33,7 @@ export const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {
|
|
|
33
33
|
props.onPaymentCreated && props.onPaymentCreated((message.details as BookPaymentEvent).data);
|
|
34
34
|
break;
|
|
35
35
|
case UnitMessage.UNIT_ON_LOAD:
|
|
36
|
-
props.onLoad && props.onLoad(message.details as
|
|
36
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
37
37
|
break;
|
|
38
38
|
case PageMessage.PAGE_HEIGHT: {
|
|
39
39
|
const currentHeight = (message.details as HeightEvent).height;
|
|
@@ -10,13 +10,20 @@ import { RequestOpenLinkEvent, RequestRenderingEvent, UnitMessage } from '../../
|
|
|
10
10
|
import { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';
|
|
11
11
|
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
12
12
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
getBottomSheetScript,
|
|
15
|
+
handleHtmlFullHeight,
|
|
16
|
+
renderingBottomSheetRequest,
|
|
17
|
+
resetHtml,
|
|
18
|
+
} from './UNBottomSheetComponent.utils';
|
|
14
19
|
import { getStylesObject } from './UNBottomSheetComponent.styles';
|
|
15
20
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
16
21
|
import { useAppStateListener } from '../../hooks/useAppStateListener';
|
|
17
22
|
import { UNAddToWalletBottomSheetItem } from './components/UNAddToWalletBottomSheetItem';
|
|
18
23
|
import { getAccountActionType } from '../UNAccountComponent/UNAccountComponent.utils';
|
|
19
24
|
import { AccountAction } from '../UNAccountComponent/UNAccountComponent';
|
|
25
|
+
import type { AccountChangedEvent } from '../../messages/webMessages/accountMessage';
|
|
26
|
+
import { AccountMessage } from '../../messages/webMessages/accountMessage';
|
|
20
27
|
|
|
21
28
|
export enum ScrollState {
|
|
22
29
|
/*
|
|
@@ -170,6 +177,9 @@ export const UNBottomSheetComponent = () => {
|
|
|
170
177
|
case CardMessage.CARD_STATUS_CHANGED:
|
|
171
178
|
EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);
|
|
172
179
|
break;
|
|
180
|
+
case AccountMessage.UNIT_ACCOUNT_CHANGED:
|
|
181
|
+
EventBus.Instance.event(AccountMessage.UNIT_ACCOUNT_CHANGED, (message.details as AccountChangedEvent).account);
|
|
182
|
+
break;
|
|
173
183
|
case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:
|
|
174
184
|
handleCloseFlow();
|
|
175
185
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import type WebView from 'react-native-webview';
|
|
3
|
-
import {
|
|
3
|
+
import { UNCardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../../messages/nativeMessages/cardMessage';
|
|
4
4
|
import EventBus from '../../../helpers/EventBus';
|
|
5
5
|
import { PresentationMode } from '../../../scripts/html/bodyHtml';
|
|
6
6
|
import { WebComponent, WebComponentType } from '../../../webComponent/WebComponent';
|
|
@@ -10,6 +10,7 @@ import { ActivityIndicator } from 'react-native';
|
|
|
10
10
|
import { useListenerToBus } from '../../../hooks/listenerToBus';
|
|
11
11
|
import type { RequestRenderingEvent } from '../../../messages/webMessages/unitMessages';
|
|
12
12
|
import UnitAddToWalletButtonView from '../../../nativeComponent/UnitAddToWalletButton';
|
|
13
|
+
import { UNCardAddToWalletStatus } from '../../../sharedTypes/wallet.types';
|
|
13
14
|
|
|
14
15
|
export interface UNAddToWalletBottomSheetItemProps {
|
|
15
16
|
renderingRequest?: RequestRenderingEvent
|
|
@@ -23,7 +24,7 @@ export const UNAddToWalletBottomSheetItem = (props: UNAddToWalletBottomSheetItem
|
|
|
23
24
|
|
|
24
25
|
const { renderingRequest, cardId } = props;
|
|
25
26
|
|
|
26
|
-
const [addToWalletStatus, setAddToWalletStatus] = useState<
|
|
27
|
+
const [addToWalletStatus, setAddToWalletStatus] = useState<UNCardAddToWalletStatus>(UNCardAddToWalletStatus.pending);
|
|
27
28
|
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
if (!cardId) return;
|
|
@@ -33,9 +34,9 @@ export const UNAddToWalletBottomSheetItem = (props: UNAddToWalletBottomSheetItem
|
|
|
33
34
|
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
if (!webRef.current) return;
|
|
36
|
-
if (addToWalletStatus ===
|
|
37
|
+
if (addToWalletStatus === UNCardAddToWalletStatus.pending) return;
|
|
37
38
|
|
|
38
|
-
const isCardInWallet = addToWalletStatus ===
|
|
39
|
+
const isCardInWallet = addToWalletStatus === UNCardAddToWalletStatus.addedToWallet;
|
|
39
40
|
webRef.current.injectJavaScript(`window.UnitMobileSDKConfig["isCardInWallet"] = ${isCardInWallet}`);
|
|
40
41
|
|
|
41
42
|
if (renderingRequest) {
|
|
@@ -43,7 +44,7 @@ export const UNAddToWalletBottomSheetItem = (props: UNAddToWalletBottomSheetItem
|
|
|
43
44
|
}
|
|
44
45
|
}, [webRef.current, renderingRequest, addToWalletStatus]);
|
|
45
46
|
|
|
46
|
-
const gotCardWalletStatus = (data?:
|
|
47
|
+
const gotCardWalletStatus = (data?: UNCardAddToWalletStatusEvent) => {
|
|
47
48
|
if (data != null) {
|
|
48
49
|
setAddToWalletStatus(data.status);
|
|
49
50
|
}
|
|
@@ -65,8 +66,8 @@ export const UNAddToWalletBottomSheetItem = (props: UNAddToWalletBottomSheetItem
|
|
|
65
66
|
presentationMode={PresentationMode.CoverInjectedHeight}
|
|
66
67
|
isScrollable={false}
|
|
67
68
|
/>
|
|
68
|
-
{addToWalletStatus ===
|
|
69
|
-
{addToWalletStatus ===
|
|
69
|
+
{addToWalletStatus === UNCardAddToWalletStatus.pending && <ActivityIndicator style={styles.loader} />}
|
|
70
|
+
{addToWalletStatus === UNCardAddToWalletStatus.readyToProvisioning && <UnitAddToWalletButtonView style={styles.addToWalletButton} onAddToWalletClicked={handleAddToWalletClicked} />}
|
|
70
71
|
</>
|
|
71
72
|
);
|
|
72
73
|
};
|
|
@@ -9,12 +9,12 @@ import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
|
9
9
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
10
10
|
import { getCardParams, getCardScript, injectRefreshEventIfNeeded, launchStartCardProvisioning } from './UNCardComponent.utils';
|
|
11
11
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
12
|
-
import type {
|
|
12
|
+
import type { UNResponseUnitOnLoadEvent, UNCardData } from '../../sharedTypes';
|
|
13
13
|
import { CardMessage } from '../../messages/webMessages/cardMessage';
|
|
14
14
|
import { launchGetWallets } from './UNCardComponent.utils';
|
|
15
15
|
import type { NativeModules } from 'react-native';
|
|
16
16
|
import type { UNWallet } from 'src/sharedTypes/wallet.types';
|
|
17
|
-
import { CardAddToWalletErrors,
|
|
17
|
+
import { CardAddToWalletErrors, UNCardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../messages/nativeMessages/cardMessage';
|
|
18
18
|
import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
|
|
19
19
|
export interface UNCardComponentProps {
|
|
20
20
|
// inputs
|
|
@@ -26,7 +26,7 @@ export interface UNCardComponentProps {
|
|
|
26
26
|
hideSensitiveDataButton?: boolean;
|
|
27
27
|
|
|
28
28
|
// events
|
|
29
|
-
onLoad?: (response:
|
|
29
|
+
onLoad?: (response: UNResponseUnitOnLoadEvent) => void
|
|
30
30
|
onStatusChanged?: (card: UNCardData) => void;
|
|
31
31
|
pushProvisioningModule?: typeof NativeModules;
|
|
32
32
|
}
|
|
@@ -83,7 +83,7 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
83
83
|
setHeight((message.details as HeightEvent).height);
|
|
84
84
|
break;
|
|
85
85
|
case UnitMessage.UNIT_ON_LOAD:
|
|
86
|
-
props.onLoad && props.onLoad(message.details as
|
|
86
|
+
props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
};
|
|
@@ -98,7 +98,7 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
98
98
|
|
|
99
99
|
walletRef.current = walletResponse;
|
|
100
100
|
|
|
101
|
-
const walletStatus:
|
|
101
|
+
const walletStatus: UNCardAddToWalletStatusEvent = { status: walletResponse.status };
|
|
102
102
|
EventBus.Instance.event(CardNativeMessage.CARD_UPDATE_ADD_TO_WALLET_STATUS, walletStatus);
|
|
103
103
|
} catch (error) {
|
|
104
104
|
console.error(error);
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
import type { UNCardAddToWalletStatus } from '../../sharedTypes/wallet.types';
|
|
2
|
+
|
|
1
3
|
export enum CardNativeMessage {
|
|
2
4
|
CARD_GET_ADD_TO_WALLET_STATUS = 'cardGetAddToWalletStatus',
|
|
3
5
|
CARD_UPDATE_ADD_TO_WALLET_STATUS = 'cardUpdateAddToWalletStatus',
|
|
4
6
|
CARD_START_PUSH_PROVISIONING = 'cardStartPushProvisioning'
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export enum CardAddToWalletStatus {
|
|
8
|
-
pending,
|
|
9
|
-
readyToProvisioning = 'ReadyToProvision',
|
|
10
|
-
addedToWallet = 'AlreadyProvisioned',
|
|
11
|
-
iosProvisionedInCurrentDevice = 'ProvisionedInCurrentDevice',
|
|
12
|
-
iosProvisionedInPairedDevice = 'ProvisionedInPairedDevice',
|
|
13
|
-
androidNotInstalled = 'NotInstalled',
|
|
14
|
-
androidWalletSetupNotCompleted = 'WalletSetupNotCompleted',
|
|
15
|
-
androidWalletAppUpdateAvailable = 'WalletAppUpdateAvailable'
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
9
|
export enum CardAddToWalletErrors {
|
|
20
10
|
closedNativeWalletScreen = 'VP_ERROR_302'
|
|
21
11
|
}
|
|
22
|
-
export interface
|
|
23
|
-
status:
|
|
12
|
+
export interface UNCardAddToWalletStatusEvent {
|
|
13
|
+
status: UNCardAddToWalletStatus
|
|
24
14
|
}
|
|
25
15
|
|
|
26
16
|
export interface CardGetAddToWalletStatusEvent {
|
|
@@ -32,6 +22,6 @@ export interface CardStartPushProvisioningEvent {
|
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
export type CardNativeEvent =
|
|
35
|
-
|
|
|
25
|
+
| UNCardAddToWalletStatusEvent
|
|
36
26
|
| CardGetAddToWalletStatusEvent
|
|
37
27
|
| CardStartPushProvisioningEvent
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UNAccountData } from '../../sharedTypes';
|
|
2
|
+
|
|
3
|
+
export enum AccountMessage {
|
|
4
|
+
UNIT_ACCOUNT_CHANGED = 'unitAccountChanged'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface AccountChangedEvent {
|
|
8
|
+
account: UNAccountData;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type AccountEvent =
|
|
12
|
+
| AccountChangedEvent
|
|
@@ -5,12 +5,14 @@ import type { CardEvent, CardMessage } from './cardMessage';
|
|
|
5
5
|
import type { PageEvent, PageMessage } from './pageMessage';
|
|
6
6
|
import type { PaymentMessage } from './paymentsMessage';
|
|
7
7
|
import type { UnitEvent, UnitMessage } from './unitMessages';
|
|
8
|
+
import type { AccountEvent, AccountMessage } from './accountMessage';
|
|
8
9
|
|
|
9
10
|
export type WebViewMessageType =
|
|
10
11
|
| PageMessage
|
|
11
12
|
| CardMessage
|
|
12
13
|
| UnitMessage
|
|
13
14
|
| PaymentMessage
|
|
15
|
+
| AccountMessage
|
|
14
16
|
|
|
15
17
|
type WebViewEvent =
|
|
16
18
|
| PageEvent
|
|
@@ -19,6 +21,7 @@ type WebViewEvent =
|
|
|
19
21
|
| BookPaymentEvent
|
|
20
22
|
| PaymentMessage
|
|
21
23
|
| ACHEvent
|
|
24
|
+
| AccountEvent
|
|
22
25
|
|
|
23
26
|
export interface WebViewMessage {
|
|
24
27
|
type: WebViewMessageType,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
|
|
2
2
|
|
|
3
3
|
export enum UnitMessage {
|
|
4
4
|
UNIT_REQUEST_RENDERING = 'unitRequestRendering',
|
|
@@ -63,7 +63,7 @@ export type UnitEvent =
|
|
|
63
63
|
| RequestRenderingEvent
|
|
64
64
|
| RequestRefreshEvent
|
|
65
65
|
| RequestOpenLinkEvent
|
|
66
|
-
|
|
|
66
|
+
| UNResponseUnitOnLoadEvent
|
|
67
67
|
| RequestDownloadEvent
|
|
68
68
|
| PlaidTokenCreatedEvent
|
|
69
69
|
| RequestExternalSdkEvent
|
|
@@ -2,6 +2,7 @@ import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
|
|
|
2
2
|
import { CardMessage } from '../../messages/webMessages/cardMessage';
|
|
3
3
|
import { PageMessage } from '../../messages/webMessages/pageMessage';
|
|
4
4
|
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
5
|
+
import { AccountMessage } from '../../messages/webMessages/accountMessage';
|
|
5
6
|
|
|
6
7
|
export const POST_MESSAGE_TO_SDK = `
|
|
7
8
|
const postMessageToSDK = (message) => {
|
|
@@ -62,7 +63,7 @@ export const LISTENERS = {
|
|
|
62
63
|
window.addEventListener("${CardMessage.CARD_STATUS_CHANGED}", (e) => {
|
|
63
64
|
const response = e.detail
|
|
64
65
|
response.then((data) => {
|
|
65
|
-
postMessageToSDK({ type: "${CardMessage.CARD_STATUS_CHANGED}", details: { card:
|
|
66
|
+
postMessageToSDK({ type: "${CardMessage.CARD_STATUS_CHANGED}", details: { card: data.data }})
|
|
66
67
|
}).catch((e) => {
|
|
67
68
|
console.log(e)
|
|
68
69
|
})
|
|
@@ -77,11 +78,22 @@ export const LISTENERS = {
|
|
|
77
78
|
window.addEventListener("${PaymentMessage.PAYMENT_CREATED}", (e) => {
|
|
78
79
|
const response = e.detail
|
|
79
80
|
response.then((data) => {
|
|
80
|
-
postMessageToSDK({ type: "${PaymentMessage.PAYMENT_CREATED}", details: { data:
|
|
81
|
+
postMessageToSDK({ type: "${PaymentMessage.PAYMENT_CREATED}", details: { data: data.data }})
|
|
81
82
|
}).catch((e) => {
|
|
82
83
|
console.log(e)
|
|
83
84
|
})
|
|
84
85
|
});`
|
|
86
|
+
,
|
|
87
|
+
unitAccountChanged: `
|
|
88
|
+
window.addEventListener("${AccountMessage.UNIT_ACCOUNT_CHANGED}", (e) => {
|
|
89
|
+
const response = e.detail
|
|
90
|
+
response.then((data) => {
|
|
91
|
+
postMessageToSDK({ type: "${AccountMessage.UNIT_ACCOUNT_CHANGED}", details: { account: data.data }})
|
|
92
|
+
}).catch((e) => {
|
|
93
|
+
console.log(e)
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
`,
|
|
85
97
|
};
|
|
86
98
|
|
|
87
99
|
export const DISPATCH_RENDERING_EVENT = `
|