react-native-timacare 3.0.8 → 3.0.10

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 (70) hide show
  1. package/lib/commonjs/assets/icons/download.svg +9 -0
  2. package/lib/commonjs/assets/icons/index.js +1 -1
  3. package/lib/commonjs/assets/icons/index.js.flow +2 -0
  4. package/lib/commonjs/assets/icons/index.js.map +1 -1
  5. package/lib/commonjs/navigation/primary-navigator.js +1 -1
  6. package/lib/commonjs/navigation/primary-navigator.js.flow +6 -0
  7. package/lib/commonjs/navigation/primary-navigator.js.map +1 -1
  8. package/lib/commonjs/screens/detail-loan/DetailLoanTima.js +1 -1
  9. package/lib/commonjs/screens/detail-loan/DetailLoanTima.js.flow +79 -232
  10. package/lib/commonjs/screens/detail-loan/DetailLoanTima.js.map +1 -1
  11. package/lib/commonjs/screens/detail-loan/QrPayment.js +2 -0
  12. package/lib/commonjs/screens/detail-loan/QrPayment.js.flow +227 -0
  13. package/lib/commonjs/screens/detail-loan/QrPayment.js.map +1 -0
  14. package/lib/commonjs/screens/detail-loan/ShowQrCode.js +2 -0
  15. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.flow +253 -0
  16. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.map +1 -0
  17. package/lib/commonjs/screens/liveness/index.js +1 -1
  18. package/lib/commonjs/screens/liveness/index.js.flow +8 -8
  19. package/lib/commonjs/screens/liveness/index.js.map +1 -1
  20. package/lib/commonjs/screens/liveness-v2/index.js +1 -1
  21. package/lib/commonjs/screens/liveness-v2/index.js.flow +3 -1
  22. package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
  23. package/lib/commonjs/screens/loginWithPassword/index.js +1 -1
  24. package/lib/commonjs/screens/loginWithPassword/index.js.flow +1 -1
  25. package/lib/commonjs/screens/loginWithPassword/index.js.map +1 -1
  26. package/lib/commonjs/services/api/api.js +1 -1
  27. package/lib/commonjs/services/api/api.js.flow +17 -0
  28. package/lib/commonjs/services/api/api.js.map +1 -1
  29. package/lib/module/assets/icons/download.svg +9 -0
  30. package/lib/module/assets/icons/index.js +1 -1
  31. package/lib/module/assets/icons/index.js.map +1 -1
  32. package/lib/module/navigation/primary-navigator.js +1 -1
  33. package/lib/module/navigation/primary-navigator.js.map +1 -1
  34. package/lib/module/screens/detail-loan/DetailLoanTima.js +1 -1
  35. package/lib/module/screens/detail-loan/DetailLoanTima.js.map +1 -1
  36. package/lib/module/screens/detail-loan/QrPayment.js +2 -0
  37. package/lib/module/screens/detail-loan/QrPayment.js.map +1 -0
  38. package/lib/module/screens/detail-loan/ShowQrCode.js +2 -0
  39. package/lib/module/screens/detail-loan/ShowQrCode.js.map +1 -0
  40. package/lib/module/screens/liveness/index.js +1 -1
  41. package/lib/module/screens/liveness/index.js.map +1 -1
  42. package/lib/module/screens/liveness-v2/index.js +1 -1
  43. package/lib/module/screens/liveness-v2/index.js.map +1 -1
  44. package/lib/module/screens/loginWithPassword/index.js +1 -1
  45. package/lib/module/screens/loginWithPassword/index.js.map +1 -1
  46. package/lib/module/services/api/api.js +1 -1
  47. package/lib/module/services/api/api.js.map +1 -1
  48. package/lib/typescript/assets/icons/index.d.ts +2 -1
  49. package/lib/typescript/assets/icons/index.d.ts.map +1 -1
  50. package/lib/typescript/navigation/primary-navigator.d.ts +2 -0
  51. package/lib/typescript/navigation/primary-navigator.d.ts.map +1 -1
  52. package/lib/typescript/screens/detail-loan/DetailLoanTima.d.ts.map +1 -1
  53. package/lib/typescript/screens/detail-loan/QrPayment.d.ts +2 -0
  54. package/lib/typescript/screens/detail-loan/QrPayment.d.ts.map +1 -0
  55. package/lib/typescript/screens/detail-loan/ShowQrCode.d.ts +2 -0
  56. package/lib/typescript/screens/detail-loan/ShowQrCode.d.ts.map +1 -0
  57. package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
  58. package/lib/typescript/services/api/api.d.ts +16 -0
  59. package/lib/typescript/services/api/api.d.ts.map +1 -1
  60. package/package.json +3 -1
  61. package/src/assets/icons/download.svg +9 -0
  62. package/src/assets/icons/index.tsx +2 -0
  63. package/src/navigation/primary-navigator.tsx +6 -0
  64. package/src/screens/detail-loan/DetailLoanTima.tsx +79 -232
  65. package/src/screens/detail-loan/QrPayment.tsx +227 -0
  66. package/src/screens/detail-loan/ShowQrCode.tsx +253 -0
  67. package/src/screens/liveness/index.tsx +8 -8
  68. package/src/screens/liveness-v2/index.tsx +3 -1
  69. package/src/screens/loginWithPassword/index.tsx +1 -1
  70. package/src/services/api/api.ts +17 -0
