ordering-ui-react-native 0.24.1 → 0.24.3

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.24.1",
3
+ "version": "0.24.3",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -163,8 +163,8 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
163
163
  </TouchableOpacity>
164
164
  {(!order?.isLogistic || (!logisticOrderStatus?.includes(order?.status) && !order?.order_group)) && (
165
165
  <Actions>
166
- {getOrderStatus(order?.status, t)?.value !==
167
- t('PENDING', 'Pending') && (
166
+ {getOrderStatus(order?.status, t)?.slug !==
167
+ 'PENDING' && (
168
168
  <>
169
169
  <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
170
170
  <MaterialCommunityIcons
@@ -244,8 +244,8 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
244
244
 
245
245
  {(!order?.isLogistic || (!logisticOrderStatus?.includes(order?.status) && !order?.order_group)) && (
246
246
  <Actions>
247
- {getOrderStatus(order?.status, t)?.value !==
248
- t('PENDING', 'Pending') && (
247
+ {getOrderStatus(order?.status, t)?.slug !==
248
+ 'PENDING' && (
249
249
  <>
250
250
  <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
251
251
  <MaterialCommunityIcons
@@ -814,14 +814,14 @@ export const OrdersListManager = (props: OrdersOptionParams) => {
814
814
  {
815
815
  key: 18,
816
816
  text: t(
817
- 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
817
+ 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
818
818
  'Driver almost arrived to business',
819
819
  ),
820
820
  },
821
821
  {
822
822
  key: 19,
823
823
  text: t(
824
- 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
824
+ 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
825
825
  'Driver almost arrived to customer',
826
826
  ),
827
827
  },
@@ -1169,14 +1169,14 @@ export const OrdersOption = (props: OrdersOptionParams) => {
1169
1169
  {
1170
1170
  key: 18,
1171
1171
  text: t(
1172
- 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
1172
+ 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
1173
1173
  'Driver almost arrived to business',
1174
1174
  ),
1175
1175
  },
1176
1176
  {
1177
1177
  key: 19,
1178
1178
  text: t(
1179
- 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
1179
+ 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
1180
1180
  'Driver almost arrived to customer',
1181
1181
  ),
1182
1182
  },
@@ -158,19 +158,19 @@ export const PreviousMessages = (props: PreviousMessagesParams) => {
158
158
  {
159
159
  key: 18,
160
160
  value: t(
161
- 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
161
+ 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
162
162
  'Driver almost arrived to business',
163
163
  ),
164
- slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
164
+ slug: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
165
165
  percentage: 0.15,
166
166
  },
167
167
  {
168
168
  key: 19,
169
169
  value: t(
170
- 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
170
+ 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
171
171
  'Driver almost arrived to customer',
172
172
  ),
173
- slug: 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
173
+ slug: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
174
174
  percentage: 0.9,
175
175
  },
176
176
  {
@@ -301,19 +301,19 @@ export const getOrderStatus = (s: string, t: any) => {
301
301
  {
302
302
  key: 18,
303
303
  value: t(
304
- 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
304
+ 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
305
305
  'Driver almost arrived to business',
306
306
  ),
307
- slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
307
+ slug: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
308
308
  percentage: 0.15,
309
309
  },
310
310
  {
311
311
  key: 19,
312
312
  value: t(
313
- 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
313
+ 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
314
314
  'Driver almost arrived to customer',
315
315
  ),
316
- slug: 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
316
+ slug: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
317
317
  percentage: 0.9,
318
318
  },
319
319
  {
@@ -349,15 +349,50 @@ const AddressFormUI = (props: AddressFormParams) => {
349
349
  };
350
350
 
351
351
  const handleChangeAddress = (data: any, details: any) => {
352
- const addressSelected = {
353
- address: data?.description || data?.address,
354
- location: details?.geometry?.location,
355
- utc_offset: details?.utc_offset || null,
356
- map_data: { library: 'google', place_id: data.place_id },
357
- zip_code: data?.zip_code || null,
358
- };
359
- updateChanges(addressSelected);
360
- };
352
+ const addressObj : any = {}
353
+ if (details?.address_components) {
354
+ details.address_components.map((component: any) => {
355
+ const addressType = component.types[0]
356
+ if (addressType === 'postal_code') {
357
+ addressObj.zipcode = component.short_name
358
+ }
359
+ if (addressType === 'street_number') {
360
+ addressObj.street_number = component.long_name
361
+ }
362
+ if (addressType === 'neighborhood') {
363
+ addressObj.neighborhood = component.long_name
364
+ }
365
+ if (addressType === 'route') {
366
+ addressObj.route = component.short_name
367
+ }
368
+ if (addressType === 'locality') {
369
+ addressObj.locality = component.long_name
370
+ }
371
+ if (component.types?.includes('sublocality')) {
372
+ addressObj.sublocality = component.long_name
373
+ }
374
+ if (addressType === 'country') {
375
+ addressObj.country = component.long_name
376
+ addressObj.country_code = component.short_name
377
+ }
378
+ if (addressType === 'administrative_area_level_1') {
379
+ addressObj.state = component.long_name
380
+ }
381
+ if (addressType === 'administrative_area_level_2') {
382
+ addressObj.city = component.long_name
383
+ }
384
+ })
385
+ }
386
+ const addressSelected = {
387
+ address: data?.description || data?.address,
388
+ location: details?.geometry?.location,
389
+ utc_offset: details?.utc_offset || null,
390
+ map_data: { library: 'google', place_id: data.place_id },
391
+ zipcode: data?.zipcode || null,
392
+ ...addressObj
393
+ };
394
+ updateChanges(addressSelected);
395
+ };
361
396
 
362
397
  const handleAddressTag = (tag: string) => {
363
398
  setAddressTag(tag);
@@ -610,7 +645,7 @@ const AddressFormUI = (props: AddressFormParams) => {
610
645
  onFail={(error) =>
611
646
  setAlertState({
612
647
  open: true,
613
- content: getTraduction(error),
648
+ content: getTraduction(error, t),
614
649
  })
615
650
  }
616
651
  styles={{
@@ -34,7 +34,8 @@ export const GPSButton = (props: any) => {
34
34
  }
35
35
  let data : any
36
36
  const details = {
37
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
37
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
38
+ address_components: results[0]?.address_components
38
39
  }
39
40
  // if (isSetInputs) {
40
41
  data = {
@@ -82,7 +82,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
82
82
  place_id: results[0]?.place_id,
83
83
  }
84
84
  const details = {
85
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
85
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
86
+ address_components: results[0]?.address_components,
86
87
  }
87
88
  handleChangeAddressMap && handleChangeAddressMap(address, details)
88
89
  setSaveLocation && setSaveLocation(false)
@@ -133,9 +133,9 @@ const MessagesUI = (props: MessagesParams) => {
133
133
  ? `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}`
134
134
  : `${message.change?.attribute !== 'logistic_status'
135
135
  ? message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])
136
- : message.change.old !== null && getLogisticTag(message.change.old)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status'
136
+ : message.change.old !== null && getLogisticTag(message.change.old, t)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status'
137
137
  ? t(ORDER_STATUS[parseInt(message.change.new, 10)])
138
- : getLogisticTag(message.change.new)}`
138
+ : getLogisticTag(message.change.new, t)}`
139
139
  }`
140
140
  : message.change.new
141
141
  ?
@@ -534,7 +534,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
534
534
  <LinearGradient
535
535
  start={{ x: 0.0, y: 0.0 }}
536
536
  end={{
537
- x: progressBarObjt(order?.status)?.percentage || 0,
537
+ x: progressBarObjt(order?.status, t)?.percentage || 0,
538
538
  y: 0,
539
539
  }}
540
540
  locations={[0.9999, 0.9999]}
@@ -547,7 +547,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
547
547
  lineHeight={24}
548
548
  weight={'600'}
549
549
  color={theme.colors.textNormal}>
550
- {progressBarObjt(order?.status)?.value}
550
+ {progressBarObjt(order?.status, t)?.value}
551
551
  </OText>
552
552
  </>
553
553
  )}
@@ -114,7 +114,7 @@ const OrderProgressUI = (props: any) => {
114
114
  setInitialLoaded(true)
115
115
  }, [orderList.loading, initialLoaded])
116
116
 
117
- const progressBarObjt = (s: any) => lastOrder?.delivery_type && lastOrder?.delivery_type === 2 ? getOrderStatuPickUp(s) : getOrderStatus(s)
117
+ const progressBarObjt = (s: any) => lastOrder?.delivery_type && lastOrder?.delivery_type === 2 ? getOrderStatuPickUp(s, t) : getOrderStatus(s, t)
118
118
 
119
119
  return (
120
120
  <>
@@ -177,7 +177,7 @@ export const VerifyPhone = (props: any) => {
177
177
  size={16}
178
178
  color={theme.colors.error}
179
179
  >
180
- {`* ${t(getTraduction(e))}`}
180
+ {`* ${t(getTraduction(e, t))}`}
181
181
  </OText>
182
182
  ))}
183
183
  </ErrorSection>
@@ -28,7 +28,7 @@ const Alert = (props: Props) => {
28
28
  show={open}
29
29
  showProgress={false}
30
30
  title={title}
31
- message={getTraduction(content?.[0])}
31
+ message={getTraduction(content?.[0], t)}
32
32
  closeOnTouchOutside={true}
33
33
  closeOnHardwareBackPress={false}
34
34
  showConfirmButton={true}
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
- import { useLanguage } from 'ordering-components/native';
3
2
  import FontAwesome from 'react-native-vector-icons/FontAwesome';
4
3
  import { CODES } from 'ordering-components/native'
5
4
  import { ORDER_TYPES } from '../config/constants';
6
5
  import { useTheme } from 'styled-components/native';
7
6
 
8
- const [languageState, t] = useLanguage();
9
7
  const theme = useTheme()
10
8
 
11
9
  export const flatArray = (arr: any) => [].concat(...arr)
@@ -19,8 +17,7 @@ export const orderTypeList = ['delivery', 'pickup', 'eatin', 'curbside', 'drivet
19
17
  * Function to return the traduction depending of a key 't'
20
18
  * @param {string} key for traduction
21
19
  */
22
- export const getTraduction = (key: string) => {
23
- const [, t] = useLanguage()
20
+ export const getTraduction = (key: string, t: any) => {
24
21
  const keyList: any = {
25
22
  // Add the key and traduction that you need below
26
23
  ERROR_ORDER_WITHOUT_CART: 'The order was placed without a cart',
@@ -130,32 +127,34 @@ export const monthsEnum: any = {
130
127
  Dec: 'MONTHSHORT12',
131
128
  }
132
129
 
133
- export const locale = {
134
- name: languageState?.language?.code?.slice(0, 2),
135
- config: {
136
- months: [
137
- t('MONTH1', 'January'),
138
- t('MONTH2', 'February'),
139
- t('MONTH3', 'March'),
140
- t('MONTH4', 'April'),
141
- t('MONTH5', 'May'),
142
- t('MONTH6', 'June'),
143
- t('MONTH7', 'July'),
144
- t('MONTH8', 'August'),
145
- t('MONTH9', 'September'),
146
- t('MONTH10', 'October'),
147
- t('MONTH11', 'November'),
148
- t('MONTH12', 'December')
149
- ],
150
- weekdaysShort: [
151
- t('DAYSHORT7', 'Sun'),
152
- t('DAYSHORT1', 'Mon'),
153
- t('DAYSHORT2', 'Tue'),
154
- t('DAYSHORT3', 'Wed'),
155
- t('DAYSHORT4', 'Thu'),
156
- t('DAYSHORT5', 'Fri'),
157
- t('DAYSHORT6', 'Sat')
158
- ],
130
+ export const locale = (languageState: any, t: any) => {
131
+ return {
132
+ name: languageState?.language?.code?.slice(0, 2),
133
+ config: {
134
+ months: [
135
+ t('MONTH1', 'January'),
136
+ t('MONTH2', 'February'),
137
+ t('MONTH3', 'March'),
138
+ t('MONTH4', 'April'),
139
+ t('MONTH5', 'May'),
140
+ t('MONTH6', 'June'),
141
+ t('MONTH7', 'July'),
142
+ t('MONTH8', 'August'),
143
+ t('MONTH9', 'September'),
144
+ t('MONTH10', 'October'),
145
+ t('MONTH11', 'November'),
146
+ t('MONTH12', 'December')
147
+ ],
148
+ weekdaysShort: [
149
+ t('DAYSHORT7', 'Sun'),
150
+ t('DAYSHORT1', 'Mon'),
151
+ t('DAYSHORT2', 'Tue'),
152
+ t('DAYSHORT3', 'Wed'),
153
+ t('DAYSHORT4', 'Thu'),
154
+ t('DAYSHORT5', 'Fri'),
155
+ t('DAYSHORT6', 'Sat')
156
+ ],
157
+ }
159
158
  }
160
159
  };
161
160
 
@@ -365,7 +364,7 @@ export const priceList = [
365
364
  { level: '5', content: '$$$$$' }
366
365
  ]
367
366
 
368
- export const getLogisticTag = (status: any) => {
367
+ export const getLogisticTag = (status: any, t: any) => {
369
368
  const keyList: any = {
370
369
  0: t('PENDING', 'Pending'),
371
370
  1: t('IN_PROGRESS', 'In progress'),
@@ -376,7 +375,7 @@ export const getLogisticTag = (status: any) => {
376
375
  return keyList[status] ? keyList[status] : t('UNKNOWN', 'Unknown')
377
376
  }
378
377
 
379
- export const getOrderStatus = (s: string) => {
378
+ export const getOrderStatus = (s: string, t: any) => {
380
379
  const status = parseInt(s);
381
380
  const orderStatus = [
382
381
  {
@@ -593,7 +592,7 @@ export const getOrderStatus = (s: string) => {
593
592
  return objectStatus && objectStatus;
594
593
  }
595
594
 
596
- export const getOrderStatuPickUp = (s: any) => {
595
+ export const getOrderStatuPickUp = (s: any, t: any) => {
597
596
  const status = parseInt(s);
598
597
  const orderStatus = [
599
598
  {