ordering-ui-react-native 0.14.75 → 0.14.78

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.14.75",
3
+ "version": "0.14.78",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -316,6 +316,7 @@ export const ProductOptionsUI = (props: any) => {
316
316
  <View style={{ width: isSoldOut || maxProductQuantity <= 0 ? '100%' : '70%' }}>
317
317
  {productCart && !isSoldOut && maxProductQuantity > 0 && auth && orderState.options?.address_id && (
318
318
  <OButton
319
+ isDisabled={orderState.loading}
319
320
  onClick={() => handleSaveProduct()}
320
321
  imgRightSrc=''
321
322
  text={`${orderState.loading ? t('LOADING', 'Loading') : editMode ? t('UPDATE', 'Update') : t('ADD_TO_CART', 'Add to Cart')} ${productCart.total ? parsePrice(productCart?.total) : ''}`}
@@ -110,7 +110,8 @@ const OrderProgressUI = (props: any) => {
110
110
  const deliveryTime = order?.delivery_datetime_utc
111
111
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm' })
112
112
  : parseDate(order?.delivery_datetime, { utc: false, outputFormat: 'YYYY-MM-DD HH:mm' })
113
- const [hour, minute] = time.split(':')
113
+ const hour = time?.split(':')?.[0]
114
+ const minute = time?.split(':')?.[1]
114
115
  const result = time ? (parseInt(hour, 10) * 60) + parseInt(minute, 10) : 0
115
116
  const returnedDate = moment(deliveryTime).add(result, 'minutes').format('hh:mm A')
116
117
  return returnedDate
@@ -62,7 +62,8 @@ const SignupFormUI = (props: SignupParams) => {
62
62
  setCheckPhoneCodeState,
63
63
  handleSendVerifyCode,
64
64
  handleCheckPhoneCode,
65
- notificationState
65
+ notificationState,
66
+ handleChangePromotions
66
67
  } = props;
67
68
 
68
69
  const theme = useTheme();
@@ -92,9 +93,9 @@ const SignupFormUI = (props: SignupParams) => {
92
93
  marginBottom: 7,
93
94
  },
94
95
  checkBoxStyle: {
95
- width: 25,
96
- height: 25,
97
- }
96
+ width: 25,
97
+ height: 25,
98
+ }
98
99
  });
99
100
 
100
101
  const [, { showToast }] = useToast();
@@ -281,9 +282,9 @@ const SignupFormUI = (props: SignupParams) => {
281
282
  const supported = await Linking.canOpenURL(url);
282
283
 
283
284
  if (supported) {
284
- await Linking.openURL(url);
285
+ await Linking.openURL(url);
285
286
  } else {
286
- showToast(ToastType.Error, t('VALIDATION_ERROR_ACTIVE_URL', 'The _attribute_ is not a valid URL.').replace('_attribute_', t('URL', 'URL')))
287
+ showToast(ToastType.Error, t('VALIDATION_ERROR_ACTIVE_URL', 'The _attribute_ is not a valid URL.').replace('_attribute_', t('URL', 'URL')))
287
288
  }
288
289
  }
289
290
 
@@ -470,6 +471,33 @@ const SignupFormUI = (props: SignupParams) => {
470
471
  </View>
471
472
  )}
472
473
 
474
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
475
+ <Controller
476
+ control={control}
477
+ render={({ onChange, value }: any) => (
478
+ <CheckBox
479
+ value={value}
480
+ onValueChange={newValue => {
481
+ onChange(newValue)
482
+ handleChangePromotions()
483
+ }}
484
+ boxType={'square'}
485
+ tintColors={{
486
+ true: theme.colors.primary,
487
+ false: theme.colors.disabled
488
+ }}
489
+ tintColor={theme.colors.disabled}
490
+ onCheckColor={theme.colors.primary}
491
+ onTintColor={theme.colors.primary}
492
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
493
+ />
494
+ )}
495
+ name='promotions'
496
+ defaultValue={false}
497
+ />
498
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
499
+ </View>
500
+
473
501
  {configs?.terms_and_conditions?.value === 'true' && (
474
502
  <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
475
503
  <Controller
@@ -592,25 +620,25 @@ const SignupFormUI = (props: SignupParams) => {
592
620
  textStyle={{ color: 'white' }}
593
621
  imgRightSrc={null}
594
622
  isDisabled={formState.loading || validationFields.loading}
595
- style={{ borderRadius: 7.6, marginTop: 6,shadowOpacity: 0 }}
623
+ style={{ borderRadius: 7.6, marginTop: 6, shadowOpacity: 0 }}
596
624
  />
597
625
  )}
598
626
  </FormInput>
599
627
 
600
628
  {
601
- onNavigationRedirect && loginButtonText && (
602
- <View style={style.wrappText}>
603
- <OText size={14} style={{ marginRight: 5 }}>
604
- {t('MOBILE_FRONT_ALREADY_HAVE_AN_ACCOUNT', 'Already have an account?')}
605
- </OText>
606
- <Pressable onPress={() => onNavigationRedirect('Login')}>
607
- <OText size={14} color={theme.colors.primary}>
608
- {loginButtonText}
609
- </OText>
610
- </Pressable>
611
- </View>
612
- )
613
- }
629
+ onNavigationRedirect && loginButtonText && (
630
+ <View style={style.wrappText}>
631
+ <OText size={14} style={{ marginRight: 5 }}>
632
+ {t('MOBILE_FRONT_ALREADY_HAVE_AN_ACCOUNT', 'Already have an account?')}
633
+ </OText>
634
+ <Pressable onPress={() => onNavigationRedirect('Login')}>
635
+ <OText size={14} color={theme.colors.primary}>
636
+ {loginButtonText}
637
+ </OText>
638
+ </Pressable>
639
+ </View>
640
+ )
641
+ }
614
642
  <View
