ordering-ui-react-native 0.17.0 → 0.17.1

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.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -58,6 +58,7 @@ const AddressFormUI = (props: AddressFormParams) => {
58
58
  saveAddress,
59
59
  isGuestUser,
60
60
  isRequiredField,
61
+ showField,
61
62
  isFromProductsList,
62
63
  hasAddressDefault,
63
64
  afterSignup,
@@ -641,129 +642,138 @@ const AddressFormUI = (props: AddressFormParams) => {
641
642
  )}
642
643
 
643
644
  <View style={{ flexDirection: 'row', flexBasis: '50%' }}>
644
- <Controller
645
- control={control}
646
- name="internal_number"
647
- rules={{
648
- required:
649
- isRequiredField && isRequiredField('internal_number')
650
- ? t(
651
- `VALIDATION_ERROR_INTERNAL_NUMBER_REQUIRED`,
652
- `The field internal number is required`,
653
- )
654
- : null,
655
- }}
656
- defaultValue={
657
- address?.internal_number ||
658
- formState.changes?.internal_number ||
659
- addressState?.address?.internal_number ||
660
- ''
661
- }
662
- render={() => (
663
- <OInput
664
- name="internal_number"
665
- placeholder={t('INTERNAL_NUMBER', 'Internal number')}
666
- onChange={(text: string) => {
667
- handleChangeInput(text);
668
- setValue('internal_number', text);
669
- }}
670
- value={
671
- address?.internal_number ||
672
- formState.changes?.internal_number ||
673
- addressState?.address?.internal_number ||
674
- ''
675
- }
676
- style={{ ...styles.inputsStyle, marginRight: 24 }}
677
- forwardRef={internalNumberRef}
678
- returnKeyType="next"
679
- onSubmitEditing={() => zipCodeRef?.current?.focus?.()}
680
- blurOnSubmit={false}
681
- />
682
- )}
683
- />
645
+ {showField && showField('internal_number') && (
646
+ <Controller
647
+ control={control}
648
+ name="internal_number"
649
+ rules={{
650
+ required:
651
+ isRequiredField && isRequiredField('internal_number')
652
+ ? t(
653
+ `VALIDATION_ERROR_INTERNAL_NUMBER_REQUIRED`,
654
+ `The field internal number is required`,
655
+ )
656
+ : null,
657
+ }}
658
+ defaultValue={
659
+ address?.internal_number ||
660
+ formState.changes?.internal_number ||
661
+ addressState?.address?.internal_number ||
662
+ ''
663
+ }
664
+ render={() => (
665
+ <OInput
666
+ name="internal_number"
667
+ placeholder={t('INTERNAL_NUMBER', 'Internal number')}
668
+ onChange={(text: string) => {
669
+ handleChangeInput(text);
670
+ setValue('internal_number', text);
671
+ }}
672
+ value={
673
+ address?.internal_number ||
674
+ formState.changes?.internal_number ||
675
+ addressState?.address?.internal_number ||
676
+ ''
677
+ }
678
+ style={{
679
+ ...styles.inputsStyle,
680
+ marginRight: showField('internal_number') && showField('zipcode') ? 24 : 0
681
+ }}
682
+ forwardRef={internalNumberRef}
683
+ returnKeyType="next"
684
+ onSubmitEditing={() => zipCodeRef?.current?.focus?.()}
685
+ blurOnSubmit={false}
686
+ />
687
+ )}
688
+ />
689
+ )}
690
+
691
+ {showField && showField('zipcode') && (
692
+ <Controller
693
+ control={control}
694
+ name="zipcode"
695
+ rules={{
696
+ required:
697
+ isRequiredField && isRequiredField('zipcode')
698
+ ? t(
699
+ `VALIDATION_ERROR_ZIP_CODE_REQUIRED`,
700
+ `The field Zip Code is required`,
701
+ )
702
+ : null,
703
+ }}
704
+ defaultValue={
705
+ address?.zipcode ||
706
+ formState.changes?.zipcode ||
707
+ addressState.address.zipcode ||
708
+ ''
709
+ }
710
+ render={() => (
711
+ <OInput
712
+ name="zipcode"
713
+ placeholder={t('ZIP_CODE', 'Zip code')}
714
+ onChange={(text: string) => {
715
+ handleChangeInput(text);
716
+ setValue('zipcode', text);
717
+ }}
718
+ value={
719
+ address?.zipcode ||
720
+ formState.changes?.zipcode ||
721
+ addressState.address.zipcode ||
722
+ ''
723
+ }
724
+ style={styles.inputsStyle}
725
+ forwardRef={zipCodeRef}
726
+ returnKeyType="next"
727
+ onSubmitEditing={() => addressNotesRef?.current?.focus?.()}
728
+ blurOnSubmit={false}
729
+ />
730
+ )}
731
+ />
732
+ )}
733
+ </View>
684
734
 
