ordering-ui-react-native 0.21.73 → 0.21.75

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.21.73",
3
+ "version": "0.21.75",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -389,6 +389,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
389
389
  <View style={styles.header}>
390
390
  <OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
391
391
  <IconWrapper>
392
+ <View style={{ marginRight: 10 }}>
393
+ <WebsocketStatus />
394
+ </View>
392
395
  <FeatherIcon
393
396
  name='refresh-cw'
394
397
  color={theme.colors.backgroundDark}
@@ -404,10 +407,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
404
407
  />
405
408
  </IconWrapper>
406
409
  </View>
407
- <WebsocketStatus />
408
410
  {configState?.configs?.order_deadlines_enabled?.value === '1' && (
409
411
  <View style={styles.SLAwrapper}>
410
- <View style={{ flex: 0.5 }}>
412
+ {/* <View style={{ flex: 0.5 }}>
411
413
  <OButton
412
414
  text={t('SLA_SETTING', 'SLA’s Settings')}
413
415
  textStyle={{ color: theme.colors.backArrow }}
@@ -421,9 +423,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
421
423
  }}
422
424
  onClick={onClickSetting}
423
425
  />
424
- </View>
425
- <View style={{ width: 10, height: '100%' }} />
426
- <View style={{ flex: 0.5, justifyContent: 'center' }}>
426
+ </View> */}
427
+ {/* <View style={{ width: 10, height: '100%' }} /> */}
428
+ {/* <View style={{ flex: 0.5, justifyContent: 'center' }}>
427
429
  <SelectDropdown
428
430
  defaultButtonText={t('SLA', 'SLA\'s')}
429
431
  data={preorderTypeList}
@@ -453,7 +455,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
453
455
  );
454
456
  }}
455
457
  />
456
- </View>
458
+ </View> */}
457
459
  </View>
458
460
  )}
459
461
  <FiltersTab>
@@ -713,6 +715,39 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
713
715
  {openSearchModal && (
714
716
  <SearchModalContent>
715
717
  <ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
718
+ <InputContainer style={{ marginBottom: 24 }}>
719
+ <SelectDropdown
720
+ defaultButtonText={search?.timeStatus
721
+ ? preorderTypeList.find(type => type.key === search?.timeStatus)?.name
722
+ : t('SLA', 'SLA\'s')}
723
+ data={preorderTypeList}
724
+ onSelect={(selectedItem, index) => {
725
+ setSearch({ ...search, timeStatus: selectedItem?.key })
726
+ }}
727
+ buttonTextAfterSelection={(selectedItem, index) => {
728
+ return selectedItem.name
729
+ }}
730
+ rowTextForSelection={(item, index) => {
731
+ return item.key
732
+ }}
733
+ buttonStyle={styles.selectOption}
734
+ buttonTextStyle={styles.buttonTextStyle}
735
+ renderDropdownIcon={isOpened => {
736
+ return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
737
+ }}
738
+ dropdownStyle={styles.dropdownStyle}
739
+ dropdownOverlayColor='transparent'
740
+ rowStyle={styles.rowStyle}
741
+ renderCustomizedRowChild={(item, index) => {
742
+ return (
743
+ <SlaOption>
744
+ {index !== 0 && <OrderStatus timeState={item?.key} />}
745
+ <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
746
+ </SlaOption>
747
+ );
748
+ }}
749
+ />
750
+ </InputContainer>
716
751
  <InputContainer>
717
752
  <OInput
718
753
  value={search.id}
@@ -153,10 +153,10 @@ export const OrderItem = React.memo((props: any) => {
153
153
  <Logo style={styles.logo}>
154
154
  <FastImage
155
155
  style={styles.icon}
156
- source={order.business?.logo ? {
157
- uri: optimizeImage(order.business?.logo, 'h_100,c_limit'),
156
+ source={order.business?.logo?.includes('https') ? {
157
+ uri: order.business?.logo,
158
158
  priority: FastImage.priority.normal,
159
- } : theme?.images?.dummies?.businessLogo}
159
+ } : order.business?.logo ?? theme?.images?.dummies?.businessLogo}
160
160
  resizeMode={FastImage.resizeMode.cover}
161
161
  />
162
162
  </Logo>
@@ -46,11 +46,10 @@ const ProfileUI = (props: ProfileParams) => {
46
46
  toggleIsEdit,
47
47
  cleanFormState,
48
48
  handleToggleAvalaibleStatusDriver,
49
- userState,
50
49
  isAlsea
51
50
  } = props;
52
51
 
53
- const [{ user }] = useSession();
52
+ const [{ user, sessionLoading }] = useSession();
54
53
  const [, t] = useLanguage();
55
54
  const [, { showToast }] = useToast();
56
55
  const [{ optimizeImage }] = useUtils();
@@ -67,6 +66,7 @@ const ProfileUI = (props: ProfileParams) => {
67
66
  },
68
67
  });
69
68
  const [phoneUpdate, setPhoneUpdate] = useState(false);
69
+ const [userState, setUserState] = useState(props.userState)
70
70
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
71
71
  const [phoneToShow, setPhoneToShow] = useState('');
72
72
  const [openModal, setOpenModal] = useState(false)
@@ -207,6 +207,22 @@ const ProfileUI = (props: ProfileParams) => {
207
207
  }
208
208
  }, [user?.country_phone_code]);
