react-native-unit-components 1.0.2 → 1.0.3

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 (213) hide show
  1. package/README.md +75 -6
  2. package/android/src/main/AndroidManifest.xml +12 -1
  3. package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
  4. package/android/src/main/java/com/unitreactnativecomponents/sharepdf/UNSharePDF.kt +75 -0
  5. package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +2 -2
  6. package/android/src/main/res/layout/un_view_google_push_provisioning.xml +1 -13
  7. package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +1 -1
  8. package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +1 -1
  9. package/android/src/main/res/xml/file_paths.xml +4 -0
  10. package/ios/UnitReactNativeComponentsViewManager.m +0 -1
  11. package/ios/UnitReactNativeComponentsViewManager.swift +6 -2
  12. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +103 -0
  13. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
  14. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +47 -0
  15. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
  16. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -4
  17. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  18. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +19 -1
  19. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  20. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +22 -10
  21. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  22. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +4 -0
  23. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  24. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +3 -3
  25. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  26. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +114 -46
  27. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  28. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -8
  29. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  30. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +95 -0
  31. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
  32. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +31 -0
  33. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
  34. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +64 -7
  35. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  36. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +57 -8
  37. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  38. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +20 -0
  39. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
  40. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +44 -0
  41. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
  42. package/lib/commonjs/components/index.js +13 -0
  43. package/lib/commonjs/components/index.js.map +1 -1
  44. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +32 -12
  45. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
  46. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +1 -1
  47. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  48. package/lib/commonjs/helpers/EventBus.js.map +1 -1
  49. package/lib/commonjs/messages/nativeMessages/cardMessage.js +36 -0
  50. package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -0
  51. package/lib/commonjs/messages/nativeMessages/index.js +0 -8
  52. package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
  53. package/lib/commonjs/messages/nativeMessages/sdkMessage.js +14 -0
  54. package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -0
  55. package/lib/commonjs/messages/webMessages/unitMessages.js +1 -0
  56. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  57. package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
  58. package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -0
  59. package/lib/commonjs/scripts/html/bodyScript.js +22 -5
  60. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  61. package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
  62. package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
  63. package/lib/commonjs/sharedTypes/index.js +13 -0
  64. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  65. package/lib/commonjs/sharedTypes/onLoadResponse.types.js +6 -0
  66. package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -0
  67. package/lib/commonjs/sharedTypes/wallet.types.js +22 -0
  68. package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -0
  69. package/lib/commonjs/unitSdkManager/UnitSdk.api.js +5 -3
  70. package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
  71. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +12 -2
  72. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
  73. package/lib/commonjs/webComponent/WebComponent.js +20 -8
  74. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  75. package/lib/commonjs/webComponent/WebComponent.utils.js +41 -0
  76. package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -0
  77. package/lib/commonjs/webComponent/html.js +9 -1
  78. package/lib/commonjs/webComponent/html.js.map +1 -1
  79. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +74 -0
  80. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
  81. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +26 -0
  82. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
  83. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +28 -6
  84. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  85. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
  86. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  87. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +21 -10
  88. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  89. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -0
  90. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  91. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +1 -1
  92. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  93. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +111 -46
  94. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  95. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +5 -9
  96. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  97. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +68 -0
  98. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
  99. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +21 -0
  100. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
  101. package/lib/module/components/UNCardComponent/UNCardComponent.js +64 -9
  102. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  103. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +48 -7
  104. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  105. package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js +10 -0
  106. package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
  107. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +29 -0
  108. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
  109. package/lib/module/components/index.js +1 -0
  110. package/lib/module/components/index.js.map +1 -1
  111. package/lib/module/helpers/BottomSheet/BottomSheet.js +30 -13
  112. package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
  113. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -2
  114. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  115. package/lib/module/helpers/EventBus.js.map +1 -1
  116. package/lib/module/messages/nativeMessages/cardMessage.js +27 -0
  117. package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -0
  118. package/lib/module/messages/nativeMessages/index.js +1 -6
  119. package/lib/module/messages/nativeMessages/index.js.map +1 -1
  120. package/lib/module/messages/nativeMessages/sdkMessage.js +7 -0
  121. package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -0
  122. package/lib/module/messages/webMessages/unitMessages.js +1 -0
  123. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  124. package/lib/module/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
  125. package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -0
  126. package/lib/module/scripts/html/bodyScript.js +19 -3
  127. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  128. package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
  129. package/lib/module/sharedTypes/card.types.js.map +1 -1
  130. package/lib/module/sharedTypes/index.js +1 -0
  131. package/lib/module/sharedTypes/index.js.map +1 -1
  132. package/lib/module/sharedTypes/onLoadResponse.types.js +2 -0
  133. package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -0
  134. package/lib/module/sharedTypes/wallet.types.js +14 -0
  135. package/lib/module/sharedTypes/wallet.types.js.map +1 -0
  136. package/lib/module/unitSdkManager/UnitSdk.api.js +4 -3
  137. package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
  138. package/lib/module/unitSdkManager/UnitSdkManager.js +12 -2
  139. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
  140. package/lib/module/webComponent/WebComponent.js +18 -7
  141. package/lib/module/webComponent/WebComponent.js.map +1 -1
  142. package/lib/module/webComponent/WebComponent.utils.js +27 -0
  143. package/lib/module/webComponent/WebComponent.utils.js.map +1 -0
  144. package/lib/module/webComponent/html.js +9 -2
  145. package/lib/module/webComponent/html.js.map +1 -1
  146. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +12 -0
  147. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +7 -0
  148. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -0
  149. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +4 -0
  150. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -1
  151. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -1
  152. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +9 -2
  153. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +2 -1
  154. package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.d.ts +6 -0
  155. package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.d.ts +17 -0
  156. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
  157. package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +9 -1
  158. package/lib/typescript/components/UNCardComponent/networking/common/UNNetworkConstants.d.ts +8 -0
  159. package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +1 -0
  160. package/lib/typescript/components/index.d.ts +1 -0
  161. package/lib/typescript/helpers/EventBus.d.ts +3 -3
  162. package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +28 -0
  163. package/lib/typescript/messages/nativeMessages/index.d.ts +7 -3
  164. package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +8 -0
  165. package/lib/typescript/messages/webMessages/unitMessages.d.ts +16 -6
  166. package/lib/typescript/scripts/html/bodyScript.d.ts +4 -1
  167. package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -3
  168. package/lib/typescript/sharedTypes/card.types.d.ts +6 -6
  169. package/lib/typescript/sharedTypes/index.d.ts +1 -0
  170. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +18 -0
  171. package/lib/typescript/sharedTypes/wallet.types.d.ts +14 -0
  172. package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +3 -0
  173. package/lib/typescript/webComponent/WebComponent.d.ts +2 -1
  174. package/lib/typescript/webComponent/WebComponent.utils.d.ts +2 -0
  175. package/package.json +2 -1
  176. package/src/components/UNAccountComponent/UNAccountComponent.tsx +82 -0
  177. package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +30 -0
  178. package/src/components/UNActivityComponent/UNActivityComponent.tsx +28 -5
  179. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +14 -0
  180. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +18 -10
  181. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -0
  182. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -1
  183. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +120 -44
  184. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +7 -10
  185. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.ts +21 -0
  186. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +74 -0
  187. package/src/components/UNCardComponent/UNCardComponent.tsx +67 -13
  188. package/src/components/UNCardComponent/UNCardComponent.utils.ts +47 -7
  189. package/src/components/UNCardComponent/networking/common/UNNetworkConstants.ts +11 -0
  190. package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +34 -0
  191. package/src/components/index.ts +1 -0
  192. package/src/helpers/BottomSheet/BottomSheet.styles.ts +2 -2
  193. package/src/helpers/BottomSheet/BottomSheet.tsx +28 -12
  194. package/src/helpers/EventBus.ts +3 -3
  195. package/src/messages/nativeMessages/cardMessage.ts +37 -0
  196. package/src/messages/nativeMessages/index.ts +14 -3
  197. package/src/messages/nativeMessages/sdkMessage.ts +11 -0
  198. package/src/messages/webMessages/unitMessages.ts +20 -7
  199. package/src/scripts/html/bodyScript.ts +21 -4
  200. package/src/sharedTypes/bookPayment.types.ts +3 -3
  201. package/src/sharedTypes/card.types.ts +6 -6
  202. package/src/sharedTypes/index.ts +1 -0
  203. package/src/sharedTypes/onLoadResponse.types.ts +27 -0
  204. package/src/sharedTypes/wallet.types.ts +17 -0
  205. package/src/unitSdkManager/UnitSdk.api.ts +3 -2
  206. package/src/unitSdkManager/UnitSdkManager.ts +11 -2
  207. package/src/webComponent/WebComponent.tsx +21 -10
  208. package/src/webComponent/WebComponent.utils.ts +26 -0
  209. package/src/webComponent/html.ts +9 -2
  210. package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
  211. package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
  212. /package/lib/typescript/nativeComponent/{UNNativeAddToWalletButton.d.ts → UnitAddToWalletButton.d.ts} +0 -0
  213. /package/src/nativeComponent/{UNNativeAddToWalletButton.tsx → UnitAddToWalletButton.tsx} +0 -0
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import { Dimensions, View } from 'react-native';
1
+ import React, { useRef, useState } from 'react';
2
+ import { Dimensions, NativeModule, View } from 'react-native';
3
3
  import type WebView from 'react-native-webview';
