react-native-timacare 0.0.35 → 0.0.37

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 (109) hide show
  1. package/lib/commonjs/components/Loading.js +1 -1
  2. package/lib/commonjs/components/Loading.js.flow +12 -4
  3. package/lib/commonjs/components/Loading.js.map +1 -1
  4. package/lib/commonjs/screens/full-submit/accept_policy.js +1 -1
  5. package/lib/commonjs/screens/full-submit/accept_policy.js.flow +99 -38
  6. package/lib/commonjs/screens/full-submit/accept_policy.js.map +1 -1
  7. package/lib/commonjs/screens/full-submit/selfie.js +1 -1
  8. package/lib/commonjs/screens/full-submit/selfie.js.flow +7 -3
  9. package/lib/commonjs/screens/full-submit/selfie.js.map +1 -1
  10. package/lib/commonjs/screens/full-submit/store.js +1 -1
  11. package/lib/commonjs/screens/full-submit/store.js.flow +28 -2
  12. package/lib/commonjs/screens/full-submit/store.js.map +1 -1
  13. package/lib/commonjs/screens/full-submit/update-document.js +1 -1
  14. package/lib/commonjs/screens/full-submit/update-document.js.flow +20 -11
  15. package/lib/commonjs/screens/full-submit/update-document.js.map +1 -1
  16. package/lib/commonjs/screens/full-submit/update-info.js +1 -1
  17. package/lib/commonjs/screens/full-submit/update-info.js.flow +16 -6
  18. package/lib/commonjs/screens/full-submit/update-info.js.map +1 -1
  19. package/lib/commonjs/screens/home/Store.js +1 -1
  20. package/lib/commonjs/screens/home/Store.js.flow +3 -0
  21. package/lib/commonjs/screens/home/Store.js.map +1 -1
  22. package/lib/commonjs/screens/home/index.js +1 -1
  23. package/lib/commonjs/screens/home/index.js.flow +60 -34
  24. package/lib/commonjs/screens/home/index.js.map +1 -1
  25. package/lib/commonjs/screens/nationalID/Store.js +1 -1
  26. package/lib/commonjs/screens/nationalID/Store.js.flow +2 -0
  27. package/lib/commonjs/screens/nationalID/Store.js.map +1 -1
  28. package/lib/commonjs/screens/nationalID/index.js +1 -1
  29. package/lib/commonjs/screens/nationalID/index.js.flow +16 -7
  30. package/lib/commonjs/screens/nationalID/index.js.map +1 -1
  31. package/lib/commonjs/screens/nationalIDBack/Store.js +1 -1
  32. package/lib/commonjs/screens/nationalIDBack/Store.js.flow +3 -1
  33. package/lib/commonjs/screens/nationalIDBack/Store.js.map +1 -1
  34. package/lib/commonjs/screens/nationalIDBack/index.js +1 -1
  35. package/lib/commonjs/screens/nationalIDBack/index.js.flow +13 -22
  36. package/lib/commonjs/screens/nationalIDBack/index.js.map +1 -1
  37. package/lib/commonjs/screens/quick-submit/index.js +1 -1
  38. package/lib/commonjs/screens/quick-submit/index.js.flow +92 -80
  39. package/lib/commonjs/screens/quick-submit/index.js.map +1 -1
  40. package/lib/commonjs/screens/quick-submit/store.js +1 -1
  41. package/lib/commonjs/screens/quick-submit/store.js.flow +4 -1
  42. package/lib/commonjs/screens/quick-submit/store.js.map +1 -1
  43. package/lib/commonjs/screens/uploadVideo/index.js +1 -1
  44. package/lib/commonjs/screens/uploadVideo/index.js.flow +1 -25
  45. package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
  46. package/lib/module/components/Loading.js +1 -1
  47. package/lib/module/components/Loading.js.map +1 -1
  48. package/lib/module/screens/full-submit/accept_policy.js +1 -1
  49. package/lib/module/screens/full-submit/accept_policy.js.map +1 -1
  50. package/lib/module/screens/full-submit/selfie.js +1 -1
  51. package/lib/module/screens/full-submit/selfie.js.map +1 -1
  52. package/lib/module/screens/full-submit/store.js +1 -1
  53. package/lib/module/screens/full-submit/store.js.map +1 -1
  54. package/lib/module/screens/full-submit/update-document.js +1 -1
  55. package/lib/module/screens/full-submit/update-document.js.map +1 -1
  56. package/lib/module/screens/full-submit/update-info.js +1 -1
  57. package/lib/module/screens/full-submit/update-info.js.map +1 -1
  58. package/lib/module/screens/home/Store.js +1 -1
  59. package/lib/module/screens/home/Store.js.map +1 -1
  60. package/lib/module/screens/home/index.js +1 -1
  61. package/lib/module/screens/home/index.js.map +1 -1
  62. package/lib/module/screens/nationalID/Store.js +1 -1
  63. package/lib/module/screens/nationalID/Store.js.map +1 -1
  64. package/lib/module/screens/nationalID/index.js +1 -1
  65. package/lib/module/screens/nationalID/index.js.map +1 -1
  66. package/lib/module/screens/nationalIDBack/Store.js +1 -1
  67. package/lib/module/screens/nationalIDBack/Store.js.map +1 -1
  68. package/lib/module/screens/nationalIDBack/index.js +1 -1
  69. package/lib/module/screens/nationalIDBack/index.js.map +1 -1
  70. package/lib/module/screens/quick-submit/index.js +1 -1
  71. package/lib/module/screens/quick-submit/index.js.map +1 -1
  72. package/lib/module/screens/quick-submit/store.js +1 -1
  73. package/lib/module/screens/quick-submit/store.js.map +1 -1
  74. package/lib/module/screens/uploadVideo/index.js +1 -1
  75. package/lib/module/screens/uploadVideo/index.js.map +1 -1
  76. package/lib/typescript/components/Loading.d.ts.map +1 -1
  77. package/lib/typescript/screens/full-submit/accept_policy.d.ts.map +1 -1
  78. package/lib/typescript/screens/full-submit/selfie.d.ts.map +1 -1
  79. package/lib/typescript/screens/full-submit/store.d.ts +3 -2
  80. package/lib/typescript/screens/full-submit/store.d.ts.map +1 -1
  81. package/lib/typescript/screens/full-submit/update-document.d.ts.map +1 -1
  82. package/lib/typescript/screens/full-submit/update-info.d.ts.map +1 -1
  83. package/lib/typescript/screens/home/Store.d.ts.map +1 -1
  84. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  85. package/lib/typescript/screens/nationalID/Store.d.ts.map +1 -1
  86. package/lib/typescript/screens/nationalID/index.d.ts.map +1 -1
  87. package/lib/typescript/screens/nationalIDBack/Store.d.ts +1 -1
  88. package/lib/typescript/screens/nationalIDBack/Store.d.ts.map +1 -1
  89. package/lib/typescript/screens/nationalIDBack/index.d.ts.map +1 -1
  90. package/lib/typescript/screens/quick-submit/index.d.ts.map +1 -1
  91. package/lib/typescript/screens/quick-submit/store.d.ts +1 -1
  92. package/lib/typescript/screens/quick-submit/store.d.ts.map +1 -1
  93. package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
  94. package/package.json +1 -1
  95. package/src/components/Loading.tsx +12 -4
  96. package/src/screens/full-submit/accept_policy.tsx +99 -38
  97. package/src/screens/full-submit/selfie.tsx +7 -3
  98. package/src/screens/full-submit/store.tsx +28 -2
  99. package/src/screens/full-submit/update-document.tsx +20 -11
  100. package/src/screens/full-submit/update-info.tsx +16 -6
  101. package/src/screens/home/Store.tsx +3 -0
  102. package/src/screens/home/index.tsx +60 -34
  103. package/src/screens/nationalID/Store.tsx +2 -0
  104. package/src/screens/nationalID/index.tsx +16 -7
  105. package/src/screens/nationalIDBack/Store.tsx +3 -1
  106. package/src/screens/nationalIDBack/index.tsx +13 -22
  107. package/src/screens/quick-submit/index.tsx +92 -80
  108. package/src/screens/quick-submit/store.tsx +4 -1
  109. package/src/screens/uploadVideo/index.tsx +1 -25
