ordering-ui-react-native 0.15.35 → 0.15.38

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.15.35",
3
+ "version": "0.15.38",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -7,11 +7,15 @@ import { SignupForm } from './src/components/SignupForm';
7
7
  import { ActiveOrders } from './src/components/ActiveOrders';
8
8
  import { AddressList } from './src/components/AddressList';
9
9
  import { AppleLogin } from './src/components/AppleLogin';
10
+ import { BusinessBasicInformation } from './src/components/BusinessBasicInformation';
11
+ import { BusinessProductsCategories } from './src/components/BusinessProductsCategories';
12
+ import { BusinessProductsList } from './src/components/BusinessProductsList';
10
13
  import { BusinessesListing } from './src/components/BusinessesListing';
11
14
  import { BusinessProductsListing } from './src/components/BusinessProductsListing';
12
15
  import { CartContent } from './src/components/CartContent';
13
16
  import { BusinessCart } from './src/components/BusinessCart';
14
17
  import { Checkout } from './src/components/Checkout';
18
+ import { FloatingButton } from './src/components/FloatingButton';
15
19
  import { ForgotPasswordForm } from './src/components/ForgotPasswordForm';
16
20
  import { MomentOption } from './src/components/MomentOption';
17
21
  import { OrdersOption } from './src/components/OrdersOption';
@@ -33,6 +37,7 @@ import { HelpOrder } from './src/components/HelpOrder';
33
37
  import { NetworkError } from './src/components/NetworkError';
34
38
  import { NotFoundSource } from './src/components/NotFoundSource';
35
39
  import { OrderTypeSelector } from './src/components/OrderTypeSelector';
40
+ import { SearchBar } from './src/components/SearchBar';
36
41
  import { Wallets } from './src/components/Wallets';
37
42
  import { PaymentOptionWallet } from './src/components/PaymentOptionWallet';
38
43
  import { ProductForm } from './src/components/ProductForm';