735
+ {showField && showField('address_notes') && (
685
736
  <Controller
686
737
  control={control}
687
- name="zipcode"
738
+ name="address_notes"
688
739
  rules={{
689
740
  required:
690
- isRequiredField && isRequiredField('zipcode')
741
+ isRequiredField && isRequiredField('address_notes')
691
742
  ? t(
692
- `VALIDATION_ERROR_ZIP_CODE_REQUIRED`,
693
- `The field Zip Code is required`,
743
+ `VALIDATION_ERROR_ADDRESS_NOTES_REQUIRED`,
744
+ `The field address notes is required`,
694
745
  )
695
746
  : null,
696
747
  }}
697
748
  defaultValue={
698
- address?.zipcode ||
699
- formState.changes?.zipcode ||
700
- addressState.address.zipcode ||
749
+ address?.address_notes ||
750
+ formState.changes?.address_notes ||
751
+ addressState.address.address_notes ||
701
752
  ''
702
753
  }
703
754
  render={() => (
704
755
  <OInput
705
- name="zipcode"
706
- placeholder={t('ZIP_CODE', 'Zip code')}
707
- onChange={(text: string) => {
756
+ name="address_notes"
757
+ placeholder={t('ADDRESS_NOTES', 'Address notes')}
758
+ onChange={(text: any) => {
708
759
  handleChangeInput(text);
709
- setValue('zipcode', text);
760
+ setValue('address_notes', text);
710
761
  }}
711
762
  value={
712
- address?.zipcode ||
713
- formState.changes?.zipcode ||
714
- addressState.address.zipcode ||
763
+ address?.address_notes ||
764
+ formState.changes?.address_notes ||
765
+ addressState.address.address_notes ||
715
766
  ''
716
767
  }
717
- style={styles.inputsStyle}
718
- forwardRef={zipCodeRef}
719
- returnKeyType="next"
720
- onSubmitEditing={() => addressNotesRef?.current?.focus?.()}
721
- blurOnSubmit={false}
768
+ multiline
769
+ style={styles.textAreaStyles}
770
+ returnKeyType="done"
771
+ forwardRef={addressNotesRef}
772
+ blurOnSubmit
722
773
  />
723
774
  )}
724
775
  />
725
- </View>
726
-
727
- <Controller
728
- control={control}
729
- name="address_notes"
730
- rules={{
731
- required:
732
- isRequiredField && isRequiredField('address_notes')
733
- ? t(
734
- `VALIDATION_ERROR_ADDRESS_NOTES_REQUIRED`,
735
- `The field address notes is required`,
736
- )
737
- : null,
738
- }}
739
- defaultValue={
740
- address?.address_notes ||
741
- formState.changes?.address_notes ||
742
- addressState.address.address_notes ||
743
- ''
744
- }
745
- render={() => (
746
- <OInput
747
- name="address_notes"
748
- placeholder={t('ADDRESS_NOTES', 'Address notes')}
749
- onChange={(text: any) => {
750
- handleChangeInput(text);
751
- setValue('address_notes', text);
752
- }}
753
- value={
754
- address?.address_notes ||
755
- formState.changes?.address_notes ||
756
- addressState.address.address_notes ||
757
- ''
758
- }
759
- multiline
760
- style={styles.textAreaStyles}
761
- returnKeyType="done"
762
- forwardRef={addressNotesRef}
763
- blurOnSubmit
764
- />
765
- )}
766
- />
776
+ )}
767
777
  </FormInput>
768
778
  <IconsContainer>
769
779
  {tagsName.map((tag) => (
@@ -1,17 +1,18 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useLanguage, useOrder } from 'ordering-components/native';
1
+ import React, { useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { useLanguage } from 'ordering-components/native';
3
4
  import { useTheme } from 'styled-components/native';
4
5
  import { CCContainer, CCNotCarts, CCList } from './styles';
5
6
 
6
7
  import { Cart } from '../Cart';
7
- import { OIcon, OText } from '../shared';
8
+ import { OButton, OText } from '../shared';
8
9
  import Spinner from 'react-native-loading-spinner-overlay';
9
- import { View } from 'react-native';
10
10
 
11
11
  export const CartContent = (props: any) => {
12
12
  const {
13
13
  carts,
14
- isOrderStateCarts
14
+ isOrderStateCarts,
15
+ onNavigationRedirect
15
16
  } = props
16
17
 
17
18
  const theme = useTheme();
@@ -22,9 +23,6 @@ export const CartContent = (props: any) => {
22
23
  <CCContainer>
23
24
  {isOrderStateCarts && carts?.length > 0 && (
24
25
  <>
25
- {/* <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
26
- {carts.length > 1 ? t('MY_CARTS', 'My Carts') : t('CART', 'Cart')}
27
- </OText> */}
28
26
  {carts.map((cart: any, i: number) => (
29
27
  <CCList key={i} style={{ overflow: 'visible' }}>
30
28
  {cart.products.length > 0 && (
@@ -48,14 +46,22 @@ export const CartContent = (props: any) => {
48
46
  )}
49
47
  {(!carts || carts?.length === 0) && (
50
48
  <CCNotCarts>
51
- {/* <OIcon
52
- url={props.icon}
53
- width={200}
54
- height={122}
55
- /> */}
56
49
  <OText size={24} style={{ textAlign: 'center' }}>
57
50
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
58
51
  </OText>
52
+ <OButton
53
+ text={t('START_SHOPPING', 'Start shopping')}
54
+ bgColor={theme.colors.primary}
55
+ borderColor={theme.colors.primary}
56
+ textStyle={{
57
+ color: theme.colors.white,
58
+ fontSize: 14,
59
+ paddingRight: 0
60
+ }}
61
+ style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
62
+ imgRightSrc={null}
63
+ onClick={() => onNavigationRedirect('BusinessList')}
64
+ />
59
65
  </CCNotCarts>
60
66
  )}
61
67
  <Spinner visible={isCartsLoading} />
@@ -89,7 +89,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
89
89
  return
90
90
  }
91
91
 
92
- if (distance <= maxLimitLocation) {
92
+ const _maxLimitLocation = typeof maxLimitLocation === 'string' ? parseInt(maxLimitLocation, 10) : maxLimitLocation
93
+
94
+ if (distance <= _maxLimitLocation) {
93
95
  setMarkerPosition(curPos)
94
96
  setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
95
97
  } else {
@@ -153,6 +155,13 @@ export const GoogleMap = (props: GoogleMapsParams) => {
153
155
  Geocoder.init(googleMapsApiKey)
154
156
  }, [])
155
157
 
158
+ useEffect(() => {
159
+ mapRef.current.animateToRegion({
160
+ ...region,
161
+ latitude: location?.lat,
162
+ longitude: location?.lng,
163
+ })
164
+ }, [location])
156
165
 
157
166
  useEffect(() => {
158
167
  if (saveLocation) {
@@ -20,7 +20,7 @@ export const NotFoundSource = (props: NotFoundSourceParams) => {
20
20
  const theme = useTheme();
21
21
 
22
22
  const errorImage = image || theme.images.general.notFound
23
- const isUrl = errorImage.includes('http')
23
+ const isUrl = typeof errorImage === 'string' && errorImage.includes('http')
24
24
 
25
25
  return (
26
26
  <NotFound>
@@ -68,6 +68,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
68
68
  },
69
69
  statusBar: {
70
70
  height: 12,
71
+ borderRadius: 8
71
72
  },
72
73
  logo: {
73
74
  width: 75,
@@ -13,7 +13,7 @@ import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, R
13
13
  import { StyleSheet, View, TouchableOpacity, Image, Animated } from 'react-native';
14
14
  import { InView } from 'react-native-intersection-observer'
15
15
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
16
- import { OButton, OText } from '../shared';
16
+ import { OButton, OIcon, OText } from '../shared';
17
17
  import FastImage from 'react-native-fast-image'
18
18
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
19
19
  import { shape } from '../../utils';
@@ -179,8 +179,10 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
179
179
  )}
180
180
  </View>
181
181
  <PricesContainer>
182
- <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
183
- {product?.offer_price !== null && product?.in_offer && (
182
+ {!!product?.price && (
183
+ <OText color={theme.colors.primary}>{parsePrice(product?.price)}</OText>
184
+ )}
185
+ {product?.offer_price !== null && !!product?.in_offer && (
184
186
  <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
185
187
  )}
186
188
  </PricesContainer>
@@ -204,7 +206,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
204
206
  )}
205
207
  </CardInfo>
206
208
  <LogoWrapper>
207
- {product?.ribbon?.enabled && (
209
+ {!!product?.ribbon?.enabled && (
208
210
  <RibbonBox
209
211
  bgColor={product?.ribbon?.color}
210
212
  isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
@@ -222,16 +224,21 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
222
224
  </OText>
223
225
  </RibbonBox>
224
226
  )}
225
- {(product?.images || theme?.images?.dummies?.product) && (
226
- <FastImage
227
- style={styles.productStyle}
228
- source={{
229
- uri: optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_250,c_limit'),
230
- priority: FastImage.priority.normal,
231
- }}
232
- resizeMode={FastImage.resizeMode.cover}
233
- />
234
- )}
227
+ {product?.images ? (
228
+ <FastImage
229
+ style={styles.productStyle}
230
+ source={{
231
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
232
+ priority: FastImage.priority.normal,
233
+ }}
234
+ resizeMode={FastImage.resizeMode.cover}
235
+ />
236
+ ) : (
237
+ <OIcon
238
+ src={theme?.images?.dummies?.product}
239
+ style={styles.productStyle}
240
+ />
241
+ )}
235
242
  </LogoWrapper>
236
243
 
237
244
  {(isSoldOut || maxProductQuantity <= 0) && (
@@ -150,7 +150,7 @@ const WalletsUI = (props: any) => {
150
150
  onPress={() => handleChangeTab(wallet)}
151
151
  >
152
152
  <OTab isSelected={tabSelected === wallet.type}>
153
- <OText size={18}>
153
+ <OText size={18} color={tabSelected === wallet.type && theme.colors.primary}>
154
154
  {walletName[wallet.type]?.name}
155
155
  </OText>
156
156
  </OTab>
@@ -165,7 +165,7 @@ const WalletsUI = (props: any) => {
165
165
  <OText size={20}>
166
166
  {`${t('LOYALTY_LEVEL_TITLE', 'Your level is')}:`}
167
167
  </OText>
168
- {loyaltyLevel.image ? (
168
+ {/* {loyaltyLevel.image ? (
169
169
  <FastImage
170
170
  style={styles.logoStyle}
171
171
  source={{
@@ -180,7 +180,7 @@ const WalletsUI = (props: any) => {
180
180
  source={theme.images.dummies.loyaltyLevel}
181
181
  resizeMode='contain'
182
182
  />
183
- )}
183
+ )} */}
184
184
  <OText
185
185
  size={22}
186
186
  weight='bold'
@@ -80,6 +80,7 @@ export interface AddressFormParams {
80
80
  saveAddress?: any,
81
81
  userCustomerSetup?: boolean,
82
82
  isRequiredField?: (field: string) => {},
83
+ showField?: (field: string) => {},
83
84
  isGuestUser?: boolean,
84
85
  useValidationFileds?: boolean,
85
86
  isSelectedAfterAdd?: boolean,