@@ -19,7 +19,7 @@ import { color } from '../../theme';
19
19
  import LinearGradient from 'react-native-linear-gradient';
20
20
  import { CommonActions, useNavigation } from '@react-navigation/native';
21
21
  import { ScreenNames } from '../../navigation';
22
- import CIMBLoading from '../../components/CIMBLoading';
22
+ import Loading from '../../components/Loading';
23
23
 
24
24
  interface IProps {
25
25
  loan: any;
@@ -41,6 +41,7 @@ export const UpdateDocument = observer(function UpdateDocument({
41
41
  { uri: 'https://unsplash.it/400/400?image=1' },
42
42
  ]);
43
43
  const [visible, setIsVisible] = useState(false);
44
+ const [isLoading, setIsLoading] = useState(false);
44
45
  const [data, setData] = useState<any[]>();
45
46
 
46
47
  const takePhoto = async (typId) => {
@@ -65,15 +66,23 @@ export const UpdateDocument = observer(function UpdateDocument({
65
66
  });
66
67
  };
67
68
  const handleSubmit = () => {
68
- FullSubmitStore.confirmData(loan?.id, () => {
69
- FullSubmitStore.tab = 1;
70
- navigation.dispatch(
71
- CommonActions.reset({
72
- index: 1,
73
- routes: [{ name: ScreenNames.Main }],
74
- })
75
- );
76
- });
69
+ setIsLoading(true);
70
+ FullSubmitStore.confirmData(
71
+ loan?.id,
72
+ () => {
73
+ setIsLoading(false);
74
+ FullSubmitStore.tab = 1;
75
+ navigation.dispatch(
76
+ CommonActions.reset({
77
+ index: 1,
78
+ routes: [{ name: ScreenNames.Main }],
79
+ })
80
+ );
81
+ },
82
+ () => {
83
+ setIsLoading(false);
84
+ }
85
+ );
77
86
  };
78
87
 
79
88
  return (
@@ -348,7 +357,7 @@ export const UpdateDocument = observer(function UpdateDocument({
348
357
  visible={visible}
349
358
  onRequestClose={() => setIsVisible(false)}
350
359
  />
351
- <CIMBLoading isLoading={FullSubmitStore.loadingButton} />
360
+ <Loading isLoading={isLoading} />
352
361
  </View>
353
362
  );
354
363
  });
@@ -30,7 +30,7 @@ import {
30
30
  import { commonStyles } from '../CommonStyles';
31
31
  import * as yup from 'yup';
32
32
  import FullSubmitStore from './store';
33
- import CIMBLoading from '../../components/CIMBLoading';
33
+ import Loading from '../../components/Loading';
34
34
  import LinearGradient from 'react-native-linear-gradient';
35
35
  import appStore from '../../AppStore';
36
36
 
@@ -46,6 +46,8 @@ export const UpdateInfo = observer(function UpdateInfo({
46
46
  const navigation = useNavigation();
47
47
  const ref = useRef(null);
48
48
  const [data, setData] = useState(null);
49
+ const [isLoading, setIsLoading] = useState(false);
50
+
49
51
  useEffect(() => {
50
52
  if (loan) {
51
53
  FullSubmitStore.getDetailLoan(loan?.id, (res) => {
@@ -125,6 +127,7 @@ export const UpdateInfo = observer(function UpdateInfo({
125
127
  }, [loan]);
126
128
 
127
129
  const onSubmit = (values: any) => {
130
+ setIsLoading(true);
128
131
  const body = {
129
132
  Id: data?.id,
130
133
  LoanAmount: data?.loanAmount,
@@ -152,10 +155,17 @@ export const UpdateInfo = observer(function UpdateInfo({
152
155
  positionCIMBId: values.jobTitle.id,
153
156
  };
154
157
 
155
- FullSubmitStore.fullSubmit(body, () => {
156
- FullSubmitStore.tab = 2;
157
- callback(2);
158
- });
158
+ FullSubmitStore.fullSubmit(
159
+ body,
160
+ () => {
161
+ setIsLoading(false);
162
+ FullSubmitStore.tab = 2;
163
+ callback(2);
164
+ },
165
+ () => {
166
+ setIsLoading(false);
167
+ }
168
+ );
159
169
  };
160
170
 
161
171
  return (
@@ -922,7 +932,7 @@ export const UpdateInfo = observer(function UpdateInfo({
922
932
  </Formik>
923
933
  </ScrollView>
924
934
  )}
925
- <CIMBLoading isLoading={FullSubmitStore.loadingButton} />
935
+ <Loading isLoading={isLoading} />
926
936
  </View>
927
937
  );
928
938
  });
@@ -171,16 +171,19 @@ class Store {
171
171
  Alert.alert('Thông báo', response.data.meta.errorMessage, [
172
172
  { text: 'Đồng ý' },
173
173
  ]);
174
+ if (onFailure) onFailure();
174
175
  } else {
175
176
  Alert.alert('Thông báo', response.data.meta.errorMessage, [
176
177
  { text: 'Đồng ý' },
177
178
  ]);
178
179
  this.listLoanPending = null;
180
+ if (onFailure) onFailure();
179
181
  }
180
182
  } else {
181
183
  this.isLoading = false;
182
184
  Alert.alert('Thông báo', 'Có lỗi xảy ra. Vui lòng thử lại sau!');
183
185
  this.listLoanPending = null;
186
+ if (onFailure) onFailure();
184
187
  }
185
188
  }
186
189
  }
@@ -79,28 +79,42 @@ export const Home = observer(function Home() {
79
79
  const [showModal2, setShowModal2] = useState(false);
80
80
  const [loan, setLoan] = useState(null);
81
81
  const [checkEKYC, setCheckEKYC] = useState(null);
82
+ const [isLoading, setIsLoading] = useState(false);
82
83
 
83
84
  const onRefresh = () => {
85
+ setIsLoading(true);
84
86
  homeStore.getListLoan();
85
- homeStore.getListLoanPending(async (loan) => {
86
- setLoan(loan);
87
- homeStore.getCheckEKYC({ loanBriefId: loan.id }, (data) => {
88
- setCheckEKYC(!data);
89
- });
90
- if (
91
- loan.messageErrorCIMB !== '' &&
92
- loan?.messageErrorCIMB &&
93
- loan?.isCimbApproveFull === null
94
- ) {
95
- setShowModal(true);
96
- }
97
- if (loan?.typeLoan === 4 && loan?.isCimbApproveFull !== null) {
98
- const checkShow = await load(`SHOW_${loan?.id}`);
99
- if (!checkShow || checkShow !== true) {
100
- setShowModal2(true);
87
+ homeStore.getListLoanPending(
88
+ async (loan) => {
89
+ setLoan(loan);
90
+ homeStore.getCheckEKYC(
91
+ { loanBriefId: loan.id },
92
+ (data) => {
93
+ setCheckEKYC(!data);
94
+ setIsLoading(false);
95
+ },
96
+ () => {
97
+ setIsLoading(false);
98
+ }
99
+ );
100
+ if (
101
+ loan.messageErrorCIMB !== '' &&
102
+ loan?.messageErrorCIMB &&
103
+ loan?.isCimbApproveFull === null
104
+ ) {
105
+ setShowModal(true);
106
+ }
107
+ if (loan?.typeLoan === 4 && loan?.isCimbApproveFull !== null) {
108
+ const checkShow = await load(`SHOW_${loan?.id}`);
109
+ if (!checkShow || checkShow !== true) {
110
+ setShowModal2(true);
111
+ }
101
112
  }
113
+ },
114
+ () => {
115
+ setIsLoading(false);
102
116
  }
103
- });
117
+ );
104
118
  };
105
119
 
106
120
  useEffect(() => {
@@ -303,10 +317,7 @@ export const Home = observer(function Home() {
303
317
  </LinearGradient>
304
318
  <ScrollView
305
319
  refreshControl={
306
- <RefreshControl
307
- refreshing={homeStore.isLoading}
308
- onRefresh={onRefresh}
309
- />
320
+ <RefreshControl refreshing={false} onRefresh={onRefresh} />
310
321
  }
311
322
  style={{ flex: 1, marginBottom: 16 }}
312
323
  >
@@ -638,18 +649,30 @@ export const Home = observer(function Home() {
638
649
  paddingHorizontal: 16,
639
650
  }}
640
651
  >
641
- <View style={{ flexDirection: 'row' }}>
642
- <Image
643
- source={require('./error.png')}
644
- style={{ width: 16, height: 16 }}
645
- />
646
- <MText style={{ marginLeft: 5 }}>
647
- Đơn vay của bạn gặp gián đoạn, vui lòng liên
648
- hệ{'\n'}
649
- <MText style={{ fontWeight: 'bold' }}>
650
- tổng đài 1900633688
652
+ <View
653
+ style={{
654
+ flexDirection: 'row',
655
+ justifyContent: 'space-between',
656
+ alignItems: 'center',
657
+ }}
658
+ >
659
+ <View
660
+ style={{
661
+ flex: 1,
662
+ flexDirection: 'row',
663
+ paddingRight: 20,
664
+ }}
665
+ >
666
+ <Image
667
+ source={require('./error.png')}
668
+ style={{ width: 16, height: 16 }}
669
+ />
670
+ <MText style={{ marginLeft: 5 }}>
671
+ Đơn vay của bạn gặp gián đoạn, vui lòng
672
+ liên hệ tổng đài 1900633688
651
673
  </MText>
652
- </MText>
674
+ </View>
675
+
653
676
  <TouchableOpacity
654
677
  onPress={() => {
655
678
  Linking.openURL(`tel:1900633688`);
@@ -658,17 +681,20 @@ export const Home = observer(function Home() {
658
681
  <LinearGradient
659
682
  colors={['#FF8E4F', '#EF592E']}
660
683
  style={{
661
- paddingHorizontal: 20,
684
+ paddingHorizontal: 10,
662
685
  height: 30,
663
686
  borderRadius: 30,
664
687
  justifyContent: 'center',
665
688
  alignItems: 'center',
689
+ flexDirection: 'row',
666
690
  }}
667
691
  >
692
+ <Call />
668
693
  <MText
669
694
  style={{
670
695
  color: 'white',
671
696
  fontSize: 12,
697
+ marginLeft: 5,
672
698
  }}
673
699
  >
674
700
  Liên hệ
@@ -1718,7 +1744,7 @@ export const Home = observer(function Home() {
1718
1744
  </View>
1719
1745
  </SafeAreaView>
1720
1746
  </Modal>
1721
- <Observer>{() => <Loading isLoading={homeStore.isLoading} />}</Observer>
1747
+ <Observer>{() => <Loading isLoading={isLoading} />}</Observer>
1722
1748
  </View>
1723
1749
  );
1724
1750
  });
@@ -121,11 +121,13 @@ class Store {
121
121
  Alert.alert('Thông báo', response.data.meta.errorMessage, [
122
122
  { text: 'Đồng ý' },
123
123
  ]);
124
+ if (onFailure) onFailure();
124
125
  }
125
126
  } else {
126
127
  this.isLoading = false;
127
128
  this.isError = false;
128
129
  Alert.alert('Thông báo', 'Có lỗi xảy ra. Vui lòng thử lại sau!');
130
+ if (onFailure) onFailure();
129
131
  }
130
132
  }
131
133
  }
@@ -55,11 +55,13 @@ const logoView: ImageStyle = {
55
55
 
56
56
  export const NationalID = observer(function NationalID(props: any) {
57
57
  const navigation = useNavigation();
58
+ const [isLoading, setIsLoading] = useState(false);
58
59
  const [photo, setPhoto] = useState(null);
59
60
  const [base64, setBase64] = useState(null);
60
61
  const loan = toJS(props.route.params?.loan);
61
62
 
62
63
  const nextStep = () => {
64
+ setIsLoading(true);
63
65
  const form = new FormData();
64
66
  form.append('image', {
65
67
  uri: photo,
@@ -72,12 +74,19 @@ export const NationalID = observer(function NationalID(props: any) {
72
74
  form.append('UploadFrom', 3);
73
75
  form.append('SubTypeId', 1);
74
76
 
75
- nationalIDStore.uploadImage(form, () => {
76
- nationalIDStore.photo = photo;
77
- navigation.dispatch(
78
- StackActions.push(ScreenNames.NationalIDBack, { loan })
79
- );
80
- });
77
+ nationalIDStore.uploadImage(
78
+ form,
79
+ () => {
80
+ setIsLoading(false);
81
+ nationalIDStore.photo = photo;
82
+ navigation.dispatch(
83
+ StackActions.push(ScreenNames.NationalIDBack, { loan })
84
+ );
85
+ },
86
+ () => {
87
+ setIsLoading(false);
88
+ }
89
+ );
81
90
  };
82
91
 
83
92
  const takePhoto = () => {
@@ -292,7 +301,7 @@ export const NationalID = observer(function NationalID(props: any) {
292
301
  )}
293
302
  <KeyboardSpacer />
294
303
  </SafeAreaView>
295
- <Loading isLoading={appStore.isLoading || nationalIDStore.isLoading} />
304
+ <Loading isLoading={isLoading} />
296
305
  </View>
297
306
  );
298
307
  });
@@ -71,7 +71,7 @@ class Store {
71
71
  }
72
72
 
73
73
  @action
74
- async uploadImage(body, onSuccess?) {
74
+ async uploadImage(body, onSuccess?, onError?) {
75
75
  this.isLoading = true;
76
76
  const response = await Api.getInstance().uploadDocument(body);
77
77
  this.isLoading = false;
@@ -84,6 +84,7 @@ class Store {
84
84
  onSuccess(response.data.data);
85
85
  }
86
86
  } else {
87
+ if (onError) onError();
87
88
  Alert.alert('Thông báo', response.data.meta.errorMessage, [
88
89
  { text: 'Đồng ý' },
89
90
  ]);
@@ -91,6 +92,7 @@ class Store {
91
92
  } else {
92
93
  this.isLoading = false;
93
94
  this.isError = false;
95
+ if (onError) onError();
94
96
  Alert.alert('Thông báo', 'Có lỗi xảy ra. Vui lòng thử lại sau', [
95
97
  { text: 'Đồng ý' },
96
98
  ]);
@@ -42,14 +42,10 @@ export const NationalIDBack = observer(function NationalIDBack(props: any) {
42
42
  const [photo, setPhoto] = useState(null);
43
43
  const loan = props.route.params?.loan;
44
44
  const [base64, setBase64] = useState(null);
45
+ const [isLoading, setIsLoading] = useState(false);
45
46
 
46
47
  const nextStep = (values) => {
47
- // const form = new FormData()
48
- // form.append("image", {
49
- // uri: photo,
50
- // type: "image/jpg",
51
- // name: "image.jpg",
52
- // })
48
+ setIsLoading(true);
53
49
  const form2 = new FormData();
54
50
  form2.append('image', {
55
51
  uri: photo,
@@ -60,21 +56,16 @@ export const NationalIDBack = observer(function NationalIDBack(props: any) {
60
56
  form2.append('TypeDocumentId', 311);
61
57
  form2.append('UploadFrom', 3);
62
58
  form2.append('SubTypeId', 2);
63
-
64
- // appStore.checkQualityImage(
65
- // base64,
66
- // () => {
67
- // nationalIDStore.uploadImage(form2, () => {
68
- // navigation.dispatch(StackActions.push(ScreenNames.Selfie, { loan }))
69
- // })
70
- // },
71
- // () => {
72
- // Alert.alert("Thông báo", "Ảnh chất lượng thấp. Vui lòng chụp lại!")
73
- // },
74
- // )
75
- nationalIDStore.uploadImage(form2, () => {
76
- navigation.dispatch(StackActions.push(ScreenNames.Selfie, { loan }));
77
- });
59
+ nationalIDStore.uploadImage(
60
+ form2,
61
+ () => {
62
+ setIsLoading(false);
63
+ navigation.dispatch(StackActions.push(ScreenNames.Selfie, { loan }));
64
+ },
65
+ () => {
66
+ setIsLoading(false);
67
+ }
68
+ );
78
69
  };
79
70
 
80
71
  const takePhoto = () => {
@@ -291,7 +282,7 @@ export const NationalIDBack = observer(function NationalIDBack(props: any) {
291
282
  )}
292
283
  <KeyboardSpacer />
293
284
  </SafeAreaView>
294
- <Loading isLoading={nationalIDStore.isLoading || appStore.isLoading} />
285
+ <Loading isLoading={isLoading} />
295
286
  </View>
296
287
  );
297
288
  });
@@ -40,93 +40,105 @@ export const QuickSubmit = observer(function QuickSubmit(props: any) {
40
40
  const [loan, setLoan] = useState(null);
41
41
  const [showDatePicker, setShowDatePicker] = useState(false);
42
42
  const [typePicker, setTypePicker] = useState(0);
43
+ const [isLoading, setIsLoading] = useState(false);
43
44
 
44
45
  useEffect(() => {
46
+ setIsLoading(true);
45
47
  QuickSubmitStore.getBrandProduct();
46
48
  QuickSubmitStore.getProvinces();
47
- QuickSubmitStore.getDetailLoan(props?.route?.params?.loan?.id, (data) => {
48
- setLoan(data);
49
- ref.current.setFieldValue(
50
- 'fullName',
51
- data?.fullName ? data?.fullName : ''
52
- );
53
- ref.current.setFieldValue('dob', data?.dob ? data?.dob : '');
54
- ref.current.setFieldValue('phone', data?.phone ? data?.phone : '');
55
- ref.current.setFieldValue(
56
- 'nationalCard',
57
- data?.nationalId ? data?.nationalId : ''
58
- );
59
- ref.current.setFieldValue(
60
- 'nationalCardDate',
61
- data?.dateNationalId ? data?.dateNationalId : ''
62
- );
63
- ref.current.setFieldValue('email', data?.email ? data?.email : '');
64
- ref.current.setFieldValue(
65
- 'loanAmount',
66
- data?.loanAmount ? data?.loanAmount : 0
67
- );
68
- ref.current.setFieldValue(
69
- 'loanTime',
70
- data?.loanTime ? data?.loanTime : ''
71
- );
72
- ref.current.setFieldValue(
73
- 'salary',
74
- data?.totalIncome ? data?.totalIncome : 0
75
- );
76
- ref.current.setFieldValue(
77
- 'province',
78
- data?.provinceId
79
- ? { id: data?.provinceId, name: data?.provinceName }
80
- : null
81
- );
82
- ref.current.setFieldValue(
83
- 'brand',
84
- data?.brandId ? { id: data?.brandId, name: data?.brandName } : null
85
- );
86
- if (data?.brandId) {
87
- QuickSubmitStore.getYearProduct(data?.brandId);
88
- }
89
- ref.current.setFieldValue(
90
- 'year',
91
- data?.yearProductBrand
92
- ? {
93
- id: data?.yearProductBrand,
94
- name: `Năm ${data?.yearProductBrand}`,
95
- }
96
- : null
97
- );
98
- if (data?.yearProductBrand) {
99
- QuickSubmitStore.getModelProduct(data?.brandId, data?.yearProductBrand);
100
- }
101
- ref.current.setFieldValue(
102
- 'model',
103
- data?.productBrandId
104
- ? { id: data?.productBrandId, name: data?.productBrandName }
105
- : null
106
- );
107
- ref.current.setFieldValue(
108
- 'occupation',
109
- data?.jobNameCIMB
110
- ? {
111
- id: data?.jobCIMBId,
112
- name: data?.jobNameCIMB,
113
- }
114
- : null
115
- );
116
- ref.current.setFieldValue('productId', data?.productId),
49
+ QuickSubmitStore.getDetailLoan(
50
+ props?.route?.params?.loan?.id,
51
+ (data) => {
52
+ setLoan(data);
117
53
  ref.current.setFieldValue(
118
- 'vehiclesCar',
119
- data?.vehiclesCar ? data?.vehiclesCar : ''
120
- ),
54
+ 'fullName',
55
+ data?.fullName ? data?.fullName : ''
56
+ );
57
+ ref.current.setFieldValue('dob', data?.dob ? data?.dob : '');
58
+ ref.current.setFieldValue('phone', data?.phone ? data?.phone : '');
121
59
  ref.current.setFieldValue(
122
- 'yearCar',
123
- data?.yearCar ? String(data?.yearCar) : ''
124
- ),
60
+ 'nationalCard',
61
+ data?.nationalId ? data?.nationalId : ''
62
+ );
125
63
  ref.current.setFieldValue(
126
- 'brandCar',
127
- data?.brandCar ? data?.brandCar : ''
64
+ 'nationalCardDate',
65
+ data?.dateNationalId ? data?.dateNationalId : ''
128
66
  );
129
- });
67
+ ref.current.setFieldValue('email', data?.email ? data?.email : '');
68
+ ref.current.setFieldValue(
69
+ 'loanAmount',
70
+ data?.loanAmount ? data?.loanAmount : 0
71
+ );
72
+ ref.current.setFieldValue(
73
+ 'loanTime',
74
+ data?.loanTime ? data?.loanTime : ''
75
+ );
76
+ ref.current.setFieldValue(
77
+ 'salary',
78
+ data?.totalIncome ? data?.totalIncome : 0
79
+ );
80
+ ref.current.setFieldValue(
81
+ 'province',
82
+ data?.provinceId
83
+ ? { id: data?.provinceId, name: data?.provinceName }
84
+ : null
85
+ );
86
+ ref.current.setFieldValue(
87
+ 'brand',
88
+ data?.brandId ? { id: data?.brandId, name: data?.brandName } : null
89
+ );
90
+ if (data?.brandId) {
91
+ QuickSubmitStore.getYearProduct(data?.brandId);
92
+ }
93
+ ref.current.setFieldValue(
94
+ 'year',
95
+ data?.yearProductBrand
96
+ ? {
97
+ id: data?.yearProductBrand,
98
+ name: `Năm ${data?.yearProductBrand}`,
99
+ }
100
+ : null
101
+ );
102
+ if (data?.yearProductBrand) {
103
+ QuickSubmitStore.getModelProduct(
104
+ data?.brandId,
105
+ data?.yearProductBrand
106
+ );
107
+ }
108
+ ref.current.setFieldValue(
109
+ 'model',
110
+ data?.productBrandId
111
+ ? { id: data?.productBrandId, name: data?.productBrandName }
112
+ : null
113
+ );
114
+ ref.current.setFieldValue(
115
+ 'occupation',
116
+ data?.jobNameCIMB
117
+ ? {
118
+ id: data?.jobCIMBId,
119
+ name: data?.jobNameCIMB,
120
+ }
121
+ : null
122
+ );
123
+ ref.current.setFieldValue('productId', data?.productId),
124
+ ref.current.setFieldValue(
125
+ 'vehiclesCar',
126
+ data?.vehiclesCar ? data?.vehiclesCar : ''
127
+ ),
128
+ ref.current.setFieldValue(
129
+ 'yearCar',
130
+ data?.yearCar ? String(data?.yearCar) : ''
131
+ ),
132
+ ref.current.setFieldValue(
133
+ 'brandCar',
134
+ data?.brandCar ? data?.brandCar : ''
135
+ );
136
+ setIsLoading(false);
137
+ },
138
+ () => {
139
+ setIsLoading(false);
140
+ }
141
+ );
130
142
  }, []);
131
143
 
132
144
  const onSubmit = (values: any) => {
@@ -1051,7 +1063,7 @@ export const QuickSubmit = observer(function QuickSubmit(props: any) {
1051
1063
  </Formik>
1052
1064
  </ScrollView>
1053
1065
  </SafeAreaView>
1054
- <CIMBLoading isLoading={QuickSubmitStore.isLoading} />
1066
+ <CIMBLoading isLoading={isLoading} />
1055
1067
  </View>
1056
1068
  );
1057
1069
  });
@@ -137,7 +137,7 @@ class Store {
137
137
  }
138
138
 
139
139
  @action
140
- async getDetailLoan(id, onSuccess?) {
140
+ async getDetailLoan(id, onSuccess?, onError?) {
141
141
  this.isLoading = true;
142
142
  try {
143
143
  const response = await Api.getInstance().getDetailLoan(id);
@@ -148,13 +148,16 @@ class Store {
148
148
  if (onSuccess) onSuccess(response.data.data);
149
149
  } else {
150
150
  Alert.alert('Thông báo', response.data.meta.errorMessage);
151
+ if (onError) onError();
151
152
  }
152
153
  } else {
153
154
  Alert.alert('Thông báo', 'Không thể lấy thông tin đơn vay');
155
+ if (onError) onError();
154
156
  }
155
157
  } catch (error) {
156
158
  this.isLoading = false;
157
159
  console.log(error);
160
+ if (onError) onError();
158
161
  }
159
162
  }
160
163
 
@@ -47,31 +47,7 @@ export const Video = observer(function Video(props: any) {
47
47
  Platform.OS === 'ios'
48
48
  ? [PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.MICROPHONE]
49
49
  : [PERMISSIONS.ANDROID.CAMERA, PERMISSIONS.ANDROID.RECORD_AUDIO]
50
- ).then((statuses) => {
51
- console.log(statuses);
52
-
53
- // if (Platform.OS === 'android') {
54
- // if (
55
- // statuses[PERMISSIONS.ANDROID.CAMERA] !== 'granted' ||
56
- // statuses[PERMISSIONS.ANDROID.RECORD_AUDIO] !== 'granted'
57
- // ) {
58
- // requestMultiple([
59
- // PERMISSIONS.ANDROID.CAMERA,
60
- // PERMISSIONS.ANDROID.RECORD_AUDIO,
61
- // ]).then((statuses) => {});
62
- // }
63
- // } else {
64
- // if (
65
- // statuses[PERMISSIONS.IOS.CAMERA] !== 'granted' ||
66
- // statuses[PERMISSIONS.IOS.MICROPHONE] !== 'granted'
67
- // ) {
68
- // requestMultiple([
69
- // PERMISSIONS.IOS.CAMERA,
70
- // PERMISSIONS.IOS.MICROPHONE,
71
- // ]).then((statuses) => {});
72
- // }
73
- // }
74
- });
50
+ ).then((statuses) => {});
75
51
  };
76
52
 
77
53
  useEffect(() => {