ordering-ui-react-native 0.16.78-release → 0.16.79-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.16.78-release",
3
+ "version": "0.16.79-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -29,6 +29,10 @@ import { ReviewCustomer } from '../ReviewCustomer'
29
29
 
30
30
  import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
31
31
 
32
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
33
+
34
+ const { useDeviceOrientation } = DeviceOrientationMethods
35
+
32
36
  interface OrderContent {
33
37
  order: any,
34
38
  logisticOrderStatus?: Array<number>,
@@ -44,7 +48,9 @@ export const OrderContentComponent = (props: OrderContent) => {
44
48
  const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
45
49
  const [{ parsePrice, parseNumber }] = useUtils();
46
50
  const [{ configs }] = useConfig();
47
- const distanceUnit = configs?.distance_unit?.value
51
+ const [orientationState] = useDeviceOrientation();
52
+
53
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
48
54
 
49
55
  const [openReviewModal, setOpenReviewModal] = useState(false)
50
56
 
@@ -103,7 +109,7 @@ export const OrderContentComponent = (props: OrderContent) => {
103
109
  }
104
110
 
105
111
  const onTextLayout = useCallback((e: any) => {
106
- setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
112
+ setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
107
113
  },[]);
108
114
 
109
115
  return (
@@ -3,6 +3,10 @@ import { View, Animated, TouchableOpacity } from 'react-native';
3
3
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
4
4
  import { useUtils, useLanguage } from 'ordering-components/native';
5
5
  import { useTheme } from 'styled-components/native';
6
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
7
+
8
+ const { useDeviceOrientation } = DeviceOrientationMethods
9
+
6
10
  import {
7
11
  Accordion,
8
12
  AccordionSection,
@@ -34,6 +38,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
34
38
  const [, t] = useLanguage();
35
39
  const theme = useTheme();
36
40
  const [{ parsePrice }] = useUtils();
41
+ const [orientationState] = useDeviceOrientation();
42
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
37
43
 
38
44
  const [isActive, setActiveState] = useState(false);
39
45
  const [isReadMore, setIsReadMore] = useState(false);
@@ -111,7 +117,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
111
117
  }, []);
112
118
 
113
119
  const onTextLayout = useCallback((e: any) => {
114
- setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
120
+ setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
115
121
  },[]);
116
122
 
117
123
  return (
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect, useRef } from 'react'
2
- import { StyleSheet, Platform, View, Dimensions } from 'react-native'
2
+ import { StyleSheet, Platform, View, Dimensions, Text } from 'react-native'
3
3
  import { useUtils, useLanguage, useConfig } from 'ordering-components/native'
4
4
  import { useTheme } from 'styled-components/native'
5
5
  import CalendarPicker from 'react-native-calendar-picker'
@@ -60,7 +60,12 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
60
60
  },
61
61
  photoStyle: {
62
62
  alignSelf: 'center'
63
- }
63
+ },
64
+ dropDownRow: {
65
+ color: theme.colors.primary,
66
+ fontSize: 14,
67
+ marginHorizontal: 0
68
+ },
64
69
  })
65
70
 
66
71
  const onDateChange = (date: any) => {
@@ -92,6 +97,28 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
92
97
  setIsEnabled(menu?.schedule?.[day]?.enabled || false)
93
98
  }
94
99
 
