ordering-ui-react-native 0.12.81 → 0.12.85

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.12.81",
3
+ "version": "0.12.85",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,6 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { OrderList, useLanguage, useOrder, ToastType, useToast } from 'ordering-components/native'
3
- import { OrderDetails as OrderDetailsConTableoller } from './naked'
2
+ import { useLanguage, useOrder, ToastType, useToast, OrderList, OrderDetails as OrderDetailsConTableoller } from 'ordering-components/native'
4
3
  import { useTheme } from 'styled-components/native';
5
4
  import { useFocusEffect } from '@react-navigation/native'
6
5
  import { OText, OModal } from '../shared'
@@ -65,8 +65,8 @@ export const BusinessBasicInformation = (
65
65
  <BusinessHeader
66
66
  style={
67
67
  isBusinessInfoShow
68
- ? {...styles.businesInfoheaderStyle, paddingTop: 0}
69
- : { ...styles.headerStyle, paddingTop: 0, backgroundColor: theme.colors.backgroundGray }
68
+ ? {...styles.businesInfoheaderStyle, paddingTop: Platform.OS === 'ios' ? 40 : 0}
69
+ : { ...styles.headerStyle, paddingTop: Platform.OS === 'ios' ? 40 : 0, backgroundColor: theme.colors.backgroundGray }
70
70
  }
71
71
  source={{
72
72
  uri:
@@ -170,7 +170,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
170
170
  ? t('SEARCH_REDIRECT', 'Go to Businesses')
171
171
  : t('CLEAR_FILTERS', 'Clear filters')
172
172
  }
173
- onClickButton={() =>
173
+ onClickButton={props.isSingleBusiness ? null : () =>
174
174
  !searchValue
175
175
  ? handleSearchRedirect && handleSearchRedirect()
176
176
  : handleCancelSearch && handleCancelSearch()
@@ -244,6 +244,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
244
244
  { id: 'featured', name: t('FEATURED', 'Featured') },
245
245
  ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
246
246
  ]}
247
+ isSingleBusiness={props.isSingleBusiness}
247
248
  category={categorySelected}
248
249
  categoryState={categoryState}
249
250
  businessId={business.id}
@@ -24,7 +24,11 @@ import { ProgressBar, TouchableRipple } from 'react-native-paper';
24
24
  import moment from 'moment';
25
25
 
26
26
  const BusinessReviewsUI = (props: BusinessReviewsParams) => {
27
- const { businessState, reviewsList } = props;
27
+ const {
28
+ reviewsList,
29
+ businessState,
30
+ handleChangeSearch,
31
+ } = props;
28
32
  const [, t] = useLanguage();
29
33
  const theme = useTheme();
30
34
  const [orderState] = useOrder();
@@ -146,11 +150,13 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
146
150
  </StarPointsView>
147
151
 
148
152
  <ReviewSearchView>
149
- <OInput
153
+ <OInput
150
154
  icon={theme.images.general.search}
151
155
  inputStyle={{ fontSize: 14 }}
152
156
  placeholder={t('SEARCH_REVIEWS', 'Search reviews')}
153
- style={{ paddingStart: 0 }}></OInput>
157
+ style={{ paddingStart: 0 }}
158
+ onChange={handleChangeSearch}
159
+ />
154
160
  </ReviewSearchView>
155
161
  <ReviewProgressView>
156
162
  <OText style={{ marginBottom: 6 }}>
@@ -1,5 +1,5 @@
1
- import React, { useState, useEffect, useCallback } from 'react';
2
- import moment, { Moment } from 'moment';
1
+ import React, { useState, useEffect } from 'react';
2
+ import moment from 'moment';
3
3
  import {
4
4
  useLanguage,
5
5
  useConfig,
@@ -9,19 +9,17 @@ import {
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
11
11
  import {
12
- ImageStore,
12
+ TouchableOpacity,
13
13
  StyleSheet,
14
14
  useWindowDimensions,
15
15
  View,
16
16
  } from 'react-native';
17
- import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
18
17
  import Spinner from 'react-native-loading-spinner-overlay';
19
18
  import { MomentOptionParams } from '../../types';
20
19
  import NavBar from '../NavBar';
21
20
  import { OIcon, OText } from '../shared';
22
21
  import { Container } from '../../layouts/Container';
23
22
  import {
24
- HeaderTitle,
25
23
  WrapSelectOption,
26
24
  Days,
27
25
  Day,
@@ -30,7 +28,6 @@ import {
30
28
  Hour,
31
29
  WrapDelveryTime,
32
30
  } from './styles';
33
- import CalendarPicker from 'react-native-calendar-picker';
34
31
  import { TouchableRipple } from 'react-native-paper';
35
32
 
36
33
  const MomentOptionUI = (props: MomentOptionParams) => {
@@ -65,6 +62,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
65
62
  paddingHorizontal: 12,
66
63
  paddingVertical: 9,
67
64
  marginBottom: 12,
65
+ marginHorizontal: 10,
66
+ marginTop: 10
68
67
  },
69
68
  dateWrap: {
70
69
  marginTop: 40,
@@ -89,6 +88,9 @@ const MomentOptionUI = (props: MomentOptionParams) => {
89
88
  const [{ configs }] = useConfig();
90
89
  const [{ parseTime }] = useUtils();
91
90
  const [orderState] = useOrder();
91
+ const { width } = useWindowDimensions();
92
+
93
+ const [toggleTime, setToggleTime] = useState(false);
92
94
  const [optionSelected, setOptionSelected] = useState({
93
95
  isAsap: false,
94
96
  isSchedule: false,
@@ -97,9 +99,9 @@ const MomentOptionUI = (props: MomentOptionParams) => {
97
99
  isLoading: 0,
98
100
  isEditing: false,
99
101
  });
100
- const { width } = useWindowDimensions();
101
-
102
- const [toggleTime, setToggleTime] = useState(false);
102
+ const momento = moment(`${dateSelected} ${timeSelected}`, 'YYYY-MM-DD HH:mm').toDate();
103
+ const momentUnix = momento.getTime() / 1000;
104
+ const momentFormat = moment.unix(momentUnix).utc().format('YYYY-MM-DD HH:mm:ss');
103
105
 
104
106
  const goToBack = () => navigation?.canGoBack() && navigation.goBack();
105
107
 
@@ -117,29 +119,6 @@ const MomentOptionUI = (props: MomentOptionParams) => {
117
119
  handleChangeTime(time);
118
120
  };
119
121
 
120
- const momento = moment(
121
- `${dateSelected} ${timeSelected}`,
122
- 'YYYY-MM-DD HH:mm',
123
- ).toDate();
124
- const momentUnix = momento.getTime() / 1000;
125
- const momentFormat = moment
126
- .unix(momentUnix)
127
- .utc()
128
- .format('YYYY-MM-DD HH:mm:ss');
129
-
130
- const getTwoChar = (ori: string) => {
131
- return ori.substring(0, 2);
132
- };
133
- const weekDays = [
134
- getTwoChar(t('SUNDAY_ABBREVIATION', 'Su')),
135
- getTwoChar(t('MONDAY_ABBREVIATION', 'Mo')),
136
- getTwoChar(t('TUESDAY_ABBREVIATION', 'Tu')),
137
- getTwoChar(t('WEDNESDAY_ABBREVIATION', 'We')),
138
- getTwoChar(t('THURSDAY_ABBREVIATION', 'Th')),
139
- getTwoChar(t('FRIDAY_ABBREVIATION', 'Fr')),
140
- getTwoChar(t('SATURDAY_ABBREVIATION', 'Sa')),
141
- ];
142
-
143
122
  useEffect(() => {
144
123
  if (orderState.options?.moment) {
145
124
  setOptionSelected({ isAsap: false, isSchedule: true });
@@ -161,15 +140,6 @@ const MomentOptionUI = (props: MomentOptionParams) => {
161
140
  }
162
141
  }, [momentState.isLoading]);
163
142
 
164
- const customDayHeaderStylesCallback = () => {
165
- return {
166
- textStyle: {
167
- color: theme.colors.disabled,
168
- fontSize: 12,
169
- },
170
- };
171
- };
172
-
173
143
  return (
174
144
  <Container style={{ paddingLeft: 40, paddingRight: 40 }}>
175
145
  <View style={{ paddingBottom: 10 }}>
@@ -200,7 +170,11 @@ const MomentOptionUI = (props: MomentOptionParams) => {
200
170
  style={{ marginEnd: 24 }}
201
171
  />
202
172
  )}
203
- <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${moment().format('dddd, MMM d, yyyy h:mm A')} + delivery time)`}</OText>
173
+ <OText
174
+ color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}
175
+ >
176
+ {t('ASAP_ABBREVIATION', 'ASAP') + ` (${moment().format('dddd, MMM D, yyyy h:mm A')} + delivery time)`}
177
+ </OText>
204
178
  </WrapSelectOption>
205
179
  <WrapSelectOption
206
180
  onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}
@@ -228,36 +202,31 @@ const MomentOptionUI = (props: MomentOptionParams) => {
228
202
  <View style={styles.dateLabel}>
229
203
  <OText size={12} color={theme.colors.disabled}>{dateSelected}</OText>
230
204
  </View>
231
- <CalendarPicker
232
- nextTitle=">"
233
- width={width - 80}
234
- previousTitle="<"
235
- nextComponent={
236
- <OIcon
237
- src={theme.images.general.chevron_right}
238
- color={theme.colors.disabled}
239
- width={12}
240
- style={{ marginHorizontal: 4 }}
241
- />
242
- }
243
- previousComponent={
244
- <OIcon
245
- src={theme.images.general.chevron_left}
246
- color={theme.colors.disabled}
247
- width={12}
248
- style={{ marginHorizontal: 4 }}
249
- />
250
- }
251
- onDateChange={(date: moment.Moment) =>
252
- handleChangeDate(date.format('YYYY-MM-DD'))
253
- }
254
- selectedDayColor={theme.colors.primaryContrast}
255
- todayBackgroundColor={theme.colors.border}
256
- dayLabelsWrapper={{ borderColor: theme.colors.clear }}
257
- customDayHeaderStyles={customDayHeaderStylesCallback}
258
- weekdays={weekDays}
259
- selectedStartDate={momento}
260
- />
205
+ <Days>
206
+ {datesList.slice(0, 6).map((date: any, i: any) => {
207
+ const dateParts = date.split('-')
208
+ const _date = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
209
+ const dayName = t('DAY' + (_date.getDay() >= 1 ? _date.getDay() : 7)).substring(0, 3).toUpperCase()
210
+ const dayNumber = (_date.getDate() < 10 ? '0' : '') + _date.getDate()
211
+ return (
212
+ <TouchableOpacity
213
+ key={dayNumber}
214
+ style={{ paddingHorizontal: 10, paddingBottom: 10, paddingTop: 10, borderColor: 'transparent', borderWidth: 1 }}
215
+ >
216
+ <Day onPress={() => handleChangeDate(date)} style={{ width: (width * 0.25) - 108 }}>
217
+ <OText
218
+ style={styles.dayNameStyle}
219
+ color={(dateSelected === date && optionSelected.isSchedule) ? theme.colors.primary : theme.colors.textSecondary}
220
+ >{dayName}</OText>
221
+ <OText
222
+ size={20}
223
+ color={(dateSelected === date && optionSelected.isSchedule) ? theme.colors.primary : theme.colors.textSecondary}
224
+ >{dayNumber}</OText>
225
+ </Day>
226
+ </TouchableOpacity>
227
+ )
228
+ })}
229
+ </Days>
261
230
  </View>
262
231
  )}
263
232
 
@@ -1,4 +1,4 @@
1
- import styled, { css } from 'styled-components/native'
1
+ import styled from 'styled-components/native'
2
2
 
3
3
  export const Container = styled.ScrollView`
4
4
  flex: 1;
@@ -16,23 +16,22 @@ export const WrapSelectOption = styled.TouchableOpacity`
16
16
  margin-vertical: 5px;
17
17
  `
18
18
  export const Days = styled.View`
19
- flex-wrap: wrap;
19
+ display: flex;
20
20
  flex-direction: row;
21
- margin-vertical: 10px;
21
+ width: 100%;
22
+ align-items: center;
23
+ flex-wrap: wrap;
22
24
  `
23
25
  export const Day = styled.TouchableOpacity`
24
26
  display: flex;
25
- flex-direction: column;
26
- align-items: center;
27
27
  justify-content: center;
28
- border-right-width: 1px;
29
- width: 25%;
30
- margin-vertical: 10px;
31
- border-color: ${(props: any) => props.theme.colors.textSecondary};
32
-
33
- ${(props: any) => props.borderLeftShow && css`
34
- border-left-width: 1px;
35
- `}
28
+ align-items: center;
29
+ padding-top: 10px;
30
+ border: 1px solid ${(props: any) => props.theme.colors.border};
31
+ text-transform: capitalize;
32
+ min-height: 60px;
33
+ min-width: 60px;
34
+ border-radius: 8px;
36
35
  `
37
36
  export const WrapHours = styled.ScrollView`
38
37
  border-width: 1px;
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  OrderTypeControl,
4
4
  useLanguage,
@@ -25,13 +25,14 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
25
25
  const theme = useTheme();
26
26
  const [orderState] = useOrder();
27
27
  const [, t] = useLanguage();
28
+ const [isTypeChanging, setTypeChanging] = useState(false);
28
29
  const _orderTypes = orderTypes.filter((type: any) => configTypes?.includes(type.value));
29
30
 
30
31
  const items = _orderTypes.map((type) => {
31
32
  return {
32
33
  value: type.value,
33
- label: t(type.content, type.content),
34
- description: t(type.description, 'Lorem ipsum dolor sit amet, consectetur.')
34
+ label: type.content,
35
+ description: type.description
35
36
  }
36
37
  })
37
38
 
@@ -40,9 +41,16 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
40
41
  const handleChangeOrderTypeCallback = (orderType: number) => {
41
42
  if (!orderState.loading) {
42
43
  handleChangeOrderType(orderType)
44
+ setTypeChanging(true)
43
45
  }
44
46
  }
45
47
 
48
+ useEffect(() => {
49
+ if (isTypeChanging && !orderState.loading) {
50
+ typeSelected === orderState?.options?.type && goToBack()
51
+ }
52
+ }, [orderState, typeSelected]);
53
+
46
54
  return (
47
55
  <Wrapper>
48
56
  <NavBar
@@ -81,11 +89,37 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
81
89
  }
82
90
 
83
91
  export const OrderTypeSelector = (props: any) => {
84
-
92
+ const [, t] = useLanguage()
85
93
  const orderTypeProps = {
86
94
  ...props,
87
95
  UIComponent: OrderTypeSelectorUI,
88
- orderTypes: props.orderType || ORDER_TYPES
96
+ orderTypes: props.orderTypes || [
97
+ {
98
+ value: 1,
99
+ content: t('DELIVERY', 'Delivery'),
100
+ description: t('ORDERTYPE_DESCRIPTION_DELIVERY', 'Lorem ipsum dolor sit amet, consectetur.')
101
+ },
102
+ {
103
+ value: 2,
104
+ content: t('PICKUP', 'Pickup'),
105
+ description: t('ORDERTYPE_DESCRIPTION_PICKUP', 'Lorem ipsum dolor sit amet, consectetur.')
106
+ },
107
+ {
108
+ value: 3,
109
+ content: t('EAT_IN', 'Eat in'),
110
+ description: t('ORDERTYPE_DESCRIPTION_EATIN', 'Lorem ipsum dolor sit amet, consectetur.')
111
+ },
112
+ {
113
+ value: 4,
114
+ content: t('CURBSIDE', 'Curbside'),
115
+ description: t('ORDERTYPE_DESCRIPTION_CURBSIDE', 'Lorem ipsum dolor sit amet, consectetur.')
116
+ },
117
+ {
118
+ value: 5,
119
+ content: t('DRIVE_THRU', 'Drive thru'),
120
+ description: t('ORDERTYPE_DESCRIPTION_DRIVETHRU', 'Lorem ipsum dolor sit amet, consectetur.')
121
+ }
122
+ ]
89
123
  }
90
124
 
91
125
  return <OrderTypeControl {...orderTypeProps} />
@@ -259,7 +259,10 @@ export const ProductOptionsUI = (props: any) => {
259
259
  }, []);
260
260
 
261
261
  return (
262
- <>
262
+ <KeyboardAvoidingView
263
+ enabled
264
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
265
+ >
263
266
  <ScrollView ref={scrollViewRef}>
264
267
  {!error && (
265
268
  <>
@@ -710,7 +713,7 @@ export const ProductOptionsUI = (props: any) => {
710
713
  </View>
711
714
  </ProductActions>
712
715
  )}
713
- </>
716
+ </KeyboardAvoidingView>
714
717
  );
715
718
  };
716
719
 
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react'
1
+ import React, { useState, useEffect, useRef } from 'react'
2
2
  import { OrderReview as ReviewOrderController, useLanguage, useToast, ToastType } from 'ordering-components/native'
3
3
  import { useForm, Controller } from 'react-hook-form'
4
4
  import LinearGradient from 'react-native-linear-gradient'
@@ -14,7 +14,7 @@ import {
14
14
  RatingTextContainer
15
15
  } from './styles'
16
16
  import { OButton, OIcon, OInput, OText } from '../shared'
17
- import { TouchableOpacity, StyleSheet, View, I18nManager } from 'react-native';
17
+ import { TouchableOpacity, StyleSheet, View, I18nManager, Keyboard } from 'react-native';
18
18
  import NavBar from '../NavBar'
19
19
  import { FloatingBottomContainer } from '../../../../../src/layouts/FloatingBottomContainer'
20
20
  import Spinner from 'react-native-loading-spinner-overlay'
@@ -90,6 +90,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
90
90
  const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
91
91
  const [comments, setComments] = useState<Array<any>>([])
92
92
  const [extraComment, setExtraComment] = useState('')
93
+ const scrollViewRef = useRef<any>()
93
94
 
94
95
  const onSubmit = () => {
95
96
  if (Object.values(stars).some((value: any) => value === 0)) {
@@ -199,9 +200,23 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
199
200
  setStars({ ...stars, comments: _comment })
200
201
  }, [comments, extraComment])
201
202
 
203
+ useEffect(() => {
204
+ const keyboardDidShowListener = Keyboard.addListener(
205
+ 'keyboardDidShow',
206
+ () => {
207
+ scrollViewRef?.current && scrollViewRef?.current?.scrollToEnd()
208
+ }
209
+ );
210
+
211
+ return () => {
212
+ keyboardDidShowListener.remove();
213
+ };
214
+ }, []);
215
+
216
+
202
217
  return (
203
218
  <>
204
- <ReviewOrderContainer>
219
+ <ReviewOrderContainer ref={scrollViewRef}>
205
220
  <NavBar
206
221
  title={t('REVIEW_ORDER', 'Review Order')}
207
222
  titleAlign={'center'}
@@ -161,6 +161,7 @@ export interface BusinessProductsListingParams {
161
161
  categorySelected: any;
162
162
  handleSearchRedirect: any;
163
163
  errorQuantityProducts?: boolean;
164
+ isSingleBusiness?: boolean;
164
165
  isFranchiseApp?: boolean;
165
166
  header?: any;
166
167
  logo?: any;
@@ -207,6 +208,7 @@ export interface BusinessProductsListParams {
207
208
  handleClearSearch?: (value: any) => {};
208
209
  isBusinessLoading?: any,
209
210
  errorQuantityProducts?: boolean,
211
+ isSingleBusiness?: boolean,
210
212
  handleCancelSearch?: () => void
211
213
  categoriesLayout?: any
212
214
  setCategoriesLayout?: any
@@ -227,6 +229,7 @@ export interface BusinessInformationParams {
227
229
  export interface BusinessReviewsParams {
228
230
  businessState: { business: any, loading: boolean, error: null };
229
231
  reviewsList: { reviews: any, loading: boolean, error: null };
232
+ handleChangeSearch: any;
230
233
  }
231
234
  export interface SearchBarParams {
232
235
  searchValue?: any;