react-native-timacare 3.3.50 → 3.3.52

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 (50) hide show
  1. package/lib/commonjs/assets/v3/13.svg +19 -0
  2. package/lib/commonjs/assets/v3/14.svg +24 -0
  3. package/lib/commonjs/assets/v3/index.js +1 -1
  4. package/lib/commonjs/assets/v3/index.js.flow +4 -0
  5. package/lib/commonjs/assets/v3/index.js.map +1 -1
  6. package/lib/commonjs/components/ItemTimaOneV3.js +1 -1
  7. package/lib/commonjs/components/ItemTimaOneV3.js.flow +574 -946
  8. package/lib/commonjs/components/ItemTimaOneV3.js.map +1 -1
  9. package/lib/commonjs/screens/detail-loan/Payment.js +1 -1
  10. package/lib/commonjs/screens/detail-loan/Payment.js.flow +211 -234
  11. package/lib/commonjs/screens/detail-loan/Payment.js.map +1 -1
  12. package/lib/commonjs/screens/home/DigitalTopupItem.js +1 -1
  13. package/lib/commonjs/screens/home/DigitalTopupItem.js.flow +565 -822
  14. package/lib/commonjs/screens/home/DigitalTopupItem.js.map +1 -1
  15. package/lib/commonjs/screens/home/ItemMotoBikeLoan.js +1 -1
  16. package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.flow +499 -705
  17. package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.map +1 -1
  18. package/lib/commonjs/screens/home/index.js +1 -1
  19. package/lib/commonjs/screens/home/index.js.flow +28 -18
  20. package/lib/commonjs/screens/home/index.js.map +1 -1
  21. package/lib/module/assets/v3/13.svg +19 -0
  22. package/lib/module/assets/v3/14.svg +24 -0
  23. package/lib/module/assets/v3/index.js +1 -1
  24. package/lib/module/assets/v3/index.js.map +1 -1
  25. package/lib/module/components/ItemTimaOneV3.js +1 -1
  26. package/lib/module/components/ItemTimaOneV3.js.map +1 -1
  27. package/lib/module/screens/detail-loan/Payment.js +1 -1
  28. package/lib/module/screens/detail-loan/Payment.js.map +1 -1
  29. package/lib/module/screens/home/DigitalTopupItem.js +1 -1
  30. package/lib/module/screens/home/DigitalTopupItem.js.map +1 -1
  31. package/lib/module/screens/home/ItemMotoBikeLoan.js +1 -1
  32. package/lib/module/screens/home/ItemMotoBikeLoan.js.map +1 -1
  33. package/lib/module/screens/home/index.js +1 -1
  34. package/lib/module/screens/home/index.js.map +1 -1
  35. package/lib/typescript/assets/v3/index.d.ts +3 -1
  36. package/lib/typescript/assets/v3/index.d.ts.map +1 -1
  37. package/lib/typescript/components/ItemTimaOneV3.d.ts.map +1 -1
  38. package/lib/typescript/screens/detail-loan/Payment.d.ts.map +1 -1
  39. package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -1
  40. package/lib/typescript/screens/home/ItemMotoBikeLoan.d.ts.map +1 -1
  41. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/assets/v3/13.svg +19 -0
  44. package/src/assets/v3/14.svg +24 -0
  45. package/src/assets/v3/index.tsx +4 -0
  46. package/src/components/ItemTimaOneV3.tsx +574 -946
  47. package/src/screens/detail-loan/Payment.tsx +211 -234
  48. package/src/screens/home/DigitalTopupItem.tsx +565 -822
  49. package/src/screens/home/ItemMotoBikeLoan.tsx +499 -705
  50. package/src/screens/home/index.tsx +28 -18
@@ -1,8 +1,8 @@
1
- // @ts-nocheck
1
+ //@ts-nocheck
2
2
  import { StackActions, useNavigation } from '@react-navigation/native';
3
3
  import { observer } from 'mobx-react-lite';
