ordering-ui-react-native 0.23.62 → 0.23.64

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.23.62",
3
+ "version": "0.23.64",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -52,7 +52,7 @@
52
52
  "@segment/analytics-react-native": "2.1.11",
53
53
  "@segment/sovran-react-native": "0.2.6",
54
54
  "@sentry/react-native": "^2.6.0",
55
- "@stripe/stripe-react-native": "0.23.0",
55
+ "@stripe/stripe-react-native": "0.23.0",
56
56
  "@types/react-native-loading-spinner-overlay": "^0.5.2",
57
57
  "@types/react-native-snap-carousel": "^3.8.4",
58
58
  "@types/styled-components": "^5.1.3",
@@ -6,6 +6,9 @@ import {
6
6
  View,
7
7
  Dimensions,
8
8
  ScrollView,
9
+ Platform,
10
+ NativeModules,
11
+ Alert as AlertReactNative
9
12
  } from 'react-native';
10
13
  import { useForm, Controller } from 'react-hook-form';
11
14
  import Recaptcha from 'react-native-recaptcha-that-works'
@@ -62,11 +65,12 @@ const LoginFormUI = (props: LoginParams) => {
62
65
  enableReCaptcha,
63
66
 
64
67
  useLoginOtp,
65
- otpType,
66
- setOtpType,
67
- generateOtpCode,
68
- useLoginOtpEmail,
69
- useLoginOtpCellphone,
68
+ otpType,
69
+ setOtpType,
70
+ generateOtpCode,
71
+ useLoginOtpEmail,
72
+ useLoginOtpCellphone,
73
+ validateDeveloperMode
70
74
  } = props;
71
75
 
72
76
  const [ordering, { setOrdering }] = useApi();
@@ -112,7 +116,7 @@ const LoginFormUI = (props: LoginParams) => {
112
116
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
113
117
  const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
114
118
  const isOtpEmail = loginTab === 'otp' && otpType === 'email'
115
- const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
119
+ const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
116
120
 
117
121
 
118
122
  const handleOpenRecaptcha = () => {
@@ -229,37 +233,58 @@ const LoginFormUI = (props: LoginParams) => {
229
233
 
230
234
  const mainLogin = (values) => {
231
235
  if (loginTab === 'otp') {
232
- if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
233
- showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
234
- return
235
- }
236
- if (loginTab === 'otp') {
237
- generateOtpCode({
238
- ...values,
239
- ...phoneInputData.phone
240
- })
241
- }
242
- setWillVerifyOtpState(true)
243
- } else {
244
- if (phoneInputData.error) {
245
- showToast(ToastType.Error, phoneInputData.error);
246
- return;
247
- }
248
- handleButtonLoginClick({
249
- ...values,
250
- ...phoneInputData.phone,
251
- });
252
- }
236
+ if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
237
+ showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
238
+ return
239
+ }
240
+ if (loginTab === 'otp') {
241
+ generateOtpCode({
242
+ ...values,
243
+ ...phoneInputData.phone
244
+ })
245
+ }
246
+ setWillVerifyOtpState(true)
247
+ } else {
248
+ if (phoneInputData.error) {
249
+ showToast(ToastType.Error, phoneInputData.error);
250
+ return;
251
+ }
252
+ handleButtonLoginClick({
253
+ ...values,
254
+ ...phoneInputData.phone,
255
+ });
256
+ }
253
257
  }
254
258
 