4
4
  import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
5
5
  import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
@@ -7,22 +7,28 @@ import EventBus from '../../helpers/EventBus';
7
7
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
8
8
  import { useListenerToBus } from '../../hooks/listenerToBus';
9
9
  import type { WebViewMessage } from '../../messages/webMessages';
10
- import { getCardParams, getCardScript, injectRefreshEventIfNeeded } from './UNCardComponent.utils';
10
+ import { getCardParams, getCardScript, injectRefreshEventIfNeeded, launchStartCardProvisioning } from './UNCardComponent.utils';
11
11
  import { PresentationMode } from '../../scripts/html/bodyHtml';
12
- import type { UNCardData } from '../../sharedTypes';
12
+ import type { ResponseUnitOnLoadEvent, UNCardData } from '../../sharedTypes';
13
13
  import { CardMessage } from '../../messages/webMessages/cardMessage';
14
-
14
+ import { launchGetWallets } from './UNCardComponent.utils';
15
+ import type { NativeModules } from 'react-native';
16
+ import type { UNWallet } from 'src/sharedTypes/wallet.types';
17
+ import { CardAddToWalletErrors, CardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../messages/nativeMessages/cardMessage';
18
+ import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
15
19
  export interface UNCardComponentProps {
16
20
  cardId: string;
17
21
  customerToken: string;
18
22
  theme?: string;
19
23
  onStatusChanged?: (card: UNCardData) => void;
24
+ pushProvisioningModule?: typeof NativeModules;
25
+ onLoad?: (response: ResponseUnitOnLoadEvent) => void
20
26
  }
21
27
 
22
28
  export const UNCardComponent = (props: UNCardComponentProps) => {
23
29
  const [height, setHeight] = useState(0);
24
- const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);
25
30
  const windowWidth = Dimensions.get('window').width;
31
+ const walletRef = useRef<UNWallet | null>(null);
26
32
 
27
33
  const webRef = useRef<WebView>(null);
28
34
 
@@ -33,26 +39,74 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
33
39
  };
