react-native-timacare 3.3.64 → 3.3.65

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 (61) hide show
  1. package/lib/commonjs/components/AlertLoan.js +1 -1
  2. package/lib/commonjs/components/AlertLoan.js.flow +11 -2
  3. package/lib/commonjs/components/AlertLoan.js.map +1 -1
  4. package/lib/commonjs/components/ItemTimaOne.js +1 -1
  5. package/lib/commonjs/components/ItemTimaOne.js.flow +2 -0
  6. package/lib/commonjs/components/ItemTimaOne.js.map +1 -1
  7. package/lib/commonjs/navigation/primary-navigator.js +1 -1
  8. package/lib/commonjs/navigation/primary-navigator.js.flow +9 -0
  9. package/lib/commonjs/navigation/primary-navigator.js.map +1 -1
  10. package/lib/commonjs/screens/full-submit/selfie.js +1 -1
  11. package/lib/commonjs/screens/full-submit/selfie.js.flow +257 -114
  12. package/lib/commonjs/screens/full-submit/selfie.js.map +1 -1
  13. package/lib/commonjs/screens/selfie/SelfieCamera.js +2 -0
  14. package/lib/commonjs/screens/selfie/SelfieCamera.js.flow +302 -0
  15. package/lib/commonjs/screens/selfie/SelfieCamera.js.map +1 -0
  16. package/lib/commonjs/screens/selfie/index.js +1 -1
  17. package/lib/commonjs/screens/selfie/index.js.flow +295 -165
  18. package/lib/commonjs/screens/selfie/index.js.map +1 -1
  19. package/lib/commonjs/screens/v3/ReviewInfoLoanBuyCar.js +2 -0
  20. package/lib/commonjs/screens/v3/ReviewInfoLoanBuyCar.js.flow +521 -0
  21. package/lib/commonjs/screens/v3/ReviewInfoLoanBuyCar.js.map +1 -0
  22. package/lib/commonjs/services/api/api.js +1 -1
  23. package/lib/commonjs/services/api/api.js.flow +41 -7
  24. package/lib/commonjs/services/api/api.js.map +1 -1
  25. package/lib/module/components/AlertLoan.js +1 -1
  26. package/lib/module/components/AlertLoan.js.map +1 -1
  27. package/lib/module/components/ItemTimaOne.js +1 -1
  28. package/lib/module/components/ItemTimaOne.js.map +1 -1
  29. package/lib/module/navigation/primary-navigator.js +1 -1
  30. package/lib/module/navigation/primary-navigator.js.map +1 -1
  31. package/lib/module/screens/full-submit/selfie.js +1 -1
  32. package/lib/module/screens/full-submit/selfie.js.map +1 -1
  33. package/lib/module/screens/selfie/SelfieCamera.js +2 -0
  34. package/lib/module/screens/selfie/SelfieCamera.js.map +1 -0
  35. package/lib/module/screens/selfie/index.js +1 -1
  36. package/lib/module/screens/selfie/index.js.map +1 -1
  37. package/lib/module/screens/v3/ReviewInfoLoanBuyCar.js +2 -0
  38. package/lib/module/screens/v3/ReviewInfoLoanBuyCar.js.map +1 -0
  39. package/lib/module/services/api/api.js +1 -1
  40. package/lib/module/services/api/api.js.map +1 -1
  41. package/lib/typescript/components/AlertLoan.d.ts.map +1 -1
  42. package/lib/typescript/components/ItemTimaOne.d.ts.map +1 -1
  43. package/lib/typescript/navigation/primary-navigator.d.ts +2 -0
  44. package/lib/typescript/navigation/primary-navigator.d.ts.map +1 -1
  45. package/lib/typescript/screens/full-submit/selfie.d.ts.map +1 -1
  46. package/lib/typescript/screens/selfie/SelfieCamera.d.ts +2 -0
  47. package/lib/typescript/screens/selfie/SelfieCamera.d.ts.map +1 -0
  48. package/lib/typescript/screens/selfie/index.d.ts.map +1 -1
  49. package/lib/typescript/screens/v3/ReviewInfoLoanBuyCar.d.ts +2 -0
  50. package/lib/typescript/screens/v3/ReviewInfoLoanBuyCar.d.ts.map +1 -0
  51. package/lib/typescript/services/api/api.d.ts +32 -0
  52. package/lib/typescript/services/api/api.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/components/AlertLoan.tsx +11 -2
  55. package/src/components/ItemTimaOne.tsx +2 -0
  56. package/src/navigation/primary-navigator.tsx +9 -0
  57. package/src/screens/full-submit/selfie.tsx +257 -114
  58. package/src/screens/selfie/SelfieCamera.tsx +302 -0
  59. package/src/screens/selfie/index.tsx +295 -165
  60. package/src/screens/v3/ReviewInfoLoanBuyCar.tsx +521 -0
  61. package/src/services/api/api.ts +41 -7
