@fadyshawky/react-native-magic 2.0.4 → 2.0.5

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 (110) hide show
  1. package/package.json +1 -1
  2. package/template/src/common/ImageResources.g.ts +33 -1
  3. package/template/src/common/components/Background.tsx +3 -1
  4. package/template/src/common/components/Container.tsx +1 -1
  5. package/template/src/common/components/OTPInput.tsx +3 -2
  6. package/template/src/common/components/PrimaryButton.tsx +23 -23
  7. package/template/src/common/components/PrimaryTextInput.tsx +189 -199
  8. package/template/src/common/components/RadioIcon.tsx +4 -4
  9. package/template/src/common/components/SafeText.tsx +41 -0
  10. package/template/src/common/components/SearchBar.tsx +19 -17
  11. package/template/src/common/components/TryAgain.tsx +3 -3
  12. package/template/src/common/localization/localization.ts +10 -0
  13. package/template/src/common/localization/translations/commonLocalization.ts +97 -0
  14. package/template/src/common/localization/translations/homeLocalization.ts +24 -0
  15. package/template/src/common/localization/translations/loginLocalization.ts +28 -2
  16. package/template/src/common/localization/translations/mainNavigationLocalization.ts +30 -0
  17. package/template/src/common/localization/translations/navigationLocalization.ts +48 -0
  18. package/template/src/common/localization/translations/otpLocalization.ts +28 -0
  19. package/template/src/common/localization/translations/passwordLocalization.ts +54 -0
  20. package/template/src/common/localization/translations/posLocalization.ts +196 -0
  21. package/template/src/common/utils/FeesCaalculation.tsx +37 -0
  22. package/template/src/common/utils/index.tsx +11 -0
  23. package/template/src/common/utils/printData.tsx +161 -0
  24. package/template/src/common/validations/errorValidations.ts +3 -2
  25. package/template/src/components/PrinterExample.js +226 -0
  26. package/template/src/core/api/serverHeaders.ts +62 -1
  27. package/template/src/core/store/Categories/categoryActions.ts +33 -0
  28. package/template/src/core/store/Categories/categorySlice.ts +75 -0
  29. package/template/src/core/store/Categories/categoryState.ts +41 -0
  30. package/template/src/core/store/Providers/providersActions.ts +102 -0
  31. package/template/src/core/store/Providers/providersSlice.ts +136 -0
  32. package/template/src/core/store/Providers/providersState.ts +37 -0
  33. package/template/src/core/store/Services/servicesActions.ts +191 -0
  34. package/template/src/core/store/Services/servicesSlice.ts +205 -0
  35. package/template/src/core/store/Services/servicesState.ts +466 -0
  36. package/template/src/core/store/app/appSlice.ts +13 -5
  37. package/template/src/core/store/app/appState.ts +10 -2
  38. package/template/src/core/store/rootReducer.ts +6 -1
  39. package/template/src/core/store/store.tsx +55 -2
  40. package/template/src/core/store/user/userActions.ts +164 -26
  41. package/template/src/core/store/user/userSlice.ts +193 -21
  42. package/template/src/core/store/user/userState.ts +148 -25
  43. package/template/src/core/theme/colors.ts +70 -94
  44. package/template/src/core/theme/commonConsts.ts +1 -1
  45. package/template/src/core/theme/commonSizes.ts +94 -119
  46. package/template/src/core/theme/commonStyles.ts +22 -22
  47. package/template/src/core/theme/fonts.ts +14 -13
  48. package/template/src/core/theme/themes.ts +75 -386
  49. package/template/src/core/theme/types.ts +15 -201
  50. package/template/src/core/utils/stringUtils.ts +114 -0
  51. package/template/src/modules/SunmiCard.js +212 -0
  52. package/template/src/modules/SunmiPrepaid.ts +122 -0
  53. package/template/src/navigation/AuthStack.tsx +8 -0
  54. package/template/src/navigation/HeaderComponents.tsx +76 -1
  55. package/template/src/navigation/MainNavigation.tsx +3 -1
  56. package/template/src/navigation/MainStack.tsx +130 -56
  57. package/template/src/navigation/TabBar.tsx +111 -59
  58. package/template/src/navigation/types.ts +24 -0
  59. package/template/src/screens/Categories/Categories.tsx +141 -0
  60. package/template/src/screens/Categories/hooks/useCategoriesData.ts +33 -0
  61. package/template/src/screens/Categories/types.ts +7 -0
  62. package/template/src/screens/Favorites/Favorites.tsx +130 -0
  63. package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +155 -0
  64. package/template/src/screens/History/History.tsx +430 -0
  65. package/template/src/screens/History/hooks/useHistoryData.ts +49 -0
  66. package/template/src/screens/History/types.ts +7 -0
  67. package/template/src/screens/InquiredBill/InquiredBill.tsx +443 -0
  68. package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +91 -0
  69. package/template/src/screens/Login/Login.tsx +85 -85
  70. package/template/src/screens/OTP/OTPScreen.tsx +170 -0
  71. package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +326 -0
  72. package/template/src/screens/Providers/Providers.tsx +166 -0
  73. package/template/src/screens/Providers/hooks/useProvidersData.ts +33 -0
  74. package/template/src/screens/Providers/types.ts +7 -0
  75. package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +181 -0
  76. package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +46 -0
  77. package/template/src/screens/ReceiptScreen/utils/utils.tsx +156 -0
  78. package/template/src/screens/Services/Services.tsx +144 -0
  79. package/template/src/screens/Services/hooks/useServicesData.ts +41 -0
  80. package/template/src/screens/SingleService/Components/FawryInputs.tsx +446 -0
  81. package/template/src/screens/SingleService/SingleService.tsx +229 -0
  82. package/template/src/screens/SingleService/hooks/useServiceData.ts +164 -0
  83. package/template/src/screens/home/Components/PayByCode.tsx +129 -0
  84. package/template/src/screens/home/HomeScreen.tsx +268 -77
  85. package/template/src/screens/home/hooks/useHomeData.ts +32 -38
  86. package/template/src/screens/index.tsx +24 -0
  87. package/template/src/screens/profile/Profile.tsx +290 -2
  88. package/template/src/services/SunmiPrinterInternal.js +268 -0
  89. package/template/src/types/sunmiPrepaid.d.ts +20 -0
  90. package/template/src/utils/SunmiPrinter.ts +442 -0
  91. package/template/src/utils/feesCalculator.ts +92 -0
  92. package/template/src/common/components/Stepper.tsx +0 -153
  93. package/template/src/common/components/Svg.tsx +0 -25
  94. package/template/src/common/hooks/useDebounce.ts +0 -17
  95. package/template/src/common/hooks/usePrevious.ts +0 -11
  96. package/template/src/common/localization/intlFormatter.ts +0 -37
  97. package/template/src/common/urls/emailUrl.ts +0 -20
  98. package/template/src/common/urls/mapUrl.ts +0 -22
  99. package/template/src/common/utils/listHandlers.ts +0 -30
  100. package/template/src/common/utils/serializeQueryParams.ts +0 -10
  101. package/template/src/common/validations/hooks/useDatesError.ts +0 -40
  102. package/template/src/common/validations/profileValidations.ts +0 -30
  103. package/template/src/core/theme/shadows.ts +0 -135
  104. package/template/src/navigation/TopTabBar.tsx +0 -77
  105. package/template/src/screens/Settings/Settings.tsx +0 -5
  106. package/template/src/screens/home/components/CarouselSection.tsx +0 -79
  107. package/template/src/screens/home/components/FeaturedCarousel.tsx +0 -128
  108. package/template/src/screens/main/Main.tsx +0 -5
  109. package/template/src/screens/registration/RegistrationScreen.tsx +0 -198
  110. package/template/src/screens/resetPassword/ForgotPasswordScreen.tsx +0 -129