255
- const onSubmit = (values: any) => {
259
+ const isDeveloperModeEnabled = async (): Promise<boolean> => {
260
+ if (Platform.OS === 'android') {
261
+ return NativeModules.DeveloperOptions?.isDeveloperModeEnabled?.();
262
+ }
263
+ return false
264
+ }
265
+
266
+ const onSubmit = async (values: any) => {
256
267
  Keyboard.dismiss();
257
268
 
258
269
  if (phoneInputData.error) {
259
270
  showToast(ToastType.Error, phoneInputData.error);
260
271
  return;
261
272
  }
262
-
273
+ if (validateDeveloperMode) {
274
+ const isDeveloperMode = await isDeveloperModeEnabled()
275
+ if (isDeveloperMode) {
276
+ AlertReactNative.alert(
277
+ t('DEVELOPER_MODE', 'Developer mode'),
278
+ t('PLEASE_DISABLE_DEVELOPER_MODE', 'Please disable developer mode for sign in'),
279
+ [{
280
+ text: t('GO_TO_SETTINGS', 'Go to settings'),
281
+ onPress: async () => await NativeModules.DeveloperOptions?.openDeveloperSettings(),
282
+ },
283
+ { text: 'OK', onPress: () => { } },]
284
+ )
285
+ return
286
+ }
287
+ }
263
288
  if (values?.project_name) {
264
289
  setOrdering({
265
290
  ...ordering,
@@ -274,21 +299,21 @@ const LoginFormUI = (props: LoginParams) => {
274
299
  };
275
300
 
276
301
  const handleChangeOtpType = (type: string) => {
277
- handleChangeTab('otp', type)
278
- setOtpType(type)
279
- }
280
-
281
- const handleLoginOtp = (code: string) => {
282
- handleButtonLoginClick({ code })
283
- }
284
-
285
- const closeAlert = () => {
286
- setAlertState({
287
- open: false,
288
- title: '',
289
- content: []
290
- })
291
- }
302
+ handleChangeTab('otp', type)
303
+ setOtpType(type)
304
+ }
305
+
306
+ const handleLoginOtp = (code: string) => {
307
+ handleButtonLoginClick({ code })
308
+ }
309
+
310
+ const closeAlert = () => {
311
+ setAlertState({
312
+ open: false,
313
+ title: '',
314
+ content: []
315
+ })
316
+ }
292
317
 
293
318
  const handleVerifyCodeClick = () => {
294
319
  if (phoneInputData.error) {
@@ -411,14 +436,14 @@ const LoginFormUI = (props: LoginParams) => {
411
436
  }, [ordering, submitted])
412
437
 
413
438
  useEffect(() => {
414
- if (checkPhoneCodeState?.result?.error) {
415
- setAlertState({
416
- open: true,
417
- content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
418
- title: ''
419
- })
420
- }
421
- }, [checkPhoneCodeState])
439
+ if (checkPhoneCodeState?.result?.error) {
440
+ setAlertState({
441
+ open: true,
442
+ content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
443
+ title: ''
444
+ })
445
+ }
446
+ }, [checkPhoneCodeState])
422
447
 
423
448
  Dimensions.addEventListener('change', ({ window: { width, height } }) => {
424
449
  setWindowWidth(
@@ -477,7 +502,7 @@ const LoginFormUI = (props: LoginParams) => {
477
502
  borderColor: theme.colors.inputSignup,
478
503
  backgroundColor: theme.colors.transparent,
479
504
  minHeight: 50,
480
- maxHeight : 50
505
+ maxHeight: 50
481
506
  },
482
507
  btn: {
483
508
  borderRadius: 7.6,
@@ -506,23 +531,23 @@ const LoginFormUI = (props: LoginParams) => {
506
531
  },
507
532
 
508
533
  borderStyleBase: {
509
- width: 30,
510
- height: 45
511
- },
512
- borderStyleHighLighted: {
513
- borderColor: "#03DAC6",
514
- },
515
- underlineStyleBase: {
516
- width: 45,
517
- height: 60,
518
- borderWidth: 1,
519
- fontSize: 16
520
- },
521
- underlineStyleHighLighted: {
522
- borderColor: theme.colors.primary,
523
- color: theme.colors.primary,
524
- fontSize: 16
525
- },
534
+ width: 30,
535
+ height: 45
536
+ },
537
+ borderStyleHighLighted: {
538
+ borderColor: "#03DAC6",
539
+ },
540
+ underlineStyleBase: {
541
+ width: 45,
542
+ height: 60,
543
+ borderWidth: 1,
544
+ fontSize: 16
545
+ },
546
+ underlineStyleHighLighted: {
547
+ borderColor: theme.colors.primary,
548
+ color: theme.colors.primary,
549
+ fontSize: 16
550
+ },
526
551
  });
527
552
 
528
553
  return (
@@ -602,7 +627,7 @@ const LoginFormUI = (props: LoginParams) => {
602
627
  )}
603
628
 
604
629
  {useLoginOtpEmail && (
605
- <Pressable
630
+ <Pressable
606
631
  style={styles.btnTab}
607
632
  onPress={() => handleChangeOtpType('email')}>
608
633
  <OText
@@ -624,10 +649,10 @@ const LoginFormUI = (props: LoginParams) => {
624
649
  : theme.colors.tabBar,
625
650
  borderBottomWidth: 2,
626
651
  }} />
627
- </Pressable>
628
- )}
629
- {useLoginOtpCellphone && (
630
- <Pressable
652
+ </Pressable>
653
+ )}
654
+ {useLoginOtpCellphone && (
655
+ <Pressable
631
656
  style={styles.btnTab}
632
657
  onPress={() => handleChangeOtpType('cellphone')}>
633
658
  <OText
@@ -644,13 +669,13 @@ const LoginFormUI = (props: LoginParams) => {
644
669
  style={{
645
670
  width: '100%',
646
671
  borderBottomColor:
647
- isOtpCellphone
672
+ isOtpCellphone
648
673
  ? theme.colors.textGray
649
674
  : theme.colors.tabBar,
650
675
  borderBottomWidth: 2,
651
676
  }} />
652
- </Pressable>
653
- )}
677
+ </Pressable>
678
+ )}
654
679
  </TabsContainer>
655
680
  </ScrollView>
656
681
  </LoginWith>
@@ -908,28 +933,28 @@ const LoginFormUI = (props: LoginParams) => {
908
933
  />
909
934
  </OModal>
910
935
  <OModal
911
- open={willVerifyOtpState}
912
- onClose={() => setWillVerifyOtpState(false)}
913
- entireModal
936
+ open={willVerifyOtpState}
937
+ onClose={() => setWillVerifyOtpState(false)}
938
+ entireModal
914
939
  hideIcons
915
- title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
916
- >
917
- <Otp
918
- willVerifyOtpState={willVerifyOtpState}
919
- setWillVerifyOtpState={setWillVerifyOtpState}
920
- handleLoginOtp={handleLoginOtp}
921
- onSubmit={handleLogin}
922
- setAlertState={setAlertState}
940
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
941
+ >
942
+ <Otp
943
+ willVerifyOtpState={willVerifyOtpState}
944
+ setWillVerifyOtpState={setWillVerifyOtpState}
945
+ handleLoginOtp={handleLoginOtp}
946
+ onSubmit={handleLogin}
947
+ setAlertState={setAlertState}
923
948
  formState={formState}
924
- />
925
- </OModal>
926
- <Alert
927
- open={alertState.open}
928
- content={alertState.content}
929
- title={alertState.title || ''}
930
- onAccept={closeAlert}
931
- onClose={closeAlert}
932
- />
949
+ />
950
+ </OModal>
951
+ <Alert
952
+ open={alertState.open}
953
+ content={alertState.content}
954
+ title={alertState.title || ''}
955
+ onAccept={closeAlert}
956
+ onClose={closeAlert}
957
+ />
933
958
  </View>
934
959
  );
935
960
  };
@@ -71,6 +71,10 @@ export const OrderContentComponent = (props: OrderContent) => {
71
71
  const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
72
72
  const deliveryTypes = [1, 7]
73
73
 
74
+ const commentDivide = ordering?.project?.includes('delosi')
75
+ ? order?.comment?.split('Total')
76
+ : [order?.comment]
77
+
74
78
  const walletName: any = {
75
79
  cash: {
76
80
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
@@ -440,19 +444,29 @@ export const OrderContentComponent = (props: OrderContent) => {
440
444
  </OText>
441
445
 
442
446
  {!!order?.comment && (
443
- <>
447
+ <View>
444
448
  <OText>
445
449
  {`${t('ORDER_COMMENT', 'Order Comment')}: `}
446
450
  </OText>
447
- <OText
448
- {...(ordering?.project?.includes('delosi') && {
449
- color: theme.colors.primary,
450
- weight: 'bold'
451
- })}
452
- >
453
- {order?.comment}
454
- </OText>
455
- </>
451
+ {commentDivide?.map((fragment: string, i: number) => (
452
+ <View
453
+ {...(ordering?.project?.includes('delosi') && i === 1 && {
454
+ backgroundColor: theme.colors.primary,
455
+ weight: 'bold',
456
+ padding: 10
457
+ })}
458
+ >
459
+ <OText
460
+ {...(ordering?.project?.includes('delosi') && i === 1 && {
461
+ color: theme.colors.white,
462
+ weight: 'bold'
463
+ })}
464
+ >
465
+ {ordering?.project?.includes('delosi') && i === 1 ? t('TOTAL', 'Total') : ''}{fragment}
466
+ </OText>
467
+ </View>
468
+ ))}
469
+ </View>
456
470
  )}
457
471
 
458
472
  {order?.products?.length > 0 &&
@@ -29,7 +29,8 @@ export interface LoginParams {
29
29
  generateOtpCode: (values?: any) => void,
30
30
  useLoginOtpEmail?: boolean,
31
31
  useLoginOtpCellphone?: boolean,
32
- useLoginOtp?: boolean
32
+ useLoginOtp?: boolean,
33
+ validateDeveloperMode: boolean
33
34
  }
34
35
  export interface otpParams {
35
36
  willVerifyOtpState: boolean,