ordering-ui-react-native 0.12.84 → 0.12.88

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.84",
3
+ "version": "0.12.88",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -46,7 +46,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
46
46
  const phoneNumber = customerCellphone;
47
47
  const titleOrder = t(orderTitle[action]?.key, orderTitle[action]?.text)
48
48
  const buttonText = t(orderTitle[action]?.btnKey, orderTitle[action]?.btnText)
49
- const showTextArea = ['reject', 'deliveryFailed', 'pickupFailed', 'notReady'].includes(action)
49
+ const showTextArea = ['reject', 'deliveryFailed', 'pickupFailed', 'notReady', 'forcePickUp', 'forceDelivery'].includes(action)
50
50
 
51
51
  const handleFocus = () => {
52
52
  viewRef?.current?.measure((x: any, y: any) => {
@@ -187,6 +187,14 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
187
187
  orderNotReady: {
188
188
  comment: comments,
189
189
  status: 14
190
+ },
191
+ forcePickUp: {
192
+ reasons: comments,
193
+ status: 9
194
+ },
195
+ forceDelivery: {
196
+ reasons: comments,
197
+ status: 11
190
198
  }
191
199
  };
192
200
 
@@ -205,6 +213,12 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
205
213
  if (actions && action === 'notReady') {
206
214
  bodyToSend = orderStatus[actions.notReady]
207
215
  }
216
+ if (actions && action === 'forcePickUp') {
217
+ bodyToSend = orderStatus[actions.forcePickUp]
218
+ }
219
+ if (actions && action === 'forceDelivery') {
220
+ bodyToSend = orderStatus[actions.forceDelivery]
221
+ }
208
222
 
209
223
  bodyToSend.id = orderId;
210
224
  handleUpdateOrder && handleUpdateOrder(bodyToSend.status, bodyToSend);
@@ -51,7 +51,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
51
51
  orderTitle,
52
52
  appTitle,
53
53
  handleClickLogisticOrder,
54
-
54
+ forceUpdate
55
55
  } = props;
56
56
  const [, { showToast }] = useToast();
57
57
  const { order } = props.order
@@ -214,6 +214,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
214
214
  }
215
215
  }, [messagesReadList]);
216
216
 
217
+ useEffect(() => {
218
+ forceUpdate && handleViewActionOrder && handleViewActionOrder(forceUpdate === 9 ? 'forcePickUp': 'forceDelivery')
219
+ },[forceUpdate])
220
+
217
221
  const styles = StyleSheet.create({
218
222
  btnPickUp: {
219
223
  borderWidth: 0,
@@ -8,6 +8,7 @@ const Wrapper = styled.View`
8
8
  `;
9
9
  const Inner = styled.TextInput`
10
10
  height: 100px;
11
+ padding: 5px 10px 5px 10px;
11
12
  `;
12
13
 
13
14
  interface Props {
@@ -370,7 +370,8 @@ export interface OrderDetailsParams {
370
370
  driverUpdateLocation?: any;
371
371
  setDriverUpdateLocation?: any;
372
372
  handleClickLogisticOrder?: (status: number, orderId: number) => void;
373
- orderTitle?: any
373
+ orderTitle?: any;
374
+ forceUpdate?: number;
374
375
  }
375
376
  export interface ProductItemAccordionParams {
376
377
  isCartPending?: boolean;
@@ -529,6 +530,8 @@ interface actions {
529
530
  pickupFailed: string;
530
531
  deliveryFailed: string;
531
532
  notReady: string;
533
+ forcePickUp: string;
534
+ forceDelivery: string;
532
535
  }
533
536
 
534
537
  interface textTranslate {
@@ -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()
@@ -210,6 +210,13 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
210
210
  noBorderShow
211
211
  placeholder={t('SEARCH', 'Search')}
212
212
  lazyLoad={businessState?.business?.lazy_load_products_recommended}
213
+ inputStyle={{
214
+ borderRadius: 8,
215
+ borderBottomWidth: 1,
216
+ borderBottomColor: theme.colors.border,
217
+ borderBottomLeftRadius: 0,
218
+ borderBottomRightRadius: 0,
219
+ }}
213
220
  />
214
221
  </WrapSearchBar>
215
222
  {!(business?.categories?.length === 0) && (
@@ -244,6 +251,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
244
251
  { id: 'featured', name: t('FEATURED', 'Featured') },
245
252
  ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
246
253
  ]}
254
+ isSingleBusiness={props.isSingleBusiness}
247
255
  category={categorySelected}
248
256
  categoryState={categoryState}
249
257
  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 }}>
@@ -106,10 +106,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
106
106
  color: theme.colors.warning5,
107
107
  marginRight: 8
108
108
  },
109
- farAwayMsg: {
110
- paddingVertical: 6,
111
- paddingHorizontal: 20
112
- }
113
109
  });
114
110
 
115
111
 
@@ -199,11 +195,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
199
195
  </OText>
200
196
  </AddressInput>
201
197
  {isFarAway && (
202
- <FarAwayMessage style={styles.farAwayMsg}>
203
- <Ionicons name='md-warning-outline' style={styles.iconStyle} />
204
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
205
- </FarAwayMessage>
206
- )}
198
+ <FarAwayMessage>
199
+ <Ionicons name='md-warning-outline' style={styles.iconStyle} />
200
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
201
+ </FarAwayMessage>
202
+ )}
207
203
  <OrderControlContainer>
208
204
  <View style={styles.wrapperOrderOptions}>
209
205
  <DropOptionButton
@@ -256,6 +252,13 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
256
252
  noBorderShow
257
253
  placeholder={t('SEARCH', 'Search')}
258
254
  lazyLoad
255
+ inputStyle={{
256
+ borderRadius: 8,
257
+ borderBottomWidth: 1,
258
+ borderBottomColor: theme.colors.border,
259
+ borderBottomLeftRadius: 0,
260
+ borderBottomRightRadius: 0,
261
+ }}
259
262
  />
260
263
  </WrapSearchBar>
261
264
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
@@ -23,7 +23,7 @@ export const AddressInput = styled.TouchableOpacity`
23
23
  justify-content: flex-start;
24
24
  background-color: white;
25
25
  padding-horizontal: 15px;
26
- border-radius: 24px;
26
+ border-radius: 8px;
27
27
  height: 44px;
28
28
  min-height: 44px;
29
29
  `
@@ -93,14 +93,16 @@ export const WrapSearchBar = styled.View`
93
93
  padding: 10px 30px;
94
94
  margin-bottom: 10px;
95
95
  background-color: ${(props: any) => props.theme.colors.white};
96
- flex: 1;
97
96
  `
98
97
 
99
98
  export const FarAwayMessage = styled.View`
99
+ display: flex;
100
100
  flex-direction: row;
101
101
  align-items: center;
102
102
  background-color: ${(props: any) => props.theme.colors.warning1};
103
- border-radius: 7.6px;
103
+ border-radius: 8px;
104
104
  border: 1px solid ${(props: any) => props.theme.colors.warning5};
105
105
  width: 100%;
106
+ padding: 6px 20px;
107
+ margin-top: 20px;
106
108
  `
@@ -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} />