@@ -0,0 +1,227 @@
1
+ // @ts-nocheck
2
+ import { observer } from 'mobx-react-lite';
3
+ import React from 'react';
4
+ import {
5
+ Clipboard,
6
+ SafeAreaView,
7
+ ScrollView,
8
+ TextInput,
9
+ TouchableOpacity,
10
+ View,
11
+ } from 'react-native';
12
+ import { commonStyles } from '../CommonStyles';
13
+ import { useNavigation } from '@react-navigation/native';
14
+ import { IconBack, IconCopy } from '../../assets/icons';
15
+ import { color } from '../../theme';
16
+ import { MText } from '../../components/MText';
17
+ import LinearGradient from 'react-native-linear-gradient';
18
+ import { formatMoney } from '../../utils';
19
+ import MHeader from '../../components/MHeader';
20
+
21
+ export const QrPayment = observer(function QrPayment(props: any) {
22
+ const navigation = useNavigation();
23
+ const [totalMoney, setTotalMoney] = React.useState(
24
+ props.route.params.item?.payMoney || 0
25
+ );
26
+
27
+ return (
28
+ <View style={{ flex: 1, backgroundColor: 'rgba(244, 244, 244, 1)' }}>
29
+ <MHeader
30
+ title={`Tạo mã QR để thanh toán`}
31
+ onBack={() => navigation.goBack()}
32
+ />
33
+ <SafeAreaView style={{ flex: 1 }}>
34
+ <ScrollView>
35
+ <View
36
+ style={{
37
+ backgroundColor: 'white',
38
+ margin: 16,
39
+ borderRadius: 16,
40
+ padding: 16,
41
+ }}
42
+ >
43
+ <MText
44
+ style={{
45
+ fontWeight: '600',
46
+ fontSize: 16,
47
+ color: 'rgba(61, 61, 61, 1)',
48
+ }}
49
+ >
50
+ Kỳ thanh toán
51
+ </MText>
52
+ <TouchableOpacity
53
+ style={{
54
+ borderWidth: 1,
55
+ borderColor: 'rgba(229, 229, 234, 1)',
56
+ height: 40,
57
+ borderRadius: 8,
58
+ flexDirection: 'row',
59
+ alignItems: 'center',
60
+ paddingHorizontal: 16,
61
+ marginTop: 8,
62
+ }}
63
+ >
64
+ <MText
65
+ style={{
66
+ fontSize: 16,
67
+ }}
68
+ >
69
+ Kỳ hiện tại
70
+ </MText>
71
+ </TouchableOpacity>
72
+ <MText
73
+ style={{
74
+ fontWeight: '600',
75
+ fontSize: 16,
76
+ color: 'rgba(61, 61, 61, 1)',
77
+ marginTop: 16,
78
+ }}
79
+ >
80
+ Số tiền
81
+ </MText>
82
+ <TextInput
83
+ value={formatMoney(totalMoney)}
84
+ style={{
85
+ height: 40,
86
+ borderWidth: 1,
87
+ borderColor: 'rgba(229, 229, 234, 1)',
88
+ borderRadius: 8,
89
+ paddingHorizontal: 16,
90
+ marginTop: 8,
91
+ fontSize: 16,
92
+ }}
93
+ onChangeText={(text) => {
94
+ const numericValue = text.replace(/\D/g, '');
95
+ setTotalMoney(numericValue);
96
+ }}
97
+ keyboardType="number-pad"
98
+ />
99
+ <View
100
+ style={{
101
+ height: 1,
102
+ backgroundColor: 'rgba(229, 229, 234, 1)',
103
+ marginVertical: 16,
104
+ }}
105
+ />
106
+ <MText
107
+ style={{
108
+ fontWeight: '600',
109
+ }}
110
+ >
111
+ Thông tin ngân hàng thanh toán của Tima
112
+ </MText>
113
+ <MText
114
+ style={{
115
+ color: 'rgba(130, 130, 130, 1)',
116
+ fontSize: 12,
117
+ marginTop: 4,
118
+ }}
119
+ >
120
+ * Lưu ý: Chỉ chuyển khoản khi hiển thị mã QR đúng với thông tin
121
+ của số tài khoản dưới đây
122
+ </MText>
123
+ <View
124
+ style={{
125
+ backgroundColor: 'rgba(255, 243, 233, 1)',
126
+ padding: 8,
127
+ borderRadius: 8,
128
+ marginTop: 8,
129
+ }}
130
+ >
131
+ <MText
132
+ style={{
133
+ color: 'rgba(51, 51, 51, 1)',
134
+ fontSize: 12,
135
+ }}
136
+ >
137
+ Số tài khoản
138
+ </MText>
139
+ <View
140
+ style={{
141
+ flexDirection: 'row',
142
+ alignItems: 'center',
143
+ justifyContent: 'space-between',
144
+ }}
145
+ >
146
+ <MText
147
+ style={{
148
+ color: 'rgba(61, 61, 61, 1)',
149
+ fontWeight: '600',
150
+ }}
151
+ >
152
+ {props.route.params?.data?.accountNumber}
153
+ </MText>
154
+ <TouchableOpacity
155
+ onPress={() =>
156
+ Clipboard.setString(props.route.params?.data?.accountNumber)
157
+ }
158
+ >
159
+ <IconCopy />
160
+ </TouchableOpacity>
161
+ </View>
162
+ <MText
163
+ style={{
164
+ color: 'rgba(51, 51, 51, 1)',
165
+ fontSize: 12,
166
+ marginTop: 5,
167
+ }}
168
+ >
169
+ Tên tài khoản thụ hưởng
170
+ </MText>
171
+ <MText
172
+ style={{
173
+ color: 'rgba(61, 61, 61, 1)',
174
+ fontWeight: '600',
175
+ }}
176
+ >
177
+ {props.route.params?.data?.accountName}
178
+ </MText>
179
+ <MText
180
+ style={{
181
+ color: 'rgba(51, 51, 51, 1)',
182
+ fontSize: 12,
183
+ marginTop: 5,
184
+ }}
185
+ >
186
+ Ngân hàng
187
+ </MText>
188
+ <MText
189
+ style={{
190
+ color: 'rgba(61, 61, 61, 1)',
191
+ fontWeight: '600',
192
+ }}
193
+ >
194
+ {props.route.params?.data?.bankName}
195
+ </MText>
196
+ </View>
197
+ </View>
198
+ </ScrollView>
199
+ <LinearGradient
200
+ style={{
201
+ borderRadius: 24,
202
+ height: 40,
203
+ alignItems: 'center',
204
+ justifyContent: 'center',
205
+ marginVertical: 24,
206
+ marginHorizontal: 16,
207
+ }}
208
+ colors={['#FF7A00', '#EF4123']}
209
+ >
210
+ <TouchableOpacity
211
+ onPress={() =>
212
+ navigation.navigate('ShowQrCode', {
213
+ amount: totalMoney,
214
+ ...props.route.params,
215
+ id: props?.route?.params?.id,
216
+ })
217
+ }
218
+ >
219
+ <MText style={{ color: 'white', fontSize: 16, fontWeight: '600' }}>
220
+ Tiếp tục & Nhận mã QR thanh toán
221
+ </MText>
222
+ </TouchableOpacity>
223
+ </LinearGradient>
224
+ </SafeAreaView>
225
+ </View>
226
+ );
227
+ });
@@ -0,0 +1,253 @@
1
+ //@ts-nocheck
2
+ import { observer } from 'mobx-react-lite';
3
+ import React, { useEffect, useState } from 'react';
4
+ import {
5
+ Alert,
6
+ Clipboard,
7
+ Dimensions,
8
+ Image,
9
+ SafeAreaView,
10
+ ScrollView,
11
+ TouchableOpacity,
12
+ View,
13
+ } from 'react-native';
14
+ import { commonStyles } from '../CommonStyles';
15
+ import { IconBack, IconCopy, IconDownload } from '../../assets/icons';
16
+ import { color } from '../../theme';
17
+ import { MText } from '../../components/MText';
18
+ import { useNavigation } from '@react-navigation/native';
19
+ import { Api } from '../../services/api';
20
+ import Loading from '../../components/Loading';
21
+ import { CameraRoll } from '@react-native-camera-roll/camera-roll';
22
+ import ReactNativeBlobUtil from 'react-native-blob-util';
23
+ import { formatMoney } from '../../utils';
24
+ import MHeader from '../../components/MHeader';
25
+
26
+ export const ShowQrCode = observer(function ShowQrCode(props: any) {
27
+ const navigation = useNavigation();
28
+ const [linkImage, setLinkImage] = useState<string>();
29
+ const [isLoading, setIsLoading] = useState(false);
30
+
31
+ const getData = () => {
32
+ setIsLoading(true);
33
+ Api.getInstance()
34
+ .getQrPayment({
35
+ LoanBriefId: props?.route?.params?.id,
36
+ TypeCloseLoan: 0, // đóng tiền kỳ
37
+ Money: props?.route?.params?.amount,
38
+ })
39
+ .then((response) => {
40
+ setIsLoading(false);
41
+ if (response.kind === 'ok') {
42
+ if (response.data.meta.errorCode === 200) {
43
+ setLinkImage(response.data?.data?.fullPath);
44
+ } else {
45
+ Alert.alert('Thông báo', response?.data?.meta?.errorMessage);
46
+ }
47
+ } else {
48
+ Alert.alert('Thông báo', 'Có lỗi xảy ra. Vui lòng thử lại sau');
49
+ }
50
+ })
51
+ .catch((err) => {
52
+ Alert.alert('Thông báo', 'Có lỗi xảy ra. Vui lòng thử lại sau');
53
+ setIsLoading(false);
54
+ });
55
+ };
56
+
57
+ useEffect(() => {
58
+ getData();
59
+ }, []);
60
+
61
+ return (
62
+ <View style={{ flex: 1, backgroundColor: 'rgba(244, 244, 244, 1)' }}>
63
+ <MHeader title="Tất toán khoản vay" onBack={() => navigation.goBack()} />
64
+ <SafeAreaView style={{ flex: 1 }}>
65
+ <ScrollView>
66
+ <View
67
+ style={{
68
+ backgroundColor: 'white',
69
+ margin: 16,
70
+ borderRadius: 16,
71
+ padding: 16,
72
+ }}
73
+ >
74
+ <MText
75
+ style={{
76
+ textAlign: 'center',
77
+ fontSize: 12,
78
+ fontWeight: '300',
79
+ }}
80
+ >
81
+ Để thanh toán hợp đồng, vui lòng chuyển khoản tới
82
+ </MText>
83
+ <MText
84
+ style={{
85
+ textAlign: 'center',
86
+ fontSize: 12,
87
+ fontWeight: '600',
88
+ color: 'rgba(51, 51, 51, 1)',
89
+ marginTop: 4,
90
+ }}
91
+ >
92
+ {props?.route?.params?.data?.bankName}
93
+ </MText>
94
+
95
+ <View
96
+ style={{
97
+ height: 1,
98
+ backgroundColor: 'rgba(224, 224, 224, 1)',
99
+ marginVertical: 10,
100
+ }}
101
+ />
102
+ <View
103
+ style={{
104
+ flexDirection: 'column',
105
+ justifyContent: 'center',
106
+ alignItems: 'center',
107
+ }}
108
+ >
109
+ <Image
110
+ source={{
111
+ uri: linkImage,
112
+ }}
113
+ style={{
114
+ width: Dimensions.get('window').width - 50,
115
+ height: Dimensions.get('window').width - 50,
116
+ resizeMode: 'contain',
117
+ }}
118
+ />
119
+ <TouchableOpacity
120
+ style={{
121
+ marginTop: 10,
122
+ flexDirection: 'row',
123
+ alignItems: 'center',
124
+ gap: 5,
125
+ }}
126
+ onPress={async () => {
127
+ ReactNativeBlobUtil.config({
128
+ fileCache: true,
129
+ appendExt: 'png',
130
+ })
131
+ .fetch('GET', linkImage) //GET request to URL which has your file
132
+ .then((res) => {
133
+ console.log(res);
134
+ CameraRoll.saveAsset(res.data, { type: 'photo' })
135
+ .then(() => {
136
+ Alert.alert('Thông báo', 'Tải mã QR thành công');
137
+ })
138
+ .catch((error) => {
139
+ Alert.alert(
140
+ 'Thông báo',
141
+ 'Có lỗi xảy ra. Vui lòng thử lại sau'
142
+ );
143
+ console.log(error);
144
+ });
145
+ })
146
+ .catch((error) => {
147
+ console.log(error);
148
+ Alert.alert(
149
+ 'Thông báo',
150
+ 'Có lỗi xảy ra. Vui lòng thử lại sau'
151
+ );
152
+ });
153
+ }}
154
+ >
155
+ <IconDownload />
156
+ <MText
157
+ style={{
158
+ color: 'rgba(51, 51, 51, 1)',
159
+ fontSize: 12,
160
+ }}
161
+ >
162
+ Tải mã QR
163
+ </MText>
164
+ </TouchableOpacity>
165
+ </View>
166
+ <View
167
+ style={{
168
+ height: 1,
169
+ backgroundColor: 'rgba(224, 224, 224, 1)',
170
+ marginVertical: 10,
171
+ }}
172
+ />
173
+ <View>
174
+ <MText
175
+ style={{
176
+ fontSize: 12,
177
+ color: 'rgba(51, 51, 51, 1)',
178
+ fontWeight: '300',
179
+ }}
180
+ >
181
+ Số tiền thanh toán
182
+ </MText>
183
+ <MText
184
+ style={{
185
+ fontSize: 16,
186
+ color: color.primary,
187
+ fontWeight: '600',
188
+ }}
189
+ >
190
+ {formatMoney(props?.route?.params?.amount)} đ
191
+ </MText>
192
+
193
+ <MText
194
+ style={{
195
+ fontSize: 12,
196
+ color: 'rgba(51, 51, 51, 1)',
197
+ fontWeight: '300',
198
+ marginTop: 16,
199
+ }}
200
+ >
201
+ Số tài khoản
202
+ </MText>
203
+ <View
204
+ style={{
205
+ flexDirection: 'row',
206
+ alignItems: 'center',
207
+ justifyContent: 'space-between',
208
+ }}
209
+ >
210
+ <MText
211
+ style={{
212
+ color: 'rgba(61, 61, 61, 1)',
213
+ fontWeight: '600',
214
+ fontSize: 16,
215
+ }}
216
+ >
217
+ {props.route.params?.data?.accountNumber}
218
+ </MText>
219
+ <TouchableOpacity
220
+ onPress={() =>
221
+ Clipboard.setString(props.route.params?.data?.accountNumber)
222
+ }
223
+ >
224
+ <IconCopy />
225
+ </TouchableOpacity>
226
+ </View>
227
+ <MText
228
+ style={{
229
+ fontSize: 12,
230
+ color: 'rgba(51, 51, 51, 1)',
231
+ fontWeight: '300',
232
+ marginTop: 16,
233
+ }}
234
+ >
235
+ Tên tài khoản thụ hưởng
236
+ </MText>
237
+ <MText
238
+ style={{
239
+ color: 'rgba(61, 61, 61, 1)',
240
+ fontWeight: '600',
241
+ fontSize: 16,
242
+ }}
243
+ >
244
+ {props.route.params?.data?.accountName}
245
+ </MText>
246
+ </View>
247
+ </View>
248
+ </ScrollView>
249
+ </SafeAreaView>
250
+ <Loading isLoading={isLoading} />
251
+ </View>
252
+ );
253
+ });
@@ -89,12 +89,12 @@ export const LiveNess = observer(function LiveNess(props: any) {
89
89
  '#timacare'
90
90
  );
91
91
  } catch (e) {}
