react-native-timacare 3.3.11 → 3.3.13

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 (238) hide show
  1. package/lib/commonjs/RNTimacare.js +1 -1
  2. package/lib/commonjs/RNTimacare.js.flow +2 -11
  3. package/lib/commonjs/RNTimacare.js.map +1 -1
  4. package/lib/commonjs/assets/digital_topup/index.js +2 -0
  5. package/lib/commonjs/assets/digital_topup/index.js.flow +28 -0
  6. package/lib/commonjs/assets/digital_topup/index.js.map +1 -0
  7. package/lib/commonjs/assets/digital_topup/step1.svg +31 -0
  8. package/lib/commonjs/assets/digital_topup/step1_disable.svg +31 -0
  9. package/lib/commonjs/assets/digital_topup/step1_success.svg +21 -0
  10. package/lib/commonjs/assets/digital_topup/step2.svg +39 -0
  11. package/lib/commonjs/assets/digital_topup/step2_disable.svg +16 -0
  12. package/lib/commonjs/assets/digital_topup/step2_success.svg +21 -0
  13. package/lib/commonjs/assets/digital_topup/step3.svg +23 -0
  14. package/lib/commonjs/assets/digital_topup/step3_disable.svg +10 -0
  15. package/lib/commonjs/assets/digital_topup/step3_success.svg +21 -0
  16. package/lib/commonjs/assets/digital_topup/step4_disable.svg +16 -0
  17. package/lib/commonjs/assets/digital_topup/step4_success.svg +21 -0
  18. package/lib/commonjs/components/AlertLoan.js +1 -1
  19. package/lib/commonjs/components/AlertLoan.js.flow +1 -1
  20. package/lib/commonjs/components/AlertLoan.js.map +1 -1
  21. package/lib/commonjs/components/ItemTimaOneV3.js +1 -1
  22. package/lib/commonjs/components/ItemTimaOneV3.js.flow +1 -5
  23. package/lib/commonjs/components/ItemTimaOneV3.js.map +1 -1
  24. package/lib/commonjs/components/MHeader.js +1 -1
  25. package/lib/commonjs/components/MHeader.js.flow +3 -2
  26. package/lib/commonjs/components/MHeader.js.map +1 -1
  27. package/lib/commonjs/components/ModalOptionLoan.js +1 -1
  28. package/lib/commonjs/components/ModalOptionLoan.js.flow +4 -2
  29. package/lib/commonjs/components/ModalOptionLoan.js.map +1 -1
  30. package/lib/commonjs/components/ModalOptionLoanDigital.js +2 -0
  31. package/lib/commonjs/components/ModalOptionLoanDigital.js.flow +297 -0
  32. package/lib/commonjs/components/ModalOptionLoanDigital.js.map +1 -0
  33. package/lib/commonjs/navigation/primary-navigator.js +1 -1
  34. package/lib/commonjs/navigation/primary-navigator.js.flow +0 -3
  35. package/lib/commonjs/navigation/primary-navigator.js.map +1 -1
  36. package/lib/commonjs/screens/camera/CCCDCameraScreen.js +1 -1
  37. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.flow +299 -126
  38. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.map +1 -1
  39. package/lib/commonjs/screens/detail-loan/QrPayment.js +1 -1
  40. package/lib/commonjs/screens/detail-loan/QrPayment.js.flow +1 -0
  41. package/lib/commonjs/screens/detail-loan/QrPayment.js.map +1 -1
  42. package/lib/commonjs/screens/detail-loan/ShowQrCode.js +1 -1
  43. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.flow +1 -1
  44. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.map +1 -1
  45. package/lib/commonjs/screens/home/DigitalTopupItem.js +2 -0
  46. package/lib/commonjs/screens/home/DigitalTopupItem.js.flow +562 -0
  47. package/lib/commonjs/screens/home/DigitalTopupItem.js.map +1 -0
  48. package/lib/commonjs/screens/home/index.js +1 -1
  49. package/lib/commonjs/screens/home/index.js.flow +49 -4
  50. package/lib/commonjs/screens/home/index.js.map +1 -1
  51. package/lib/commonjs/screens/liveness-v2/index.js +1 -1
  52. package/lib/commonjs/screens/liveness-v2/index.js.flow +12 -9
  53. package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
  54. package/lib/commonjs/screens/nationalID/index.js +1 -1
  55. package/lib/commonjs/screens/nationalID/index.js.flow +4 -2
  56. package/lib/commonjs/screens/nationalID/index.js.map +1 -1
  57. package/lib/commonjs/screens/nationalIDBack/index.js +1 -1
  58. package/lib/commonjs/screens/nationalIDBack/index.js.flow +3 -1
  59. package/lib/commonjs/screens/nationalIDBack/index.js.map +1 -1
  60. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  61. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +3 -1
  62. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  63. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js +1 -1
  64. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.flow +1 -375
  65. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  66. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js +1 -1
  67. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js.flow +12 -9
  68. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js.map +1 -1
  69. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
  70. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +16 -10
  71. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  72. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js +1 -1
  73. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js.flow +18 -15
  74. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js.map +1 -1
  75. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js +1 -1
  76. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js.flow +1 -1
  77. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js.map +1 -1
  78. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  79. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +8 -1
  80. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  81. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js +1 -1
  82. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js.flow +20 -17
  83. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js.map +1 -1
  84. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js +1 -1
  85. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js.flow +14 -9
  86. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js.map +1 -1
  87. package/lib/commonjs/screens/uploadVideo/index.js +1 -1
  88. package/lib/commonjs/screens/uploadVideo/index.js.flow +109 -61
  89. package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
  90. package/lib/commonjs/screens/uploadVideo/videoStore.js +1 -1
  91. package/lib/commonjs/screens/uploadVideo/videoStore.js.flow +4 -4
  92. package/lib/commonjs/screens/uploadVideo/videoStore.js.map +1 -1
  93. package/lib/commonjs/sdkConfig.js +1 -1
  94. package/lib/commonjs/sdkConfig.js.flow +6 -0
  95. package/lib/commonjs/sdkConfig.js.map +1 -1
  96. package/lib/commonjs/services/api/api.js +1 -1
  97. package/lib/commonjs/services/api/api.js.flow +32 -0
  98. package/lib/commonjs/services/api/api.js.map +1 -1
  99. package/lib/module/RNTimacare.js +1 -1
  100. package/lib/module/RNTimacare.js.map +1 -1
  101. package/lib/module/assets/digital_topup/index.js +2 -0
  102. package/lib/module/assets/digital_topup/index.js.map +1 -0
  103. package/lib/module/assets/digital_topup/step1.svg +31 -0
  104. package/lib/module/assets/digital_topup/step1_disable.svg +31 -0
  105. package/lib/module/assets/digital_topup/step1_success.svg +21 -0
  106. package/lib/module/assets/digital_topup/step2.svg +39 -0
  107. package/lib/module/assets/digital_topup/step2_disable.svg +16 -0
  108. package/lib/module/assets/digital_topup/step2_success.svg +21 -0
  109. package/lib/module/assets/digital_topup/step3.svg +23 -0
  110. package/lib/module/assets/digital_topup/step3_disable.svg +10 -0
  111. package/lib/module/assets/digital_topup/step3_success.svg +21 -0
  112. package/lib/module/assets/digital_topup/step4_disable.svg +16 -0
  113. package/lib/module/assets/digital_topup/step4_success.svg +21 -0
  114. package/lib/module/components/AlertLoan.js +1 -1
  115. package/lib/module/components/AlertLoan.js.map +1 -1
  116. package/lib/module/components/ItemTimaOneV3.js +1 -1
  117. package/lib/module/components/ItemTimaOneV3.js.map +1 -1
  118. package/lib/module/components/MHeader.js +1 -1
  119. package/lib/module/components/MHeader.js.map +1 -1
  120. package/lib/module/components/ModalOptionLoan.js +1 -1
  121. package/lib/module/components/ModalOptionLoan.js.map +1 -1
  122. package/lib/module/components/ModalOptionLoanDigital.js +2 -0
  123. package/lib/module/components/ModalOptionLoanDigital.js.map +1 -0
  124. package/lib/module/navigation/primary-navigator.js +1 -1
  125. package/lib/module/navigation/primary-navigator.js.map +1 -1
  126. package/lib/module/screens/camera/CCCDCameraScreen.js +1 -1
  127. package/lib/module/screens/camera/CCCDCameraScreen.js.map +1 -1
  128. package/lib/module/screens/detail-loan/QrPayment.js +1 -1
  129. package/lib/module/screens/detail-loan/QrPayment.js.map +1 -1
  130. package/lib/module/screens/detail-loan/ShowQrCode.js +1 -1
  131. package/lib/module/screens/detail-loan/ShowQrCode.js.map +1 -1
  132. package/lib/module/screens/home/DigitalTopupItem.js +2 -0
  133. package/lib/module/screens/home/DigitalTopupItem.js.map +1 -0
  134. package/lib/module/screens/home/index.js +1 -1
  135. package/lib/module/screens/home/index.js.map +1 -1
  136. package/lib/module/screens/liveness-v2/index.js +1 -1
  137. package/lib/module/screens/liveness-v2/index.js.map +1 -1
  138. package/lib/module/screens/nationalID/index.js +1 -1
  139. package/lib/module/screens/nationalID/index.js.map +1 -1
  140. package/lib/module/screens/nationalIDBack/index.js +1 -1
  141. package/lib/module/screens/nationalIDBack/index.js.map +1 -1
  142. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  143. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  144. package/lib/module/screens/toan-trinh-so/ReviewLoan.js +1 -1
  145. package/lib/module/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  146. package/lib/module/screens/toan-trinh-so/TTSNationalIDFront.js +1 -1
  147. package/lib/module/screens/toan-trinh-so/TTSNationalIDFront.js.map +1 -1
  148. package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
  149. package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  150. package/lib/module/screens/toan-trinh-so/TTSSignLoan.js +1 -1
  151. package/lib/module/screens/toan-trinh-so/TTSSignLoan.js.map +1 -1
  152. package/lib/module/screens/toan-trinh-so/TopupLoanInfo.js +1 -1
  153. package/lib/module/screens/toan-trinh-so/TopupLoanInfo.js.map +1 -1
  154. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  155. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  156. package/lib/module/screens/toan-trinh-so/VehicleRegistration.js +1 -1
  157. package/lib/module/screens/toan-trinh-so/VehicleRegistration.js.map +1 -1
  158. package/lib/module/screens/toan-trinh-so/VehicleRegistrationFront.js +1 -1
  159. package/lib/module/screens/toan-trinh-so/VehicleRegistrationFront.js.map +1 -1
  160. package/lib/module/screens/uploadVideo/index.js +1 -1
  161. package/lib/module/screens/uploadVideo/index.js.map +1 -1
  162. package/lib/module/screens/uploadVideo/videoStore.js +1 -1
  163. package/lib/module/screens/uploadVideo/videoStore.js.map +1 -1
  164. package/lib/module/sdkConfig.js +1 -1
  165. package/lib/module/sdkConfig.js.map +1 -1
  166. package/lib/module/services/api/api.js +1 -1
  167. package/lib/module/services/api/api.js.map +1 -1
  168. package/lib/typescript/RNTimacare.d.ts +1 -1
  169. package/lib/typescript/RNTimacare.d.ts.map +1 -1
  170. package/lib/typescript/assets/digital_topup/index.d.ts +14 -0
  171. package/lib/typescript/assets/digital_topup/index.d.ts.map +1 -0
  172. package/lib/typescript/components/ItemTimaOneV3.d.ts.map +1 -1
  173. package/lib/typescript/components/MHeader.d.ts.map +1 -1
  174. package/lib/typescript/components/ModalOptionLoan.d.ts.map +1 -1
  175. package/lib/typescript/components/ModalOptionLoanDigital.d.ts +9 -0
  176. package/lib/typescript/components/ModalOptionLoanDigital.d.ts.map +1 -0
  177. package/lib/typescript/navigation/primary-navigator.d.ts.map +1 -1
  178. package/lib/typescript/screens/camera/CCCDCameraScreen.d.ts.map +1 -1
  179. package/lib/typescript/screens/detail-loan/QrPayment.d.ts.map +1 -1
  180. package/lib/typescript/screens/home/DigitalTopupItem.d.ts +7 -0
  181. package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -0
  182. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  183. package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
  184. package/lib/typescript/screens/nationalID/index.d.ts.map +1 -1
  185. package/lib/typescript/screens/nationalIDBack/index.d.ts.map +1 -1
  186. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  187. package/lib/typescript/screens/toan-trinh-so/ReviewLoan.d.ts.map +1 -1
  188. package/lib/typescript/screens/toan-trinh-so/TTSNationalIDFront.d.ts.map +1 -1
  189. package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
  190. package/lib/typescript/screens/toan-trinh-so/TTSSignLoan.d.ts.map +1 -1
  191. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  192. package/lib/typescript/screens/toan-trinh-so/VehicleRegistration.d.ts.map +1 -1
  193. package/lib/typescript/screens/toan-trinh-so/VehicleRegistrationFront.d.ts.map +1 -1
  194. package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
  195. package/lib/typescript/sdkConfig.d.ts.map +1 -1
  196. package/lib/typescript/services/api/api.d.ts +32 -0
  197. package/lib/typescript/services/api/api.d.ts.map +1 -1
  198. package/package.json +3 -2
  199. package/src/RNTimacare.tsx +2 -11
  200. package/src/assets/digital_topup/index.tsx +28 -0
  201. package/src/assets/digital_topup/step1.svg +31 -0
  202. package/src/assets/digital_topup/step1_disable.svg +31 -0
  203. package/src/assets/digital_topup/step1_success.svg +21 -0
  204. package/src/assets/digital_topup/step2.svg +39 -0
  205. package/src/assets/digital_topup/step2_disable.svg +16 -0
  206. package/src/assets/digital_topup/step2_success.svg +21 -0
  207. package/src/assets/digital_topup/step3.svg +23 -0
  208. package/src/assets/digital_topup/step3_disable.svg +10 -0
  209. package/src/assets/digital_topup/step3_success.svg +21 -0
  210. package/src/assets/digital_topup/step4_disable.svg +16 -0
  211. package/src/assets/digital_topup/step4_success.svg +21 -0
  212. package/src/components/AlertLoan.tsx +1 -1
  213. package/src/components/ItemTimaOneV3.tsx +1 -5
  214. package/src/components/MHeader.tsx +3 -2
  215. package/src/components/ModalOptionLoan.tsx +4 -2
  216. package/src/components/ModalOptionLoanDigital.tsx +297 -0
  217. package/src/navigation/primary-navigator.tsx +0 -3
  218. package/src/screens/camera/CCCDCameraScreen.tsx +299 -126
  219. package/src/screens/detail-loan/QrPayment.tsx +1 -0
  220. package/src/screens/detail-loan/ShowQrCode.tsx +1 -1
  221. package/src/screens/home/DigitalTopupItem.tsx +562 -0
  222. package/src/screens/home/index.tsx +49 -4
  223. package/src/screens/liveness-v2/index.tsx +12 -9
  224. package/src/screens/nationalID/index.tsx +4 -2
  225. package/src/screens/nationalIDBack/index.tsx +3 -1
  226. package/src/screens/toan-trinh-so/OCR.tsx +3 -1
  227. package/src/screens/toan-trinh-so/ReviewLoan.tsx +1 -375
  228. package/src/screens/toan-trinh-so/TTSNationalIDFront.tsx +12 -9
  229. package/src/screens/toan-trinh-so/TTSSelfie.tsx +16 -10
  230. package/src/screens/toan-trinh-so/TTSSignLoan.tsx +18 -15
  231. package/src/screens/toan-trinh-so/TopupLoanInfo.tsx +1 -1
  232. package/src/screens/toan-trinh-so/VehicleCamera.tsx +8 -1
  233. package/src/screens/toan-trinh-so/VehicleRegistration.tsx +20 -17
  234. package/src/screens/toan-trinh-so/VehicleRegistrationFront.tsx +14 -9
  235. package/src/screens/uploadVideo/index.tsx +109 -61
  236. package/src/screens/uploadVideo/videoStore.tsx +4 -4
  237. package/src/sdkConfig.ts +6 -0
  238. package/src/services/api/api.ts +32 -0