34
40
 
35
41
  const requestRefresh = (data: RequestRefreshEvent) => {
36
- setRequestRefreshEvent(data);
42
+ injectRefreshEventIfNeeded(webRef.current, data, props.cardId);
43
+ };
44
+
45
+ const startPushProvisioning = async (data: CardStartPushProvisioningEvent) => {
46
+ if (data.cardId !== props.cardId) return;
47
+ onAddToWalletClicked();
48
+ };
49
+
50
+ const getAddToWalletStatus = (data: CardGetAddToWalletStatusEvent) => {
51
+ if (data.cardId !== props.cardId) return;
52
+ getWallets();
37
53
  };
38
54
 
39
55
  useListenerToBus([
40
56
  { busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged },
41
57
  { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },
58
+ { busEventKey: CardNativeMessage.CARD_START_PUSH_PROVISIONING, action: startPushProvisioning },
59
+ { busEventKey: CardNativeMessage.CARD_GET_ADD_TO_WALLET_STATUS, action: getAddToWalletStatus }
42
60
  ]);
43
61
 
44
- useEffect(() => {
45
- injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent, props.cardId);
46
- }, [requestRefreshEvent]);
47
-
48
62
  const handleMessage = (message: WebViewMessage) => {
63
+ if (!message || !message.details) return;
64
+
49
65
  switch (message.type) {
50
- case UnitMessage.UNIT_REQUEST_RENDERING:
51
- EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, (message.details as RequestRenderingEvent).data);
66
+ case UnitMessage.UNIT_REQUEST_RENDERING: {
67
+ const event: BottomSheetSlotData = {
68
+ componentName: WebComponentType.card,
69
+ componentResourceId: props.cardId,
70
+ requestRenderingEvent: message.details as RequestRenderingEvent
71
+ };
72
+ EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);
52
73
  break;
74
+ }
53
75
  case PageMessage.PAGE_HEIGHT:
54
76
  setHeight((message.details as HeightEvent).height);
55
77
  break;
