@fadyshawky/react-native-magic 2.0.4 → 2.0.6

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 (80) hide show
  1. package/package.json +1 -1
  2. package/template/App.tsx +28 -19
  3. package/template/ios/reactnativemagic/AppDelegate.mm +5 -0
  4. package/template/src/common/components/Background.tsx +6 -4
  5. package/template/src/common/components/Container.tsx +6 -9
  6. package/template/src/common/components/OTPInput.tsx +3 -2
  7. package/template/src/common/components/PrimaryButton.tsx +23 -23
  8. package/template/src/common/components/PrimaryTextInput.tsx +189 -199
  9. package/template/src/common/components/RadioIcon.tsx +4 -4
  10. package/template/src/common/components/SafeText.tsx +41 -0
  11. package/template/src/common/components/SearchBar.tsx +19 -17
  12. package/template/src/common/components/TryAgain.tsx +3 -3
  13. package/template/src/common/localization/LocalizationProvider.tsx +14 -17
  14. package/template/src/common/localization/RTLInitializer.tsx +90 -0
  15. package/template/src/common/localization/localization.ts +8 -0
  16. package/template/src/common/localization/translations/commonLocalization.ts +33 -6
  17. package/template/src/common/localization/translations/emptyLocalization.ts +6 -2
  18. package/template/src/common/localization/translations/errorsLocalization.ts +33 -13
  19. package/template/src/common/localization/translations/homeLocalization.ts +6 -2
  20. package/template/src/common/localization/translations/loginLocalization.ts +32 -9
  21. package/template/src/common/localization/translations/mainNavigationLocalization.ts +30 -0
  22. package/template/src/common/localization/translations/navigationLocalization.ts +48 -0
  23. package/template/src/common/localization/translations/onboardingLocalization.ts +40 -9
  24. package/template/src/common/localization/translations/otpLocalization.ts +28 -0
  25. package/template/src/common/localization/translations/pagesLocalization.ts +13 -1
  26. package/template/src/common/localization/translations/passwordLocalization.ts +54 -0
  27. package/template/src/common/localization/translations/profileLocalization.ts +4 -4
  28. package/template/src/common/utils/FeesCaalculation.tsx +37 -0
  29. package/template/src/common/utils/index.tsx +11 -0
  30. package/template/src/common/utils/printData.tsx +161 -0
  31. package/template/src/common/validations/errorValidations.ts +3 -2
  32. package/template/src/core/api/serverHeaders.ts +62 -1
  33. package/template/src/core/store/Categories/categoryActions.ts +33 -0
  34. package/template/src/core/store/Categories/categorySlice.ts +75 -0
  35. package/template/src/core/store/Categories/categoryState.ts +41 -0
  36. package/template/src/core/store/Providers/providersActions.ts +102 -0
  37. package/template/src/core/store/Providers/providersSlice.ts +136 -0
  38. package/template/src/core/store/Providers/providersState.ts +37 -0
  39. package/template/src/core/store/Services/servicesActions.ts +191 -0
  40. package/template/src/core/store/Services/servicesSlice.ts +205 -0
  41. package/template/src/core/store/Services/servicesState.ts +466 -0
  42. package/template/src/core/store/app/appSlice.ts +13 -5
  43. package/template/src/core/store/app/appState.ts +10 -2
  44. package/template/src/core/store/rootReducer.ts +6 -1
  45. package/template/src/core/store/store.tsx +55 -2
  46. package/template/src/core/store/user/userActions.ts +164 -26
  47. package/template/src/core/store/user/userSlice.ts +193 -21
  48. package/template/src/core/store/user/userState.ts +148 -25
  49. package/template/src/core/theme/colors.ts +12 -0
  50. package/template/src/core/theme/themes.ts +1 -1
  51. package/template/src/core/utils/stringUtils.ts +114 -0
  52. package/template/src/navigation/AuthStack.tsx +8 -0
  53. package/template/src/navigation/HeaderComponents.tsx +52 -1
  54. package/template/src/navigation/MainNavigation.tsx +3 -1
  55. package/template/src/navigation/MainStack.tsx +39 -56
  56. package/template/src/navigation/TabBar.tsx +111 -59
  57. package/template/src/navigation/types.ts +24 -0
  58. package/template/src/screens/Login/Login.tsx +83 -85
  59. package/template/src/screens/OTP/OTPScreen.tsx +169 -0
  60. package/template/src/screens/home/Components/PayByCode.tsx +129 -0
  61. package/template/src/screens/home/HomeScreen.tsx +1 -103
  62. package/template/src/screens/home/hooks/useHomeData.ts +32 -38
  63. package/template/src/screens/index.tsx +24 -0
  64. package/template/src/common/components/Stepper.tsx +0 -153
  65. package/template/src/common/components/Svg.tsx +0 -25
  66. package/template/src/common/hooks/useDebounce.ts +0 -17
  67. package/template/src/common/hooks/usePrevious.ts +0 -11
  68. package/template/src/common/urls/emailUrl.ts +0 -20
  69. package/template/src/common/urls/mapUrl.ts +0 -22
  70. package/template/src/common/utils/listHandlers.ts +0 -30
  71. package/template/src/common/utils/serializeQueryParams.ts +0 -10
  72. package/template/src/common/validations/hooks/useDatesError.ts +0 -40
  73. package/template/src/common/validations/profileValidations.ts +0 -30
  74. package/template/src/navigation/TopTabBar.tsx +0 -77
  75. package/template/src/screens/Settings/Settings.tsx +0 -5
  76. package/template/src/screens/home/components/CarouselSection.tsx +0 -79
  77. package/template/src/screens/home/components/FeaturedCarousel.tsx +0 -128
  78. package/template/src/screens/main/Main.tsx +0 -5
  79. package/template/src/screens/registration/RegistrationScreen.tsx +0 -198
  80. package/template/src/screens/resetPassword/ForgotPasswordScreen.tsx +0 -129