100
+ const getMomentTime = (time) => {
101
+ const _moment = moment(`${moment(selectDate).format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm').toDate()
102
+ return _moment
103
+ }
104
+
105
+ const isBusyTime = (professional, selectedMoment) => {
106
+ if (!selectedMoment) return false
107
+ const startDay = moment(selectedMoment).utc().format('d')
108
+ const isStartScheduleEnabled = professional?.schedule?.[startDay]?.enabled
109
+ if (!isStartScheduleEnabled) return true
110
+
111
+ if (professional?.busy_times?.length === 0) return false
112
+
113
+ const busyTimes = professional?.busy_times
114
+
115
+ const valid = busyTimes.some(item => {
116
+ return (moment.utc(item?.start).local().valueOf() <= moment(selectedMoment).valueOf() &&
117
+ moment(selectedMoment).valueOf() < moment.utc(item?.end).local().valueOf())
118
+ })
119
+ return valid
120
+ }
121
+
95
122
  const getTimes = (curdate: any, menu: any) => {
96
123
  validateSelectedDate(curdate, menu)
97
124
  const date = new Date()
@@ -238,10 +265,12 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
238
265
  paddingTop: 8,
239
266
  paddingHorizontal: 12
240
267
  }}
241
- rowTextStyle={{
242
- color: theme.colors.disabled,
243
- fontSize: 14,
244
- marginHorizontal: 0
268
+ renderCustomizedRowChild={(item, index) => {
269
+ return (
270
+ <Text style={[styles.dropDownRow, { color: isBusyTime(professional, getMomentTime(item.value)) ? theme.colors.lightGray : theme.colors.primary } ]}>
271
+ {item.text}
272
+ </Text>
273
+ )
245
274
  }}
246
275
  renderDropdownIcon={() => dropDownIcon()}
247
276
  dropdownOverlayColor='transparent'
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useRef } from 'react'
2
2
  import { useTheme } from 'styled-components/native'
3
- import { Platform, View, StyleSheet, Dimensions, ScrollView, TouchableOpacity } from 'react-native'
3
+ import { Platform, View, StyleSheet, Dimensions, ScrollView, TouchableOpacity, Text } from 'react-native'
4
4
  import { OText, OButton, OModal, OIcon } from '../shared'
5
5
  import FastImage from 'react-native-fast-image'
6
6
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
@@ -110,31 +110,41 @@ const ServiceFormUI = (props: ServiceFormParams) => {
110
110
  height: 40,
111
111
  marginBottom: 30
112
112
  },
113
+ dropDownRow: {
114
+ color: theme.colors.primary,
115
+ fontSize: 14,
116
+ marginHorizontal: 0
117
+ },
113
118
  professionalList: {
114
119
  paddingHorizontal: 40,
115
- paddingVertical: 30
120
+ paddingVertical: 30,
116
121
  }
117
122
  })
118
123
 
119
- const isBusyTime = (professional: any) => {
120
- if (!dateSelected) return false
121
- const startDay = moment(dateSelected).utc().format('d')
124
+ const getMomentTime = (time) => {
125
+ const _moment = moment(`${moment(selectDate).format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm').toDate()
126
+ return _moment
127
+ }
128
+
129
+ const isBusyTime = (professional, selectedMoment) => {
130
+ if (!selectedMoment) return false
131
+ const startDay = moment(selectedMoment).utc().format('d')
122
132
  const isStartScheduleEnabled = professional?.schedule?.[startDay]?.enabled
123
133
  const duration = product?.duration ?? 0
124
- const endDay = moment(dateSelected).add(duration - 1, 'minutes').utc().format('d')
134
+ const endDay = moment(selectedMoment).add(duration - 1, 'minutes').utc().format('d')
125
135
  const isEndScheduleEnabled = professional?.schedule?.[endDay]?.enabled
126
136
  if (!isStartScheduleEnabled || !isEndScheduleEnabled) return true
127
137
 
128
138
  if (professional?.busy_times?.length === 0) return false
129
-
139
+
130
140
  const busyTimes = isCartProduct
131
- ? professional?.busy_times.filter((item: any) => !(item.start === productCart?.calendar_event?.start && item.end === productCart?.calendar_event?.end))
141
+ ? professional?.busy_times.filter(item => !(item.start === productCart?.calendar_event?.start && item.end === productCart?.calendar_event?.end))
132
142
  : [...professional?.busy_times]
133
- const valid = busyTimes.some((item: any) => {
134
- return (moment.utc(item?.start).local().valueOf() <= moment(dateSelected).valueOf() &&
135
- moment(dateSelected).valueOf() < moment.utc(item?.end).local().valueOf()) ||
136
- (moment.utc(item?.start).local().valueOf() <= moment(dateSelected).add(duration, 'minutes').valueOf() &&
137
- moment(dateSelected).add(duration, 'minutes').valueOf() < moment.utc(item?.end).local().valueOf())
143
+ const valid = busyTimes.some(item => {
144
+ return (moment.utc(item?.start).local().valueOf() <= moment(selectedMoment).valueOf() &&
145
+ moment(selectedMoment).valueOf() < moment.utc(item?.end).local().valueOf()) ||
146
+ (moment.utc(item?.start).local().valueOf() < moment(selectedMoment).add(duration, 'minutes').valueOf() &&
147
+ moment(selectedMoment).add(duration, 'minutes').valueOf() < moment.utc(item?.end).local().valueOf())
138
148
  })
139
149
  return valid
140
150
  }
@@ -391,9 +401,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
391
401
  size={12}
392
402
  weight={'400'}
393
403
  lineHeight={17}
394
- color={isBusyTime(currentProfessional) ? theme.colors.danger5 : theme.colors.success500}
404
+ color={isBusyTime(currentProfessional, dateSelected) ? theme.colors.danger5 : theme.colors.success500}
395
405
  >
396
- {isBusyTime(currentProfessional)
406
+ {isBusyTime(currentProfessional, dateSelected)
397
407
  ? t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')
398
408
  : t('AVAILABLE', 'Available')
399
409
  }
@@ -473,10 +483,12 @@ const ServiceFormUI = (props: ServiceFormParams) => {
473
483
  paddingTop: 8,
474
484
  paddingHorizontal: 12
475
485
  }}
476
- rowTextStyle={{
477
- color: theme.colors.disabled,
478
- fontSize: 14,
479
- marginHorizontal: 0
486
+ renderCustomizedRowChild={(item, index) => {
487
+ return (
488
+ <Text style={[styles.dropDownRow, { color: isBusyTime(currentProfessional, getMomentTime(item.value)) ? theme.colors.lightGray : theme.colors.primary } ]}>
489
+ {item.text}
490
+ </Text>
491
+ )
480
492
  }}
481
493
  renderDropdownIcon={() => dropDownIcon()}
482
494
  dropdownOverlayColor='transparent'
@@ -549,7 +561,7 @@ const ServiceFormUI = (props: ServiceFormParams) => {
549
561
  ? t('SOLD_OUT', 'Sold out')
550
562
  : t('BOOK', 'Book'))}
551
563
  style={styles.buttonStyle}
552
- isDisabled={isSoldOut || maxProductQuantity <= 0 || !currentProfessional?.id || !dateSelected || isBusyTime(currentProfessional)}
564
+ isDisabled={isSoldOut || maxProductQuantity <= 0 || !currentProfessional?.id || !dateSelected || isBusyTime(currentProfessional, dateSelected)}
553
565
  textStyle={{ fontSize: 14, color: theme.colors.white }}
554
566
  />
555
567
  )}
@@ -647,9 +659,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
647
659
  size={12}
648
660
  weight={'400'}
649
661
  lineHeight={17}
650
- color={isBusyTime(professional) ? theme.colors.danger5 : theme.colors.success500}
662
+ color={isBusyTime(professional, dateSelected) ? theme.colors.danger5 : theme.colors.success500}
651
663
  >
652
- {isBusyTime(professional)
664
+ {isBusyTime(professional, dateSelected)
653
665
  ? t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')
654
666
  : t('AVAILABLE', 'Available')
655
667
  }