@@ -0,0 +1,443 @@
1
+ import {useNavigation} from '@react-navigation/native';
2
+ import {NativeStackNavigationProp} from '@react-navigation/native-stack';
3
+ import React, {Dispatch, SetStateAction, useEffect, useRef} from 'react';
4
+ import {
5
+ Image,
6
+ ImageResizeMode,
7
+ ImageStyle,
8
+ ImageURISource,
9
+ View,
10
+ ViewStyle,
11
+ } from 'react-native';
12
+ import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
13
+ import {Container} from '../../common/components/Container';
14
+ import {PrimaryButton} from '../../common/components/PrimaryButton';
15
+ import {PrimaryTextInput} from '../../common/components/PrimaryTextInput';
16
+ import {RTLAwareText} from '../../common/components/RTLAwareText';
17
+ import {
18
+ RTLAwareTouchableOpacity,
19
+ RTLAwareView,
20
+ } from '../../common/components/RTLAwareView';
21
+ import {ImageResources} from '../../common/ImageResources.g';
22
+ import {useTranslation} from '../../common/localization/LocalizationProvider';
23
+ import {useAppSelector} from '../../core/store/reduxHelpers';
24
+ import {RootState} from '../../core/store/rootReducer';
25
+ import {CommonSizes} from '../../core/theme/commonSizes';
26
+ import {createThemedStyles} from '../../core/theme/commonStyles';
27
+ import {scaleHeight, scaleWidth} from '../../core/theme/scaling';
28
+ import {useTheme} from '../../core/theme/ThemeProvider';
29
+ import {Theme} from '../../core/theme/types';
30
+ import {HeaderBack} from '../../navigation/HeaderComponents';
31
+ import {RootStackParamList} from '../../navigation/types';
32
+ import {useInquiredData} from './hooks/useInquiredData';
33
+ import {SkypeIndicator} from 'react-native-indicators';
34
+ import {ButtonType} from '../../../types';
35
+
36
+ // Reusable components
37
+ const BillHeader = ({
38
+ serviceName,
39
+ billLabel,
40
+ }: {
41
+ serviceName: string;
42
+ billLabel?: string;
43
+ }) => {
44
+ const {theme} = useTheme();
45
+ return (
46
+ <>
47
+ <RTLAwareText style={styles.headerText(theme)}>
48
+ {serviceName}
49
+ </RTLAwareText>
50
+ {billLabel && (
51
+ <RTLAwareText style={styles.headerText(theme)}>
52
+ {billLabel}
53
+ </RTLAwareText>
54
+ )}
55
+ </>
56
+ );
57
+ };
58
+
59
+ const ProviderImage = ({imageUrl}: {imageUrl: string}) => {
60
+ return <Image source={{uri: imageUrl}} style={styles.sectionImage} />;
61
+ };
62
+
63
+ const BillAmount = ({title, amount}: {title: string; amount: string}) => {
64
+ const {theme} = useTheme();
65
+ return (
66
+ <>
67
+ <RTLAwareText style={styles.subheaderText(theme)}>{title}</RTLAwareText>
68
+ <RTLAwareText style={styles.subheaderText(theme)}>{amount}</RTLAwareText>
69
+ </>
70
+ );
71
+ };
72
+
73
+ const AmountInput = ({
74
+ paymentType,
75
+ currencyCode,
76
+ amount1,
77
+ amount2,
78
+ value,
79
+ setAmount,
80
+ }: {
81
+ paymentType: string;
82
+ currencyCode: string;
83
+ amount1: string;
84
+ amount2: string;
85
+ value: string;
86
+
87
+ setAmount: Dispatch<SetStateAction<string>>;
88
+ }) => {
89
+ const {theme} = useTheme();
90
+ const {service} = useAppSelector((state: RootState) => state.services);
91
+ const t = useTranslation();
92
+
93
+ return (
94
+ <RTLAwareView style={styles.amountInputContainer}>
95
+ <PrimaryTextInput
96
+ editable={
97
+ service?.PaymentRules?.IsFracAcpt && paymentType === 'partial'
98
+ }
99
+ onChangeText={text =>
100
+ setAmount(
101
+ service?.PaymentRules?.IsFracAcpt ? text : Number(text).toString(),
102
+ )
103
+ }
104
+ width={'30%'}
105
+ placeholder={t('amount', 'common')}
106
+ keyboardType={'numeric'}
107
+ value={value}
108
+ />
109
+ <Image source={ImageResources.arrows} style={styles.arrowsImage} />
110
+ <RTLAwareText style={styles.bodyText(theme)}>
111
+ {`${currencyCode || ''} ${
112
+ (Number(amount1) || 0) + (Number(amount2) || 0)
113
+ }`}
114
+ </RTLAwareText>
115
+ </RTLAwareView>
116
+ );
117
+ };
118
+
119
+ const RadioButtonItem = ({
120
+ image,
121
+ text,
122
+ isSelected,
123
+ onPress,
124
+ }: {
125
+ image: ImageURISource;
126
+ text: string;
127
+ isSelected: boolean;
128
+ onPress: () => void;
129
+ }) => {
130
+ const {theme} = useTheme();
131
+ return (
132
+ <RTLAwareTouchableOpacity
133
+ style={styles.radioButtonItem}
134
+ onPressIn={onPress}>
135
+ <Image source={image} />
136
+ <RTLAwareView style={styles.radioButtonItemText}>
137
+ <View
138
+ style={{
139
+ width: scaleWidth(35),
140
+ height: scaleHeight(35),
141
+ borderRadius: CommonSizes.borderRadius.extraLarge,
142
+ backgroundColor: theme.colors.surface,
143
+ ...createThemedStyles(theme).dropShadow,
144
+ alignItems: 'center',
145
+ justifyContent: 'center',
146
+ }}>
147
+ {isSelected && (
148
+ <View
149
+ style={{
150
+ width: scaleWidth(23),
151
+ height: scaleHeight(23),
152
+ backgroundColor: theme.colors.indigoBlue,
153
+ borderRadius: CommonSizes.borderRadius.extraLarge,
154
+ }}
155
+ />
156
+ )}
157
+ </View>
158
+
159
+ <RTLAwareText style={theme.text.body1}>{text}</RTLAwareText>
160
+ </RTLAwareView>
161
+ </RTLAwareTouchableOpacity>
162
+ );
163
+ };
164
+ const RadioButton = ({
165
+ selectedPaymentType,
166
+ setSelectedPaymentType,
167
+ setAmount,
168
+ amount,
169
+ amount1,
170
+ }: {
171
+ selectedPaymentType: string;
172
+ setSelectedPaymentType: (paymentType: string) => void;
173
+ setAmount: Dispatch<SetStateAction<string>>;
174
+ amount: string;
175
+ amount1: string;
176
+ }) => {
177
+ const t = useTranslation();
178
+ return (
179
+ <RTLAwareView style={styles.radioButtonContainer}>
180
+ <RadioButtonItem
181
+ image={ImageResources.full_ammount}
182
+ text={t('fullAmount', 'common')}
183
+ isSelected={selectedPaymentType === 'full'}
184
+ onPress={() => {
185
+ setSelectedPaymentType('full');
186
+ setAmount(amount1);
187
+ }}
188
+ />
189
+ <RadioButtonItem
190
+ image={ImageResources.partial_ammount}
191
+ text={t('partialAmount', 'common')}
192
+ isSelected={selectedPaymentType === 'partial'}
193
+ onPress={() => {
194
+ setAmount('');
195
+ setSelectedPaymentType('partial');
196
+ }}
197
+ />
198
+ </RTLAwareView>
199
+ );
200
+ };
201
+
202
+ export function InquiredBill(): JSX.Element {
203
+ const {theme} = useTheme();
204
+ const navigation =
205
+ useNavigation<NativeStackNavigationProp<RootStackParamList>>();
206
+ const scroll = useRef<KeyboardAwareScrollView>(null);
207
+ const {
208
+ amount,
209
+ amount1,
210
+ billInfo,
211
+ currencyCode,
212
+ fees,
213
+ service,
214
+ setShowPaymentType,
215
+ setSelectedPaymentType,
216
+ setAmount,
217
+ showPaymentType,
218
+ selectedProvider,
219
+ selectedPaymentType,
220
+ totalAmount,
221
+ inquiredBill,
222
+ isLoading,
223
+ handleSubmit,
224
+ } = useInquiredData();
225
+
226
+ useEffect(() => {
227
+ setAmount(totalAmount.replace('EGP ', ''));
228
+ return () => {
229
+ setSelectedPaymentType('full');
230
+ setAmount('');
231
+ setShowPaymentType(false);
232
+ };
233
+ }, [totalAmount]);
234
+
235
+ const t = useTranslation();
236
+
237
+ const hasDetails =
238
+ billInfo?.RulesAwareness ||
239
+ billInfo?.DueDt ||
240
+ billInfo?.IssueDt ||
241
+ billInfo?.ExtraBillInfo ||
242
+ inquiredBill?.BillTypeDescription ||
243
+ inquiredBill?.BillTypeExtraRefKeys?.BillTypeRefKey.length > 0;
244
+
245
+ return (
246
+ <Container
247
+ ref={scroll}
248
+ testID={'InquiredBillScreenID'}
249
+ contentContainerStyle={styles.contentContainer}
250
+ style={styles.container}
251
+ backgroundImage={ImageResources.background_2}
252
+ withoutPadding
253
+ extendedBackground
254
+ bounces={true}
255
+ backgroundColor={theme.colors.background}>
256
+ {isLoading ? (
257
+ <SkypeIndicator size={80} color={theme.colors.mutedLavender} />
258
+ ) : (
259
+ <>
260
+ <HeaderBack onPress={navigation.goBack} />
261
+ <BillHeader
262
+ serviceName={service.Name || ''}
263
+ billLabel={billInfo?.BillLabel}
264
+ />
265
+ <ProviderImage imageUrl={selectedProvider.img_url || ''} />
266
+ <BillAmount title={t('billAmount', 'common')} amount={totalAmount} />
267
+
268
+ {(service?.PaymentRules?.IsPrtAcpt ||
269
+ service?.PaymentRules?.IsOvrAcpt ||
270
+ service?.PaymentRules?.IsAdvAcpt) && (
271
+ <RTLAwareTouchableOpacity
272
+ style={{
273
+ backgroundColor: theme.colors.surface,
274
+ borderWidth: 1,
275
+ borderColor: theme.colors.indigoBlue,
276
+ justifyContent: 'flex-end',
277
+ alignItems: 'center',
278
+ flexDirection: 'row',
279
+ paddingHorizontal: CommonSizes.spacing.large,
280
+ paddingVertical: CommonSizes.spacing.large,
281
+ borderRadius: CommonSizes.borderRadius.large,
282
+ }}
283
+ onPressIn={() => {
284
+ setShowPaymentType(!showPaymentType);
285
+ }}>
286
+ <RTLAwareText style={{color: theme.colors.mutedLavender}}>
287
+ {t('otherAmount', 'common')}
288
+ </RTLAwareText>
289
+ <Image source={0} />
290
+ </RTLAwareTouchableOpacity>
291
+ )}
292
+ {(service?.PaymentRules?.IsPrtAcpt ||
293
+ service?.PaymentRules?.IsOvrAcpt ||
294
+ service?.PaymentRules?.IsAdvAcpt) &&
295
+ showPaymentType && (
296
+ <RadioButton
297
+ selectedPaymentType={selectedPaymentType}
298
+ setSelectedPaymentType={setSelectedPaymentType}
299
+ setAmount={setAmount}
300
+ amount={amount}
301
+ amount1={amount1?.toString()}
302
+ />
303
+ )}
304
+ <AmountInput
305
+ paymentType={selectedPaymentType}
306
+ currencyCode={currencyCode}
307
+ amount1={amount}
308
+ amount2={fees?.toString()}
309
+ value={amount?.toString()}
310
+ setAmount={setAmount}
311
+ />
312
+ {hasDetails && (
313
+ <RTLAwareView
314
+ style={{
315
+ backgroundColor: theme.colors.surface,
316
+ padding: CommonSizes.spacing.large,
317
+ borderRadius: CommonSizes.borderRadius.large,
318
+ borderWidth: 1,
319
+ borderColor: theme.colors.indigoBlue,
320
+ }}>
321
+ {billInfo?.RulesAwareness && (
322
+ <RTLAwareText style={{...theme.text.body1}}>
323
+ {billInfo?.RulesAwareness}
324
+ </RTLAwareText>
325
+ )}
326
+ {billInfo?.DueDt && (
327
+ <RTLAwareText style={{...theme.text.body1}}>
328
+ {`${t('dueDate', 'common')}: ${billInfo?.DueDt}`}
329
+ </RTLAwareText>
330
+ )}
331
+ {billInfo?.IssueDt && (
332
+ <RTLAwareText style={{...theme.text.body1}}>
333
+ {`${t('issueDate', 'common')}: ${billInfo?.IssueDt}`}
334
+ </RTLAwareText>
335
+ )}
336
+ {billInfo?.ExtraBillInfo && (
337
+ <RTLAwareText style={{...theme.text.body1}}>
338
+ {billInfo?.ExtraBillInfo}
339
+ </RTLAwareText>
340
+ )}
341
+ {inquiredBill?.BillTypeDescription && (
342
+ <RTLAwareText style={{...theme.text.body1}}>
343
+ {inquiredBill?.BillTypeDescription}
344
+ </RTLAwareText>
345
+ )}
346
+ {inquiredBill?.BillTypeExtraRefKeys?.BillTypeRefKey.length > 0 &&
347
+ inquiredBill?.BillTypeExtraRefKeys?.BillTypeRefKey.map(
348
+ (item: any) => (
349
+ <RTLAwareText style={{...theme.text.body1}}>
350
+ {`${item.key}: ${item.value}`}
351
+ </RTLAwareText>
352
+ ),
353
+ )}
354
+ </RTLAwareView>
355
+ )}
356
+ <PrimaryButton
357
+ isLoading={isLoading}
358
+ disabled={isLoading || !amount}
359
+ label={t('submit', 'common')}
360
+ onPressIn={() => {
361
+ handleSubmit();
362
+ }}
363
+ style={styles.submitButton}
364
+ type={ButtonType.solid}
365
+ />
366
+ <PrimaryButton
367
+ label={t('backToHome', 'common')}
368
+ onPress={() => {
369
+ navigation.reset({
370
+ index: 0,
371
+ routes: [{name: 'Main'}],
372
+ });
373
+ }}
374
+ style={{alignSelf: 'flex-end'}}
375
+ type={ButtonType.outlineNegative}
376
+ />
377
+ </>
378
+ )}
379
+ </Container>
380
+ );
381
+ }
382
+
383
+ const styles = {
384
+ container: {
385
+ flexGrow: 1,
386
+ paddingBottom: scaleHeight(130),
387
+ borderTopRightRadius: CommonSizes.spacing.large,
388
+ borderTopLeftRadius: CommonSizes.spacing.large,
389
+ paddingHorizontal: CommonSizes.spacing.large,
390
+ gap: CommonSizes.spacing.xl,
391
+ justifyContent: 'flex-start' as const,
392
+ } as ViewStyle,
393
+ contentContainer: {
394
+ flexGrow: 1,
395
+ } as ViewStyle,
396
+ headerText: (theme: Theme) => ({
397
+ ...theme.text.header1,
398
+ alignSelf: 'center' as const,
399
+ }),
400
+ subheaderText: (theme: Theme) => ({
401
+ ...theme.text.header2,
402
+ alignSelf: 'center' as const,
403
+ }),
404
+ bodyText: (theme: Theme) => ({
405
+ ...theme.text.body1,
406
+ alignSelf: 'center' as const,
407
+ }),
408
+ sectionImage: {
409
+ width: '100%',
410
+ height: scaleHeight(150),
411
+ resizeMode: 'contain' as ImageResizeMode,
412
+ } as ImageStyle,
413
+ amountInputContainer: {
414
+ flexDirection: 'row' as const,
415
+ alignItems: 'center' as const,
416
+ justifyContent: 'space-evenly' as const,
417
+ width: '100%',
418
+ } as ViewStyle,
419
+ arrowsImage: {
420
+ width: 24,
421
+ height: 24,
422
+ resizeMode: 'contain' as ImageResizeMode,
423
+ } as ImageStyle,
424
+ submitButton: {
425
+ alignSelf: 'flex-end' as const,
426
+ } as ViewStyle,
427
+ radioButtonContainer: {
428
+ flexDirection: 'row' as const,
429
+ alignItems: 'flex-start' as const,
430
+ justifyContent: 'space-evenly' as const,
431
+ width: '100%',
432
+ } as ViewStyle,
433
+ radioButtonItem: {
434
+ alignItems: 'center' as const,
435
+ justifyContent: 'space-evenly' as const,
436
+ } as ViewStyle,
437
+ radioButtonItemText: {
438
+ flexDirection: 'row' as const,
439
+ alignItems: 'center' as const,
440
+ justifyContent: 'space-evenly' as const,
441
+ gap: CommonSizes.spacing.large,
442
+ } as ViewStyle,
443
+ };
@@ -0,0 +1,91 @@
1
+ import {useNavigation} from '@react-navigation/native';
2
+ import {NativeStackNavigationProp} from '@react-navigation/native-stack';
3
+ import {omit} from 'lodash';
4
+ import {useState} from 'react';
5
+ import {initFees} from '../../../common/utils/FeesCaalculation';
6
+ import {useAppDispatch, useAppSelector} from '../../../core/store/reduxHelpers';
7
+ import {RootState} from '../../../core/store/rootReducer';
8
+ import {payService} from '../../../core/store/Services/servicesActions';
9
+ import {RootStackParamList} from '../../../navigation/types';
10
+
11
+ // Define the PaymentConfirmationProps interface
12
+ interface PaymentConfirmationProps {
13
+ amountToBePaid: string;
14
+ billInfo: any;
15
+ fees: number;
16
+ currencyCode: string;
17
+ billRec: {
18
+ BillingAcct: string;
19
+ BillerId: string;
20
+ BillTypeCode: number;
21
+ BillRefNumber: string;
22
+ BillStatus: string;
23
+ };
24
+ }
25
+
26
+ export function useInquiredData() {
27
+ const [isLoading, setIsLoading] = useState(false);
28
+ const dispatch = useAppDispatch();
29
+
30
+ const [selectedPaymentType, setSelectedPaymentType] =
31
+ useState<string>('full');
32
+ const [showPaymentType, setShowPaymentType] = useState<boolean>(false);
33
+ const {service} = useAppSelector((state: RootState) => state.services);
34
+ const {inquiredBill} = useAppSelector((state: RootState) => state.services);
35
+ const billInfo = inquiredBill?.BillRec?.[0]?.BillInfo;
36
+ let billRec: any = inquiredBill?.BillRec?.[0];
37
+ billRec = omit(billRec, ['BillInfo']);
38
+ const amount1 = billInfo?.BillSummAmt?.[0]?.CurAmt?.Amt || 0;
39
+ const {selectedProvider} = useAppSelector(
40
+ (state: RootState) => state.providers,
41
+ );
42
+ const [amount, setAmount] = useState<string>(amount1?.toString());
43
+ const currencyCode = billInfo?.BillSummAmt?.[0]?.CurAmt?.CurCode || '';
44
+ const fees = initFees(service, amount);
45
+ const totalAmount = `${currencyCode} ${amount1}`;
46
+ const navigation =
47
+ useNavigation<NativeStackNavigationProp<RootStackParamList>>();
48
+
49
+ const fetchData = async () => {
50
+ setAmount(amount1?.toString());
51
+ setIsLoading(true);
52
+ try {
53
+ } catch (error) {
54
+ console.error('Error fetching history data:', error);
55
+ } finally {
56
+ setIsLoading(false);
57
+ }
58
+ };
59
+
60
+ const refreshData = () => {
61
+ fetchData();
62
+ };
63
+ const handleSubmit = async () => {
64
+ setIsLoading(false);
65
+ navigation.navigate('PaymentConfirmation', {
66
+ paymentData: {amountToBePaid: amount, fees},
67
+ });
68
+ };
69
+
70
+ return {
71
+ isLoading,
72
+ refreshData,
73
+ fetchData,
74
+ showPaymentType,
75
+ setShowPaymentType,
76
+ selectedPaymentType,
77
+ setSelectedPaymentType,
78
+ billInfo,
79
+ billRec,
80
+ service,
81
+ selectedProvider,
82
+ amount,
83
+ setAmount,
84
+ fees,
85
+ totalAmount,
86
+ amount1,
87
+ currencyCode,
88
+ inquiredBill,
89
+ handleSubmit,
90
+ };
91
+ }