@@ -0,0 +1,466 @@
1
+ import {LoadState} from '../../../../types';
2
+
3
+ export interface ServicesState {
4
+ services: Service[];
5
+ service: Service;
6
+ selectedService: Service;
7
+ loading: boolean;
8
+ inquiredBill: InquiredBill;
9
+ paymentResponse: any[];
10
+ }
11
+
12
+ export interface PaySvcRs {
13
+ Response: Response;
14
+ }
15
+ export interface Response {
16
+ SignonRs: SignonRs;
17
+ PaySvcRs: PaySvcRs1;
18
+ }
19
+ export interface SignonRs {
20
+ ServerDt: string;
21
+ Language: string;
22
+ SignonProfile: SignonProfile;
23
+ }
24
+ export interface SignonProfile {
25
+ Sender: string;
26
+ Receiver: string;
27
+ MsgCode: string;
28
+ Version: string;
29
+ }
30
+ export interface PaySvcRs1 {
31
+ RqUID: string;
32
+ AsyncRqUID: string;
33
+ MsgRqHdr: MsgRqHdr;
34
+ Status: Status;
35
+ PmtAddRs: PmtAddRs;
36
+ }
37
+ export interface MsgRqHdr {
38
+ NetworkTrnInfo: NetworkTrnInfo;
39
+ ClientTerminalSeqId: string;
40
+ CustomProperties: CustomProperties;
41
+ }
42
+ export interface NetworkTrnInfo {
43
+ OriginatorCode: string;
44
+ TerminalId: string;
45
+ }
46
+ export interface CustomProperties {
47
+ CustomProperty?: CustomPropertyEntity[] | null;
48
+ }
49
+ export interface CustomPropertyEntity {
50
+ Key: string;
51
+ Value: string;
52
+ }
53
+ export interface Status {
54
+ StatusCode: number;
55
+ Severity: string;
56
+ StatusDesc: string;
57
+ }
58
+ export interface PmtAddRs {
59
+ CustId?: null[] | null;
60
+ PmtInfoVal?: PmtInfoValEntity[] | null;
61
+ }
62
+ export interface PmtInfoValEntity {
63
+ status: Status;
64
+ PmtTransId?: PmtTransIdEntity[] | null;
65
+ PmtInfo: PmtInfo;
66
+ }
67
+ export interface PmtTransIdEntity {
68
+ PmtId: string;
69
+ PmtIdType: string;
70
+ CreatedDt: string;
71
+ }
72
+ export interface PmtInfo {
73
+ CorrelationUID: string;
74
+ BillingAcct: string;
75
+ BillRefNumber: string;
76
+ BillTypeCode: number;
77
+ BankId: string;
78
+ PmtType: string;
79
+ DeliveryMethod: string;
80
+ CurAmt: CurAmtOrFeesAmt;
81
+ FeesAmt: CurAmtOrFeesAmt;
82
+ DepAccIdFrom: DepAccIdFrom;
83
+ PmtMethod: string;
84
+ PrcDt: string;
85
+ ExtraBillInfo: string;
86
+ MerchantName: string;
87
+ }
88
+ export interface CurAmtOrFeesAmt {
89
+ Amt: number;
90
+ CurCode: string;
91
+ }
92
+ export interface DepAccIdFrom {
93
+ AcctId: string;
94
+ AcctType: string;
95
+ AcctCur: string;
96
+ Balance: Balance;
97
+ }
98
+ export interface Balance {
99
+ Balance: number;
100
+ CurCode: string;
101
+ }
102
+
103
+ export interface InquiredBill {
104
+ success: boolean;
105
+ Response: Response;
106
+ }
107
+ export interface Response {
108
+ SignonRs: SignonRs;
109
+ PresSvcRs: PresSvcRs;
110
+ }
111
+ export interface SignonRs {
112
+ SignonPswd: SignonPswd;
113
+ ClientDt: string;
114
+ CustLangPref: string;
115
+ ServerDt: string;
116
+ Language: string;
117
+ SignonProfile: SignonProfile;
118
+ }
119
+ export interface SignonPswd {
120
+ UserAccess: UserAccess;
121
+ }
122
+ export interface UserAccess {
123
+ UserIPAddress: string;
124
+ }
125
+ export interface SignonProfile {
126
+ Sender: string;
127
+ Receiver: string;
128
+ MsgCode: string;
129
+ Version: string;
130
+ }
131
+ export interface PresSvcRs {
132
+ RqUID: string;
133
+ AsyncRqUID: string;
134
+ Status: Status;
135
+ BillInqRs: BillInqRs;
136
+ MsgRqHdr: MsgRqHdr;
137
+ }
138
+ export interface Status {
139
+ StatusCode: number;
140
+ Severity: string;
141
+ StatusDesc: string;
142
+ }
143
+ export interface BillInqRs {
144
+ CustId?: null[] | null;
145
+ IncOpenAmt: boolean;
146
+ DeliveryMethod: string;
147
+ BillRec?: BillRecEntity[] | null;
148
+ }
149
+ export interface BillRecEntity {
150
+ BillingAcct: string;
151
+ BillerId: string;
152
+ BillTypeCode: number;
153
+ BillRefNumber: string;
154
+ BillInfo: BillInfo;
155
+ BillStatus: string;
156
+ ExtraBillingAcctKeys: any;
157
+ }
158
+ export interface BillInfo {
159
+ BillSummAmt?: BillSummAmtEntity[] | null;
160
+ PaymentRange?: PaymentRangeEntity[] | null;
161
+ RulesAwareness: string;
162
+ ExtraBillInfo: string;
163
+ }
164
+ export interface BillSummAmtEntity {
165
+ BillSummAmtCode: string;
166
+ CurAmt: CurAmtOrLowerOrUpper;
167
+ }
168
+ export interface CurAmtOrLowerOrUpper {
169
+ Amt: number;
170
+ CurCode: string;
171
+ }
172
+ export interface PaymentRangeEntity {
173
+ Lower: CurAmtOrLowerOrUpper;
174
+ Upper: CurAmtOrLowerOrUpper;
175
+ }
176
+
177
+ export interface Service {
178
+ id?: number | null;
179
+ BillerId: string;
180
+ BillTypeCode?: number | null;
181
+ Name?: string | null;
182
+ PmtType?: string | null;
183
+ ServiceType?: string | null;
184
+ ServiceName?: string | null;
185
+ BillTypeAcctLabel?: string | null;
186
+ AcctInputMethod?: string;
187
+ IsHidden?: boolean | null;
188
+ BillTypeExtraRefKeys?: BillTypeExtraRefKeys | null;
189
+ BillRefType?: boolean | null;
190
+ PaymentRules?: PaymentRules | null;
191
+ BillTypeStatus?: string | null;
192
+ BillTypeDescription?: string | null;
193
+ AllowRctRePrint?: boolean | null;
194
+ OTPEnabled?: boolean | null;
195
+ ValidationEnabled?: boolean | null;
196
+ OTPRequired?: boolean | null;
197
+ IsBAConfRequired?: null;
198
+ IsTermsConditionReq?: boolean | null;
199
+ SupportPmtReverse?: null;
200
+ PaymentRanges?: null;
201
+ createdAt?: string | null;
202
+ updatedAt?: string | null;
203
+ Fees?: FeesEntity[] | null;
204
+ ReceiptFooter?: string | null;
205
+ BillingActRegEX?: null;
206
+ isActive?: boolean | null;
207
+ meta?: Meta | null;
208
+ commission_config?: null;
209
+ info_text?: boolean | null;
210
+ commission_with_vat?: boolean | null;
211
+ category_id?: string | null;
212
+ vat_value?: null;
213
+ BillerName?: string | null;
214
+ BillerInfo?: BillerInfoEntity[] | null;
215
+ BillerStatus?: string | null;
216
+ BillerNameLang?: string | null;
217
+ }
218
+ export interface BillTypeExtraRefKeys {
219
+ BillTypeRefKey?: BillTypeRefKeyEntity[] | null;
220
+ }
221
+ export interface BillTypeRefKeyEntity {
222
+ Key: string;
223
+ Value?: string | undefined;
224
+ Label: string;
225
+ Required: boolean;
226
+ EnumValues: EnumValues;
227
+ InputMethod: string;
228
+ IsBAKeyPart: boolean;
229
+ IsPrintKeyPart: boolean;
230
+ }
231
+ export interface EnumValues {
232
+ EnumValue?: EnumValueEntity[] | null;
233
+ }
234
+ export interface EnumValueEntity {
235
+ Alias: string;
236
+ Value: string;
237
+ }
238
+ export interface PaymentRules {
239
+ IsInqRqr: boolean;
240
+ IsAdvAcpt: boolean;
241
+ IsMobNtfy: boolean;
242
+ IsOvrAcpt: boolean;
243
+ IsPrtAcpt: boolean;
244
+ IsFracAcpt: boolean;
245
+ IsAcptCardPmt: boolean;
246
+ }
247
+ export interface FeesEntity {
248
+ Tier?: TierEntity[] | null;
249
+ IsEmbeddedFees: boolean;
250
+ AcctType?: string | null;
251
+ }
252
+ export interface TierEntity {
253
+ Percent: Percent;
254
+ FixedAmt: FixedAmtOrLowerOrUpper;
255
+ LowerAmt: number;
256
+ UpperAmt: number;
257
+ }
258
+ export interface Percent {
259
+ Value: number;
260
+ MaxAmt: number;
261
+ }
262
+ export interface FixedAmtOrLowerOrUpper {
263
+ Amt: number;
264
+ CurCode: string;
265
+ }
266
+ export interface Meta {
267
+ note: string;
268
+ explain: string;
269
+ poweredBy: string;
270
+ }
271
+ export interface BillerInfoEntity {
272
+ BillTypeCode: number;
273
+ Name: string;
274
+ PmtType: string;
275
+ ServiceType: string;
276
+ ServiceName: string;
277
+ BillTypeAcctLabel?: string | null;
278
+ IsHidden: boolean;
279
+ BillRefType: boolean;
280
+ ReceiptFooterLang?: string | null;
281
+ ReceiptFooter?: string | null;
282
+ PaymentRules: PaymentRules1;
283
+ BillTypeStatus: string;
284
+ PaymentRanges?: PaymentRanges | null;
285
+ BillTypeDescription?: string | null;
286
+ AllowRctRePrint: boolean;
287
+ OTPEnabled?: boolean | null;
288
+ ValidationEnabled: boolean;
289
+ Timeout?: string | null;
290
+ OTPRequired?: boolean | null;
291
+ IsBAConfRequired?: boolean | null;
292
+ IsTermsConditionReq?: boolean | null;
293
+ NextBTCs?: string | null;
294
+ IsSeparateNextPmt?: boolean | null;
295
+ Fees?: FeesEntity1[] | null;
296
+ SupportPmtReverse?: boolean | null;
297
+ BillingActRegEX?: string | null;
298
+ BillTypeExtraRefKeys?: BillTypeExtraRefKeys1 | null;
299
+ ReceiptHeader?: string | null;
300
+ NameLang?: string | null;
301
+ AcctInputMethod?: string | null;
302
+ IsAcceptPromo?: boolean | null;
303
+ Type?: string | null;
304
+ EchoInqCustProp?: boolean | null;
305
+ BillingActHint?: string | null;
306
+ RequiredLocation?: string | null;
307
+ IsSupportInstallment?: boolean | null;
308
+ CorrBillTypeCode?: number | null;
309
+ BillTypeNature?: string | null;
310
+ BalanceInqRequired?: boolean | null;
311
+ ReceiptCorrMerchMsg?: string | null;
312
+ ReceiptCorrCustMsg?: string | null;
313
+ ReceiptLogoName?: string | null;
314
+ DisableBulk?: boolean | null;
315
+ IsAcceptZeroPmt?: boolean | null;
316
+ SaveFavorite?: boolean | null;
317
+ ReceiptHeaderLang?: string | null;
318
+ TermsCondition?: string | null;
319
+ }
320
+ export interface PaymentRules1 {
321
+ IsInqRqr: boolean;
322
+ IsAdvAcpt?: boolean | null;
323
+ IsMobNtfy: boolean;
324
+ IsOvrAcpt?: boolean | null;
325
+ IsPrtAcpt?: boolean | null;
326
+ IsFracAcpt: boolean;
327
+ IsAcptCardPmt: boolean;
328
+ MultipleOfAmt?: number | null;
329
+ }
330
+ export interface PaymentRanges {
331
+ PaymentRangeType?: PaymentRangeTypeEntity[] | null;
332
+ }
333
+ export interface PaymentRangeTypeEntity {
334
+ Lower: FixedAmtOrLowerOrUpper;
335
+ Upper: FixedAmtOrLowerOrUpper;
336
+ }
337
+ export interface FeesEntity1 {
338
+ Tier?: TierEntity1[] | null;
339
+ IsEmbeddedFees: boolean;
340
+ AcctType?: string | null;
341
+ }
342
+ export interface TierEntity1 {
343
+ LowerAmt: number;
344
+ UpperAmt: number;
345
+ Percent?: Percent1 | null;
346
+ FixedAmt?: FixedAmtOrLowerOrUpper1 | null;
347
+ }
348
+ export interface Percent1 {
349
+ Value: number;
350
+ MaxAmt?: number | null;
351
+ MinAmt?: number | null;
352
+ }
353
+ export interface FixedAmtOrLowerOrUpper1 {
354
+ Amt: number;
355
+ CurCode: string;
356
+ }
357
+ export interface BillTypeExtraRefKeys1 {
358
+ BillTypeRefKey?: BillTypeRefKeyEntity1[] | null;
359
+ }
360
+ export interface BillTypeRefKeyEntity1 {
361
+ Key: string;
362
+ Label: string;
363
+ Required?: boolean | null;
364
+ IsPrintKeyPart: boolean;
365
+ IsBAKeyPart?: boolean | null;
366
+ InputMethod: string;
367
+ EnumValues?: EnumValues1 | null;
368
+ KeyHint?: string | null;
369
+ RegEX?: string | null;
370
+ IsCnfrmRequired?: boolean | null;
371
+ IsEncryptRequired?: boolean | null;
372
+ IsInputMasked?: boolean | null;
373
+ }
374
+ export interface EnumValues1 {
375
+ EnumValue?: EnumValueEntity1[] | null;
376
+ }
377
+ export interface EnumValueEntity1 {
378
+ Alias?: string | null;
379
+ Value: string;
380
+ Amount?: number | null;
381
+ Description?: string | null;
382
+ }
383
+
384
+ export interface ServicePayload {
385
+ services: Service[];
386
+ service: Service;
387
+ data: InquiredBill | {Response: Response};
388
+ }
389
+
390
+ export const ServicesInitialState: ServicesState = {
391
+ services: [],
392
+ service: {} as Service,
393
+ selectedService: {} as Service,
394
+ loading: false,
395
+ inquiredBill: {
396
+ success: false,
397
+ Response: {
398
+ SignonRs: {
399
+ SignonPswd: {
400
+ UserAccess: {
401
+ UserIPAddress: '',
402
+ },
403
+ },
404
+ ServerDt: '',
405
+ Language: '',
406
+ SignonProfile: {
407
+ Sender: '',
408
+ Receiver: '',
409
+ MsgCode: '',
410
+ Version: '',
411
+ },
412
+ ClientDt: '',
413
+ CustLangPref: '',
414
+ },
415
+ PaySvcRs: {
416
+ RqUID: '',
417
+ AsyncRqUID: '',
418
+ MsgRqHdr: {
419
+ NetworkTrnInfo: {
420
+ OriginatorCode: '',
421
+ TerminalId: '',
422
+ },
423
+ ClientTerminalSeqId: '',
424
+ CustomProperties: {
425
+ CustomProperty: [],
426
+ },
427
+ },
428
+ Status: {
429
+ StatusCode: 0,
430
+ Severity: '',
431
+ StatusDesc: '',
432
+ },
433
+ PmtAddRs: {
434
+ CustId: [],
435
+ PmtInfoVal: [],
436
+ },
437
+ },
438
+ PresSvcRs: {
439
+ RqUID: '',
440
+ AsyncRqUID: '',
441
+ Status: {
442
+ StatusCode: 0,
443
+ Severity: '',
444
+ StatusDesc: '',
445
+ },
446
+ BillInqRs: {
447
+ CustId: [],
448
+ IncOpenAmt: false,
449
+ DeliveryMethod: '',
450
+ BillRec: [],
451
+ },
452
+ MsgRqHdr: {
453
+ NetworkTrnInfo: {
454
+ OriginatorCode: '',
455
+ TerminalId: '',
456
+ },
457
+ ClientTerminalSeqId: '',
458
+ CustomProperties: {
459
+ CustomProperty: [],
460
+ },
461
+ },
462
+ },
463
+ },
464
+ },
465
+ paymentResponse: [],
466
+ };
@@ -1,11 +1,19 @@
1
- import {createSlice} from '@reduxjs/toolkit';
2
-
3
- import {appInitialState} from './appState';
1
+ import {createSlice, PayloadAction} from '@reduxjs/toolkit';
2
+ import {newState} from '../../../common/utils/newState';
3
+ import {Languages} from '../../../common/localization/localization';
4
+ import {appInitialState, AppInitialEntity} from './appState';
4
5
 