4
- import React, { useEffect, useState } from 'react';
5
- import { ScrollView, TouchableOpacity, View } from 'react-native';
4
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
5
+ import { FlatList, StyleSheet, TouchableOpacity, View } from 'react-native';
6
6
  import LinearGradient from 'react-native-linear-gradient';
7
7
  import { CIMBBank } from '../../assets/icons';
8
8
  import Loading from '../../components/Loading';
@@ -16,267 +16,244 @@ interface IProps {
16
16
  data: any;
17
17
  }
18
18
 
19
+ const InfoRow = ({ label, value, subRow = false, valueStyle, style }: any) => (
20
+ <View style={[styles.row, style]}>
21
+ <View style={styles.labelWrapper}>
22
+ <MText style={[commonStyles.textNormal, subRow && styles.subLabel]}>
23
+ {label}
24
+ </MText>
25
+ </View>
26
+ <MText style={[commonStyles.textNormal, valueStyle]}>{value}</MText>
27
+ </View>
28
+ );
29
+
19
30
  export const Payment = observer(function Payment({ data }: IProps) {
20
31
  const navigation = useNavigation();
21
32
  const [isLoading, setIsLoading] = useState(false);
22
33
  const [listPayment, setListPayment] = useState<any[]>();
23
- const [lastDay, setLastDay] = useState<any>();
34
+ const isFetching = useRef(false);
35
+ const paymentCount = DetailLoanStore.listPayment.length;
24
36
 
25
- const getData = () => {
37
+ const getData = useCallback(() => {
38
+ if (isFetching.current) return;
39
+ isFetching.current = true;
26
40
  setIsLoading(true);
27
41
  DetailLoanStore.getListPayment(
28
42
  data?.id,
29
43
  (res) => {
44
+ isFetching.current = false;
30
45
  setIsLoading(false);
31
46
  setListPayment(res);
32
- const newList = res?.filter((item) => item.status === 0);
33
- setLastDay(
34
- Math.min(
35
- ...newList.map((element) => {
36
- return new Date(element.payDate);
37
- })
38
- )
39
- );
40
47
  },
41
48
  () => {
49
+ isFetching.current = false;
42
50
  setIsLoading(false);
43
51
  }
44
52
  );
45
- };
53
+ }, [data?.id]);
46
54
 
47
55
  useEffect(() => {
48
56
  getData();
49
- }, []);
57
+ }, [getData]);
50
58
 
51
59
  useEffect(() => {
52
- return navigation.addListener('focus', () => {
53
- getData();
54
- });
55
- }, [navigation]);
60
+ return navigation.addListener('focus', getData);
61
+ }, [navigation, getData]);
56
62
 