209
209
 
210
+ useEffect(() => {
211
+ setUserState({ ...userState, ...props.userState })
212
+ }, [props.userState])
213
+
214
+ useEffect(() => {
215
+ if (!user?.id) return
216
+
217
+ setUserState({
218
+ ...userState,
219
+ result: {
220
+ error: true,
221
+ result: user
222
+ }
223
+ })
224
+ }, [user, props.isFocused])
225
+
210
226
  const styles = StyleSheet.create({
211
227
  label: {
212
228
  color: theme.colors.textGray,
@@ -255,7 +271,7 @@ const ProfileUI = (props: ProfileParams) => {
255
271
  />
256
272
  )}
257
273
 
258
- {formState?.loading && !validationFields.error && (
274
+ {(formState?.loading || sessionLoading) && !validationFields.error && (
259
275
  <View
260
276
  style={{
261
277
  backgroundColor: theme.colors.backgroundLight,
@@ -326,7 +342,7 @@ const ProfileUI = (props: ProfileParams) => {
326
342
  </View>
327
343
  )}
328
344
 
329
- {!formState?.loading && !validationFields.error && (
345
+ {!(formState?.loading || sessionLoading) && !validationFields.error && (
330
346
  <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
331
347
  <CenterView>
332
348
  <OIcon
@@ -51,7 +51,7 @@ const SocketStatusUI = (props: any) => {
51
51
  return '#E63757';
52
52
  default:
53
53
  return '#FF9922';
54
- }
54
+ }
55
55
  }
56
56
 
57
57
  return (
@@ -73,7 +73,7 @@ const SocketStatusUI = (props: any) => {
73
73
  <OText
74
74
  style={{ color: theme.colors.backArrow, fontSize: 16, marginBottom: 0, lineHeight: 16 }}
75
75
  >
76
- {t('CONNECTION_STATUS', 'Connection status')}
76
+ {t('CONNECTION_STATUS_SHORT', 'Status')}
77
77
  </OText>
78
78
  <MaterialIcon
79
79
  name='circle'
@@ -58,6 +58,7 @@ export interface ProfileParams {
58
58
  isRequiredField?: any;
59
59
  isAlsea?: boolean;
60
60
  isShowDriverStatus?: boolean;
61
+ isFocused?: boolean;
61
62
  }
62
63
 
63
64
  export interface AddressListParams {
@@ -120,53 +120,55 @@ export const CartContent = (props: any) => {
120
120
  {isMultiCheckout && (
121
121
  <>
122
122
  {!!cartsAvailable.length && (
123
- <ChCartsTotal>
124
- {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
125
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
126
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
127
- {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
128
- </OText>
129
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
130
- {parsePrice(totalCartsFee)}
131
- </OText>
132
- </View>
133
- )}
134
- {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
135
- configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
123
+ <>
124
+ <ChCartsTotal>
125
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
136
126
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
137
127
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
138
- {t('DRIVER_TIP', 'Driver tip')}
128
+ {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
139
129
  </OText>
140
130
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
141
- {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
131
+ {parsePrice(totalCartsFee)}
142
132
  </OText>
143
133
  </View>
144
134
  )}
145
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
146
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
147
- {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
148
- </OText>
149
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
150
- </View>
151
- <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
152
- <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
153
- {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
154
- </OText>
155
- </View>
156
- </ChCartsTotal>
135
+ {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
136
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
137
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
138
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
139
+ {t('DRIVER_TIP', 'Driver tip')}
140
+ </OText>
141
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
142
+ {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
143
+ </OText>
144
+ </View>
145
+ )}
146
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
147
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
148
+ {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
149
+ </OText>
150
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
151
+ </View>
152
+ <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
153
+ <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
154
+ {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
155
+ </OText>
156
+ </View>
157
+ </ChCartsTotal>
158
+ <CheckoutAction style={{ marginTop: 0 }}>
159
+ <OButton
160
+ text={t('CHECKOUT', 'Checkout')}
161
+ bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
162
+ isDisabled={!cartsAvailable.length}
163
+ borderColor={theme.colors.primary}
164
+ imgRightSrc={null}
165
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
166
+ onClick={() => handleCheckoutRedirect()}
167
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
168
+ />
169
+ </CheckoutAction>
170
+ </>
157
171
  )}
158
- <CheckoutAction style={{ marginTop: 0 }}>
159
- <OButton
160
- text={t('CHECKOUT', 'Checkout')}
161
- bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
162
- isDisabled={!cartsAvailable.length}
163
- borderColor={theme.colors.primary}
164
- imgRightSrc={null}
165
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
166
- onClick={() => handleCheckoutRedirect()}
167
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
168
- />
169
- </CheckoutAction>
170
172
  </>
171
173
  )}
172
174
  </>
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect, useCallback, useRef } from 'react';
2
- import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard } from 'react-native';
2
+ import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler } from 'react-native';
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
5
5
  import Picker from 'react-native-country-picker-modal';
@@ -159,7 +159,7 @@ const CheckoutUI = (props: any) => {
159
159
  const [phoneUpdate, setPhoneUpdate] = useState(false);
160
160
  const [openChangeStore, setOpenChangeStore] = useState(false)
161
161
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
162
- const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
162
+ const [showGateway, setShowGateway] = useState<any>({ closedByUser: false, open: false });
163
163
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
164
164
  const [isOpen, setIsOpen] = useState(false)
165
165
  const [requiredFields, setRequiredFields] = useState<any>([])
@@ -431,6 +431,21 @@ const CheckoutUI = (props: any) => {
431
431
  }
432
432
  }, [])
433
433
 
434
+ useEffect(() => {
435
+ const onBackFunction = () => {
436
+ if (webviewPaymethod?.gateway === 'paypal' && showGateway.open) {
437
+ setShowGateway({ open: false, closedByUser: true })
438
+ return true
439
+ } else {
440
+ return false
441
+ }
442
+ }
443
+ BackHandler.addEventListener('hardwareBackPress', onBackFunction)
444
+ return () => {
445
+ BackHandler.removeEventListener('hardwareBackPress', onBackFunction)
446
+ }
447
+ }, [BackHandler, webviewPaymethod?.gateway, showGateway.open])
448
+
434
449
  return (
435
450
  <>
436
451
  <View style={styles.wrapperNavbar}>
@@ -12,6 +12,7 @@ import {
12
12
  } from 'ordering-components/native'
13
13
  import { View, StyleSheet, Platform, ScrollView } from 'react-native'
14
14
  import { useTheme } from 'styled-components/native';
15
+ import IconAntDesign from 'react-native-vector-icons/AntDesign';
15
16
  import { Container } from '../../layouts/Container';
16
17
  import NavBar from '../NavBar';
17
18
  import { OText, OIcon, OModal, OButton } from '../shared';
@@ -30,6 +31,8 @@ import { SignupForm } from '../SignupForm'
30
31
  import { LoginForm } from '../LoginForm'
31
32
 
32
33
  import {
34
+ TopHeader,
35
+ TopActions,
33
36
  ChContainer,
34
37
  ChSection,
35
38
  ChHeader,
@@ -76,7 +79,11 @@ const MultiCheckoutUI = (props: any) => {
76
79
  paddingLeft: 20,
77
80
  paddingRight: 20
78
81
  },
79
- wrapperNavbar: { paddingHorizontal: 20 },
82
+ wrapperNavbar: {
83
+ paddingHorizontal: 20,
84
+ backgroundColor: theme?.colors?.white,
85
+ borderWidth: 0
86
+ },
80
87
  detailWrapper: {
81
88
  paddingHorizontal: 20,
82
89
  width: '100%'
@@ -136,6 +143,7 @@ const MultiCheckoutUI = (props: any) => {
136
143
  ?.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
137
144
  ?.toFixed(configs.format_number_decimal_length?.value ?? 2)
138
145
 
146
+ const [showTitle, setShowTitle] = useState(false)
139
147
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
140
148
  const [phoneUpdate, setPhoneUpdate] = useState(false);
141
149
  const [userErrors, setUserErrors] = useState<any>([]);
@@ -233,6 +241,10 @@ const MultiCheckoutUI = (props: any) => {
233
241
  if (user) setOpenModal({ ...openModal, login: false })
234
242
  }
235
243
 
244
+ const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
245
+ setShowTitle(contentOffset.y > 30)
246
+ }
247
+
236
248
  useEffect(() => {
237
249
  if (validationFields && validationFields?.fields?.checkout) {
238
250
  checkValidationFields()
@@ -273,15 +285,42 @@ const MultiCheckoutUI = (props: any) => {
273
285
 
274
286
  return (
275
287
  <>
276
- <Container noPadding>
288
+ <View style={styles.wrapperNavbar}>
289
+ <TopHeader>
290
+ <>
291
+ <TopActions onPress={() => navigation?.canGoBack() && navigation.goBack()}>
292
+ <IconAntDesign
293
+ name='arrowleft'
294
+ size={26}
295
+ />
296
+ </TopActions>
297
+ {showTitle && (
298
+ <OText
299
+ size={16}
300
+ style={{ flex: 1, textAlign: 'center', right: 15 }}
301
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
302
+ numberOfLines={2}
303
+ ellipsizeMode='tail'
304
+ >
305
+ {t('CHECKOUT', 'Checkout')}
306
+ </OText>
307
+ )}
308
+ </>
309
+ </TopHeader>
310
+ </View>
311
+ <Container noPadding onScroll={handleScroll}>
277
312
  <View style={styles.wrapperNavbar}>
278
313
  <NavBar
314
+ hideArrowLeft
279
315
  title={t('CHECKOUT', 'Checkout')}
280
316
  titleAlign={'center'}
281
317
  onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
282
318
  showCall={false}
283
319
  paddingTop={Platform.OS === 'ios' ? 0 : 4}
284
320
  btnStyle={{ paddingLeft: 0 }}
321
+ titleWrapStyle={{ paddingHorizontal: 0 }}
322
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
323
+ style={{ marginTop: 20 }}
285
324
  />
286
325
  </View>
287
326
  <ChContainer style={styles.pagePadding}>
@@ -1,5 +1,22 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
+ export const TopActions = styled.TouchableOpacity`
4
+ height: 60px;
5
+ justify-content: center;
6
+ min-width: 30px;
7
+ padding-right: 15px;
8
+ `;
9
+
10
+ export const TopHeader = styled.View`
11
+ width: 100%;
12
+ flex-direction: row;
13
+ align-items: center;
14
+ justify-content: space-between;
15
+ z-index: 1;
16
+ height: 60px;
17
+ min-height: 60px;
18
+ `
19
+
3
20
  export const ChContainer = styled.View`
4
21
  margin-bottom: 60px;
5
22
  `
@@ -368,7 +368,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
368
368
  }, [order?.delivery_type])
369
369
 
370
370
  return (
371
- <SafeAreaView>
371
+ <>
372
372
  <View style={styles.wrapperNavbar}>
373
373
  <TopHeader>
374
374
  <>
@@ -1125,8 +1125,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1125
1125
  />
1126
1126
  </OModal>
1127
1127
  </OrderDetailsContainer>
1128
- </SafeAreaView>
1129
-
1128
+ </>
1130
1129
  );
1131
1130
  };
1132
1131