92
- RNFS.unlink(livenessStore.videoFile);
93
- for (let i = 1; i <= 20; i++) {
94
- const file =
95
- 'file://' + template + `_img_${('000' + i).slice(-4)}.jpg`;
96
- RNFS.unlink(file);
97
- }
92
+ // RNFS.unlink(livenessStore.videoFile);
93
+ // for (let i = 1; i <= 20; i++) {
94
+ // const file =
95
+ // 'file://' + template + `_img_${('000' + i).slice(-4)}.jpg`;
96
+ // RNFS.unlink(file);
97
+ // }
98
98
  },
99
99
  (errorMessage) => {
100
100
  try {
@@ -155,7 +155,7 @@ export const LiveNess = observer(function LiveNess(props: any) {
155
155
  for (let i = 0; i < numFrames; i++) {
156
156
  const time = i * 500;
157
157
  const result = await createThumbnail({
158
- url: videoPath,
158
+ url: videoFile,
159
159
  timeStamp: time,
160
160
  });
161
161
  console.log(`Thumbnail at ${time}ms: `, result.path);
@@ -216,7 +216,7 @@ export const LiveNess = observer(function LiveNess(props: any) {
216
216
  await RNFS.copyFile(data.uri, newPath).then(() => {
217
217
  console.log('Copied to:', newPath);
218
218
  });
219
- captureFromVideo(newPath);
219
+ captureFromVideo(Platform.OS === 'android' ? data?.uri : newPath);
220
220
  } else {
221
221
  Alert.alert(
222
222
  'Thông báo',
@@ -358,7 +358,9 @@ export const LivenessV2 = observer(function LivenessV2(props: any) {
358
358
  await RNFS.copyFile(data.uri, newPath).then(() => {
359
359
  console.log('Copied to:', newPath);
360
360
  });
361
- const thump = await extractFramesFromVideo(newPath);
361
+ const thump = await extractFramesFromVideo(
362
+ Platform.OS === 'android' ? data.uri : newPath
363
+ );
362
364
  if (thump.length > 0) {
363
365
  uploadLiveness(thump);
364
366
  }
@@ -112,7 +112,7 @@ export const LoginWithPassword = observer(function LoginWithPassword(
112
112
  setFieldValue,
113
113
  isValid,
114
114
  }) => (
115
- <View style={{ flex: 1 }}>
115
+ <View style={{ flex: 1, marginTop: 16 }}>
116
116
  <TextInput
117
117
  secureTextEntry
118
118
  style={{
@@ -2474,4 +2474,21 @@ export class Api {
2474
2474
  }
2475
2475
  }
2476
2476
 
2477
+ async getQrPayment(body) {
2478
+ // make the api call
2479
+ const response: ApiResponse<any> = await this.apisauce.post(`api/v2.0/loanbrief/qr_payment_tima`, body)
2480
+ myLog(response)
2481
+ // the typical ways to die when calling an api
2482
+ if (!response.ok) {
2483
+ const problem = getGeneralApiProblem(response)
2484
+ if (problem) return problem
2485
+ }
2486
+ // transform the data into the format we are expecting
2487
+ try {
2488
+ return { kind: "ok", data: response.data }
2489
+ } catch {
2490
+ return { kind: "bad-data" }
2491
+ }
2492
+ }
2493
+
2477
2494
  }