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.
Files changed (119) hide show
  1. package/README.md +70 -1
  2. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  3. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  4. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +8 -0
  5. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  6. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +12 -0
  7. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  8. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  9. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -0
  10. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  11. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +6 -5
  12. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
  13. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  14. package/lib/commonjs/messages/nativeMessages/cardMessage.js +1 -13
  15. package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -1
  16. package/lib/commonjs/messages/webMessages/accountMessage.js +12 -0
  17. package/lib/commonjs/messages/webMessages/accountMessage.js.map +1 -0
  18. package/lib/commonjs/messages/webMessages/index.js.map +1 -1
  19. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  20. package/lib/commonjs/scripts/html/bodyScript.js +14 -3
  21. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  22. package/lib/commonjs/sharedTypes/account.types.js +31 -0
  23. package/lib/commonjs/sharedTypes/account.types.js.map +1 -0
  24. package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
  25. package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
  26. package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
  27. package/lib/commonjs/sharedTypes/index.js +11 -0
  28. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  29. package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
  30. package/lib/commonjs/sharedTypes/payments.types.js +6 -6
  31. package/lib/commonjs/sharedTypes/payments.types.js.map +1 -1
  32. package/lib/commonjs/sharedTypes/types.js.map +1 -1
  33. package/lib/commonjs/sharedTypes/wallet.types.js +13 -1
  34. package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -1
  35. package/lib/commonjs/webComponent/html.js +2 -0
  36. package/lib/commonjs/webComponent/html.js.map +1 -1
  37. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  38. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  39. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +8 -0
  40. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  41. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +11 -0
  42. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  43. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  44. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +4 -0
  45. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  46. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +7 -6
  47. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -1
  48. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  49. package/lib/module/messages/nativeMessages/cardMessage.js +0 -11
  50. package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -1
  51. package/lib/module/messages/webMessages/accountMessage.js +5 -0
  52. package/lib/module/messages/webMessages/accountMessage.js.map +1 -0
  53. package/lib/module/messages/webMessages/index.js.map +1 -1
  54. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  55. package/lib/module/scripts/html/bodyScript.js +14 -3
  56. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  57. package/lib/module/sharedTypes/account.types.js +23 -0
  58. package/lib/module/sharedTypes/account.types.js.map +1 -0
  59. package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
  60. package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
  61. package/lib/module/sharedTypes/card.types.js.map +1 -1
  62. package/lib/module/sharedTypes/index.js +1 -0
  63. package/lib/module/sharedTypes/index.js.map +1 -1
  64. package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
  65. package/lib/module/sharedTypes/payments.types.js +4 -4
  66. package/lib/module/sharedTypes/payments.types.js.map +1 -1
  67. package/lib/module/sharedTypes/types.js.map +1 -1
  68. package/lib/module/sharedTypes/wallet.types.js +11 -0
  69. package/lib/module/sharedTypes/wallet.types.js.map +1 -1
  70. package/lib/module/webComponent/html.js +2 -0
  71. package/lib/module/webComponent/html.js.map +1 -1
  72. package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +2 -2
  73. package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +2 -2
  74. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +4 -2
  75. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -2
  76. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
  77. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +2 -2
  78. package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +4 -13
  79. package/lib/typescript/messages/webMessages/accountMessage.d.ts +8 -0
  80. package/lib/typescript/messages/webMessages/index.d.ts +3 -2
  81. package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
  82. package/lib/typescript/scripts/html/bodyScript.d.ts +1 -0
  83. package/lib/typescript/sharedTypes/account.types.d.ts +114 -0
  84. package/lib/typescript/sharedTypes/achCredit.types.d.ts +13 -13
  85. package/lib/typescript/sharedTypes/bookPayment.types.d.ts +11 -11
  86. package/lib/typescript/sharedTypes/card.types.d.ts +18 -18
  87. package/lib/typescript/sharedTypes/index.d.ts +1 -0
  88. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +3 -3
  89. package/lib/typescript/sharedTypes/payments.types.d.ts +5 -5
  90. package/lib/typescript/sharedTypes/types.d.ts +7 -7
  91. package/lib/typescript/sharedTypes/wallet.types.d.ts +11 -2
  92. package/package.json +1 -1
  93. package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +3 -3
  94. package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +3 -3
  95. package/src/components/UNAccountComponent/UNAccountComponent.tsx +11 -3
  96. package/src/components/UNActivityComponent/UNActivityComponent.tsx +15 -4
  97. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +3 -3
  98. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +11 -1
  99. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +8 -7
  100. package/src/components/UNCardComponent/UNCardComponent.tsx +5 -5
  101. package/src/messages/nativeMessages/cardMessage.ts +5 -15
  102. package/src/messages/webMessages/accountMessage.ts +12 -0
  103. package/src/messages/webMessages/index.ts +3 -0
  104. package/src/messages/webMessages/unitMessages.ts +2 -2
  105. package/src/scripts/html/bodyScript.ts +14 -2
  106. package/src/sharedTypes/account.types.ts +117 -0
  107. package/src/sharedTypes/achCredit.types.ts +13 -13
  108. package/src/sharedTypes/bookPayment.types.ts +11 -11
  109. package/src/sharedTypes/card.types.ts +18 -18
  110. package/src/sharedTypes/index.ts +1 -0
  111. package/src/sharedTypes/onLoadResponse.types.ts +5 -5
  112. package/src/sharedTypes/payments.types.ts +5 -5
  113. package/src/sharedTypes/types.ts +8 -8
  114. package/src/sharedTypes/wallet.types.ts +13 -3
  115. package/src/webComponent/html.ts +2 -0
  116. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  117. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  118. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcuserdata/alonshprung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  119. 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 { ResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
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: ResponseUnitOnLoadEvent) => void;
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 ResponseUnitOnLoadEvent);
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 { ResponseUnitOnLoadEvent } from '../../sharedTypes';
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: ResponseUnitOnLoadEvent) => void;
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 ResponseUnitOnLoadEvent);
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 { ResponseUnitOnLoadEvent } from '../../sharedTypes';
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: ResponseUnitOnLoadEvent) => void
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 ResponseUnitOnLoadEvent);
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 { ResponseUnitOnLoadEvent, UNBookPaymentData } from '../../sharedTypes';
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: ResponseUnitOnLoadEvent) => void;
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 ResponseUnitOnLoadEvent);
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 { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';
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 { CardAddToWalletStatus, CardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../../messages/nativeMessages/cardMessage';
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<CardAddToWalletStatus>(CardAddToWalletStatus.pending);
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 === CardAddToWalletStatus.pending) return;
37
+ if (addToWalletStatus === UNCardAddToWalletStatus.pending) return;
37
38
 
38
- const isCardInWallet = addToWalletStatus === CardAddToWalletStatus.addedToWallet;
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?: CardAddToWalletStatusEvent) => {
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 === CardAddToWalletStatus.pending && <ActivityIndicator style={styles.loader} />}
69
- {addToWalletStatus === CardAddToWalletStatus.readyToProvisioning && <UnitAddToWalletButtonView style={styles.addToWalletButton} onAddToWalletClicked={handleAddToWalletClicked} />}
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 { ResponseUnitOnLoadEvent, UNCardData } from '../../sharedTypes';
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, CardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../messages/nativeMessages/cardMessage';
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: ResponseUnitOnLoadEvent) => void
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 ResponseUnitOnLoadEvent);
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: CardAddToWalletStatusEvent = { status: walletResponse.status };
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 CardAddToWalletStatusEvent {
23
- status: CardAddToWalletStatus
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
- | CardAddToWalletStatusEvent
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 { ResponseUnitOnLoadEvent } from '../../sharedTypes';
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
- | ResponseUnitOnLoadEvent
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: JSON.stringify(data.data) }})
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: JSON.stringify(data.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 { AchCounterparty, CounterpartyVerificationMethod, PaymentStatus } from './payments.types';
2
- import type { Tags, Relationship } from './types';
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: PaymentStatus,
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: Tags,
16
+ tags: UNTags,
17
17
  addenda?: string
18
- counterparty: AchCounterparty
18
+ counterparty: UNAchCounterparty
19
19
  expectedCompletionDate?: Date
20
- counterpartyVerificationMethod?:keyof typeof CounterpartyVerificationMethod
20
+ counterpartyVerificationMethod?:keyof typeof UNCounterpartyVerificationMethod
21
21
  sameDay?: boolean
22
22
  },
23
23
  relationships: {
24
- account: Relationship,
25
- customer?: Relationship,
26
- customers?: Relationship,
27
- counterpartyAccount: Relationship,
28
- counterpartyCustomer: Relationship,
29
- transaction: Relationship,
30
- recurringPayment: Relationship
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 { PaymentStatus } from './payments.types';
2
- import type { Tags, Relationship } from './types';
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: PaymentStatus,
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: Tags,
15
+ tags: UNTags,
16
16
  },
17
17
  relationships: {
18
- account: Relationship,
19
- customer?: Relationship,
20
- customers?: Relationship,
21
- counterpartyAccount: Relationship,
22
- counterpartyCustomer: Relationship,
23
- transaction: Relationship,
24
- recurringPayment: Relationship
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
  }