615
643
  style={{
616
644
  flexDirection: 'row',
@@ -632,23 +660,23 @@ const SignupFormUI = (props: SignupParams) => {
632
660
 
633
661
  {configs && Object.keys(configs).length > 0 && (
634
662
  (((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value) ||
635
- (configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null)) &&
663
+ (configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null)) &&
636
664
  (
637
665
  <ButtonsWrapper>
638
666
  <SocialButtons>
639
667
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
640
- configs?.facebook_id?.value && (
641
- <FacebookLogin
642
- notificationState={notificationState}
643
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
644
- handleLoading={(val: boolean) => setIsFBLoading(val)}
645
- handleSuccessFacebookLogin={handleSuccessFacebook}
646
- />
647
- )}
668
+ configs?.facebook_id?.value && (
669
+ <FacebookLogin
670
+ notificationState={notificationState}
671
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
672
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
673
+ handleSuccessFacebookLogin={handleSuccessFacebook}
674
+ />
675
+ )}
648
676
  {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
649
677
  <GoogleLogin
650
678
  notificationState={notificationState}
651
- webClientId={configs?.google_login_client_id?.value}
679
+ webClientId={configs?.google_login_client_id?.value}
652
680
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
653
681
  handleLoading={(val: boolean) => setIsFBLoading(val)}
654
682
  handleSuccessGoogleLogin={handleSuccessFacebook}
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { StyleSheet, View } from 'react-native';
2
+ import { Platform, StyleSheet, View } from 'react-native';
3
3
  import { useSession, useLanguage, ToastType, useToast, useConfig } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { useForm, Controller } from 'react-hook-form';
@@ -10,6 +10,7 @@ import { OText, OButton, OInput } from '../shared';
10
10
 
11
11
  import { PhoneInputNumber } from '../PhoneInputNumber';
12
12
  import { sortInputFields } from '../../utils';
13
+ import CheckBox from '@react-native-community/checkbox';
13
14
 
14
15
  export const UserFormDetailsUI = (props: any) => {
15
16
  const {
@@ -24,6 +25,7 @@ export const UserFormDetailsUI = (props: any) => {
24
25
  handleButtonUpdateClick,
25
26
  phoneUpdate,
26
27
  hideUpdateButton,
28
+ handleChangePromotions
27
29
  } = props;
28
30
 
29
31
  const theme = useTheme();
@@ -58,6 +60,10 @@ export const UserFormDetailsUI = (props: any) => {
58
60
  paddingStart: 0,
59
61
  paddingBottom: 0,
60
62
  marginBottom: -0,
63
+ },
64
+ checkBoxStyle: {
65
+ width: 25,
66
+ height: 25,
61
67
  }
62
68
  });
63
69
 
@@ -320,7 +326,7 @@ export const UserFormDetailsUI = (props: any) => {
320
326
  render={() => (
321
327
  <>
322
328
  <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
323
- {t('PASSWORD', 'Password')}
329
+ {t('PASSWORD', 'Password')}
324
330
  </OText>
325
331
  <OInput
326
332
  name='password'
@@ -347,9 +353,37 @@ export const UserFormDetailsUI = (props: any) => {
347
353
  </>
348
354
  )}
349
355
  name='password'
350
- rules={getInputRules({name: 'password', code: 'password'})}
356
+ rules={getInputRules({ name: 'password', code: 'password' })}
351
357
  defaultValue=''
352
358
  />
359
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}>
360
+ <Controller
361
+ control={control}
362
+ render={({ onChange, value }: any) => (
363
+ <CheckBox
364
+ value={value}
365
+ onValueChange={newValue => {
366
+ onChange(newValue)
367
+ handleChangePromotions(newValue)
368
+ }}
369
+ boxType={'square'}
370
+ tintColors={{
371
+ true: theme.colors.primary,
372
+ false: theme.colors.disabled
373
+ }}
374
+ tintColor={theme.colors.disabled}
375
+ onCheckColor={theme.colors.primary}
376
+ onTintColor={theme.colors.primary}
377
+ style={Platform.OS === 'ios' && styles.checkBoxStyle}
378
+ />
379
+ )}
380
+ name='promotions'
381
+ defaultValue={formState?.result?.result
382
+ ? !!formState?.result?.result?.settings?.notification?.newsletter
383
+ : !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
384
+ />
385
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
386
+ </View>
353
387
  </UDWrapper>
354
388
  )}
355
389
  {validationFields?.loading && (
@@ -93,6 +93,7 @@ export interface SignupParams {
93
93
  handleSendVerifyCode?: any;
94
94
  handleCheckPhoneCode?: any;
95
95
  notificationState?: any;
96
+ handleChangePromotions: () => void;
96
97
  }
97
98
 
98
99
  export interface PhoneInputParams {