ordering-ui-react-native 0.20.1-release → 0.20.3-release

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.20.1-release",
3
+ "version": "0.20.3-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -156,6 +156,7 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
156
156
  user_id: user?.id,
157
157
  user_name: user?.name
158
158
  },
159
+ xappx: ordering?.appId,
159
160
  currency: configs?.stripe_currency?.value || currency,
160
161
  userToken: token,
161
162
  clientId: webviewPaymethod?.credentials?.client_id,
@@ -11,6 +11,7 @@ import {
11
11
  useToast,
12
12
  useLanguage,
13
13
  useUtils,
14
+ useConfig
14
15
  } from 'ordering-components/native';
15
16
  import {
16
17
  CenterView,
@@ -55,6 +56,7 @@ const ProfileUI = (props: ProfileParams) => {
55
56
  const [, t] = useLanguage();
56
57
  const [, { showToast }] = useToast();
57
58
  const [{ optimizeImage }] = useUtils();
59
+ const [{ configs }] = useConfig()
58
60
  const { errors } = useForm();
59
61
  const theme = useTheme();
60
62
 
@@ -70,7 +72,7 @@ const ProfileUI = (props: ProfileParams) => {
70
72
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
71
73
  const [phoneToShow, setPhoneToShow] = useState('');
72
74
  const [openModal, setOpenModal] = useState(false)
73
-
75
+ const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
74
76
  useEffect(() => {
75
77
  if (phoneInputData.phone.cellphone) {
76
78
  const codeNumberPhone = phoneInputData.phone.cellphone.slice(0, 3);
@@ -116,14 +118,14 @@ const ProfileUI = (props: ProfileParams) => {
116
118
  includeBase64: true,
117
119
  },
118
120
  (image: any) => {
119
- const response = image?.assets[0];
120
- if (response.didCancel) {
121
+ const response = image?.assets?.[0];
122
+ if (response?.didCancel) {
121
123
  console.log('User cancelled image picker');
122
- } else if (response.errorMessage) {
124
+ } else if (response?.errorMessage) {
123
125
  console.log('ImagePicker Error: ', response.errorMessage);
124
126
  showToast(ToastType.Error, response.errorMessage);
125
127
  } else {
126
- if (response.uri) {
128
+ if (response?.uri) {
127
129
  const url = `data:${response.type};base64,${response.base64}`;
128
130
  handleButtonUpdateClick(null, true, url);
129
131
  } else {
@@ -352,14 +354,15 @@ const ProfileUI = (props: ProfileParams) => {
352
354
  height={150}
353
355
  style={{ borderRadius: 7.2 }}
354
356
  />
355
-
356
- <OIconButton
357
- icon={theme.images.general.camera}
358
- borderColor={theme.colors.clear}
359
- iconStyle={{ width: 21, height: 21 }}
360
- style={{ maxWidth: 40 }}
361
- onClick={() => handleImagePicker()}
362
- />
357
+ {allowDriverUpdateData && (
358
+ <OIconButton
359
+ icon={theme.images.general.camera}
360
+ borderColor={theme.colors.clear}
361
+ iconStyle={{ width: 21, height: 21 }}
362
+ style={{ maxWidth: 40 }}
363
+ onClick={() => handleImagePicker()}
364
+ />
365
+ )}
363
366
  </CenterView>
364
367
 
365
368
  {user?.level === 4 && (
@@ -485,7 +488,7 @@ const ProfileUI = (props: ProfileParams) => {
485
488
  />
486
489
  </View>
487
490
  )}
488
- {!validationFields.loading && !isEdit && (
491
+ {!validationFields.loading && !isEdit && allowDriverUpdateData && (
489
492
  <EditButton>
490
493
  <OButton
491
494
  text={t('EDIT', 'Edit')}
@@ -100,7 +100,7 @@ import { MultiCart } from './src/components/MultiCart'
100
100
  import { PageBanner } from './src/components/PageBanner'
101
101
  import { USER_TYPE, ORDER_TYPES } from './src/config/constants'
102
102
  import { DatePickerUI } from './src/components/DatePicker'
103
-
103
+ import { WebsocketStatus } from './src/components/WebsocketStatus';
104
104
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from './src/components/OrderSummary/styles';
105
105
 
106
106
  import { FormInput, FormSide, ButtonsWrapper, LoginWith, OTab, OTabs } from './src/components/LoginForm/styles';
@@ -265,6 +265,7 @@ export {
265
265
  PageBanner,
266
266
  MyOrders,
267
267
  MultiCart,
268
+ WebsocketStatus,
268
269
  ORDER_TYPES,
269
270
  USER_TYPE,
270
271
 
@@ -1,27 +1,37 @@
1
1
  import React from 'react';
2
2
  import FastImage from 'react-native-fast-image'
3
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
+ import { StyleSheet, TouchableOpacity, useWindowDimensions } from 'react-native';
4
4
  import {
5
5
  AddressDetails as AddressDetailsController,
6
6
  useOrder,
7
7
  useLanguage,
8
8
  } from 'ordering-components/native';
9
+ import { useTheme } from 'styled-components/native';
9
10
 
10
11
  import { ADContainer, ADHeader, ADAddress, ADMap } from './styles';
11
-
12
- import { useTheme } from 'styled-components/native';
13
- import { OText, OIcon } from '../shared';
14
- import { useWindowDimensions } from 'react-native';
12
+ import { OText } from '../shared';
13
+ import { getTypesText } from '../../utils';
15
14
 
16
15
  const AddressDetailsUI = (props: any) => {
17
- const { navigation, addressToShow, isCartPending, googleMapsUrl, apiKey } =
18
- props;
16
+ const {
17
+ navigation,
18
+ addressToShow,
19
+ isCartPending,
20
+ googleMapsUrl,
21
+ apiKey
22
+ } = props;
19
23
 
20
24
  const theme = useTheme();
21
25
  const [orderState] = useOrder();
26
+ const [{ options }] = useOrder();
22
27
  const [, t] = useLanguage();
23
28
  const { width } = useWindowDimensions();
24
29
 
30
+ const orderTypeText = {
31
+ key: getTypesText(options?.type || 1),
32
+ value: t(getTypesText(options?.type || 1), 'Delivery')
33
+ }
34
+
25
35
  const styles = StyleSheet.create({
26
36
  productStyle: {
27
37
  width,
@@ -39,7 +49,7 @@ const AddressDetailsUI = (props: any) => {
39
49
  lineHeight={24}
40
50
  color={theme.colors.textNormal}
41
51
  >
42
- {t('DELIVERY_ADDRESS', 'Delivery address')}
52
+ {t(`${orderTypeText.key}_ADDRESS`, `${orderTypeText.value} address`)}
43
53
  </OText>
44
54
  )}
45
55
  </ADHeader>
@@ -247,7 +247,7 @@ export const BusinessBasicInformation = (
247
247
  <View style={styles.tiktokIcon}>
248
248
  <OIcon
249
249
  src={theme.images.general.tiktok}
250
- style={{ width: 10, height: 12 }}
250
+ style={{ width: 10, height: 12, bottom: 1 }}
251
251
  cover
252
252
  />
253
253
  </View>
@@ -237,7 +237,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
237
237
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
238
238
  <SingleProductCard
239
239
  key={`${product?.id}_${i}`}
240
- enableIntersection={!isFiltMode}
240
+ // enableIntersection={!isFiltMode}
241
241
  isSoldOut={product.inventoried && !product.quantity}
242
242
  businessId={businessId}
243
243
  product={product}
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react'
2
- import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView, Keyboard, KeyboardEvent, BackHandler } from 'react-native'
2
+ import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView, Keyboard, KeyboardEvent, BackHandler, ScrollView } from 'react-native'
3
3
  import { IOScrollView } from 'react-native-intersection-observer'
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
5
  import { useTheme } from 'styled-components/native';
@@ -534,7 +534,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
534
534
  </View>
535
535
  </FiltProductsContainer>
536
536
  )}
537
- <IOScrollView
537
+ <ScrollView
538
538
  stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 : 3]}
539
539
  style={{
540
540
  ...styles.mainContainer,
@@ -662,7 +662,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
662
662
  {isOpenFiltProducts && (
663
663
  <BackgroundGray isIos={Platform.OS === 'ios'} />
664
664
  )}
665
- </IOScrollView>
665
+ </ScrollView>
666
666
  {viewOrderButtonVisible && (
667
667
  <View style={{ marginBottom: 0 }}>
668
668
  <FloatingButton
@@ -219,7 +219,7 @@ const CartUI = (props: any) => {
219
219
 
220
220
  return (
221
221
  <CContainer>
222
- {openUpselling && (
222
+ {!!openUpselling && (
223
223
  <UpsellingProducts
224
224
  handleUpsellingPage={handleUpsellingPage}
225
225
  openUpselling={openUpselling}
@@ -859,7 +859,7 @@ const CheckoutUI = (props: any) => {
859
859
  {!cartState.loading && cart && (
860
860
  <ChSection>
861
861
  <ChCart>
862
- {cartsWithProducts && cart?.products?.length === 0 ? (
862
+ {cartsWithProducts?.length > 0 && cart?.products?.length === 0 ? (
863
863
  <NotFoundSource
864
864
  content={t('NOT_FOUND_CARTS', 'Sorry, You don\'t seem to have any carts.')}
865
865
  btnTitle={t('SEARCH_REDIRECT', 'Go to Businesses')}
@@ -937,13 +937,15 @@ const CheckoutUI = (props: any) => {
937
937
  </OText>
938
938
  )}
939
939
 
940
- {!cart?.valid_products && cart?.status !== 2 && (
941
- <OText
942
- color={theme.colors.error}
943
- size={12}
944
- >
945
- {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
946
- </OText>
940
+ {!cart?.valid_products && cart?.status !== 2 && cart?.total !== 0 && (
941
+ <>
942
+ <OText
943
+ color={theme.colors.error}
944
+ size={12}
945
+ >
946
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
947
+ </OText>
948
+ </>
947
949
  )}
948
950
  {cart?.valid_preorder !== undefined && !cart?.valid_preorder && (
949
951
  <OText
@@ -310,7 +310,7 @@ const MultiCheckoutUI = (props: any) => {
310
310
  </TopHeader>
311
311
  </View>
312
312
  </SafeAreaView>
313
- <Container pt={0} noPadding onScroll={handleScroll}>
313
+ <Container pt={0} noPadding onScroll={handleScroll} showsVerticalScrollIndicator={false}>
314
314
  <View style={styles.wrapperNavbar}>
315
315
  <NavBar
316
316
  hideArrowLeft
@@ -62,8 +62,6 @@ import { IOScrollView } from 'react-native-intersection-observer';
62
62
 
63
63
  const windowWidth = Dimensions.get('window').width;
64
64
 
65
-
66
-
67
65
  export const ProductOptionsUI = (props: any) => {
68
66
  const {
69
67
  navigation,
@@ -441,7 +439,7 @@ export const ProductOptionsUI = (props: any) => {
441
439
  selOpt
442
440
  }
443
441
 
444
- const suboptionsLength = product.extras.reduce((acc : number, extras : any) => acc + extras?.options?.reduce((accSuboptions : number, options: any) => accSuboptions + options?.suboptions?.length, 0), 0)
442
+ const suboptionsLength = product?.extras?.reduce((acc : number, extras : any) => acc + extras?.options?.reduce((accSuboptions : number, options: any) => accSuboptions + options?.suboptions?.length, 0), 0)
445
443
 
446
444
  return (
447
445
  <SafeAreaView style={{ flex: 1 }}>
@@ -169,7 +169,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
169
169
  }
170
170
 
171
171
  return (
172
- <InView style={{ minHeight: hideAddButton ? 125 : 190, marginLeft: logoPosition === 'left' ? 12.5 : 0 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
172
+ <View style={{ minHeight: hideAddButton ? 125 : 190, marginLeft: logoPosition === 'left' ? 12.5 : 0 }}>
173
173
  {isIntersectionObserver ? (
174
174
  <CardAnimation
175
175
  onClick={() => handleClickproduct()}
@@ -340,7 +340,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
340
340
  </Placeholder>
341
341
  </View>
342
342
  )}
343
- </InView>
343
+ </View>
344
344
  );
345
345
  }, SingleProductCardPropsAreEqual);
346
346
 
@@ -20,7 +20,7 @@ import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
20
20
  import FontAwesome from 'react-native-vector-icons/FontAwesome'
21
21
  import FastImage from 'react-native-fast-image'
22
22
  import { OAlert } from '../../../../../src/components/shared'
23
-
23
+ import { WebsocketStatus } from '../WebsocketStatus'
24
24
  import {
25
25
  OIcon,
26
26
  OText,
@@ -270,6 +270,7 @@ const ProfileListUI = (props: ProfileParams) => {
270
270
  <View style={{ height: 17 }} />
271
271
  </Actions>
272
272
  </ListWrap>
273
+ <WebsocketStatus />
273
274
  <OAlert
274
275
  open={confirm.open}
275
276
  title={confirm.title}
@@ -0,0 +1,172 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage, useUtils, WebsocketStatus as WebsocketStatusController } from 'ordering-components/native'
3
+ import { TouchableOpacity, View, StyleSheet } from 'react-native'
4
+ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
5
+ import { useTheme } from 'styled-components/native'
6
+ import RNRestart from 'react-native-restart'
7
+ import { OModal, OButton, OText, OIcon } from '../shared'
8
+
9
+ import {
10
+ Container,
11
+ ModalContainer,
12
+ ModalTitle,
13
+ StatusItemWrapper,
14
+ StatusText
15
+ } from './styles'
16
+
17
+ const SocketStatusUI = (props: any) => {
18
+ const {
19
+ socketStatus,
20
+ connectedDate
21
+ } = props
22
+
23
+ const theme = useTheme()
24
+ const [, t] = useLanguage()
25
+ const [{ parseDate }] = useUtils()
26
+ const [openModal, setOpenModal] = useState(false)
27
+
28
+ const styles = StyleSheet.create({
29
+ btnBackArrow: {
30
+ borderWidth: 0,
31
+ width: 32,
32
+ height: 32,
33
+ tintColor: theme.colors.textGray,
34
+ backgroundColor: theme.colors.clear,
35
+ borderColor: theme.colors.clear,
36
+ shadowColor: theme.colors.clear,
37
+ paddingLeft: 0,
38
+ paddingRight: 0,
39
+ marginBottom: 30,
40
+ marginTop: 30
41
+ },
42
+ })
43
+
44
+ const getStatusColor = (status: number) => {
45
+ switch (status) {
46
+ case 0:
47
+ return '#FF9922';
48
+ case 1:
49
+ return '#00D27A';
50
+ case 2:
51
+ return '#E63757';
52
+ default:
53
+ return '#FF9922';
54
+ }
55
+ }
56
+
57
+ return (
58
+ <Container>
59
+ <TouchableOpacity
60
+ style={{
61
+ flexDirection: 'row',
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ backgroundColor: theme.colors.inputChat,
65
+ borderRadius: 7.6,
66
+ marginVertical: 10,
67
+ paddingVertical: 10,
68
+ paddingHorizontal: 15,
69
+ marginHorizontal: 15
70
+ }}
71
+ activeOpacity={0.6}
72
+ onPress={() => setOpenModal(true)}
73
+ >
74
+ <OText
75
+ style={{ color: theme.colors.backArrow, fontSize: 16, marginBottom: 0, lineHeight: 16 }}
76
+ >
77
+ {t('CONNECTION_STATUS', 'Status')}
78
+ </OText>
79
+ <MaterialIcon
80
+ name='circle'
81
+ size={12}
82
+ color={getStatusColor(socketStatus)}
83
+ style={{ marginLeft: 8 }}
84
+ />
85
+ </TouchableOpacity>
86
+
87
+ <OModal
88
+ open={openModal}
89
+ onClose={() => setOpenModal(false)}
90
+ entireModal
91
+ customClose
92
+ >
93
+ <ModalContainer nestedScrollEnabled={true}>
94
+ <TouchableOpacity
95
+ onPress={() => setOpenModal(false)}
96
+ style={styles.btnBackArrow}
97
+ >
98
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
99
+ </TouchableOpacity>
100
+ <View>
101
+ <ModalTitle>{t('CONNECTION_STATUS', 'Connection status')}</ModalTitle>
102
+ <OText style={{ marginBottom: 20 }}>
103
+ {t('LAST_UPDATE', 'Last update')}: {parseDate(connectedDate)}
104
+ </OText>
105
+ <StatusItemWrapper>
106
+ <MaterialIcon
107
+ name='circle'
108
+ size={12}
109
+ color={getStatusColor(1)}
110
+ style={{ marginTop: 10, marginHorizontal: 8 }}
111
+ />
112
+ <View style={{ marginLeft: 16 }}>
113
+ <StatusText>{t('OK', 'Ok')}</StatusText>
114
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_OK', 'The websocket works normally.')}</OText>
115
+ </View>
116
+ </StatusItemWrapper>
117
+ <StatusItemWrapper>
118
+ <MaterialIcon
119
+ name='circle'
120
+ size={12}
121
+ color={getStatusColor(0)}
122
+ style={{ marginTop: 10, marginHorizontal: 8 }}
123
+ />
124
+ <View style={{ marginLeft: 16 }}>
125
+ <StatusText>{t('CONNECTING', 'Connecting')}</StatusText>
126
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_CONNECTING', 'The websocket is connecting.')}</OText>
127
+ </View>
128
+ </StatusItemWrapper>
129
+ <StatusItemWrapper>
130
+ <MaterialIcon
131
+ name='circle'
132
+ size={12}
133
+ color={getStatusColor(2)}
134
+ style={{ marginTop: 10, marginHorizontal: 8 }}
135
+ />
136
+ <View style={{ marginLeft: 16 }}>
137
+ <StatusText>{t('DISCONNECTED', 'Disconnected')}</StatusText>
138
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_DISCONNECTED', 'The server is slow, please reload.')}</OText>
139
+ </View>
140
+ </StatusItemWrapper>
141
+
142
+ <View style={{ flexDirection: 'row', marginTop: 50 }}>
143
+ <OButton
144
+ onClick={() => setOpenModal(false)}
145
+ bgColor={theme.colors.white}
146
+ borderColor={theme.colors.primary}
147
+ textStyle={{ color: theme.colors.primary }}
148
+ style={{ borderRadius: 8, height: 48 }}
149
+ text={t('CLOSE', 'Close')}
150
+ />
151
+ <OButton
152
+ onClick={() => RNRestart.Restart()}
153
+ borderColor={theme.colors.primary}
154
+ textStyle={{ color: theme.colors.white }}
155
+ style={{ borderRadius: 8, marginLeft: 16, height: 48 }}
156
+ text={t('UPDATE', 'Update')}
157
+ />
158
+ </View>
159
+ </View>
160
+ </ModalContainer>
161
+ </OModal>
162
+ </Container>
163
+ )
164
+ }
165
+
166
+ export const WebsocketStatus = (props: any) => {
167
+ const socketProps = {
168
+ ...props,
169
+ UIComponent: SocketStatusUI
170
+ }
171
+ return <WebsocketStatusController {...socketProps} />
172
+ }
@@ -0,0 +1,28 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ display: flex;
5
+ flex-direction: column;
6
+ `
7
+ export const ModalContainer = styled.ScrollView`
8
+ padding: 0px 30px;
9
+ `
10
+ export const ModalTitle = styled.Text`
11
+ font-family: Poppins;
12
+ font-style: normal;
13
+ font-weight: bold;
14
+ font-size: 20px;
15
+ color: ${(props: any) => props.theme.colors.textGray};
16
+ margin-bottom: 10px;
17
+ `
18
+ export const StatusItemWrapper = styled.View`
19
+ flex-direction: row;
20
+ margin-bottom: 16px;
21
+ `
22
+ export const StatusText = styled.Text`
23
+ font-family: Poppins;
24
+ font-style: normal;
25
+ font-weight: 500;
26
+ font-size: 18px;
27
+ color: ${(props: any) => props.theme.colors.textGray};
28
+ `