5
6
  export const {reducer: AppReducer, actions} = createSlice({
6
7
  name: 'app',
7
8
  initialState: appInitialState,
8
- reducers: {},
9
+ reducers: {
10
+ setLanguage: (state, action: PayloadAction<Languages>) => {
11
+ return newState(state, {
12
+ language: action.payload,
13
+ isRTL: action.payload === Languages.ar,
14
+ });
15
+ },
16
+ },
9
17
  });
10
18
 
11
- export const {} = actions;
19
+ export const {setLanguage} = actions;
@@ -1,3 +1,11 @@
1
- export interface AppInitialEntity {}
1
+ import {Languages} from '../../../common/localization/localization';
2
2
 
3
- export const appInitialState: AppInitialEntity = {};
3
+ export interface AppInitialEntity {
4
+ language?: Languages;
5
+ isRTL?: boolean;
6
+ }
7
+
8
+ export const appInitialState: AppInitialEntity = {
9
+ language: Languages.en,
10
+ isRTL: true,
11
+ };
@@ -1,10 +1,15 @@
1
1
  import {combineReducers} from '@reduxjs/toolkit';
2
2
  import {AppReducer} from './app/appSlice';
3
3
  import {UserReducer} from './user/userSlice';
4
-
4
+ import {CategoriesReducer} from './Categories/categorySlice';
5
+ import {ProvidersReducer} from './Providers/providersSlice';
6
+ import {ServicesReducer} from './Services/servicesSlice';
5
7
  export const rootReducer = combineReducers({
6
8
  app: AppReducer,
7
9
  user: UserReducer,
10
+ categories: CategoriesReducer,
11
+ providers: ProvidersReducer,
12
+ services: ServicesReducer,
8
13
  });
