react-native-unit-components 1.1.0 → 1.2.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 +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/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/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/html.ts +2 -0
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcuserdata/alonshprung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/UnitReactNativeComponents.xcodeproj/xcuserdata/alonshprung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -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 = `
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { UNRelationship, UNTags } from './types';
|
|
2
|
+
|
|
3
|
+
export type UNAccountData = UNDepositAccount | UNBatchAccount | UNCreditAccount
|
|
4
|
+
|
|
5
|
+
enum UNAccountStatus {
|
|
6
|
+
Open = "Open",
|
|
7
|
+
Closed = "Closed",
|
|
8
|
+
Frozen = "Frozen",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum UNCloseReason {
|
|
12
|
+
Fraud = "Fraud",
|
|
13
|
+
ByCustomer = "ByCustomer",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum UNFraudReason {
|
|
17
|
+
ACHActivity = "ACHActivity",
|
|
18
|
+
CardActivity = "CardActivity",
|
|
19
|
+
CheckActivity = "CheckActivity",
|
|
20
|
+
ApplicationHistory = "ApplicationHistory",
|
|
21
|
+
AccountActivity = "AccountActivity",
|
|
22
|
+
ClientIdentified = "ClientIdentified",
|
|
23
|
+
IdentityTheft = "IdentityTheft",
|
|
24
|
+
LinkedToFraudulentCustomer = "LinkedToFraudulentCustomer",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type UNDepositAccount = {
|
|
28
|
+
id: string
|
|
29
|
+
type: "depositAccount"
|
|
30
|
+
attributes: {
|
|
31
|
+
createdAt: string
|
|
32
|
+
updatedAt?: string
|
|
33
|
+
name: string
|
|
34
|
+
depositProduct: string
|
|
35
|
+
routingNumber: string
|
|
36
|
+
accountNumber: string
|
|
37
|
+
maskedAccountNumber?: string
|
|
38
|
+
secondaryAccountNumber?: {
|
|
39
|
+
routingNumber: string
|
|
40
|
+
accountNumber: string
|
|
41
|
+
}
|
|
42
|
+
balance: number
|
|
43
|
+
hold: number
|
|
44
|
+
reserve: number
|
|
45
|
+
available: number
|
|
46
|
+
overdraftLimit?: number
|
|
47
|
+
currency: string
|
|
48
|
+
tags: UNTags
|
|
49
|
+
status: UNAccountStatus
|
|
50
|
+
closeReason?: string
|
|
51
|
+
fraudReason?: UNFraudReason
|
|
52
|
+
closeReasonText?: string
|
|
53
|
+
freezeReason?: string
|
|
54
|
+
isOverdrawnWithinLimit?: boolean
|
|
55
|
+
}
|
|
56
|
+
relationships: {
|
|
57
|
+
customer?: UNRelationship
|
|
58
|
+
customers?: UNRelationship
|
|
59
|
+
org: UNRelationship
|
|
60
|
+
}
|
|
61
|
+
// included?: Individual[]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type UNBatchAccount = {
|
|
65
|
+
id: string
|
|
66
|
+
type: "batchAccount"
|
|
67
|
+
attributes: {
|
|
68
|
+
createdAt: Date
|
|
69
|
+
updatedAt?: Date
|
|
70
|
+
name: string
|
|
71
|
+
depositProduct: string
|
|
72
|
+
routingNumber: string
|
|
73
|
+
accountNumber: string
|
|
74
|
+
maskedAccountNumber?: string
|
|
75
|
+
balance: number
|
|
76
|
+
hold: number
|
|
77
|
+
reserve: number
|
|
78
|
+
available: number
|
|
79
|
+
currency: string
|
|
80
|
+
status: "Open" | "Closed"
|
|
81
|
+
closeReason?: string
|
|
82
|
+
fraudReason?: UNFraudReason
|
|
83
|
+
closeReasonText?: string
|
|
84
|
+
freezeReason?: string
|
|
85
|
+
tags?: {[key: string]: string}
|
|
86
|
+
}
|
|
87
|
+
relationships: {
|
|
88
|
+
org: UNRelationship
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type UNCreditAccount = {
|
|
93
|
+
id: string
|
|
94
|
+
type: "creditAccount"
|
|
95
|
+
attributes: {
|
|
96
|
+
createdAt: Date
|
|
97
|
+
updatedAt?: Date
|
|
98
|
+
name: string
|
|
99
|
+
creditTerms: string
|
|
100
|
+
balance: number
|
|
101
|
+
hold: number
|
|
102
|
+
reserve: number
|
|
103
|
+
available: number
|
|
104
|
+
creditLimit: number
|
|
105
|
+
currency: string
|
|
106
|
+
tags: {[key: string]: string}
|
|
107
|
+
status: UNAccountStatus
|
|
108
|
+
closeReason?: UNCloseReason
|
|
109
|
+
fraudReason?: UNFraudReason
|
|
110
|
+
closeReasonText?: string
|
|
111
|
+
freezeReason?: string
|
|
112
|
+
}
|
|
113
|
+
relationships: {
|
|
114
|
+
customer: UNRelationship,
|
|
115
|
+
org: UNRelationship
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { UNAchCounterparty, UNCounterpartyVerificationMethod, UNPaymentStatus } from './payments.types';
|
|
2
|
+
import type { UNTags, UNRelationship } from './types';
|
|
3
3
|
|
|
4
4
|
export type UNACHData = {
|
|
5
5
|
type: 'achPayment',
|
|
6
6
|
id: string,
|
|
7
7
|
attributes: {
|
|
8
8
|
createdAt: string | Date,
|
|
9
|
-
status:
|
|
9
|
+
status: UNPaymentStatus,
|
|
10
10
|
settlementDate?: Date,
|
|
11
11
|
reason: string,
|
|
12
12
|
direction: 'Debit' | 'Credit',
|
|
13
13
|
description: string,
|
|
14
14
|
transactionSummaryOverride?: string,
|
|
15
15
|
amount: string,
|
|
16
|
-
tags:
|
|
16
|
+
tags: UNTags,
|
|
17
17
|
addenda?: string
|
|
18
|
-
counterparty:
|
|
18
|
+
counterparty: UNAchCounterparty
|
|
19
19
|
expectedCompletionDate?: Date
|
|
20
|
-
counterpartyVerificationMethod?:keyof typeof
|
|
20
|
+
counterpartyVerificationMethod?:keyof typeof UNCounterpartyVerificationMethod
|
|
21
21
|
sameDay?: boolean
|
|
22
22
|
},
|
|
23
23
|
relationships: {
|
|
24
|
-
account:
|
|
25
|
-
customer?:
|
|
26
|
-
customers?:
|
|
27
|
-
counterpartyAccount:
|
|
28
|
-
counterpartyCustomer:
|
|
29
|
-
transaction:
|
|
30
|
-
recurringPayment:
|
|
24
|
+
account: UNRelationship,
|
|
25
|
+
customer?: UNRelationship,
|
|
26
|
+
customers?: UNRelationship,
|
|
27
|
+
counterpartyAccount: UNRelationship,
|
|
28
|
+
counterpartyCustomer: UNRelationship,
|
|
29
|
+
transaction: UNRelationship,
|
|
30
|
+
recurringPayment: UNRelationship
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { UNPaymentStatus } from './payments.types';
|
|
2
|
+
import type { UNTags, UNRelationship } from './types';
|
|
3
3
|
|
|
4
4
|
export type UNBookPaymentData = {
|
|
5
5
|
type: 'bookPayment',
|
|
6
6
|
id: string,
|
|
7
7
|
attributes: {
|
|
8
8
|
createdAt: string | Date,
|
|
9
|
-
status:
|
|
9
|
+
status: UNPaymentStatus,
|
|
10
10
|
reason: string,
|
|
11
11
|
direction: 'Debit' | 'Credit',
|
|
12
12
|
description: string,
|
|
13
13
|
transactionSummaryOverride?: string,
|
|
14
14
|
amount: string,
|
|
15
|
-
tags:
|
|
15
|
+
tags: UNTags,
|
|
16
16
|
},
|
|
17
17
|
relationships: {
|
|
18
|
-
account:
|
|
19
|
-
customer?:
|
|
20
|
-
customers?:
|
|
21
|
-
counterpartyAccount:
|
|
22
|
-
counterpartyCustomer:
|
|
23
|
-
transaction:
|
|
24
|
-
recurringPayment:
|
|
18
|
+
account: UNRelationship,
|
|
19
|
+
customer?: UNRelationship,
|
|
20
|
+
customers?: UNRelationship,
|
|
21
|
+
counterpartyAccount: UNRelationship,
|
|
22
|
+
counterpartyCustomer: UNRelationship,
|
|
23
|
+
transaction: UNRelationship,
|
|
24
|
+
recurringPayment: UNRelationship
|
|
25
25
|
}
|
|
26
26
|
}
|