57
- return (
58
- <View style={{ marginVertical: 16, flex: 1 }}>
59
- <ScrollView style={{ flex: 1, paddingHorizontal: 16 }}>
60
- {listPayment?.map((item, index) => (
61
- <View
62
- key={index}
63
- style={{
64
- backgroundColor: '#FFFFFF',
65
- borderWidth: 1,
66
- borderRadius: 8,
67
- borderColor: '#E0E0E0',
68
- marginBottom: 8,
69
- padding: 16,
70
- }}
71
- >
72
- <View
73
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
74
- >
75
- <MText style={commonStyles.textNormal}>Kỳ thanh toán</MText>
76
- <MText style={commonStyles.textNormalBold}>Kỳ {index + 1}</MText>
77
- </View>
78
- <View
79
- style={{
80
- height: 1,
81
- backgroundColor: '#E0E0E0',
82
- marginVertical: 8,
83
- }}
84
- />
85
- <View
86
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
87
- >
88
- <View style={{ flex: 1, paddingRight: 15 }}>
89
- <MText style={commonStyles.textNormal}>Tổng phải trả</MText>
90
- </View>
91
- <MText
92
- style={[commonStyles.textNormalBold, { color: '#F05123' }]}
93
- >
94
- {formatMoney(item?.totalMoney)} VNĐ
95
- </MText>
96
- </View>
97
- <View
98
- style={{
99
- flexDirection: 'row',
100
- justifyContent: 'space-between',
101
- marginTop: 8,
102
- }}
103
- >
104
- <View style={{ flex: 1, paddingRight: 15 }}>
105
- <MText
106
- style={[
107
- commonStyles.textNormal,
108
- { color: '#828282', paddingLeft: 15 },
109
- ]}
110
- >
111
- Nghĩa vụ phải trả Tima
112
- </MText>
113
- </View>
114
- <MText style={[commonStyles.textNormal, { color: '#828282' }]}>
115
- {formatMoney(item?.totalMoneyTima)} VNĐ
116
- </MText>
117
- </View>
118
- <View
119
- style={{
120
- flexDirection: 'row',
121
- justifyContent: 'space-between',
122
- marginTop: 8,
123
- }}
124
- >
125
- <View style={{ flex: 1, paddingRight: 15 }}>
126
- <MText
127
- style={[
128
- commonStyles.textNormal,
129
- { color: '#828282', paddingLeft: 15 },
130
- ]}
63
+ const renderItem = useCallback(
64
+ ({ item, index }) => {
65
+ const isUnpaid = item?.status === 0;
66
+ return (
67
+ <View style={styles.card}>
68
+ <InfoRow
69
+ label="Kỳ thanh toán"
70
+ value={`Kỳ ${index + 1}`}
71
+ valueStyle={commonStyles.textNormalBold}
72
+ />
73
+ <View style={styles.divider} />
74
+ <InfoRow
75
+ label="Tổng phải trả"
76
+ value={`${formatMoney(item?.totalMoney)} VNĐ`}
77
+ valueStyle={[commonStyles.textNormalBold, styles.highlightValue]}
78
+ />
79
+ <InfoRow
80
+ label="Nghĩa vụ phải trả Tima"
81
+ value={`${formatMoney(item?.totalMoneyTima)} VNĐ`}
82
+ subRow
83
+ valueStyle={styles.mutedValue}
84
+ style={styles.rowSpacing}
85
+ />
86
+ <InfoRow
87
+ label="Nghĩa vụ phải trả CIMB"
88
+ value={`${formatMoney(item?.totalMoneyCIMB)} VNĐ`}
89
+ subRow
90
+ valueStyle={styles.mutedValue}
91
+ style={styles.rowSpacing}
92
+ />
93
+ <InfoRow
94
+ label="Ngày phải thanh toán"
95
+ value={formatDDMMYYY(item?.payDate)}
96
+ style={styles.rowSpacing}
97
+ />
98
+ <View style={styles.divider} />
99
+ <InfoRow
100
+ label="Trạng thái"
101
+ value={isUnpaid ? 'Chưa thanh toán' : 'Đã thanh toán'}
102
+ valueStyle={isUnpaid ? styles.statusUnpaid : styles.statusPaid}
103
+ />
104
+ {isUnpaid && (
105
+ <>
106
+ <View style={styles.divider} />
107
+ <View style={styles.buttonRow}>
108
+ <TouchableOpacity
109
+ disabled={item.isDue !== 1}
110
+ onPress={() => {
111
+ navigation.dispatch(
112
+ StackActions.push(ScreenNames.PaymentInfo, {
113
+ loan: data,
114
+ isFull: false,
115
+ })
116
+ );
117
+ }}
131
118
  >
132
- Nghĩa vụ phải trả CIMB
133
- </MText>
119
+ <LinearGradient
120
+ colors={
121
+ item.isDue === 1
122
+ ? ['#FF7A00', '#EF4123']
123
+ : ['#8A8A8A', '#D0CFCF']
124
+ }
125
+ style={styles.payButton}
126
+ >
127
+ <MText style={[commonStyles.textNormal, styles.whiteText]}>
128
+ Thanh toán
129
+ </MText>
130
+ </LinearGradient>
131
+ </TouchableOpacity>
134
132
  </View>
135
- <MText style={[commonStyles.textNormal, { color: '#828282' }]}>
136
- {formatMoney(item?.totalMoneyCIMB)} VNĐ
137
- </MText>
138
- </View>
139
- <View
140
- style={{
141
- flexDirection: 'row',
142
- justifyContent: 'space-between',
143
- marginTop: 8,
144
- }}
145
- >
146
- <View style={{ flex: 1, paddingRight: 15 }}>
147
- <MText style={commonStyles.textNormal}>
148
- Ngày phải thanh toán
149
- </MText>
150
- </View>
151
- <MText style={commonStyles.textNormal}>
152
- {formatDDMMYYY(item?.payDate)}
153
- </MText>
154
- </View>
133
+ </>
134
+ )}
135
+ </View>
136
+ );
137
+ },
138
+ [data, navigation]
139
+ );
155
140
 
156
- <View
157
- style={{
158
- height: 1,
159
- backgroundColor: '#E0E0E0',
160
- marginVertical: 8,
141
+ return (
142
+ <View style={styles.container}>
143
+ <FlatList
144
+ data={listPayment}
145
+ style={styles.list}
146
+ keyExtractor={(item, index) => String(item?.id ?? index)}
147
+ renderItem={renderItem}
148
+ ListFooterComponent={
149
+ <>
150
+ <TouchableOpacity
151
+ style={styles.settlementButton}
152
+ onPress={() => {
153
+ navigation.dispatch(
154
+ StackActions.push(ScreenNames.PaymentAll, {
155
+ loan: data,
156
+ count: paymentCount,
157
+ })
158
+ );
161
159
  }}
162
- />
163
-
164
- <View
165
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
166
160
  >
167
- <View style={{ flex: 1, paddingRight: 15 }}>
168
- <MText style={commonStyles.textNormal}>Trạng thái</MText>
169
- </View>
170
- <MText
171
- style={[
172
- commonStyles.textNormal,
173
- { color: item?.status === 0 ? '#F05123' : '#27AE60' },
174
- ]}
175
- >
176
- {item?.status === 0 ? 'Chưa thanh toán' : 'Đã thanh toán'}
161
+ <MText style={[commonStyles.textNormal, styles.settlementText]}>
162
+ Xem thông tin tất toán
177
163
  </MText>
164
+ </TouchableOpacity>
165
+ <View style={styles.footer}>
166
+ <MText style={styles.footerText}>Cung cấp bởi </MText>
167
+ <CIMBBank />
178
168
  </View>
179
- {item.status === 0 && (
180
- <>
181
- <View
182
- style={{
183
- height: 1,
184
- backgroundColor: '#E0E0E0',
185
- marginVertical: 8,
186
- }}
187
- />
188
- {item?.status === 0 && item.isDue === 1 ? (
189
- <View style={{ flexDirection: 'row-reverse' }}>
190
- <TouchableOpacity
191
- onPress={() => {
192
- navigation.dispatch(
193
- StackActions.push(ScreenNames.PaymentInfo, {
194
- loan: data,
195
- isFull: false,
196
- })
197
- );
198
- }}
199
- >
200
- <LinearGradient
201
- colors={['#FF7A00', '#EF4123']}
202
- style={{
203
- paddingVertical: 8,
204
- borderRadius: 30,
205
- paddingHorizontal: 24,
206
- }}
207
- >
208
- <MText
209
- style={[
210
- commonStyles.textNormal,
211
- { color: '#FFFFFF' },
212
- ]}
213
- >
214
- Thanh toán
215
- </MText>
216
- </LinearGradient>
217
- </TouchableOpacity>
218
- </View>
219
- ) : (
220
- <View style={{ flexDirection: 'row-reverse' }}>
221
- <LinearGradient
222
- colors={['#8A8A8A', '#D0CFCF']}
223
- style={{
224
- paddingVertical: 8,
225
- borderRadius: 30,
226
- paddingHorizontal: 24,
227
- backgroundColor: '#C7C7C7',
228
- }}
229
- >
230
- <MText
231
- style={[commonStyles.textNormal, { color: '#FDFDFD' }]}
232
- >
233
- Thanh toán
234
- </MText>
235
- </LinearGradient>
236
- </View>
237
- )}
238
- </>
239
- )}
240
- </View>
241
- ))}
242
- <TouchableOpacity
243
- style={{
244
- borderRadius: 30,
245
- borderWidth: 1,
246
- borderColor: '#EF592E',
247
- alignItems: 'center',
248
- paddingVertical: 10,
249
- backgroundColor: '#FFEAD8',
250
- marginTop: 10,
251
- }}
252
- onPress={() => {
253
- navigation.dispatch(
254
- StackActions.push(ScreenNames.PaymentAll, {
255
- loan: data,
256
- count: DetailLoanStore.listPayment.length,
257
- })
258
- );
259
- }}
260
- >
261
- <MText style={[commonStyles.textNormal, { color: '#EF592E' }]}>
262
- Xem thông tin tất toán
263
- </MText>
264
- </TouchableOpacity>
265
- <View
266
- style={{
267
- marginTop: 8,
268
- flexDirection: 'row',
269
- justifyContent: 'center',
270
- alignItems: 'center',
271
- }}
272
- >
273
- <MText style={{ fontSize: 12, color: '#333333' }}>
274
- Cung cấp bởi{' '}
275
- </MText>
276
- <CIMBBank />
277
- </View>
278
- </ScrollView>
169
+ </>
170
+ }
171
+ />
279
172
  <Loading isLoading={isLoading} />
280
173
  </View>
281
174
  );
282
175
  });
176
+
177
+ const styles = StyleSheet.create({
178
+ container: {
179
+ marginVertical: 16,
180
+ flex: 1,
181
+ },
182
+ list: {
183
+ flex: 1,
184
+ paddingHorizontal: 16,
185
+ },
186
+ card: {
187
+ backgroundColor: '#FFFFFF',
188
+ borderWidth: 1,
189
+ borderRadius: 8,
190
+ borderColor: '#E0E0E0',
191
+ marginBottom: 8,
192
+ padding: 16,
193
+ },
194
+ row: {
195
+ flexDirection: 'row',
196
+ justifyContent: 'space-between',
197
+ },
198
+ rowSpacing: {
199
+ marginTop: 8,
200
+ },
201
+ labelWrapper: {
202
+ flex: 1,
203
+ paddingRight: 15,
204
+ },
205
+ subLabel: {
206
+ color: '#828282',
207
+ paddingLeft: 15,
208
+ },
209
+ divider: {
210
+ height: 1,
211
+ backgroundColor: '#E0E0E0',
212
+ marginVertical: 8,
213
+ },
214
+ highlightValue: {
215
+ color: '#F05123',
216
+ },
217
+ mutedValue: {
218
+ color: '#828282',
219
+ },
220
+ statusUnpaid: {
221
+ color: '#F05123',
222
+ },
223
+ statusPaid: {
224
+ color: '#27AE60',
225
+ },
226
+ buttonRow: {
227
+ flexDirection: 'row-reverse',
228
+ },
229
+ payButton: {
230
+ paddingVertical: 8,
231
+ borderRadius: 30,
232
+ paddingHorizontal: 24,
233
+ },
234
+ whiteText: {
235
+ color: '#FFFFFF',
236
+ },
237
+ settlementButton: {
238
+ borderRadius: 30,
239
+ borderWidth: 1,
240
+ borderColor: '#EF592E',
241
+ alignItems: 'center',
242
+ paddingVertical: 10,
243
+ backgroundColor: '#FFEAD8',
244
+ marginTop: 10,
245
+ },
246
+ settlementText: {
247
+ color: '#EF592E',
248
+ },
249
+ footer: {
250
+ marginTop: 8,
251
+ flexDirection: 'row',
252
+ justifyContent: 'center',
253
+ alignItems: 'center',
254
+ },
255
+ footerText: {
256
+ fontSize: 12,
257
+ color: '#333333',
258
+ },
259
+ });