@@ -40,18 +40,23 @@ export default function VehicleRegistrationFront(props: any) {
40
40
  const [photo, setPhoto] = useState(null);
41
41
  const [isLoading, setIsLoading] = useState(false);
42
42
 
43
- useEffect(async () => {
43
+ useEffect(() => {
44
44
  if (props?.route?.params?.uri) {
45
45
  setPhoto(props?.route?.params?.uri);
46
46
  }
47
- await logEvent('dangky_started', {
48
- event: 'dangky_started',
49
- createdAt: new Date(),
50
- deviceId: appStore.deviceId,
51
- loanId: String(props?.route?.params?.loan?.id),
52
- utmSource: props?.route?.params?.loan?.utmSource,
53
- });
54
- logEventFb('dangky_started');
47
+
48
+ const trackStarted = async () => {
49
+ await logEvent('dangky_started', {
50
+ event: 'dangky_started',
51
+ createdAt: new Date(),
52
+ deviceId: appStore.deviceId,
53
+ loanId: String(props?.route?.params?.loan?.id),
54
+ utmSource: props?.route?.params?.loan?.utmSource,
55
+ });
56
+ logEventFb('dangky_started');
57
+ };
58
+
59
+ trackStarted();
55
60
  }, []);
56
61
 
57
62
  const takePhoto = () => {
@@ -1,6 +1,6 @@
1
1
  //@ts-nocheck
2
- import { observer, Observer } from 'mobx-react-lite';
3
- import React, { useEffect, useRef, useState } from 'react';
2
+ import { observer } from 'mobx-react-lite';
3
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
4
4
  import {
5
5
  Alert,
6
6
  Platform,
@@ -12,7 +12,7 @@ import {
12
12
  import { formatDDMMYYY, formatMoney } from '../../utils';
13
13
  import { RNCamera } from 'react-native-camera';
14
14
  import MButton from '../../components/MButton';
15
- import { IconBack, IconPause, IconPlay } from '../../assets/icons';
15
+ import { IconPause, IconPlay } from '../../assets/icons';
16
16
  import { MText } from '../../components/MText';
17
17
  import { useNavigation } from '@react-navigation/native';
18
18
  import videoStore from './videoStore';
@@ -21,89 +21,137 @@ import {
21
21
  requestMultiple,
22
22
  openSettings,
23
23
  PERMISSIONS,
24
- request,
25
24
  RESULTS,
26
25
  } from 'react-native-permissions';
27
26
  import Loading from '../../components/Loading';
28
27
  import MHeader from '../../components/MHeader';
29
28
 
29
+ const COUNTDOWN_SECONDS = 3;
30
+
31
+ const getCameraPermissions = () =>
32
+ Platform.OS === 'ios'
33
+ ? [PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.MICROPHONE]
34
+ : [PERMISSIONS.ANDROID.CAMERA, PERMISSIONS.ANDROID.RECORD_AUDIO];
35
+
30
36
  export const Video = observer(function Video(props: any) {
31
37
  const navigation = useNavigation();
32
38
  const camera = useRef(null);
33
- const [count, setCount] = useState(3);
34
- const interval = React.useRef(null);
35
- const [isRecording, setIsRecording] = React.useState(false);
36
- const [isLoading, setIsLoading] = React.useState(false);
37
-
38
- const content = `Hôm nay ngày ${formatDDMMYYY(new Date())} tôi tên là ${
39
- props.route.params.loan.fullname
40
- } thực hiện khoản vay tại Tima với số tiền là ${formatMoney(
41
- props.route.params.loan.loanAmount
42
- )}`;
43
-
44
- let second = 3;
45
-
46
- const requestPermissions = () => {
47
- checkMultiple(
48
- Platform.OS === 'ios'
49
- ? [PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.MICROPHONE]
50
- : [PERMISSIONS.ANDROID.CAMERA, PERMISSIONS.ANDROID.RECORD_AUDIO]
51
- ).then((statuses) => {});
39
+ const [count, setCount] = useState(COUNTDOWN_SECONDS);
40
+ const [isRecording, setIsRecording] = useState(false);
41
+ const [isLoading, setIsLoading] = useState(false);
42
+
43
+ const loan = props?.route?.params?.loan;
44
+ const content = useMemo(() => {
45
+ return `Hôm nay ngày ${formatDDMMYYY(new Date())} tôi tên là ${
46
+ loan?.fullname || ''
47
+ } có thực hiện khoản vay tại Tima với số tiền là ${formatMoney(
48
+ loan?.loanAmount || 0
49
+ )}`;
50
+ }, [loan?.fullname, loan?.loanAmount]);
51
+
52
+ const requestPermissions = async () => {
53
+ const permissions = getCameraPermissions();
54
+ const statuses = await checkMultiple(permissions);
55
+ const toRequest = permissions.filter(
56
+ (permission) => statuses[permission] !== RESULTS.GRANTED
57
+ );
58
+
59
+ if (toRequest.length === 0) return true;
60
+
61
+ const requested = await requestMultiple(toRequest);
62
+ const values = Object.values(requested);
63
+ const allGranted = values.every((status) => status === RESULTS.GRANTED);
64
+ const anyBlocked = values.some((status) => status === RESULTS.BLOCKED);
65
+
66
+ if (!allGranted) {
67
+ Alert.alert(
68
+ 'Thông báo',
69
+ anyBlocked
70
+ ? 'Vui lòng bật quyền Camera và Micro trong Cài đặt để tiếp tục.'
71
+ : 'Vui lòng cấp quyền Camera và Micro để tiếp tục.',
72
+ anyBlocked
73
+ ? [
74
+ { text: 'Huỷ' },
75
+ {
76
+ text: 'Mở cài đặt',
77
+ onPress: () => openSettings(),
78
+ },
79
+ ]
80
+ : [{ text: 'OK' }]
81
+ );
82
+ }
83
+
84
+ return allGranted;
52
85
  };
53
86
 
54
87
  useEffect(() => {
55
88
  requestPermissions();
56
- interval.current = setInterval(() => {
57
- second--;
58
- setCount(second);
59
- if (second === 0) {
60
- clearInterval(interval.current);
61
- }
89
+ setCount(COUNTDOWN_SECONDS);
90
+ const id = setInterval(() => {
91
+ setCount((prev) => {
92
+ if (prev <= 1) {
93
+ clearInterval(id);
94
+ return 0;
95
+ }
96
+ return prev - 1;
97
+ });
62
98
  }, 1000);
99
+ return () => clearInterval(id);
63
100
  }, []);
64
101
 
65
102
  const stopRecording = () => {
103
+ if (!camera.current) return;
66
104
  camera.current.stopRecording();
67
105
  setIsRecording(false);
68
- setIsLoading(true);
69
106
  };
70
107
 
71
108
  const startVideo = async () => {
72
- if (!camera) {
109
+ if (!camera.current || isLoading || isRecording || count > 0) {
73
110
  return;
74
111
  }
112
+ const hasPermission = await requestPermissions();
113
+ if (!hasPermission) return;
114
+
75
115
  setIsRecording(true);
76
- const data = await camera.current.recordAsync({
77
- ...{
116
+ try {
117
+ const data = await camera.current.recordAsync({
78
118
  quality: RNCamera.Constants.VideoQuality['480p'],
79
119
  videoBitrate: 1500000,
80
- },
81
- ...(Platform.OS === 'ios'
82
- ? { codec: RNCamera.Constants.VideoCodec.H264 }
83
- : {}),
84
- });
85
- let formData = new FormData();
86
- formData.append('video', {
87
- name: data.uri.split(/[\\/]/).pop(),
88
- uri: data.uri,
89
- type: 'video/*',
90
- });
91
- videoStore.uploadVideo(
92
- props.route.params.loan.id,
93
- formData,
94
- () => {
95
- setIsLoading(false);
96
- Alert.alert('Thông báo', 'Tải video lên thành công', [
97
- {
98
- text: 'Ok',
99
- onPress: () => navigation.goBack(),
100
- },
101
- ]);
102
- },
103
- () => {
104
- setIsLoading(false);
105
- }
106
- );
120
+ ...(Platform.OS === 'ios'
121
+ ? { codec: RNCamera.Constants.VideoCodec.H264 }
122
+ : {}),
123
+ });
124
+
125
+ setIsLoading(true);
126
+ const formData = new FormData();
127
+ formData.append('video', {
128
+ name: data.uri.split(/[\\/]/).pop(),
129
+ uri: data.uri,
130
+ type: 'video/*',
131
+ });
132
+
133
+ videoStore.uploadVideo(
134
+ loan?.id,
135
+ formData,
136
+ () => {
137
+ setIsLoading(false);
138
+ Alert.alert('Thông báo', 'Tải video lên thành công', [
139
+ {
140
+ text: 'Ok',
141
+ onPress: () => navigation.goBack(),
142
+ },
143
+ ]);
144
+ },
145
+ () => {
146
+ setIsLoading(false);
147
+ }
148
+ );
149
+ } catch (err) {
150
+ setIsRecording(false);
151
+ setIsLoading(false);
152
+ console.error(err);
153
+ Alert.alert('Thông báo', 'Không thể quay video. Vui lòng thử lại.');
154
+ }
107
155
  };
108
156
 
109
157
  return (
@@ -143,7 +191,7 @@ export const Video = observer(function Video(props: any) {
143
191
  <RNCamera
144
192
  ref={camera}
145
193
  style={styles.preview}
146
- type="front"
194
+ type={RNCamera.Constants.Type.front}
147
195
  permissionDialogTitle={'Permission to use camera'}
148
196
  permissionDialogMessage={
149
197
  'We need your permission to use your camera phone'
@@ -8,11 +8,9 @@ class Store {
8
8
 
9
9
  @action
10
10
  async uploadVideo(loanID, body, onSuccess?, onError) {
11
+ this.isLoading = true;
11
12
  try {
12
- this.isLoading = true;
13
13
  const response = await Api.getInstance().uploadVideo(loanID, body);
14
- console.log(response);
15
- this.isLoading = false;
16
14
  if (response.kind === 'ok') {
17
15
  if (response.data.meta.errorCode === 200) {
18
16
  if (onSuccess) onSuccess();
@@ -21,13 +19,15 @@ class Store {
21
19
  if (onError) onError();
22
20
  }
23
21
  } else {
24
- this.isLoading = false;
25
22
  Alert.alert('Thông báo', 'Lỗi đã xảy ra. Vui lòng thực hiện lại');
26
23
  if (onError) onError();
27
24
  }
28
25
  } catch (error) {
29
26
  console.log(error);
27
+ Alert.alert('Thông báo', 'Lỗi đã xảy ra. Vui lòng thực hiện lại');
30
28
  if (onError) onError();
29
+ } finally {
30
+ this.isLoading = false;
31
31
  }
32
32
  }
33
33
  }
package/src/sdkConfig.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import appStore from "./AppStore";
2
+
1
3
  export type SDKConfig = {
2
4
  baseUrl: string;
3
5
  token?: string;
@@ -7,6 +9,10 @@ let config: SDKConfig | null = null;
7
9
 
8
10
  export const initSDK = (options: SDKConfig) => {
9
11
  config = options;
12
+ appStore.getDeviceId();
13
+ appStore.getPublicIp();
14
+ appStore.getAppId();
15
+ appStore.getDevicePayload();
10
16
  };
11
17
 
12
18
  export const getSDKConfig = (): SDKConfig => {
@@ -3279,4 +3279,36 @@ export class Api {
3279
3279
  return { kind: "bad-data" }
3280
3280
  }
3281
3281
  }
3282
+
3283
+ async getSuggestDigitalTopup(id) {
3284
+ // make the api call
3285
+ const response: ApiResponse<any> = await this.apisauce.get(`api/v2.0/autodev2/digital_topup_get_product_suggerst?loanBriefId=${id}`)
3286
+ // the typical ways to die when calling an api
3287
+ if (!response.ok) {
3288
+ const problem = getGeneralApiProblem(response)
3289
+ if (problem) return problem
3290
+ }
3291
+ // transform the data into the format we are expecting
3292
+ try {
3293
+ return { kind: "ok", data: response.data }
3294
+ } catch {
3295
+ return { kind: "bad-data" }
3296
+ }
3297
+ }
3298
+
3299
+ async updateDigitalProductLoan(body) {
3300
+ // make the api call
3301
+ const response: ApiResponse<any> = await this.apisauce.post(`api/v2.0/autodev2/digital_topup_update_product`, body)
3302
+ // the typical ways to die when calling an api
3303
+ if (!response.ok) {
3304
+ const problem = getGeneralApiProblem(response)
3305
+ if (problem) return problem
3306
+ }
3307
+ // transform the data into the format we are expecting
3308
+ try {
3309
+ return { kind: "ok", data: response.data }
3310
+ } catch {
3311
+ return { kind: "bad-data" }
3312
+ }
3313
+ }
3282
3314
  }