@@ -0,0 +1,521 @@
1
+ //@ts-nocheck
2
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
3
+ import {
4
+ ScrollView,
5
+ TextInput,
6
+ TextStyle,
7
+ TouchableOpacity,
8
+ View,
9
+ ViewStyle,
10
+ } from 'react-native';
11
+ import MHeader from '../../components/MHeader';
12
+ import { commonStyles } from '../CommonStyles';
13
+ import { useNavigation, CommonActions } from '@react-navigation/native';
14
+ import Loading from '../../components/Loading';
15
+ import { AlertGlobal } from '../../components/ModalNotification/AlertGlobal';
16
+ import { ScreenNames } from '../../navigation';
17
+ import { MText } from '../../components/MText';
18
+ import { IconBack } from '../../assets/svgs';
19
+ import { Formik } from 'formik';
20
+ import DatePicker from 'react-native-date-picker';
21
+ import { formatDDMMYYY, logEvent, logEventFb } from '../../utils';
22
+ import { DropDown2 } from '../../assets/icons';
23
+ import LinearGradient from 'react-native-linear-gradient';
24
+ import MButton from '../../components/MButton';
25
+ import { Api } from '../../services/api';
26
+ import KeyboardSpacer from '../../components/keyboardspace';
27
+ import * as yup from 'yup';
28
+ import moment from 'moment';
29
+
30
+ export default function ReviewInfoLoanBuyCar(props: any) {
31
+ const navigation = useNavigation();
32
+ const formRef = useRef(null);
33
+ const [showDate, setShowDate] = useState(false);
34
+ const [typeDate, setTypeDate] = useState(1);
35
+ const [isLoading, setIsLoading] = useState(false);
36
+
37
+ const getData = async () => {
38
+ try {
39
+ setIsLoading(true);
40
+ const response = await Api.getInstance().getInfoCustomerLoanByCar(
41
+ props.route?.params?.loan?.id
42
+ );
43
+ console.log(response);
44
+
45
+ setIsLoading(false);
46
+ if (response.kind === 'ok') {
47
+ if (response.data?.meta.errorCode === 200) {
48
+ formRef.current.setFieldValue(
49
+ 'fullName',
50
+ response?.data?.data?.fullName
51
+ );
52
+ formRef.current.setFieldValue(
53
+ 'dob',
54
+ response?.data?.data?.dob
55
+ ? formatDDMMYYY(response?.data?.data?.dob)
56
+ : ''
57
+ );
58
+ formRef.current.setFieldValue(
59
+ 'gender',
60
+ response?.data?.data?.gender ?? null
61
+ );
62
+ formRef.current.setFieldValue(
63
+ 'nationalCard',
64
+ response?.data?.data?.nationalCard
65
+ ? response?.data?.data?.nationalCard
66
+ : ''
67
+ );
68
+ formRef.current.setFieldValue(
69
+ 'dateNationalId',
70
+ response?.data?.data?.dateNationalId
71
+ ? formatDDMMYYY(response?.data?.data?.dateNationalId)
72
+ : ''
73
+ );
74
+ formRef.current.setFieldValue(
75
+ 'phone',
76
+ response?.data?.data?.phone ? response?.data?.data?.phone : ''
77
+ );
78
+ } else {
79
+ }
80
+ }
81
+ } catch (error) {
82
+ setIsLoading(false);
83
+ console.log(error);
84
+ }
85
+ };
86
+
87
+ useEffect(() => {
88
+ getData();
89
+ const trackEvent = async () => {
90
+ await logEvent('thongtinvay_started', {
91
+ event: 'thongtinvay_started',
92
+ createdAt: new Date(),
93
+ deviceId: appStore.deviceId,
94
+ loanId: String(props.route?.params?.loan?.id),
95
+ utmSource: props.route?.params?.loan?.utmSource,
96
+ });
97
+ logEventFb('thongtinvay_started');
98
+ };
99
+ trackEvent();
100
+ }, []);
101
+
102
+ const onSubmit = async (values) => {
103
+ const body = {
104
+ LoanBriefId: props?.route?.params?.loan?.id,
105
+ FullName: values.fullName,
106
+ Dob: moment(values.dob, 'DD/MM/YYYY').format('YYYY-MM-DD'),
107
+ Gender: values.gender,
108
+ NationalCard: values.nationalCard,
109
+ DateNationalId: moment(values.dateNationalId, 'DD/MM/YYYY').format(
110
+ 'YYYY-MM-DD'
111
+ ),
112
+ };
113
+ try {
114
+ setIsLoading(true);
115
+ const response = await Api.getInstance().updateInfoCustomerLoanBuyCar(
116
+ body
117
+ );
118
+ setIsLoading(false);
119
+ if (response.kind === 'ok') {
120
+ if (response.data?.meta?.errorCode === 200) {
121
+ navigation.dispatch(
122
+ CommonActions.reset({
123
+ index: 1,
124
+ routes: [{ name: ScreenNames.Main }],
125
+ })
126
+ );
127
+ } else {
128
+ AlertGlobal.show({
129
+ type: 'warning',
130
+ title: 'Thông báo',
131
+ message: response.data?.meta?.errorMessage,
132
+ primaryText: 'Đóng',
133
+ });
134
+ }
135
+ } else {
136
+ AlertGlobal.show({
137
+ type: 'warning',
138
+ title: 'Thông báo',
139
+ message: 'Có lỗi xảy ra. Vui lòng thử lại sau',
140
+ primaryText: 'Đóng',
141
+ });
142
+ }
143
+ } catch (error) {
144
+ setIsLoading(false);
145
+ }
146
+ };
147
+
148
+ return (
149
+ <View style={{ flex: 1 }}>
150
+ <MHeader title="Vay Online 24/7" />
151
+ <View style={commonStyles.fill}>
152
+ <View style={$h} />
153
+ <View style={$bg}>
154
+ <View
155
+ style={{
156
+ paddingVertical: 10,
157
+ flexDirection: 'row',
158
+ alignItems: 'center',
159
+ paddingHorizontal: 16,
160
+ }}
161
+ >
162
+ <TouchableOpacity
163
+ style={{
164
+ zIndex: 1000,
165
+ }}
166
+ onPress={() => {
167
+ AlertGlobal.show({
168
+ type: 'confirm',
169
+ title: 'Thoát cập nhật thông tin',
170
+ message:
171
+ 'Bạn có chắc chắn muốn thoát cập nhật thông tin không?',
172
+ primaryText: 'Có',
173
+ onPrimaryPress: () => {
174
+ navigation.dispatch(
175
+ CommonActions.reset({
176
+ index: 1,
177
+ routes: [{ name: ScreenNames.Main }],
178
+ })
179
+ );
180
+ },
181
+ secondaryText: 'Không',
182
+ });
183
+ }}
184
+ >
185
+ <IconBack />
186
+ </TouchableOpacity>
187
+ <MText style={$title}>Thông tin cá nhân</MText>
188
+ </View>
189
+ <Formik
190
+ innerRef={formRef}
191
+ onSubmit={onSubmit}
192
+ initialValues={{
193
+ fullName: '',
194
+ dob: '',
195
+ gender: null,
196
+ nationalCard: '',
197
+ dateNationalId: '',
198
+ phone: '',
199
+ }}
200
+ validationSchema={yup.object().shape({
201
+ fullName: yup.string().required('Vui lòng nhập họ tên'),
202
+ dob: yup.string().required('Vui lòng nhập ngày sinh').nullable(),
203
+ gender: yup
204
+ .number()
205
+ .required('Vui lòng chọn giới tính')
206
+ .nullable(),
207
+ nationalCard: yup.string().required('Vui lòng nhập CCCD/CMND'),
208
+ dateNationalId: yup
209
+ .string()
210
+ .required('Vui lòng nhập ngày cấp')
211
+ .nullable(),
212
+ phone: yup
213
+ .string()
214
+ .required('Vui lòng nhập số điện thoại')
215
+ .nullable(),
216
+ })}
217
+ >
218
+ {({
219
+ values,
220
+ errors,
221
+ handleChange,
222
+ handleSubmit,
223
+ setFieldValue,
224
+ }) => {
225
+ const renderView = useMemo(
226
+ () => (
227
+ <>
228
+ <ScrollView
229
+ style={[commonStyles.fill, { paddingHorizontal: 16 }]}
230
+ showsVerticalScrollIndicator={false}
231
+ >
232
+ <MText style={$title2}>1.1 Thông tin cá nhân</MText>
233
+ <MText style={$label}>Họ và tên</MText>
234
+ <TextInput
235
+ style={[
236
+ $textInput,
237
+ {
238
+ color: '#333333',
239
+ fontWeight: '500',
240
+ fontFamily: 'BeVietnamPro-Medium',
241
+ },
242
+ ]}
243
+ value={values.fullName}
244
+ onChangeText={handleChange('fullName')}
245
+ />
246
+ {errors && errors.fullName && (
247
+ <MText style={$error}>{errors.fullName}</MText>
248
+ )}
249
+ <View style={[$row, { marginTop: 16 }]}>
250
+ <View style={[commonStyles.fill]}>
251
+ <MText style={$label}>Sinh ngày</MText>
252
+ <TouchableOpacity
253
+ style={$select}
254
+ onPress={() => {
255
+ setTypeDate(1);
256
+ setShowDate(true);
257
+ }}
258
+ >
259
+ <MText
260
+ style={{
261
+ color: '#333333',
262
+ fontWeight: '500',
263
+ fontFamily: 'BeVietnamPro-Medium',
264
+ }}
265
+ >
266
+ {values.dob}
267
+ </MText>
268
+ </TouchableOpacity>
269
+ {errors && errors.dob && (
270
+ <MText style={$error}>{errors.dob}</MText>
271
+ )}
272
+ </View>
273
+ <View style={[commonStyles.fill]}>
274
+ <MText style={$label}>Giới tính</MText>
275
+ <TouchableOpacity
276
+ style={$select}
277
+ onPress={() => {
278
+ navigation.push(ScreenNames.MSelect, {
279
+ title: 'Chọn giới tính',
280
+ data: EnumGender,
281
+ callback: (item) => {
282
+ setFieldValue('gender', item.id);
283
+ },
284
+ });
285
+ }}
286
+ >
287
+ <MText
288
+ style={{
289
+ color: '#333333',
290
+ fontSize: 16,
291
+ fontWeight: '500',
292
+ flex: 1,
293
+ }}
294
+ >
295
+ {values.gender === 0
296
+ ? 'Nam'
297
+ : values.gender === 1
298
+ ? 'Nữ'
299
+ : ''}
300
+ </MText>
301
+ <DropDown2 />
302
+ </TouchableOpacity>
303
+ {errors && errors.gender && (
304
+ <MText style={$error}>{errors.gender}</MText>
305
+ )}
306
+ </View>
307
+ </View>
308
+ <View style={[$row]}>
309
+ <View style={[commonStyles.fill]}>
310
+ <MText style={$label}>Số CCCD/CMND</MText>
311
+ <TextInput
312
+ keyboardType="number-pad"
313
+ style={[
314
+ $textInput,
315
+ {
316
+ color: '#333333',
317
+ fontWeight: '500',
318
+ fontFamily: 'BeVietnamPro-Medium',
319
+ },
320
+ ]}
321
+ value={values.nationalCard}
322
+ onChangeText={handleChange('nationalCard')}
323
+ />
324
+ {errors && errors.nationalCard && (
325
+ <MText style={$error}>{errors.nationalCard}</MText>
326
+ )}
327
+ </View>
328
+ <View style={[commonStyles.fill]}>
329
+ <MText style={$label}>Ngày cấp</MText>
330
+ <TouchableOpacity
331
+ style={$select}
332
+ onPress={() => {
333
+ setTypeDate(2);
334
+ setShowDate(true);
335
+ }}
336
+ >
337
+ <MText
338
+ numberOfLines={1}
339
+ style={{
340
+ color:
341
+ values.dateNationalId !== ''
342
+ ? '#333333'
343
+ : '#BDBDBD',
344
+ fontWeight: '500',
345
+ flex: 1,
346
+ fontFamily: 'BeVietnamPro-Medium',
347
+ }}
348
+ >
349
+ {values.dateNationalId !== ''
350
+ ? values.dateNationalId
351
+ : 'DD/MM/YYYY'}
352
+ </MText>
353
+ </TouchableOpacity>
354
+ {errors && errors.dateNationalId && (
355
+ <MText style={$error}>
356
+ {errors.dateNationalId}
357
+ </MText>
358
+ )}
359
+ </View>
360
+ </View>
361
+ <MText style={$label}>Số điện thoại</MText>
362
+ <TextInput
363
+ editable={false}
364
+ keyboardType="number-pad"
365
+ style={[
366
+ $textInput,
367
+ {
368
+ color: '#333333',
369
+ fontWeight: '500',
370
+ fontFamily: 'BeVietnamPro-Medium',
371
+ backgroundColor: '#E0E0E0',
372
+ },
373
+ ]}
374
+ value={values.phone}
375
+ onChangeText={handleChange('phone')}
376
+ />
377
+ {errors && errors.phone && (
378
+ <MText style={$error}>{errors.phone}</MText>
379
+ )}
380
+ </ScrollView>
381
+ <MButton
382
+ onPress={() => {
383
+ handleSubmit();
384
+ }}
385
+ style={{
386
+ marginVertical: 24,
387
+ marginHorizontal: 16,
388
+ }}
389
+ >
390
+ <LinearGradient
391
+ start={{ x: 1, y: 0 }}
392
+ end={{ x: 0, y: 1 }}
393
+ style={{
394
+ height: 40,
395
+ marginVertical: 16,
396
+ borderRadius: 30,
397
+ alignItems: 'center',
398
+ justifyContent: 'center',
399
+ }}
400
+ colors={['#FF7A00', '#EF4123']}
401
+ >
402
+ <MText
403
+ style={{
404
+ color: 'white',
405
+ fontSize: 16,
406
+ }}
407
+ >
408
+ Tiếp tục
409
+ </MText>
410
+ </LinearGradient>
411
+ </MButton>
412
+ </>
413
+ ),
414
+ [values, errors]
415
+ );
416
+ return (
417
+ <>
418
+ {renderView}
419
+
420
+ <DatePicker
421
+ mode="date"
422
+ open={showDate}
423
+ modal
424
+ title="Chọn thời gian"
425
+ locale="vi"
426
+ date={new Date()}
427
+ onCancel={() => {
428
+ setShowDate(false);
429
+ }}
430
+ onConfirm={(date) => {
431
+ setShowDate(false);
432
+ if (typeDate === 1) {
433
+ setFieldValue('dob', formatDDMMYYY(date));
434
+ }
435
+ if (typeDate === 2) {
436
+ setFieldValue('dateNationalId', formatDDMMYYY(date));
437
+ }
438
+ }}
439
+ />
440
+ </>
441
+ );
442
+ }}
443
+ </Formik>
444
+ <KeyboardSpacer />
445
+ </View>
446
+ </View>
447
+ <Loading isLoading={isLoading} />
448
+ </View>
449
+ );
450
+ }
451
+ const $row: ViewStyle = {
452
+ flexDirection: 'row',
453
+ // alignItems: 'center',
454
+ marginBottom: 16,
455
+ gap: 16,
456
+ };
457
+
458
+ const $textInput: ViewStyle = {
459
+ borderWidth: 1,
460
+ borderRadius: 4,
461
+ borderColor: '#E0E0E0',
462
+ height: 40,
463
+ paddingHorizontal: 8,
464
+ fontFamily: 'BeVietnamPro-Medium',
465
+ };
466
+
467
+ const $label: TextStyle = {
468
+ fontSize: 14,
469
+ color: '#333333',
470
+ paddingBottom: 5,
471
+ };
472
+
473
+ const $title2: TextStyle = {
474
+ fontSize: 16,
475
+ fontWeight: 'bold',
476
+ color: '#333333',
477
+ paddingBottom: 10,
478
+ marginTop: 6,
479
+ };
480
+
481
+ const $title: TextStyle = {
482
+ fontSize: 16,
483
+ fontWeight: 'bold',
484
+ color: '#333333',
485
+ position: 'absolute',
486
+ left: 0,
487
+ right: 0,
488
+ textAlign: 'center',
489
+ };
490
+ const $h: ViewStyle = {
491
+ backgroundColor: '#EF592E',
492
+ position: 'absolute',
493
+ height: 30,
494
+ width: '100%',
495
+ };
496
+
497
+ const $bg: ViewStyle = {
498
+ borderTopLeftRadius: 30,
499
+ borderTopRightRadius: 30,
500
+ backgroundColor: 'white',
501
+ flex: 1,
502
+ };
503
+
504
+ const $select: ViewStyle = {
505
+ flexDirection: 'row',
506
+ height: 40,
507
+ alignItems: 'center',
508
+ paddingHorizontal: 8,
509
+ borderWidth: 1,
510
+ borderRadius: 4,
511
+ borderColor: '#E0E0E0',
512
+ };
513
+
514
+ const $error: TextStyle = {
515
+ color: '#EB5757',
516
+ fontSize: 14,
517
+ fontStyle: 'italic',
518
+ fontFamily: 'BeVietnamPro-Thin',
519
+ fontWeight: '300',
520
+ marginTop: 5,
521
+ };
@@ -123,15 +123,10 @@ export class Api {
123
123
  primaryText: 'Đồng ý',
124
124
  onPrimaryPress: () => {
125
125
  try {
126
- if (
127
- this.config.logout &&
128
- typeof this.config.logout === 'function'
129
- ) {
126
+ if (this.config.logout && typeof this.config.logout === 'function') {
130
127
  this.config.logout();
131
128
  } else {
132
- myLog(
133
- '[API] Warning: logout function not configured in SDKConfig'
134
- );
129
+ myLog('[API] Warning: logout function not configured in SDKConfig');
135
130
  }
136
131
  } catch (error) {
137
132
  myLog('[API] Error during logout:', error);
@@ -4204,4 +4199,43 @@ export class Api {
4204
4199
  return { kind: 'bad-data' };
4205
4200
  }
4206
4201
  }
4202
+
4203
+ // Lấy thông tin khách hàng luồng vay mua xe
4204
+ async getInfoCustomerLoanByCar(id) {
4205
+ // make the api call
4206
+ const response: ApiResponse<any> = await this.apisauce.get(
4207
+ `api/v2.0/autodev2/get_info_customer_vaymuaxe?loanBriefId=${id}`
4208
+ );
4209
+ // the typical ways to die when calling an api
4210
+ if (!response.ok) {
4211
+ const problem = getGeneralApiProblem(response);
4212
+ if (problem) return problem;
4213
+ }
4214
+ // transform the data into the format we are expecting
4215
+ try {
4216
+ return { kind: 'ok', data: response.data };
4217
+ } catch {
4218
+ return { kind: 'bad-data' };
4219
+ }
4220
+ }
4221
+
4222
+ // cập nhật thông tin khách hàng luồng vay mua xe
4223
+ async updateInfoCustomerLoanBuyCar(body) {
4224
+ // make the api call
4225
+ const response: ApiResponse<any> = await this.apisauce.post(
4226
+ `api/v2.0/autodev2/update_info_customer_vaymuaxe`,
4227
+ body
4228
+ );
4229
+ // the typical ways to die when calling an api
4230
+ if (!response.ok) {
4231
+ const problem = getGeneralApiProblem(response);
4232
+ if (problem) return problem;
4233
+ }
4234
+ // transform the data into the format we are expecting
4235
+ try {
4236
+ return { kind: 'ok', data: response.data };
4237
+ } catch {
4238
+ return { kind: 'bad-data' };
4239
+ }
4240
+ }
4207
4241
  }