78
+ case UnitMessage.UNIT_ON_LOAD:
79
+ props.onLoad && props.onLoad(message.details as ResponseUnitOnLoadEvent);
80
+ break;
81
+ }
82
+ };
83
+
84
+ const getWallets = async () => {
85
+
86
+ try {
87
+
88
+ const walletResponse = await launchGetWallets(props.customerToken, props.cardId, props.pushProvisioningModule as NativeModule);
89
+
90
+ if (!walletResponse) return;
91
+
92
+ walletRef.current = walletResponse;
93
+
94
+ const walletStatus: CardAddToWalletStatusEvent = { status: walletResponse.status };
95
+ EventBus.Instance.event(CardNativeMessage.CARD_UPDATE_ADD_TO_WALLET_STATUS, walletStatus);
96
+ } catch (error) {
97
+ console.error(error);
98
+ }
99
+ };
100
+
101
+ const onAddToWalletClicked = async () => {
102
+ try {
103
+ await launchStartCardProvisioning(props.pushProvisioningModule as NativeModule, walletRef.current);
104
+ } catch (error) {
105
+ if (error instanceof Error) {
106
+ const parsedError = JSON.parse(error.message);
107
+ if (parsedError.code === CardAddToWalletErrors.closedNativeWalletScreen) return;
108
+ }
109
+ console.log(error);
56
110
  }
57
111
  };
58
112
 
@@ -1,22 +1,22 @@
1
+ import { DISPATCH_REQUEST_REFRESH } from './../../scripts/html/bodyScript';
1
2
  import type WebView from 'react-native-webview';
2
3
  import type { UNCardComponentProps } from './UNCardComponent';
3
4
  import { WebComponentType } from '../../webComponent/WebComponent';
4
- import { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
5
+ import type { NativeModules } from 'react-native';
6
+ import { getMobileWalletPayload } from './networking/requests/UNWalletPayloadRequest';
7
+ import { UNWallet, UNWalletCode, UNWalletName } from '../../../src/sharedTypes/wallet.types';
8
+ import type { RequestRefreshEvent } from '../../messages/webMessages/unitMessages';
5
9
 
6
10
  export const getCardParams = (props: UNCardComponentProps) => {
7
11
  return `
8
12
  card-id="${props.cardId}"
9
13
  customer-token="${props.customerToken}"
14
+ enable-mobile-wallet="${!!props.pushProvisioningModule}"
10
15
  `;
11
16
  };
12
17
 
13
18
  export const getCardScript = () => {
14
- return `
15
- const dispatchRefreshEvent = (details) => {
16
- const event = new CustomEvent("${UnitMessage.UNIT_REQUEST_REFRESH}",{ detail: JSON.parse(details) })
17
- window.dispatchEvent(event)
18
- }
19
- `;
19
+ return DISPATCH_REQUEST_REFRESH;
20
20
  };
21
21
 
22
22
  export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null, cardId: string) => {
@@ -24,3 +24,43 @@ export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRe
24
24
  currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
25
25
  }
26
26
  };
27
+
28
+ export const launchGetWallets = async (customerToken: string, cardId: string, pushProvisioningModule: typeof NativeModules) => {
29
+ try {
30
+ const encryptedPayload = await getMobileWalletPayload(customerToken, cardId);
31
+ if (!encryptedPayload) return null;
32
+
33
+ const walletsResponse = await pushProvisioningModule.launchGetWallets(JSON.stringify({ encPayload: encryptedPayload }));
34
+ const parsedWalletsResponse = JSON.parse(walletsResponse);
35
+ const wallets = parsedWalletsResponse.wallets;
36
+
37
+ if (!wallets) return null;
38
+ if (wallets[0].code === UNWalletCode.Apple) {
39
+ return ({ name: UNWalletName.Apple, code: UNWalletCode.Apple, status: wallets[0].status });
40
+ } else {
41
+ const googleWallet = wallets.filter((wallet: { name: UNWalletName }) => {
42
+ return wallet.name === UNWalletName.Google;
43
+ });
44
+ if (!googleWallet) return;
45
+ return ({ name: UNWalletName.Google, code: UNWalletCode.Google, status: googleWallet[0].status });
46
+ }
47
+ } catch (error) {
48
+ return Promise.reject(error);
49
+ }
50
+
51
+ };
52
+
53
+ export const launchStartCardProvisioning = async (pushProvisioningModule: typeof NativeModules, wallet: UNWallet | null) => {
54
+ try {
55
+ const response = await pushProvisioningModule.launchStartCardProvisioning(
56
+ JSON.stringify({
57
+ walletCode: wallet?.code,
58
+ walletName: wallet?.name
59
+ }));
60
+ return response;
61
+ }
62
+
63
+ catch (error) {
64
+ return Promise.reject(error);
65
+ }
66
+ };
@@ -0,0 +1,11 @@
1
+ import { UNEnvironment } from '../../../../unitSdkManager/UnitSdkManager';
2
+
3
+ export const APIHeaders = {
4
+ AUTHORIZATION: 'Authorization',
5
+ CONTENT_TYPE: 'application/vnd.api+json',
6
+ };
7
+
8
+ export const UNIT_SECURE_URL = {
9
+ [UNEnvironment.sandbox]: 'https://secure.api.s.unit.sh',
10
+ [UNEnvironment.production]: 'https://secure.api.unit.co'
11
+ };
@@ -0,0 +1,34 @@
1
+ import axios from 'axios';
2
+ import { APIHeaders, UNIT_SECURE_URL } from '../common/UNNetworkConstants';
3
+ import { UNEnvironment, UnitSDK } from 'react-native-unit-components';
4
+
5
+ const env = UnitSDK.getEnv();
6
+
7
+ export const getMobileWalletPayload = async (customerToken: string, cardId: string) => {
8
+ const headers = {
9
+ 'Content-Type': APIHeaders.CONTENT_TYPE,
10
+ 'Authorization': `Bearer ${customerToken}`,
11
+ };
12
+
13
+ const data = {
14
+ data: {
15
+ attributes: {
16
+ signedNonce: UnitSDK.getSignedNonce(),
17
+ },
18
+ },
19
+ };
20
+
21
+ const baseURL = `${UNIT_SECURE_URL[env as keyof typeof UNEnvironment]}/cards/${cardId}/mobile-wallet-payload`;
22
+ try {
23
+ const response = await axios.post(
24
+ baseURL,
25
+ data,
26
+ {
27
+ headers: headers,
28
+ });
29
+ const encryptedPayload = response.data.data.attributes.payload;
30
+ return encryptedPayload;
31
+ } catch (error) {
32
+ return Promise.reject(error);
33
+ }
34
+ };
@@ -2,3 +2,4 @@ export * from './UNCardComponent/UNCardComponent';
2
2
  export * from './UNBottomSheetComponent/UNBottomSheetComponent';
