ordering-ui-react-native 0.17.53 → 0.17.54
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
|
@@ -131,7 +131,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
131
131
|
const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
|
|
132
132
|
const [openService, setOpenService] = useState(false)
|
|
133
133
|
const [currentProduct, setCurrentProduct] = useState(null)
|
|
134
|
-
|
|
134
|
+
const [searchBarHeight, setSearchBarHeight] = useState(60)
|
|
135
135
|
|
|
136
136
|
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
137
137
|
const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
|
|
@@ -256,6 +256,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
256
256
|
}
|
|
257
257
|
}, [isFocused])
|
|
258
258
|
|
|
259
|
+
const subtotalWithTaxes = currentCart?.taxes?.reduce((acc: any, item: any) => {
|
|
260
|
+
if (item?.type === 1)
|
|
261
|
+
return acc = acc + item?.summary?.tax
|
|
262
|
+
return acc = acc
|
|
263
|
+
}, currentCart?.subtotal)
|
|
264
|
+
|
|
259
265
|
return (
|
|
260
266
|
<>
|
|
261
267
|
<View style={{ flex: 1 }}>
|
|
@@ -264,7 +270,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
264
270
|
style={{
|
|
265
271
|
marginTop: Platform.OS === 'ios' ? insets.top : 0
|
|
266
272
|
}}
|
|
267
|
-
|
|
273
|
+
onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height)}
|
|
268
274
|
>
|
|
269
275
|
{!isOpenSearchBar && (
|
|
270
276
|
<>
|
|
@@ -325,12 +331,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
325
331
|
|
|
326
332
|
{business?.categories?.length > 0 && isOpenFiltProducts && (
|
|
327
333
|
<FiltProductsContainer
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
+
style={{
|
|
335
|
+
height: Dimensions.get('window').height - filtProductsHeight,
|
|
336
|
+
top: Platform.OS === 'ios' ? searchBarHeight + insets.top : searchBarHeight
|
|
337
|
+
}}
|
|
338
|
+
contentContainerStyle={{ flexGrow: 1 }}
|
|
339
|
+
>
|
|
334
340
|
<View style={{ padding: 20, backgroundColor: theme.colors.white }}>
|
|
335
341
|
<BusinessProductsList
|
|
336
342
|
categories={[
|
|
@@ -491,21 +497,21 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
491
497
|
{!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
|
|
492
498
|
<View style={{ marginBottom: Platform.OS === 'ios' ? 20 : 0 }}>
|
|
493
499
|
<FloatingButton
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
500
|
+
btnText={
|
|
501
|
+
openUpselling
|
|
502
|
+
? t('LOADING', 'Loading')
|
|
503
|
+
: subtotalWithTaxes >= currentCart?.minimum
|
|
504
|
+
? t('VIEW_ORDER', 'View Order')
|
|
505
|
+
: `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
|
|
506
|
+
}
|
|
507
|
+
isSecondaryBtn={subtotalWithTaxes < currentCart?.minimum || openUpselling}
|
|
508
|
+
btnLeftValueShow={subtotalWithTaxes >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
509
|
+
btnRightValueShow={subtotalWithTaxes >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
510
|
+
btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
|
|
511
|
+
btnRightValue={parsePrice(currentCart?.total)}
|
|
512
|
+
disabled={subtotalWithTaxes < currentCart?.minimum || openUpselling}
|
|
513
|
+
handleClick={() => setOpenUpselling(true)}
|
|
514
|
+
/>
|
|
509
515
|
</View>
|
|
510
516
|
)}
|
|
511
517
|
{openUpselling && (
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
TimeItem
|
|
29
29
|
} from './styles';
|
|
30
30
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
31
|
+
import { locale, monthsEnum } from '../../utils';
|
|
31
32
|
|
|
32
33
|
const MomentOptionUI = (props: MomentOptionParams) => {
|
|
33
34
|
const {
|
|
@@ -281,7 +282,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
281
282
|
style={{ marginEnd: 24 }}
|
|
282
283
|
/>
|
|
283
284
|
)}
|
|
284
|
-
<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>
|
|
285
|
+
<OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${t(moment().format('dddd')?.toLocaleUpperCase(), moment().format('dddd'))}, ${t(monthsEnum[moment().format('MMM')], moment().format('MMM'))}${moment().format(' D, yyyy h:mm A')} + ${t('DELIVERY_TIME', 'delivery time')})`}</OText>
|
|
285
286
|
</WrapSelectOption>
|
|
286
287
|
<WrapSelectOption
|
|
287
288
|
onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}
|
|
@@ -308,6 +309,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
308
309
|
{selectDate && datesWhitelist[0]?.start !== null && (
|
|
309
310
|
<CalendarStrip
|
|
310
311
|
scrollable
|
|
312
|
+
locale={locale}
|
|
311
313
|
style={styles.calendar}
|
|
312
314
|
calendarHeaderContainerStyle={styles.calendarHeaderContainer}
|
|
313
315
|
calendarHeaderStyle={styles.calendarHeader}
|
|
@@ -342,12 +344,12 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
342
344
|
style={{
|
|
343
345
|
lineHeight: 24
|
|
344
346
|
}}
|
|
345
|
-
>{is12hours ? (
|
|
346
|
-
time.startTime.includes('12')
|
|
347
|
+
>{is12hours ? (
|
|
348
|
+
time.startTime.includes('12')
|
|
347
349
|
? `${time.startTime}PM`
|
|
348
350
|
: parseTime(moment(time.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
) : time.startTime
|
|
352
|
+
}</OText>
|
|
351
353
|
</TimeItem>
|
|
352
354
|
</TouchableOpacity>
|
|
353
355
|
))}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useLanguage } from 'ordering-components/native';
|
|
3
3
|
import FontAwesome from 'react-native-vector-icons/FontAwesome';
|
|
4
|
-
import {CODES} from 'ordering-components/native'
|
|
4
|
+
import { CODES } from 'ordering-components/native'
|
|
5
5
|
import { ORDER_TYPES } from '../config/constants';
|
|
6
6
|
|
|
7
7
|
export const flatArray = (arr: any) => [].concat(...arr)
|
|
8
|
+
const [languageState, t] = useLanguage();
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Function to return the traduction depending of a key 't'
|
|
@@ -43,69 +44,113 @@ export const getTraduction = (key: string) => {
|
|
|
43
44
|
/**
|
|
44
45
|
* Change local moment variables
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
export const setLocalMoment = (moment: any, t: any) => {
|
|
47
48
|
moment.locale('custom', {
|
|
48
49
|
months: [
|
|
49
|
-
t('MONTH1','January'),
|
|
50
|
-
t('MONTH2','February'),
|
|
51
|
-
t('MONTH3','March'),
|
|
52
|
-
t('MONTH4','April'),
|
|
53
|
-
t('MONTH5','May'),
|
|
54
|
-
t('MONTH6','June'),
|
|
55
|
-
t('MONTH7','July'),
|
|
56
|
-
t('MONTH8','August'),
|
|
57
|
-
t('MONTH9','September'),
|
|
58
|
-
t('MONTH10','October'),
|
|
59
|
-
t('MONTH11','November'),
|
|
60
|
-
t('MONTH12','December')
|
|
50
|
+
t('MONTH1', 'January'),
|
|
51
|
+
t('MONTH2', 'February'),
|
|
52
|
+
t('MONTH3', 'March'),
|
|
53
|
+
t('MONTH4', 'April'),
|
|
54
|
+
t('MONTH5', 'May'),
|
|
55
|
+
t('MONTH6', 'June'),
|
|
56
|
+
t('MONTH7', 'July'),
|
|
57
|
+
t('MONTH8', 'August'),
|
|
58
|
+
t('MONTH9', 'September'),
|
|
59
|
+
t('MONTH10', 'October'),
|
|
60
|
+
t('MONTH11', 'November'),
|
|
61
|
+
t('MONTH12', 'December')
|
|
61
62
|
],
|
|
62
63
|
monthsShort: [
|
|
63
|
-
t('MONTHSHORT1','Jan'),
|
|
64
|
-
t('MONTHSHORT2','Feb'),
|
|
65
|
-
t('MONTHSHORT3','Mar'),
|
|
66
|
-
t('MONTHSHORT4','Apr'),
|
|
67
|
-
t('MONTHSHORT5','May'),
|
|
68
|
-
t('MONTHSHORT6','Jun'),
|
|
69
|
-
t('MONTHSHORT7','Jul'),
|
|
70
|
-
t('MONTHSHORT8','Aug'),
|
|
71
|
-
t('MONTHSHORT9','Sep'),
|
|
72
|
-
t('MONTHSHORT10','Oct'),
|
|
73
|
-
t('MONTHSHORT11','Nov'),
|
|
74
|
-
t('MONTHSHORT12','Dec')
|
|
64
|
+
t('MONTHSHORT1', 'Jan'),
|
|
65
|
+
t('MONTHSHORT2', 'Feb'),
|
|
66
|
+
t('MONTHSHORT3', 'Mar'),
|
|
67
|
+
t('MONTHSHORT4', 'Apr'),
|
|
68
|
+
t('MONTHSHORT5', 'May'),
|
|
69
|
+
t('MONTHSHORT6', 'Jun'),
|
|
70
|
+
t('MONTHSHORT7', 'Jul'),
|
|
71
|
+
t('MONTHSHORT8', 'Aug'),
|
|
72
|
+
t('MONTHSHORT9', 'Sep'),
|
|
73
|
+
t('MONTHSHORT10', 'Oct'),
|
|
74
|
+
t('MONTHSHORT11', 'Nov'),
|
|
75
|
+
t('MONTHSHORT12', 'Dec')
|
|
75
76
|
],
|
|
76
77
|
weekdays: [
|
|
77
|
-
t('DAY7','Sunday'),
|
|
78
|
-
t('DAY1','Monday'),
|
|
79
|
-
t('DAY2','Tuesday'),
|
|
80
|
-
t('DAY3','Wednesday'),
|
|
81
|
-
t('DAY4','Thursday'),
|
|
82
|
-
t('DAY5','Friday'),
|
|
83
|
-
t('DAY6','Saturday')
|
|
78
|
+
t('DAY7', 'Sunday'),
|
|
79
|
+
t('DAY1', 'Monday'),
|
|
80
|
+
t('DAY2', 'Tuesday'),
|
|
81
|
+
t('DAY3', 'Wednesday'),
|
|
82
|
+
t('DAY4', 'Thursday'),
|
|
83
|
+
t('DAY5', 'Friday'),
|
|
84
|
+
t('DAY6', 'Saturday')
|
|
84
85
|
],
|
|
85
86
|
weekdaysShort: [
|
|
86
|
-
t('DAYSHORT7','Sun'),
|
|
87
|
-
t('DAYSHORT1','Mon'),
|
|
88
|
-
t('DAYSHORT2','Tue'),
|
|
89
|
-
t('DAYSHORT3','Wed'),
|
|
90
|
-
t('DAYSHORT4','Thu'),
|
|
91
|
-
t('DAYSHORT5','Fri'),
|
|
92
|
-
t('DAYSHORT6','Sat')
|
|
87
|
+
t('DAYSHORT7', 'Sun'),
|
|
88
|
+
t('DAYSHORT1', 'Mon'),
|
|
89
|
+
t('DAYSHORT2', 'Tue'),
|
|
90
|
+
t('DAYSHORT3', 'Wed'),
|
|
91
|
+
t('DAYSHORT4', 'Thu'),
|
|
92
|
+
t('DAYSHORT5', 'Fri'),
|
|
93
|
+
t('DAYSHORT6', 'Sat')
|
|
93
94
|
],
|
|
94
95
|
weekdaysMin: [
|
|
95
|
-
t('DAYMIN7','Su'),
|
|
96
|
-
t('DAYMIN1','Mo'),
|
|
97
|
-
t('DAYMIN2','Tu'),
|
|
98
|
-
t('DAYMIN3','We'),
|
|
99
|
-
t('DAYMIN4','Th'),
|
|
100
|
-
t('DAYMIN5','Fr'),
|
|
101
|
-
t('DAYMIN6','Sa')
|
|
96
|
+
t('DAYMIN7', 'Su'),
|
|
97
|
+
t('DAYMIN1', 'Mo'),
|
|
98
|
+
t('DAYMIN2', 'Tu'),
|
|
99
|
+
t('DAYMIN3', 'We'),
|
|
100
|
+
t('DAYMIN4', 'Th'),
|
|
101
|
+
t('DAYMIN5', 'Fr'),
|
|
102
|
+
t('DAYMIN6', 'Sa')
|
|
102
103
|
],
|
|
103
|
-
meridiem
|
|
104
|
-
return hours < 12 ? t('AM', 'AM') : t('PM','PM');
|
|
104
|
+
meridiem: function (hours: any) {
|
|
105
|
+
return hours < 12 ? t('AM', 'AM') : t('PM', 'PM');
|
|
105
106
|
}
|
|
106
107
|
})
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
export const monthsEnum: any = {
|
|
111
|
+
Jan: 'MONTHSHORT1',
|
|
112
|
+
Feb: 'MONTHSHORT2',
|
|
113
|
+
Mar: 'MONTHSHORT3',
|
|
114
|
+
Apr: 'MONTHSHORT4',
|
|
115
|
+
May: 'MONTHSHORT5',
|
|
116
|
+
Jun: 'MONTHSHORT6',
|
|
117
|
+
Jul: 'MONTHSHORT7',
|
|
118
|
+
Aug: 'MONTHSHORT8',
|
|
119
|
+
Sep: 'MONTHSHORT9',
|
|
120
|
+
Oct: 'MONTHSHORT10',
|
|
121
|
+
Nov: 'MONTHSHORT11',
|
|
122
|
+
Dec: 'MONTHSHORT12',
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const locale = {
|
|
126
|
+
name: languageState?.language?.code?.slice(0, 2),
|
|
127
|
+
config: {
|
|
128
|
+
months: [
|
|
129
|
+
t('MONTH1', 'January'),
|
|
130
|
+
t('MONTH2', 'February'),
|
|
131
|
+
t('MONTH3', 'March'),
|
|
132
|
+
t('MONTH4', 'April'),
|
|
133
|
+
t('MONTH5', 'May'),
|
|
134
|
+
t('MONTH6', 'June'),
|
|
135
|
+
t('MONTH7', 'July'),
|
|
136
|
+
t('MONTH8', 'August'),
|
|
137
|
+
t('MONTH9', 'September'),
|
|
138
|
+
t('MONTH10', 'October'),
|
|
139
|
+
t('MONTH11', 'November'),
|
|
140
|
+
t('MONTH12', 'December')
|
|
141
|
+
],
|
|
142
|
+
weekdaysShort: [
|
|
143
|
+
t('DAYSHORT7', 'Sun'),
|
|
144
|
+
t('DAYSHORT1', 'Mon'),
|
|
145
|
+
t('DAYSHORT2', 'Tue'),
|
|
146
|
+
t('DAYSHORT3', 'Wed'),
|
|
147
|
+
t('DAYSHORT4', 'Thu'),
|
|
148
|
+
t('DAYSHORT5', 'Fri'),
|
|
149
|
+
t('DAYSHORT6', 'Sat')
|
|
150
|
+
],
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
109
154
|
/**
|
|
110
155
|
* Function to convert delivery time in minutes
|
|
111
156
|
* @param {string} time business delivery time
|
|
@@ -182,7 +227,7 @@ export const getIconCard = (brand: string, size: number) => {
|
|
|
182
227
|
* Function to return a static google maps image based in location
|
|
183
228
|
* @param {object} param object with latitude and logitude
|
|
184
229
|
*/
|
|
185
|
-
|
|
230
|
+
export const getGoogleMapImage = ({ lat, lng }: any, apiKey: string) => {
|
|
186
231
|
return `https://maps.googleapis.com/maps/api/staticmap?size=500x190¢er=${lat},${lng}&zoom=17&scale=2&maptype=roadmap&&markers=icon:https://res.cloudinary.com/ditpjbrmz/image/upload/f_auto,q_auto,w_45,q_auto:best,q_auto:best/v1564675872/marker-customer_kvxric.png%7Ccolor:white%7C${lat},${lng}&key=${apiKey}`
|
|
187
232
|
}
|
|
188
233
|
/**
|
|
@@ -213,8 +258,8 @@ export const sortInputFields = ({ fields, values }: any) => {
|
|
|
213
258
|
return fieldsSorted;
|
|
214
259
|
}
|
|
215
260
|
|
|
216
|
-
export const transformCountryCode = (countryCode
|
|
217
|
-
const code = CODES.find((code
|
|
261
|
+
export const transformCountryCode = (countryCode: number) => {
|
|
262
|
+
const code = CODES.find((code: any) => code.phoneCode === countryCode)
|
|
218
263
|
return code?.countryCode
|
|
219
264
|
}
|
|
220
265
|
|
|
@@ -224,7 +269,7 @@ export const transformCountryCode = (countryCode : number) => {
|
|
|
224
269
|
* @param {*} parser function fallback when is decimal
|
|
225
270
|
* @returns string
|
|
226
271
|
*/
|
|
227
|
-
|
|
272
|
+
export const verifyDecimals = (value: number, parser: any) => {
|
|
228
273
|
if (value % 1 === 0) {
|
|
229
274
|
return value
|
|
230
275
|
} else {
|
|
@@ -240,7 +285,7 @@ export const getTypesText = (value: number) => {
|
|
|
240
285
|
/**
|
|
241
286
|
* List shape for ribbon
|
|
242
287
|
*/
|
|
243
|
-
|
|
288
|
+
export const shape = {
|
|
244
289
|
rectangle: 'rectangle',
|
|
245
290
|
rectangleRound: 'rectangle_round',
|
|
246
291
|
capsuleShape: 'capsule_shape'
|
|
@@ -251,7 +296,7 @@ export const getTypesText = (value: number) => {
|
|
|
251
296
|
* @param {number} value for transform
|
|
252
297
|
*
|
|
253
298
|
*/
|
|
254
|
-
|
|
299
|
+
export const convertToRadian = (value: number) => {
|
|
255
300
|
return value * Math.PI / 180
|
|
256
301
|
}
|
|
257
302
|
|
|
@@ -273,14 +318,14 @@ export const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
|
|
|
273
318
|
return R * c
|
|
274
319
|
}
|
|
275
320
|
|
|
276
|
-
export const formatUrlVideo = (url
|
|
321
|
+
export const formatUrlVideo = (url: string) => {
|
|
277
322
|
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/
|
|
278
323
|
const match = url.match(regExp)
|
|
279
324
|
const id = (match && match[7].length === 11) ? match[7] : false
|
|
280
325
|
return `https://www.youtube-nocookie.com/embed/${id}`
|
|
281
326
|
}
|
|
282
327
|
|
|
283
|
-
export const formatSeconds = (seconds
|
|
328
|
+
export const formatSeconds = (seconds: number) => {
|
|
284
329
|
// Hours, minutes and seconds
|
|
285
330
|
var hrs = ~~(seconds / 3600)
|
|
286
331
|
var mins = ~~((seconds % 3600) / 60)
|
|
@@ -299,7 +344,7 @@ export const formatSeconds = (seconds : number) => {
|
|
|
299
344
|
/**
|
|
300
345
|
* List of price to filter businesses
|
|
301
346
|
*/
|
|
302
|
-
|
|
347
|
+
export const priceList = [
|
|
303
348
|
{ level: '1', content: '$' },
|
|
304
349
|
{ level: '2', content: '$$' },
|
|
305
350
|
{ level: '3', content: '$$$' },
|