ordering-ui-react-native 0.15.8 → 0.15.11

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.8",
3
+ "version": "0.15.11",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -6,7 +6,7 @@ import { GiftedChat, Actions, InputToolbar, Composer, Send, Bubble, MessageImage
6
6
  import { USER_TYPE } from '../../config/constants'
7
7
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
8
8
  import { OIcon, OIconButton, OText, OButton } from '../shared'
9
- import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard,I18nManager } from 'react-native'
9
+ import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard, I18nManager } from 'react-native'
10
10
  import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles'
11
11
  import { MessagesParams } from '../../types'
12
12
 
@@ -36,6 +36,8 @@ const ORDER_STATUS: any = {
36
36
  19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
37
37
  20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
38
38
  21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
39
+ 22: 'ORDER_LOOKING_FOR_DRIVER',
40
+ 23: 'ORDER_DRIVER_ON_WAY'
39
41
  }
40
42
 
41
43
  const imgOptions = {
@@ -93,7 +95,7 @@ const MessagesUI = (props: MessagesParams) => {
93
95
  }
94
96
 
95
97
  const handleImagePicker = () => {
96
- launchImageLibrary(imgOptions, (response : any) => {
98
+ launchImageLibrary(imgOptions, (response: any) => {
97
99
  if (response.didCancel) {
98
100
  // showToast(ToastType.Error, response.errorMessage);
99
101
  } else if (response.errorMessage) {
@@ -119,10 +121,10 @@ const MessagesUI = (props: MessagesParams) => {
119
121
  const messageConsole = (message: any) => {
120
122
  return message.change?.attribute !== 'driver_id'
121
123
  ?
122
- `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
123
- filterSpecialStatus.includes(message.change.attribute) ?
124
- `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
125
- `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
124
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute) ?
125
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new || ''} ${t('MINUTES', 'Minutes')}` :
126
+ message.change.attribute === 'status' ? `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
127
+ : `${message.change.old} ${t('TO', 'to')} ${message.change.new || t('EMPTY', 'Empty')}`
126
128
  }`
127
129
  : message.change.new
128
130
  ?
@@ -133,13 +135,17 @@ const MessagesUI = (props: MessagesParams) => {
133
135
 
134
136
  useEffect(() => {
135
137
  let newMessages: Array<any> = []
136
- const console = `${t('ORDER_PLACED_FOR', 'Order placed for')} ${parseDate(order?.created_at)} ${t('VIA', 'Via')} ${order?.app_id ? t(order?.app_id.toUpperCase(), order?.app_id) : t('OTHER', 'Other')}`
138
+ const consoleText = `${t('ORDER_PLACED_FOR', 'Order placed for')} ${parseDate(order?.created_at)} ${t('VIA', 'Via')} ${order?.app_id ? t(order?.app_id.toUpperCase(), order?.app_id) : t('OTHER', 'Other')}`
137
139
  const firstMessage = {
138
140
  _id: 0,
139
- text: console,
141
+ text: consoleText,
140
142
  createdAt: order?.created_at,
141
- system: true
143
+ system: true,
144
+ user: {
145
+ _id: 0
146
+ }
142
147
  }
148
+
143
149
  messages.messages.map((message: any) => {
144
150
  let newMessage
145
151
  if (message.type !== 0 && (messagesToShow?.messages?.length || (message?.can_see?.includes('2')) || (message?.can_see?.includes('4') && type === USER_TYPE.DRIVER))) {
@@ -159,7 +165,9 @@ const MessagesUI = (props: MessagesParams) => {
159
165
  if (message.type === 0) {
160
166
  newMessage = firstMessage
161
167
  }
162
- newMessages = [...newMessages, newMessage]
168
+ if (newMessage) {
169
+ newMessages = [...newMessages, newMessage]
170
+ }
163
171
  })
164
172
  setFormattedMessages([...newMessages.reverse()])
165
173
  }, [messages.messages.length])
@@ -177,7 +185,7 @@ const MessagesUI = (props: MessagesParams) => {
177
185
  }
178
186
  }, [])
179
187
 
180
- const RenderActions = (props : any) => {
188
+ const RenderActions = (props: any) => {
181
189
  return (
182
190
  <Actions
183
191
  {...props}
@@ -210,7 +218,7 @@ const MessagesUI = (props: MessagesParams) => {
210
218
  )
211
219
  }
212
220
 
213
- const renderInputToolbar = (props : any) => (
221
+ const renderInputToolbar = (props: any) => (
214
222
  <InputToolbar
215
223
  {...props}
216
224
  containerStyle={{
@@ -271,7 +279,7 @@ const MessagesUI = (props: MessagesParams) => {
271
279
  <OText size={14}>{t('NOT_SEND_MESSAGES', 'You can\'t send messages because the order has ended')}</OText>
272
280
  </View>
273
281
  ) : (
274
- <View style={{flexDirection: 'row', width: '80%'}}>
282
+ <View style={{ flexDirection: 'row', width: '80%' }}>
275
283
  <Composer
276
284
  {...props}
277
285
  textInputStyle={{
@@ -308,20 +316,20 @@ const MessagesUI = (props: MessagesParams) => {
308
316
  alwaysShowSend
309
317
  containerStyle={styles.containerSend}
310
318
  >
311
- <OIconButton
312
- onClick={onSubmit}
313
- style={{
314
- height: 32,
315
- borderRadius: 25,
316
- opacity: (sendMessage?.loading || (message === '' && !image) || messages?.loading) ? 0.4 : 1,
317
- borderColor: theme.colors.primary,
318
- }}
319
- iconStyle={{ marginTop: 3, marginRight: 2 }}
320
- icon={!sendMessage?.loading ? paperIcon : undefined}
321
- RenderIcon={sendMessage?.loading ? () => <ActivityIndicator size='small' color={theme.colors.primary} /> : undefined}
322
- disabled={(sendMessage?.loading || (message === '' && !image) || messages?.loading)}
323
- disabledColor={theme.colors.white}
324
- />
319
+ <OIconButton
320
+ onClick={onSubmit}
321
+ style={{
322
+ height: 32,
323
+ borderRadius: 25,
324
+ opacity: (sendMessage?.loading || (message === '' && !image) || messages?.loading) ? 0.4 : 1,
325
+ borderColor: theme.colors.primary,
326
+ }}
327
+ iconStyle={{ marginTop: 3, marginRight: 2 }}
328
+ icon={!sendMessage?.loading ? paperIcon : undefined}
329
+ RenderIcon={sendMessage?.loading ? () => <ActivityIndicator size='small' color={theme.colors.primary} /> : undefined}
330
+ disabled={(sendMessage?.loading || (message === '' && !image) || messages?.loading)}
331
+ disabledColor={theme.colors.white}
332
+ />
325
333
  </Send>
326
334
  )
327
335
 
@@ -338,7 +346,7 @@ const MessagesUI = (props: MessagesParams) => {
338
346
  }}
339
347
  wrapperStyle={{
340
348
  left: { backgroundColor: '#f7f7f7', padding: 5, borderBottomLeftRadius: 0 },
341
- right: { backgroundColor: theme.colors.primary, padding: 5, borderBottomRightRadius: 0}
349
+ right: { backgroundColor: theme.colors.primary, padding: 5, borderBottomRightRadius: 0 }
342
350
  }}
343
351
  />
344
352
  )
@@ -357,7 +365,7 @@ const MessagesUI = (props: MessagesParams) => {
357
365
  <>
358
366
  <Wrapper>
359
367
  <Header>
360
- <OIcon
368
+ <OIcon
361
369
  url={type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo}
362
370
  width={60}
363
371
  height={60}
@@ -415,7 +423,7 @@ const styles = StyleSheet.create({
415
423
  justifyContent: 'center',
416
424
  marginHorizontal: 4
417
425
  },
418
- editButton : {
426
+ editButton: {
419
427
  borderRadius: 50,
420
428
  backgroundColor: '#E9ECEF',
421
429
  marginRight: 10,
@@ -47,6 +47,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
47
47
  const [optionSelected, setOptionSelected] = useState({ isAsap: false, isSchedule: false })
48
48
  const [momentState, setMomentState] = useState({ isLoading: 0, isEditing: false })
49
49
 
50
+ const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
51
+
50
52
  const goToBack = () => navigation?.canGoBack() && navigation.goBack()
51
53
 
52
54
  const _handleAsap = () => {
@@ -192,7 +194,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
192
194
  disabled={orderState.loading}
193
195
  >
194
196
  <OText color={timeSelected === hour.startTime ? theme.colors.primary : theme.colors.textSecondary}>
195
- {configs?.format_time?.value === '12' ? (
197
+ {is12hours ? (
196
198
  hour.startTime.includes('12')
197
199
  ? `${hour.startTime}PM`
198
200
  : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
@@ -387,7 +387,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
387
387
  <OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
388
388
  </View>
389
389
  )}
390
- {order?.comment && (
390
+ {!!order?.comment && (
391
391
  <View>
392
392
  <OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
393
393
  <OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
@@ -32,7 +32,8 @@ export const getTraduction = (key: string, t: any) => {
32
32
  ERROR_PLACE_PAY_WITH_CARD1: 'An error occurred while trying to pay by card',
33
33
  ERROR_PLACE_PAY_WITH_PAYPAL_CAPTURE: 'An error occurred while trying to pay by PayPal',
34
34
  ERROR_ADD_PRODUCT_VERY_FAR_FOR_DELIVERY: 'Error adding product, very far for delivery',
35
- ERROR_PRODUCT_NOT_FOUND: 'Error with the product'
35
+ ERROR_PRODUCT_NOT_FOUND: 'Error with the product',
36
+ ERROR_ADD_BUSINESS_INVALID: 'An error occurred with the business',
36
37
  }
37
38
 
38
39
  return keyList[key] ? t(key, keyList[key]) : t(key)
@@ -94,8 +94,8 @@ const ChatUI = (props: MessagesParams) => {
94
94
  Dimensions.get('window').width < Dimensions.get('window').height
95
95
  ? parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0))
96
96
  : parseInt(
97
- parseFloat(String(Dimensions.get('window').height)).toFixed(0),
98
- );
97
+ parseFloat(String(Dimensions.get('window').height)).toFixed(0),
98
+ );
99
99
 
100
100
  const [orientation, setOrientation] = useState<string>(
101
101
  Dimensions.get('window').width < Dimensions.get('window').height
@@ -218,7 +218,7 @@ const ChatUI = (props: MessagesParams) => {
218
218
  paddingLeft: 12,
219
219
  paddingRight: 5,
220
220
  },
221
- editButton : {
221
+ editButton: {
222
222
  borderRadius: 50,
223
223
  backgroundColor: '#E9ECEF',
224
224
  marginRight: 10,
@@ -366,15 +366,18 @@ const ChatUI = (props: MessagesParams) => {
366
366
  return 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS';
367
367
  case 21:
368
368
  return 'ORDER_CUSTOMER_ARRIVED_BUSINESS';
369
+ case 22:
370
+ return 'ORDER_LOOKING_FOR_DRIVER'
371
+ case 23:
372
+ return 'ORDER_DRIVER_ON_WAY'
369
373
  default:
370
374
  return ``;
371
375
  }
372
376
  }
373
377
 
374
378
  if (attribute === 'prepared_in' || attribute === 'delivered_in') {
375
- return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min} ${
376
- status > 60 ? 'hours' : 'minutes'
377
- }`;
379
+ return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min} ${status > 60 ? 'hours' : 'minutes'
380
+ }`;
378
381
  }
379
382
  };
380
383
 
@@ -400,30 +403,27 @@ const ChatUI = (props: MessagesParams) => {
400
403
  style={{ ...styles.firstMessageText, textAlign: 'center' }}>
401
404
  {message.change?.attribute !== 'driver_id'
402
405
  ? `${t('ORDER', 'Order')} ${t(
403
- message.change.attribute.toUpperCase(),
404
- message.change.attribute,
405
- )} ${t('CHANGED_FROM', 'Changed from')} ${
406
- message.change.old !== null
407
- ? t(
408
- getStatus(
409
- parseInt(message.change.old, 10),
410
- message.change?.attribute,
411
- ),
412
- )
413
- : '0'
414
- } ${t('TO', 'to')} ${t(
406
+ message.change.attribute.toUpperCase(),
407
+ message.change.attribute,
408
+ )} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null
409
+ ? t(
415
410
  getStatus(
416
- parseInt(message.change.new, 10),
411
+ parseInt(message.change.old, 10),
417
412
  message.change?.attribute,
418
413
  ),
419
- )}`
414
+ )
415
+ : '0'
416
+ } ${t('TO', 'to')} ${t(
417
+ getStatus(
418
+ parseInt(message.change.new, 10),
419
+ message.change?.attribute,
420
+ ),
421
+ )}`
420
422
  : message.change.new
421
- ? `${message.driver?.name} ${
422
- message.driver?.lastname !== null ? message.driver.lastname : ''
423
- } ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${
424
- message.comment ? message.comment.length : ''
423
+ ? `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''
424
+ } ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''
425
425
  }`
426
- : `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`}
426
+ : `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`}
427
427
  </OText>
428
428
  <OText size={10} color={'#aaa'} style={{ alignSelf: 'flex-start' }}>
429
429
  {parseTime(message?.created_at, { outputFormat: 'hh:mma' })}
@@ -928,8 +928,8 @@ const ChatUI = (props: MessagesParams) => {
928
928
  borderWidth: 0,
929
929
  opacity:
930
930
  sendMessage?.loading ||
931
- (message === '' && !image) ||
932
- messages?.loading
931
+ (message === '' && !image) ||
932
+ messages?.loading
933
933
  ? 0.6
934
934
  : 1,
935
935
  borderColor: theme.colors.transparent,
@@ -1034,7 +1034,7 @@ const ChatUI = (props: MessagesParams) => {
1034
1034
  <OIcon
1035
1035
  url={optimizeImage(
1036
1036
  order?.customer?.photo ||
1037
- theme?.images?.dummies?.customerPhoto,
1037
+ theme?.images?.dummies?.customerPhoto,
1038
1038
  'h_300,c_limit',
1039
1039
  )}
1040
1040
  style={styles.avatarIcon}
@@ -1141,7 +1141,7 @@ const ChatUI = (props: MessagesParams) => {
1141
1141
  backgroundColor={theme.colors.composerView}
1142
1142
  onEnd={handleEnd}
1143
1143
  />
1144
- <TouchableOpacity
1144
+ <TouchableOpacity
1145
1145
  style={{
1146
1146
  position: 'absolute',
1147
1147
  right: 35,
@@ -38,7 +38,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
38
38
  },
39
39
  });
40
40
 
41
- const _categories: any = business?.original?.categories;
41
+ const _categories: any = business?.categories;
42
42
  let _promos: any = [];
43
43
  _categories?.forEach((categ: any) => {
44
44
  const _featuredProds = categ?.products?.filter(
@@ -183,8 +183,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
183
183
  resetInactivityTimeout()
184
184
  navigation.navigate('Category', {
185
185
  category,
186
- categories: business.original.categories,
187
- businessId: business?.api?.businessId,
186
+ categories: business?.categories,
187
+ businessId: business?.id,
188
188
  businessSlug: business?.slug,
189
189
  clearInactivityTimeout,
190
190
  resetInactivityTimeout,
@@ -212,6 +212,7 @@ const CategoriesMenu = (props: any): React.ReactElement => {
212
212
  businessId={parseInt(businessId, 10)}
213
213
  businessSlug={businessSlug}
214
214
  onSave={() => {
215
+ showCartBottomSheet()
215
216
  setDrawerValues({ isOpen: !drawerState.isOpen, data: null })
216
217
  }}
217
218
  navigation={navigation}
@@ -87,7 +87,6 @@ export const ProductOptionsUI = (props: any) => {
87
87
  const isErrors = Object.values(errors).length > 0
88
88
  if (!isErrors) {
89
89
  handleSave && handleSave()
90
- showCartBottomSheet()
91
90
  return
92
91
  }
93
92
  }
@@ -58,9 +58,9 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
58
58
  const maxDistanceOptions = [1000, 2000, 5000, 'default']
59
59
  const maxTimeOptions = [5, 15, 30, 'default']
60
60
  const sortItems = [
61
- { text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: 'default' },
61
+ { text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: 'distance' },
62
62
  { text: t('DELIVERY_TIME', 'Delivery time'), value: 'delivery_time' },
63
- { text: t('PICKUP_TIME', 'Pickup time'), value: 'pickup_type' }
63
+ { text: t('PICKUP_TIME', 'Pickup time'), value: 'pickup_time' }
64
64
  ]
65
65
 
66
66
  const styles = StyleSheet.create({
@@ -396,7 +396,7 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
396
396
  <OText weight='bold' mBottom={7} size={16}>
397
397
  {t('SORT', 'Sort')}
398
398
  </OText>
399
- {sortItems?.map(item => (
399
+ {sortItems?.filter(item => !(orderState?.options?.type === 1 && item?.value === 'pickup_time') && !(orderState?.options?.type === 2 && item?.value === 'delivery_time'))?.map(item => (
400
400
  <TouchableOpacity
401
401
  key={item?.value}
402
402
  onPress={() => handleChangeFilters('orderBy', item?.value)}
@@ -39,7 +39,8 @@ import {
39
39
  ChCart,
40
40
  DeliveryOptionsContainer,
41
41
  DeliveryOptionItem,
42
- WalletPaymentOptionContainer
42
+ WalletPaymentOptionContainer,
43
+ CartHeader
43
44
  } from './styles';
44
45
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
45
46
 
@@ -570,9 +571,28 @@ const CheckoutUI = (props: any) => {
570
571
  />
571
572
  ) : (
572
573
  <>
573
- <OText size={16} lineHeight={24} color={theme.colors.textNormal}>
574
- {t('ORDER_SUMMARY', 'Order Summary')}
575
- </OText>
574
+ <CartHeader>
575
+ <OText
576
+ size={16}
577
+ lineHeight={24}
578
+ color={theme.colors.textNormal}
579
+ style={{ fontWeight: '500' }}
580
+ >
581
+ {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
582
+ </OText>
583
+ <TouchableOpacity
584
+ onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
585
+ >
586
+ <OText
587
+ size={10}
588
+ lineHeight={15}
589
+ color={theme.colors.primary}
590
+ style={{ textDecorationLine: 'underline' }}
591
+ >
592
+ {t('ADD_PRODUCTS', 'Add products')}
593
+ </OText>
594
+ </TouchableOpacity>
595
+ </CartHeader>
576
596
  {props.isFranchiseApp && (
577
597
  <TouchableOpacity
578
598
  onPress={() => setOpenChangeStore(true)}
@@ -105,3 +105,10 @@ export const DeliveryOptionItem = styled.View`
105
105
  flex-direction: row;
106
106
  background-color: ${(props : any) => props?.backgroundColor ?? '#fff'};
107
107
  `;
108
+
109
+ export const CartHeader = styled.View`
110
+ align-items: center;
111
+ flex-direction: row;
112
+ justify-content: space-between;
113
+ margin-bottom: 10px;
114
+ `
@@ -35,6 +35,8 @@ const ORDER_STATUS: any = {
35
35
  19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
36
36
  20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
37
37
  21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
38
+ 22: 'ORDER_LOOKING_FOR_DRIVER',
39
+ 23: 'ORDER_DRIVER_ON_WAY'
38
40
  }
39
41
 
40
42
  const filterSpecialStatus = ['prepared_in', 'delivered_in']