3
3
  export * from './UNBookPaymentComponent/UNBookPaymentComponent';
4
4
  export * from './UNActivityComponent/UNActivityComponent';
5
+ export * from './UNAccountComponent/UNAccountComponent';
@@ -1,5 +1,5 @@
1
1
  import { Dimensions, StyleSheet } from 'react-native';
2
- import { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';
2
+ import { BOTTOM_SHEET_MAX_PERCENTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';
3
3
  import { VARIABLES } from '../../styles/variables';
4
4
 
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -20,7 +20,7 @@ export const getStylesObject = (fadeAnim: any) => {
20
20
  container: {
21
21
  position: 'relative',
22
22
  flex: 1,
23
- marginTop: Dimensions.get('window').height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE),
23
+ marginTop: Dimensions.get('window').height * (1 - BOTTOM_SHEET_MAX_PERCENTAGE_SIZE),
24
24
  shadowColor: VARIABLES.COLORS.BLACK,
25
25
  shadowOffset: {
26
26
  width: 0,
@@ -13,8 +13,9 @@ import {
13
13
  } from 'react-native';
14
14
  import PropTypes from 'prop-types';
15
15
  import { CloseIcon } from '../../assets/images';
16
- import { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';
16
+ import { BOTTOM_SHEET_MAX_PERCENTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';
17
17
  import { getStylesObject } from './BottomSheet.styles';
18
+ import { useAppStateListener } from '../../hooks/useAppStateListener';
18
19
 
19
20
  export interface BottomSheetProps {
20
21
  isOpen: boolean
@@ -40,6 +41,8 @@ const BottomSheet = (props: BottomSheetProps) => {
40
41
 
41
42
  const [dy, setDy] = useState(0);
42
43
 
44
+ const isAppActive = useAppStateListener();
45
+
43
46
  const _parentPanResponder = PanResponder.create({
44
47
  onMoveShouldSetPanResponderCapture: (_, gestureState) => {
45
48
  return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;
@@ -66,6 +69,13 @@ const BottomSheet = (props: BottomSheetProps) => {
66
69
  }
67
70
  });
68
71
 
72
+ useEffect(() => {
73
+ if (!isAppActive && isPanelOpened) {
74
+ setContentHeight(0);
75
+ _dismiss(false);
76
+ }
77
+ }, [isAppActive]);
78
+
69
79
  useEffect(() => {
70
80
  if (props.isOpen && !isPanelOpened) {
71
81
  fadeIn();
@@ -86,21 +96,27 @@ const BottomSheet = (props: BottomSheetProps) => {
86
96
  }, []);
87
97
 
88
98
  const fadeIn = () => {
99
+ setIsPanelOpened(true);
89
100
  Animated.timing(fadeAnim, {
90
101
  toValue: 0.3,
91
102
  duration: 500,
92
103
  useNativeDriver: false
93
- }).start(() => { setIsPanelOpened(true); });
104
+ }).start();
94
105
  };
95
106
 
96
- const fadeOut = () => {
107
+ const fadeOut = (withTimeout = true) => {
108
+ /*
109
+ withTimeout - most of the time we declare 'Close' after the animation is end.
110
+ In a case that the app is not active we do it without timeout. (Otherwise a race condition may occur.)
111
+ */
112
+ setIsPanelOpened(false);
113
+ !withTimeout && props.onClose();
97
114
  Animated.timing(fadeAnim, {
98
115
  toValue: 0,
99
116
  duration: 500,
100
117
  useNativeDriver: false
101
118
  }).start(() => {
102
- setIsPanelOpened(false);
103
- props.onClose();
119
+ withTimeout && props.onClose();
104
120
  });
105
121
  };
106
122
 
@@ -115,7 +131,7 @@ const BottomSheet = (props: BottomSheetProps) => {
115
131
 
116
132
  const expand = () => {
117
133
  const { animationDuration } = props;
118
-
134
+ props.onOpen();
119
135
  if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {
120
136
  setToContentHeight(contentHeight);
121
137
  return;
@@ -150,7 +166,7 @@ const BottomSheet = (props: BottomSheetProps) => {
150
166
  setToContentHeight(newContentHeight);
151
167
  };
152
168
 
153
- const _dismiss = () => {
169
+ const _dismiss = (withTimeout = true) => {
154
170
  const { animationDuration } = props;
155
171
  Animated.timing(panelHeightValue, {
156
172
  duration: animationDuration,
@@ -160,7 +176,7 @@ const BottomSheet = (props: BottomSheetProps) => {
160
176
  }).start(() => {
161
177
  null;
162
178
  });
163
- fadeOut();
179
+ fadeOut(withTimeout);
164
180
  };
165
181
 
166
182
  const {
@@ -172,7 +188,7 @@ const BottomSheet = (props: BottomSheetProps) => {
172
188
  <>
173
189
  <TouchableOpacity
174
190
  style={styles.outsideContainer} activeOpacity={1}
175
- onPress={_dismiss}
191
+ onPress={() => _dismiss()}
176
192
  >
177
193
  <Animated.View
178
194
  style={styles.animation}
@@ -195,7 +211,7 @@ const BottomSheet = (props: BottomSheetProps) => {
195
211
  <TouchableOpacity
196
212
  activeOpacity={1}
197
213
  style={styles.closeButton}
198
- onPress={_dismiss}
214
+ onPress={() => _dismiss()}
199
215
  >
200
216
  <Image source={CloseIcon} />
201
217
  </TouchableOpacity>
@@ -206,7 +222,7 @@ const BottomSheet = (props: BottomSheetProps) => {
206
222
  <KeyboardAvoidingView
207
223
  behavior="padding"
208
224
  style={{ height: props.height }}
209
- keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}
225
+ keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PERCENTAGE_SIZE)}
210
226
  >
211
227
  {children}
212
228
  </KeyboardAvoidingView>
@@ -231,7 +247,7 @@ BottomSheet.propTypes = {
231
247
  BottomSheet.defaultProps = {
232
248
  children: <View />,
233
249
  isOpen: true,
234
- sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,
250
+ sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PERCENTAGE_SIZE,
235
251
  animationDuration: 200,
236
252
  onOpen: () => null,
237
253
  onClose: () => null,
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { NativeMessage } from '../messages/nativeMessages';
2
+ import type { NativeMessageType } from '../messages/nativeMessages';
3
3
  import type { WebViewMessageType } from '../messages/webMessages';
4
4
 
5
- export type BusEventKey = NativeMessage | WebViewMessageType
5
+ export type BusEventKey = NativeMessageType | WebViewMessageType
6
6
 
7
7
  export default class EventBus {
8
8
  private static _instance: EventBus;
@@ -17,7 +17,7 @@ export default class EventBus {
17
17
  return this._instance || (this._instance = new this());
18
18
  }
19
19
 
20
- public event(event: BusEventKey, data: any) {
20
+ public event(event: BusEventKey, data?: any) {
21
21
  const listeners = this.eventListeners[event.valueOf()];
22
22
  if (Array.isArray(listeners)) {
23
23
  listeners.map(listener => {
@@ -0,0 +1,37 @@
1
+ export enum CardNativeMessage {
2
+ CARD_GET_ADD_TO_WALLET_STATUS = 'cardGetAddToWalletStatus',
3
+ CARD_UPDATE_ADD_TO_WALLET_STATUS = 'cardUpdateAddToWalletStatus',
4
+ CARD_START_PUSH_PROVISIONING = 'cardStartPushProvisioning'
5
+ }
6
+
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
+ export enum CardAddToWalletErrors {
20
+ closedNativeWalletScreen = 'VP_ERROR_302'
21
+ }
22
+ export interface CardAddToWalletStatusEvent {
23
+ status: CardAddToWalletStatus
24
+ }
25
+
26
+ export interface CardGetAddToWalletStatusEvent {
27
+ cardId: string
28
+ }
29
+
30
+ export interface CardStartPushProvisioningEvent {
31
+ cardId: string
32
+ }
33
+
34
+ export type CardNativeEvent =
35
+ | CardAddToWalletStatusEvent
36
+ | CardGetAddToWalletStatusEvent
37
+ | CardStartPushProvisioningEvent
@@ -1,4 +1,15 @@
1
- export enum NativeMessage {
2
- IS_SCRIPT_FETCHED = 'isScriptFetched',
3
- IS_SDK_INITIALIZED = 'isSdkInitialized'
1
+ import type { CardNativeEvent, CardNativeMessage } from './cardMessage';
2
+ import type { SDKEvent, SDKMessage } from './sdkMessage';
3
+
4
+ export type NativeMessageType =
5
+ | SDKMessage
6
+ | CardNativeMessage
7
+
8
+ export type NativeEvent =
9
+ | CardNativeEvent
10
+ | SDKEvent
11
+
12
+ export interface NativeMessage {
13
+ type: NativeMessageType,
14
+ details?: NativeEvent
4
15
  }
@@ -0,0 +1,11 @@
1
+ export enum SDKMessage {
2
+ IS_SCRIPT_FETCHED = 'isScriptFetched',
3
+ IS_SDK_INITIALIZED = 'isSdkInitialized',
4
+ }
5
+
6
+ export interface SdkScriptFetched {
7
+ unitScript: string
8
+ }
9
+
10
+ export type SDKEvent =
11
+ | SdkScriptFetched
@@ -1,18 +1,21 @@
1
+ import type { ResponseUnitOnLoadEvent } from '../../sharedTypes';
2
+
1
3
  export enum UnitMessage {
2
4
  UNIT_REQUEST_RENDERING = 'unitRequestRendering',
3
5
  UNIT_REQUEST_REFRESH = 'unitRequestRefresh',
4
6
  UNIT_REQUEST_CLOSE_FLOW = 'unitRequestCloseFlow',
5
7
  UNIT_REQUEST_OPEN_LINK = 'unitRequestOpenLink',
6
- UNIT_ON_LOAD = 'unitOnLoad'
8
+ UNIT_ON_LOAD = 'unitOnLoad',
9
+ UNIT_REQUEST_DOWNLOAD = 'unitRequestDownload'
7
10
  }
8
-
9
- export interface RequestRenderingData {
10
- nativePlace: string;
11
- nativeComponent: string;
11
+ export interface RequestRenderingEvent {
12
+ data: RequestRenderingEventData
12
13
  }
13
14
 
14
- export interface RequestRenderingEvent {
15
- data: string;
15
+ export interface RequestRenderingEventData {
16
+ actionType?: string,
17
+ nativePlace: string,
18
+ nativeComponent: string,
16
19
  }
17
20
 
18
21
  export interface RequestRefreshEvent {
@@ -26,7 +29,17 @@ export interface RequestOpenLinkEvent {
26
29
  target: string
27
30
  }
28
31
 
32
+ export interface RequestDownloadEvent {
33
+ url: string
34
+ accessToken: string
35
+ fileType: string
36
+ responseType: string
37
+ fileName: string
38
+ }
39
+
29
40
  export type UnitEvent =
30
41
  | RequestRenderingEvent
31
42
  | RequestRefreshEvent
32
43
  | RequestOpenLinkEvent
44
+ | ResponseUnitOnLoadEvent
45
+ | RequestDownloadEvent
@@ -21,20 +21,25 @@ export const POST_PAGE_HEIGHT = `
21
21
  `;
22
22
 
23
23
  export const LISTENERS = {
24
- isPageLoaded:`
24
+ isPageLoaded: `
25
25
  window.addEventListener('DOMContentLoaded', e => {
26
26
  postMessageToSDK({ type: "${PageMessage.PAGE_LOADED}" })
27
27
  });
28
28
  `,
29
29
  requestRendering: `
30
30
  window.addEventListener("${UnitMessage.UNIT_REQUEST_RENDERING}", (e) => {
31
- postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_RENDERING}", details: { data: JSON.stringify(e.detail) }})
31
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_RENDERING}", details: { data: e.detail }})
32
+ });
33
+ `,
34
+ requestRefresh: `
35
+ window.addEventListener("${UnitMessage.UNIT_REQUEST_REFRESH}", (e) => {
36
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_REFRESH}", details: e.detail })
32
37
  });
33
38
  `,
34
39
  onLoad: `
35
40
  window.addEventListener("${UnitMessage.UNIT_ON_LOAD}", (e) => {
36
41
  postHeight()
37
- postMessageToSDK({ type: "${UnitMessage.UNIT_ON_LOAD}" })
42
+ postMessageToSDK({ type: "${UnitMessage.UNIT_ON_LOAD}", details: e.detail })
38
43
  });
39
44
  `,
40
45
  requestCloseFlow: `
@@ -47,6 +52,11 @@ export const LISTENERS = {
47
52
  postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_OPEN_LINK}", details: e.detail })
48
53
  });
49
54
  `,
55
+ unitRequestDownload: `
56
+ window.addEventListener("${UnitMessage.UNIT_REQUEST_DOWNLOAD}", (e) => {
57
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_DOWNLOAD}", details: e.detail })
58
+ });
59
+ `,
50
60
  cardStatusChange: `
51
61
  window.addEventListener("${CardMessage.CARD_STATUS_CHANGED}", (e) => {
52
62
  const response = e.detail
@@ -59,9 +69,16 @@ export const LISTENERS = {
59
69
  `
60
70
  };
61
71
 
62
- export const DISPTACH_RENDERING_EVENT = `
72
+ export const DISPATCH_RENDERING_EVENT = `
63
73
  const dispatchRenderingEvent = (details) => {
64
74
  const event = new CustomEvent("${UnitMessage.UNIT_REQUEST_RENDERING}",{ detail: JSON.parse(details) })
65
75
  window.dispatchEvent(event)
66
76
  }
67
77
  `;
78
+
79
+ export const DISPATCH_REQUEST_REFRESH = `
80
+ const dispatchRefreshEvent = (details) => {
81
+ const event = new CustomEvent("${UnitMessage.UNIT_REQUEST_REFRESH}",{ detail: JSON.parse(details) })
82
+ window.dispatchEvent(event)
83
+ }
84
+ `;
@@ -1,9 +1,9 @@
1
- import type { Tags, Relationship } from "./types"
1
+ import type { Tags, Relationship } from './types';
2
2
 
3
- type BookPaymentStatus = "Sent" | "Rejected"
3
+ type BookPaymentStatus = 'Sent' | 'Rejected'
4
4
 
5
5
  export type UNBookPaymentData = {
6
- type: "bookPayment",
6
+ type: 'bookPayment',
7
7
  id: string,
8
8
  attributes: {
9
9
  createdAt: string | Date,
@@ -1,12 +1,12 @@
1
- import type { Address, FullName, Limits, Relationship, Tags } from "./types"
1
+ import type { Address, FullName, Limits, Relationship, Tags } from './types';
2
2
 
3
3
  export type UNCardData = IndividualDebitCard | BusinessDebitCard
4
4
 
5
- type CardStatus = "Active" | "Inactive" | "Stolen" | "Lost" | "Frozen" | "ClosedByCustomer" | "SuspectedFraud"
5
+ type CardStatus = 'Active' | 'Inactive' | 'Stolen' | 'Lost' | 'Frozen' | 'ClosedByCustomer' | 'SuspectedFraud'
6
6
 
7
- type IndividualDebitCard = {
7
+ export type IndividualDebitCard = {
8
8
  id: string,
9
- type: "individualDebitCard" | "individualVirtualDebitCard",
9
+ type: 'individualDebitCard' | 'individualVirtualDebitCard',
10
10
  attributes: {
11
11
  createdAt: string,
12
12
  last4Digits: string,
@@ -27,9 +27,9 @@ type IndividualDebitCard = {
27
27
  }
28
28
  }
29
29
 
30
- type BusinessDebitCard = {
30
+ export type BusinessDebitCard = {
31
31
  id: string,
32
- type: "businessDebitCard" | "businessVirtualDebitCard",
32
+ type: 'businessDebitCard' | 'businessVirtualDebitCard',
33
33
  attributes: {
34
34
  fullName: FullName,
35
35
  dateOfBirth: string,
@@ -1,2 +1,3 @@
1
1
  export * from './bookPayment.types';
2
2
  export * from './card.types';
3
+ export * from './onLoadResponse.types';
@@ -0,0 +1,27 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
2
+ import type { UNCardData } from '../sharedTypes';
3
+
4
+ export type SuccessResponseUnitOnLoad = {
5
+ /*
6
+ Object since the current response data types from 'Activities' and 'BookPayment' do not have documentation.
7
+ When things are determined, we may update it
8
+ */
9
+ data: UNCardData | Object,
10
+ included: [Object],
11
+ errors: null
12
+ }
13
+
14
+ export type ErrorResponseUnitOnLoad = {
15
+ errors: [
16
+ {
17
+ status: string,
18
+ title: string,
19
+ detail?: string,
20
+ details?: string,
21
+ meta?: Record<string, string>
22
+ }
23
+ ]
24
+ }
25
+ export type ResponseUnitOnLoadEvent =
26
+ | SuccessResponseUnitOnLoad
27
+ | ErrorResponseUnitOnLoad