@@ -94,7 +99,7 @@ export {
94
99
  BusinessMenuList,
95
100
  UserProfile,
96
101
  MessageListing,
97
- Messages,
102
+ Messages,
98
103
  Help,
99
104
  HelpAccountAndPayment,
100
105
  HelpGuide,
@@ -108,6 +113,11 @@ export {
108
113
  UpsellingProducts,
109
114
  UserVerification,
110
115
  BusinessListingSearch,
116
+ BusinessBasicInformation,
117
+ BusinessProductsCategories,
118
+ BusinessProductsList,
119
+ FloatingButton,
120
+ SearchBar,
111
121
 
112
122
  // OComponents
113
123
  Toast,
@@ -4,6 +4,7 @@ import {
4
4
  useUtils,
5
5
  useOrder,
6
6
  useLanguage,
7
+ useConfig
7
8
  } from 'ordering-components/native';
8
9
  import { OIcon, OText } from '../shared';
9
10
  import { StyleSheet, View } from 'react-native';
@@ -44,6 +45,8 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
44
45
  const [orderState] = useOrder();
45
46
  const [, t] = useLanguage();
46
47
  const theme = useTheme()
48
+ const [{ configs }] = useConfig();
49
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
47
50
 
48
51
  const styles = StyleSheet.create({
49
52
  headerStyle: {
@@ -112,7 +115,7 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
112
115
  };
113
116
 
114
117
  const handleBusinessClick = (selectedBusiness: any) => {
115
- if (business?.open) handleClick && handleClick(selectedBusiness)
118
+ if (business?.open || !isPreOrderSetting) handleClick && handleClick(selectedBusiness)
116
119
  else {
117
120
  navigation.navigate('BusinessPreorder', { business: selectedBusiness, handleBusinessClick: handleClick })
118
121
  }
@@ -189,9 +192,11 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
189
192
  </View>
190
193
  ) : (
191
194
  <View style={styles.bullet}>
192
- <OText size={10} color={theme.colors.textSecondary}>
193
- {`${t('DELIVERY_FEE', 'Delivery fee')} ${parsePrice(businessDeliveryPrice ?? business?.delivery_price) + ' \u2022 '}`}
194
- </OText>
195
+ {orderState?.options?.type === 1 && (
196
+ <OText size={10} color={theme.colors.textSecondary}>
197
+ {`${t('DELIVERY_FEE', 'Delivery fee')} ${parsePrice(businessDeliveryPrice ?? business?.delivery_price) + ' \u2022 '}`}
198
+ </OText>
199
+ )}
195
200
  <OText size={10} color={theme.colors.textSecondary}>{`${convertHoursToMinutes(
196
201
  orderState?.options?.type === 1
197
202
  ? (businessDeliveryTime ?? business?.delivery_time)
@@ -137,6 +137,10 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
137
137
  }
138
138
  }, [filters, openFilters])
139
139
 
140
+ useEffect(() => {
141
+ handleSearchbusinessAndProducts(true)
142
+ }, [])
143
+
140
144
  const MaxSectionItem = ({ title, options, filter }: any) => {
141
145
  const parseValue = (option: number) => {
142
146
  return filter === 'max_distance'
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import { useLanguage, BusinessMenuListing } from 'ordering-components/native'
3
3
  import { OText } from '../shared'
4
4
  import { BusinessMenuListParams } from '../../types'
@@ -19,7 +19,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
19
19
 
20
20
  const [, t] = useLanguage()
21
21
  const theme = useTheme()
22
- const {top} = useSafeAreaInsets()
22
+ const { top } = useSafeAreaInsets()
23
23
 
24
24
  const styles = StyleSheet.create({
25
25
  container: {
@@ -36,7 +36,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
36
36
  height: 44,
37
37
  width: '100%'
38
38
  }
39
- })
39
+ })
40
40
 
41
41
  const dropDownIcon = () => {
42
42
  return (
@@ -48,12 +48,18 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
48
48
  )
49
49
  }
50
50
 
51
+ useEffect(() => {
52
+ if (!businessMenuList?.loading && businessMenuList?.menus?.length === 1){
53
+ setMenu(businessMenuList?.menus[0])
54
+ }
55
+ }, [businessMenuList?.menus])
56
+
51
57
  return (
52
58
  <>
53
59
  {businessMenuList.loading ? (
54
60
  <Placeholder Animation={Fade}>
55
61
  <View>
56
- <PlaceholderLine height={44}/>
62
+ <PlaceholderLine height={44} />
57
63
  </View>
58
64
  </Placeholder>
59
65
  ) : (
@@ -67,6 +73,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
67
73
  onSelect={(selectedItem, index) => {
68
74
  setMenu(selectedItem)
69
75
  }}
76
+ defaultValue={businessMenuList?.menus?.length === 1 && businessMenuList?.menus[0]}
70
77
  buttonTextAfterSelection={(selectedItem, index) => {
71
78
  return selectedItem.name
72
79
  }}
@@ -51,7 +51,8 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
51
51
  const [selectDate, setSelectedDate] = useState<any>(null)
52
52
  const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
53
53
  const [isEnabled, setIsEnabled] = useState(false)
54
- const {top} = useSafeAreaInsets()
54
+ const { top } = useSafeAreaInsets()
55
+ const showOrderTime = (selectedPreorderType === 1 && Object.keys(menu)?.length > 0) || selectedPreorderType === 0
55
56
  const styles = StyleSheet.create({
56
57
  container: {
57
58
  height: windowHeight,
@@ -373,78 +374,80 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
373
374
  />
374
375
  </MenuWrapper>
375
376
  )}
376
- <OrderTimeWrapper>
377
- <OText
378
- size={16}
379
- style={{
380
- fontWeight: '600',
381
- lineHeight: 24
382
- }}
383
- >
384
- {t('ORDER_TIME', 'Order time')}
385
- </OText>
386
- <View style={{ flex: 1 }}>
387
- {selectDate && datesWhitelist[0]?.start !== null && (
388
- <CalendarStrip
389
- scrollable
390
- style={styles.calendar}
391
- calendarHeaderContainerStyle={styles.calendarHeaderContainer}
392
- calendarHeaderStyle={styles.calendarHeader}
393
- dateNumberStyle={styles.dateNumber}
394
- dateNameStyle={styles.dateName}
395
- iconContainer={{ flex: 0.1 }}
396
- highlightDateNameStyle={styles.highlightDateName}
397
- highlightDateNumberStyle={styles.highlightDateNumber}
398
- dayContainerStyle={{ height: '100%' }}
399
- highlightDateContainerStyle={{ height: '100%' }}
400
- calendarHeaderFormat='MMMM, YYYY'
401
- iconStyle={{ borderWidth: 1 }}
402
- selectedDate={selectDate}
403
- datesWhitelist={datesWhitelist}
404
- disabledDateNameStyle={styles.disabledDateName}
405
- disabledDateNumberStyle={styles.disabledDateNumber}
406
- disabledDateOpacity={0.6}
407
- onDateSelected={(date) => onSelectDate(date)}
408
- leftSelector={<LeftSelector />}
409
- rightSelector={<RightSelector />}
410
- />
411
- )}
412
- </View>
413
- <TimeListWrapper nestedScrollEnabled={true}>
414
- {(isEnabled && timeList?.length > 0) ? (
415
- <TimeContentWrapper>
416
- {timeList.map((time: any, i: number) => (
417
- <TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
418
- <TimeItem active={timeSelected === time.value}>
419
- <OText
420
- size={14}
421
- color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
422
- style={{
423
- lineHeight: 24
424
- }}
425
- >{time.text}</OText>
426
- </TimeItem>
427
- </TouchableOpacity>
428
- ))}
429
- {timeList.length % 3 === 2 && (
430
- <TimeItem style={{ backgroundColor: 'transparent' }} />
431
- )}
432
- </TimeContentWrapper>
433
- ) : (
434
- <OText
435
- size={16}
436
- style={{
437
- fontWeight: '600',
438
- lineHeight: 24,
439
- marginBottom: 12,
440
- textAlign: 'center'
441
- }}
442
- >
443
- {t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
444
- </OText>
445
- )}
446
- </TimeListWrapper>
447
- </OrderTimeWrapper>
377
+ {showOrderTime && (
378
+ <OrderTimeWrapper>
379
+ <OText
380
+ size={16}
381
+ style={{
382
+ fontWeight: '600',
383
+ lineHeight: 24
384
+ }}
385
+ >
386
+ {t('ORDER_TIME', 'Order time')}
387
+ </OText>
388
+ <View style={{ flex: 1 }}>
389
+ {selectDate && datesWhitelist[0]?.start !== null && (
390
+ <CalendarStrip
391
+ scrollable
392
+ style={styles.calendar}
393
+ calendarHeaderContainerStyle={styles.calendarHeaderContainer}
394
+ calendarHeaderStyle={styles.calendarHeader}
395
+ dateNumberStyle={styles.dateNumber}
396
+ dateNameStyle={styles.dateName}
397
+ iconContainer={{ flex: 0.1 }}
398
+ highlightDateNameStyle={styles.highlightDateName}
399
+ highlightDateNumberStyle={styles.highlightDateNumber}
400
+ dayContainerStyle={{ height: '100%' }}
401
+ highlightDateContainerStyle={{ height: '100%' }}
402
+ calendarHeaderFormat='MMMM, YYYY'
403
+ iconStyle={{ borderWidth: 1 }}
404
+ selectedDate={selectDate}
405
+ datesWhitelist={datesWhitelist}
406
+ disabledDateNameStyle={styles.disabledDateName}
407
+ disabledDateNumberStyle={styles.disabledDateNumber}
408
+ disabledDateOpacity={0.6}
409
+ onDateSelected={(date) => onSelectDate(date)}
410
+ leftSelector={<LeftSelector />}
411
+ rightSelector={<RightSelector />}
412
+ />
413
+ )}
414
+ </View>
415
+ <TimeListWrapper nestedScrollEnabled={true}>
416
+ {(isEnabled && timeList?.length > 0) ? (
417
+ <TimeContentWrapper>
418
+ {timeList.map((time: any, i: number) => (
419
+ <TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
420
+ <TimeItem active={timeSelected === time.value}>
421
+ <OText
422
+ size={14}
423
+ color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
424
+ style={{
425
+ lineHeight: 24
426
+ }}
427
+ >{time.text}</OText>
428
+ </TimeItem>
429
+ </TouchableOpacity>
430
+ ))}
431
+ {timeList.length % 3 === 2 && (
432
+ <TimeItem style={{ backgroundColor: 'transparent' }} />
433
+ )}
434
+ </TimeContentWrapper>
435
+ ) : (
436
+ <OText
437
+ size={16}
438
+ style={{
439
+ fontWeight: '600',
440
+ lineHeight: 24,
441
+ marginBottom: 12,
442
+ textAlign: 'center'
443
+ }}
444
+ >
445
+ {t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
446
+ </OText>
447
+ )}
448
+ </TimeListWrapper>
449
+ </OrderTimeWrapper>
450
+ )}
448
451
  <OButton
449
452
  text={t('GO_TO_MENU', 'Go to menu')}
450
453
  textStyle={{ color: 'white' }}
@@ -17,6 +17,7 @@ import { SearchBar } from '../SearchBar'
17
17
  import { BusinessProductsCategories } from '../BusinessProductsCategories'
18
18
  import { BusinessProductsList } from '../BusinessProductsList'
19
19
  import { BusinessProductsListingParams } from '../../types'
20
+ import { _retrieveStoreData, _removeStoreData } from '../../providers/StoreUtil';
20
21
  import {
21
22
  TopHeader,
22
23
  WrapSearchBar,
@@ -50,7 +51,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
50
51
  const theme = useTheme();
51
52
  const [, t] = useLanguage()
52
53
  const [{ auth }] = useSession()
53
- const [orderState] = useOrder()
54
+ const [orderState, { clearCart }] = useOrder()
54
55
  const [{ parsePrice }] = useUtils()
55
56
  const [, { showToast }] = useToast()
56
57
  const [{ configs }] = useConfig()
@@ -163,6 +164,19 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
163
164
  navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
164
165
  }
165
166
 
167
+ const removeCartByReOrder = async () => {
168
+ const removeCardId = await _retrieveStoreData('remove-cartId')
169
+ if (currentCart && removeCardId) {
170
+ clearCart(removeCardId)
171
+ _removeStoreData('remove-cartId')
172
+ showToast(ToastType.Info, t('PRODUCT_REMOVED', 'Products removed from cart'))
173
+ }
174
+ }
175
+
176
+ useEffect(() => {
177
+ removeCartByReOrder()
178
+ }, [])
179
+
166
180
  return (
167
181
  <SafeAreaView
168
182
  style={{ flex: 1 }}
@@ -61,7 +61,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
61
61
  handleChangeSearch,
62
62
  businessId
63
63
  } = props;
64
-
64
+
65
65
  const theme = useTheme();
66
66
  const isFocused = useIsFocused();
67
67
  const appState = useRef(AppState.currentState)
@@ -120,7 +120,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
120
120
 
121
121
  const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
122
122
  Number(configs?.max_days_preorder?.value) > 0
123
-
123
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
124
124
  const timerId = useRef<any>(false)
125
125
  // const panResponder = useRef(
126
126
  // PanResponder.create({
@@ -266,25 +266,27 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
266
266
  style={{ marginStart: 8 }}
267
267
  />
268
268
  </WrapMomentOption>
269
- <WrapMomentOption
270
- onPress={() => handleMomentClick()}>
271
- <OText
272
- size={12}
273
- numberOfLines={1}
274
- ellipsizeMode="tail"
275
- color={theme.colors.textSecondary}>
276
- {orderState.options?.momentß
277
- ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
278
- : t('ASAP_ABBREVIATION', 'ASAP')}
279
- </OText>
280
- {isPreorderEnabled && (
281
- <OIcon
282
- src={theme.images.general.arrow_down}
283
- width={10}
284
- style={{ marginStart: 8 }}
285
- />
286
- )}
287
- </WrapMomentOption>
269
+ {isPreOrderSetting && (
270
+ <WrapMomentOption
271
+ onPress={() => handleMomentClick()}>
272
+ <OText
273
+ size={12}
274
+ numberOfLines={1}
275
+ ellipsizeMode="tail"
276
+ color={theme.colors.textSecondary}>
277
+ {orderState.options?.momentß
278
+ ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
279
+ : t('ASAP_ABBREVIATION', 'ASAP')}
280
+ </OText>
281
+ {isPreorderEnabled && (
282
+ <OIcon
283
+ src={theme.images.general.arrow_down}
284
+ width={10}
285
+ style={{ marginStart: 8 }}
286
+ />
287
+ )}
288
+ </WrapMomentOption>
289
+ )}
288
290
 
289
291
  {!businessId && (
290
292
  <SearchBar
@@ -1,10 +1,12 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { View, StyleSheet, BackHandler, Platform, Linking } from 'react-native';
3
3
  import LinearGradient from 'react-native-linear-gradient';
4
+ import { _setStoreData } from '../../providers/StoreUtil';
4
5
  import {
5
6
  useLanguage,
6
7
  OrderDetails as OrderDetailsConTableoller,
7
8
  useUtils,
9
+ useOrder,
8
10
  useConfig
9
11
  } from 'ordering-components/native';
10
12
  import { useTheme } from 'styled-components/native';
@@ -87,9 +89,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
87
89
  const [, t] = useLanguage();
88
90
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
89
91
  const [{ configs }] = useConfig();
92
+ const [{ carts }] = useOrder()
93
+
90
94
  const [isReviewed, setIsReviewed] = useState(false)
91
95
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
92
-
93
96
  const { order, businessData } = props.order;
94
97
 
95
98
  const walletName: any = {
@@ -362,7 +365,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
362
365
 
363
366
  useEffect(() => {
364
367
  if (reorderState?.error) {
365
- navigation.navigate('Business', { store: businessData?.slug })
368
+ const _businessId = 'businessId:' + businessData?.id
369
+ const _uuid = carts[_businessId]?.uuid
370
+ if (_uuid) {
371
+ _setStoreData('remove-cartId', JSON.stringify(_uuid))
372
+ navigation.navigate('Business', { store: businessData?.slug })
373
+ }
366
374
  }
367
375
  if (!reorderState?.error && reorderState?.result?.uuid) {
368
376
  onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
@@ -46,7 +46,6 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
46
46
  import { NotFoundSource } from '../NotFoundSource';
47
47
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
48
48
  import { useState } from 'react';
49
-
50
49
  const windowHeight = Dimensions.get('window').height;
51
50
  const windowWidth = Dimensions.get('window').width;
52
51
 
@@ -291,15 +290,23 @@ export const ProductOptionsUI = (props: any) => {
291
290
  if (img?.video) {
292
291
  const keys = img?.video.split('/')
293
292
  let _videoId = keys[keys.length - 1]
293
+
294
294
  if (_videoId.includes('watch')) {
295
- const __url = _videoId.split('=')[1]
296
- _videoId = __url
295
+ const __url = _videoId.split('=')[1]
296
+ _videoId = __url
297
+ } else if (_videoId.includes('?')) {
298
+ const __url = _videoId.split('?')[0]
299
+ _videoId = __url
300
+ }
301
+
302
+ if (_videoId.search(/&/i) >= 0) {
303
+ _videoId = _videoId.split('&')[0]
304
+ } else if (_videoId.search(/\?/i) >= 0) {
305
+ _videoId = _videoId.split('?')[0]
297
306
  }
298
- if (_videoId.includes('?')) {
299
- const __url = _videoId.split('?')[0]
300
- _videoId = __url
307
+ if ((_videoId.length === 11)) {
308
+ videoList.push(_videoId)
301
309
  }
302
- videoList.push(_videoId)
303
310
  }
304
311
  }
305
312
  }
@@ -338,9 +345,9 @@ export const ProductOptionsUI = (props: any) => {
338
345
  </OText>
339
346
  </TouchableOpacity>
340
347
  )}
341
- {options.map(({ id, name, respect_to }: any) => (
348
+ {options.map(({ id, name, respect_to, suboptions }: any) => (
342
349
  <React.Fragment key={`cont_key_${id}`}>
343
- {respect_to == null && (
350
+ {respect_to == null && suboptions?.length > 0 && (
344
351
  <TouchableOpacity
345
352
  key={`eopt_key_${id}`}
346
353
  onPress={() => setSelectedOpt(id)}