ordering-ui-react-native 0.15.37 → 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.37",
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",
@@ -192,9 +192,11 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
192
192
  </View>
193
193
  ) : (
194
194
  <View style={styles.bullet}>
195
- <OText size={10} color={theme.colors.textSecondary}>
196
- {`${t('DELIVERY_FEE', 'Delivery fee')} ${parsePrice(businessDeliveryPrice ?? business?.delivery_price) + ' \u2022 '}`}
197
- </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
+ )}
198
200
  <OText size={10} color={theme.colors.textSecondary}>{`${convertHoursToMinutes(
199
201
  orderState?.options?.type === 1
200
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' }}