9
14
 
10
15
  export type RootState = ReturnType<typeof rootReducer>;
@@ -1,18 +1,62 @@
1
1
  import React from 'react';
2
2
  import {Action, configureStore, ThunkAction} from '@reduxjs/toolkit';
3
- import {PersistConfig, persistReducer, persistStore} from 'redux-persist';
3
+ import {
4
+ createTransform,
5
+ PersistConfig,
6
+ persistReducer,
7
+ persistStore,
8
+ } from 'redux-persist';
4
9
  import {rootReducer, RootState} from './rootReducer';
5
10
  import {Provider} from 'react-redux';
6
11
  import {PersistGate} from 'redux-persist/integration/react';
7
12
  import AsyncStorage from '@react-native-async-storage/async-storage';
8
13
  import {createWhitelistFilter} from 'redux-persist-transform-filter';
14
+ import {getUniqueId} from 'react-native-device-info';
15
+ import CryptoJS from 'crypto-js';
16
+
17
+ let deviceId: string;
18
+ getUniqueId()
19
+ .then(res => {
20
+ deviceId = res;
21
+ })
22
+ .catch(error => {});
23
+
24
+ const encrypt = createTransform(
25
+ (inboundState, key) => {
26
+ if (!inboundState) {
27
+ return inboundState;
28
+ }
29
+
30
+ const cryptedText = CryptoJS.AES.encrypt(
31
+ JSON.stringify(inboundState),
32
+ deviceId,
33
+ );
34
+
35
+ return cryptedText?.toString();
36
+ },
37
+ (outboundState, key) => {
38
+ if (!outboundState) {
39
+ return outboundState;
40
+ }
41
+ const bytes = CryptoJS.AES.decrypt(outboundState, deviceId);
42
+ const decrypted = bytes.toString(CryptoJS.enc.Utf8);
43
+
44
+ return JSON.parse(decrypted);
45
+ },
46
+ );
9
47
 
10
48
  const persistConfig: PersistConfig<RootState> = {
11
49
  key: 'root',
12
50
  storage: AsyncStorage,
13
51
  version: 1,
14
52
  timeout: 1000,
15
- transforms: [createWhitelistFilter('user', ['accessToken', 'user'])],
53
+ transforms: [
54
+ createWhitelistFilter('app'),
55
+ createWhitelistFilter('user'),
56
+ createWhitelistFilter('services'),
57
+ createWhitelistFilter('providers'),
58
+ createWhitelistFilter('categories'),
59
+ ],
16
60
  };
17
61
 
18
62
  const persistedReducer = persistReducer(persistConfig, rootReducer);
@@ -22,7 +66,16 @@ export const store = configureStore({
22
66
  middleware: getDefaultMiddleware =>
23
67
  getDefaultMiddleware({
24
68
  serializableCheck: false,
69
+ immutableCheck: {
70
+ warnAfter: 300,
71
+ ignoredPaths: [
72
+ 'services.inquiredBill',
73
+ 'providers.providers',
74
+ 'categories.categories',
75
+ ],
76
+ },
25
77
  }),
78
+ devTools: process.env.NODE_ENV !== 'production',
26
79
  });
27
80
 
28
81
  export const persistor = persistStore(store);