ordering-ui-react-native 0.15.75 → 0.15.78
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 +1 -1
- package/src/utils/index.tsx +68 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
- package/themes/original/src/components/Promotions/index.tsx +20 -19
- package/themes/original/src/components/Promotions/styles.tsx +0 -1
package/package.json
CHANGED
package/src/utils/index.tsx
CHANGED
|
@@ -201,7 +201,7 @@ export const transformCountryCode = (countryCode : number) => {
|
|
|
201
201
|
*/
|
|
202
202
|
export const reviewCommentList = (type: string) => {
|
|
203
203
|
const [, t] = useLanguage()
|
|
204
|
-
|
|
204
|
+
// TODO: improve this function
|
|
205
205
|
const reviews: any = {
|
|
206
206
|
order: {
|
|
207
207
|
1: {
|
|
@@ -387,3 +387,70 @@ export const transformCountryCode = (countryCode : number) => {
|
|
|
387
387
|
|
|
388
388
|
return reviews[type]
|
|
389
389
|
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* function to manage order comment list
|
|
393
|
+
* @param {string} param0 type of orders to return
|
|
394
|
+
* @returns object with orders dictionary
|
|
395
|
+
*/
|
|
396
|
+
export const orderCommentList = (value: string) => {
|
|
397
|
+
const [, t] = useLanguage()
|
|
398
|
+
const dictionary: any = {
|
|
399
|
+
reject: 6,
|
|
400
|
+
forcePickUp: 9,
|
|
401
|
+
pickupFailed: 10,
|
|
402
|
+
forceDelivery: 11,
|
|
403
|
+
deliveryFailed: 12,
|
|
404
|
+
notReady: 14
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const status = dictionary[value]
|
|
408
|
+
|
|
409
|
+
const messages: any = {
|
|
410
|
+
6: [// on reject order
|
|
411
|
+
'Very far away',
|
|
412
|
+
'Driver/ vehicle incident',
|
|
413
|
+
'Destination unreachable',
|
|
414
|
+
'Unavailable driver',
|
|
415
|
+
'Other'
|
|
416
|
+
],
|
|
417
|
+
9: [// on force pickup status
|
|
418
|
+
'I forgot to complete it in the location',
|
|
419
|
+
'I didn\'t have internet connection',
|
|
420
|
+
'Other'
|
|
421
|
+
],
|
|
422
|
+
10: [// on pickup failed by driver
|
|
423
|
+
'Very far away',
|
|
424
|
+
'Driver/ vehicle incident',
|
|
425
|
+
'Destination unreachable',
|
|
426
|
+
'Store closed',
|
|
427
|
+
'Unavailable driver',
|
|
428
|
+
'Other'
|
|
429
|
+
],
|
|
430
|
+
11: [// on force delivery status
|
|
431
|
+
'I forgot to complete it in the location',
|
|
432
|
+
'I didn\'t have internet connection',
|
|
433
|
+
'Other'
|
|
434
|
+
],
|
|
435
|
+
12: [// on delivery failed by driver
|
|
436
|
+
'Very far away',
|
|
437
|
+
'Driver/ vehicle incident',
|
|
438
|
+
'Destination unreachable',
|
|
439
|
+
'Recipient unavailable',
|
|
440
|
+
'Refused- incorrect/ missing items',
|
|
441
|
+
'Refused- damage',
|
|
442
|
+
'Other'
|
|
443
|
+
],
|
|
444
|
+
14: [// on order not ready
|
|
445
|
+
'Store didn\'t receive the order on time',
|
|
446
|
+
'Store very busy',
|
|
447
|
+
'Other'
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (!messages[status]) return null
|
|
452
|
+
|
|
453
|
+
const list = messages[status].map((val: any, i: number) => ({ key: i, content: t(`ORDER_STATUS_${status}_QUICK_COMMENT_${i}`, val) }))
|
|
454
|
+
|
|
455
|
+
return { list }
|
|
456
|
+
}
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { useTheme } from 'styled-components/native';
|
|
11
11
|
import { useLanguage } from 'ordering-components/native';
|
|
12
|
-
import { Content, Timer, TimeField, Header, Action, Comments } from './styles';
|
|
12
|
+
import { Content, Timer, TimeField, Header, Action, Comments, CommentsButtonGroup } from './styles';
|
|
13
13
|
import { FloatingButton } from '../FloatingButton';
|
|
14
14
|
import { OText, OButton, OTextarea, OIconButton } from '../shared';
|
|
15
15
|
import { AcceptOrRejectOrderParams } from '../../types';
|
|
16
16
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
17
|
|
|
18
|
+
import { orderCommentList } from '../../../../../src/utils'
|
|
19
|
+
|
|
18
20
|
export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
19
21
|
const {
|
|
20
22
|
customerCellphone,
|
|
@@ -39,15 +41,33 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
39
41
|
const [min, setMin] = useState('00');
|
|
40
42
|
const [time, setTime] = useState('');
|
|
41
43
|
const [comments, setComments] = useState('');
|
|
44
|
+
const [commentList, setCommentList] = useState<any>([]);
|
|
42
45
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
43
46
|
const { top, bottom } = useSafeAreaInsets()
|
|
44
47
|
|
|
48
|
+
const orderCommentsList = orderCommentList(action)
|
|
49
|
+
|
|
45
50
|
let codeNumberPhone, numberPhone, numberToShow;
|
|
46
51
|
const phoneNumber = customerCellphone;
|
|
47
52
|
const titleOrder = t(orderTitle[action]?.key, orderTitle[action]?.text)
|
|
48
53
|
const buttonText = t(orderTitle[action]?.btnKey, orderTitle[action]?.btnText)
|
|
49
54
|
const showTextArea = ['reject', 'deliveryFailed', 'pickupFailed', 'notReady', 'forcePickUp', 'forceDelivery'].includes(action)
|
|
50
55
|
|
|
56
|
+
const isSelectedComment = (commentKey: number) => {
|
|
57
|
+
const found = commentList.find((comment: any) => comment?.key === commentKey)
|
|
58
|
+
return found
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const handleChangeComments = (commentItem: any) => {
|
|
62
|
+
const found = commentList.find((comment: any) => comment?.key === commentItem.key)
|
|
63
|
+
if (found) {
|
|
64
|
+
const _comments = commentList.filter((comment: any) => comment?.key !== commentItem.key)
|
|
65
|
+
setCommentList(_comments)
|
|
66
|
+
} else {
|
|
67
|
+
setCommentList([...commentList, commentItem])
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
const handleFocus = () => {
|
|
52
72
|
viewRef?.current?.measure((x: any, y: any) => {
|
|
53
73
|
scrollViewRef?.current?.scrollTo({ x: 0, y });
|
|
@@ -152,6 +172,12 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
152
172
|
const handleAcceptOrReject = () => {
|
|
153
173
|
handleFixTime();
|
|
154
174
|
|
|
175
|
+
let _comments = ''
|
|
176
|
+
if (commentList.length > 0) {
|
|
177
|
+
commentList.map((comment: any) => (_comments += comment.content + '. '))
|
|
178
|
+
}
|
|
179
|
+
const _comment = _comments + comments
|
|
180
|
+
|
|
155
181
|
let minsToSend = min;
|
|
156
182
|
|
|
157
183
|
if (min > '60') minsToSend = '59';
|
|
@@ -165,7 +191,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
165
191
|
status: 7,
|
|
166
192
|
},
|
|
167
193
|
rejectByBusiness: {
|
|
168
|
-
comment:
|
|
194
|
+
comment: _comment,
|
|
169
195
|
status: 5,
|
|
170
196
|
},
|
|
171
197
|
acceptByDriver: {
|
|
@@ -173,27 +199,27 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
173
199
|
status: 8,
|
|
174
200
|
},
|
|
175
201
|
rejectByDriver: {
|
|
176
|
-
comment:
|
|
202
|
+
comment: _comment,
|
|
177
203
|
status: 6,
|
|
178
204
|
},
|
|
179
205
|
pickupFailedByDriver: {
|
|
180
|
-
comment:
|
|
206
|
+
comment: _comment,
|
|
181
207
|
status: 10
|
|
182
208
|
},
|
|
183
209
|
deliveryFailedByDriver: {
|
|
184
|
-
comment:
|
|
210
|
+
comment: _comment,
|
|
185
211
|
status: 12
|
|
186
212
|
},
|
|
187
213
|
orderNotReady: {
|
|
188
|
-
comment:
|
|
214
|
+
comment: _comment,
|
|
189
215
|
status: 14
|
|
190
216
|
},
|
|
191
217
|
forcePickUp: {
|
|
192
|
-
reasons:
|
|
218
|
+
reasons: _comment,
|
|
193
219
|
status: 9
|
|
194
220
|
},
|
|
195
221
|
forceDelivery: {
|
|
196
|
-
reasons:
|
|
222
|
+
reasons: _comment,
|
|
197
223
|
status: 11
|
|
198
224
|
}
|
|
199
225
|
};
|
|
@@ -387,6 +413,28 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
387
413
|
onBlur={() => actions && action === 'accept' && timerRef?.current?.focus?.()}
|
|
388
414
|
/>
|
|
389
415
|
|
|
416
|
+
{orderCommentsList && (
|
|
417
|
+
<CommentsButtonGroup>
|
|
418
|
+
{orderCommentsList?.list?.map((comment: any) => (
|
|
419
|
+
<OButton
|
|
420
|
+
key={comment.key}
|
|
421
|
+
text={comment.content}
|
|
422
|
+
bgColor={isSelectedComment(comment.key) ? theme.colors.primary : theme.colors.tabBar}
|
|
423
|
+
borderColor={isSelectedComment(comment.key) ? theme.colors.primary : theme.colors.tabBar}
|
|
424
|
+
textStyle={{
|
|
425
|
+
color: isSelectedComment(comment.key) ? theme.colors.white : theme.colors.darkText,
|
|
426
|
+
fontSize: 12,
|
|
427
|
+
paddingRight: isSelectedComment(comment.key) ? 15 : 0
|
|
428
|
+
}}
|
|
429
|
+
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
430
|
+
imgRightSrc={isSelectedComment(comment.key) ? theme.images.general.close : null}
|
|
431
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
432
|
+
onClick={() => handleChangeComments(comment) }
|
|
433
|
+
/>
|
|
434
|
+
))}
|
|
435
|
+
</CommentsButtonGroup>
|
|
436
|
+
)}
|
|
437
|
+
|
|
390
438
|
{showTextArea && (
|
|
391
439
|
<Comments ref={viewRef}>
|
|
392
440
|
<OTextarea
|
|
@@ -268,6 +268,12 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
268
268
|
<OText size={13} weight='bold'>{`${t('ORDER_TYPE', 'Order Type')}: `}</OText>
|
|
269
269
|
{orderTypes(order.delivery_type)}
|
|
270
270
|
</OText>
|
|
271
|
+
{order?.delivery_option && (
|
|
272
|
+
<OText size={13}>
|
|
273
|
+
<OText size={13} weight='bold'>{`${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: `}</OText>
|
|
274
|
+
{order?.delivery_option?.name}
|
|
275
|
+
</OText>
|
|
276
|
+
)}
|
|
271
277
|
{order?.payment_events?.length > 0 && (
|
|
272
278
|
<View>
|
|
273
279
|
<OText size={13}>
|
|
@@ -20,7 +20,7 @@ import { NotFoundSource } from '../NotFoundSource'
|
|
|
20
20
|
import { View, StyleSheet, ScrollView } from 'react-native'
|
|
21
21
|
import FastImage from 'react-native-fast-image'
|
|
22
22
|
import { PromotionParams } from '../../types'
|
|
23
|
-
const PromotionsUI = (props
|
|
23
|
+
const PromotionsUI = (props: PromotionParams) => {
|
|
24
24
|
const {
|
|
25
25
|
navigation,
|
|
26
26
|
offersState,
|
|
@@ -65,20 +65,19 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
65
65
|
|
|
66
66
|
const [, t] = useLanguage()
|
|
67
67
|
const [{ parseDate, parsePrice, optimizeImage }] = useUtils()
|
|
68
|
-
const [events] = useEvent()
|
|
69
68
|
const [openModal, setOpenModal] = useState(false)
|
|
70
69
|
|
|
71
|
-
const handleClickOffer = (offer
|
|
70
|
+
const handleClickOffer = (offer: any) => {
|
|
72
71
|
setOpenModal(true)
|
|
73
72
|
setOfferSelected(offer)
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
const handleBusinessClick = (
|
|
77
|
-
|
|
75
|
+
const handleBusinessClick = (store: any) => {
|
|
76
|
+
setOpenModal(false)
|
|
77
|
+
navigation.navigate('Business', { store: store.slug })
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const filteredOffers = offersState?.offers?.filter((offer
|
|
81
|
-
|
|
80
|
+
const filteredOffers = offersState?.offers?.filter((offer: any) => offer.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
82
81
|
const targetString = offerSelected?.target === 1
|
|
83
82
|
? t('SUBTOTAL', 'Subtotal')
|
|
84
83
|
: offerSelected?.target === 2
|
|
@@ -121,21 +120,23 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
121
120
|
/>
|
|
122
121
|
)}
|
|
123
122
|
<ScrollView>
|
|
124
|
-
{!offersState?.loading && offersState.offers?.length > 0 && filteredOffers?.map((offer
|
|
123
|
+
{!offersState?.loading && offersState.offers?.length > 0 && filteredOffers?.map((offer: any) => (
|
|
125
124
|
<SingleOfferContainer key={offer.id}>
|
|
126
125
|
<OfferInformation>
|
|
127
|
-
<OText style={styles.offerTitle}>{offer?.name}</OText>
|
|
126
|
+
<OText style={styles.offerTitle} numberOfLines={2}>{offer?.name}</OText>
|
|
128
127
|
{offer?.description && (
|
|
129
|
-
<OText style={styles.offerDescription}>{offer?.description}</OText>
|
|
128
|
+
<OText style={styles.offerDescription} numberOfLines={2}>{offer?.description}</OText>
|
|
130
129
|
)}
|
|
131
130
|
<OText style={styles.offerExtraInfo}>
|
|
132
131
|
{t('EXPIRES', 'Expires')} {parseDate(offer?.end, { outputFormat: 'MMM DD, YYYY' })}
|
|
133
132
|
</OText>
|
|
134
133
|
<AvailableBusinesses>
|
|
135
|
-
<OText style={styles.offerExtraInfo}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
<OText style={styles.offerExtraInfo} numberOfLines={1}>
|
|
135
|
+
{t('APPLY_FOR', 'Apply for')}:
|
|
136
|
+
{offer.businesses.map((business: any, i: number) => (
|
|
137
|
+
<React.Fragment key={i}>{' '}{business?.name}{i + 1 < offer.businesses?.length ? ',' : ''}</React.Fragment>
|
|
138
|
+
))}
|
|
139
|
+
</OText>
|
|
139
140
|
</AvailableBusinesses>
|
|
140
141
|
</OfferInformation>
|
|
141
142
|
<OButton
|
|
@@ -170,7 +171,7 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
170
171
|
<OText>{t('OFFER_AUTOMATIC', 'This offer applies automatic')}</OText>
|
|
171
172
|
)}
|
|
172
173
|
{offerSelected?.minimum && (
|
|
173
|
-
<OText>{t('MINIMUM_PURCHASE_FOR_OFFER', 'Minimum
|
|
174
|
+
<OText>{t('MINIMUM_PURCHASE_FOR_OFFER', 'Minimum purchase for use this offer')}: {parsePrice(offerSelected?.minimum)}</OText>
|
|
174
175
|
)}
|
|
175
176
|
{offerSelected?.max_discount && (
|
|
176
177
|
<OText>{t('MAX_DISCOUNT_ALLOWED', 'Max discount allowed')}: {parsePrice(offerSelected?.max_discount)}</OText>
|
|
@@ -182,8 +183,8 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
182
183
|
<OText style={{ marginTop: 10, marginBottom: 10 }}>
|
|
183
184
|
{t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
|
|
184
185
|
</OText>
|
|
185
|
-
<ScrollView style={{height: '75%'}}>
|
|
186
|
-
{offerSelected?.businesses?.map((business
|
|
186
|
+
<ScrollView style={{ height: '75%' }}>
|
|
187
|
+
{offerSelected?.businesses?.map((business: any) => {
|
|
187
188
|
return (
|
|
188
189
|
<SingleBusinessOffer key={business.id}>
|
|
189
190
|
{business?.logo ? (
|
|
@@ -202,7 +203,7 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
202
203
|
/>
|
|
203
204
|
)}
|
|
204
205
|
<BusinessInfo>
|
|
205
|
-
<OText>{business.name}</OText>
|
|
206
|
+
<OText style={{ maxWidth: '60%' }}>{business.name}</OText>
|
|
206
207
|
<OButton
|
|
207
208
|
onClick={() => handleBusinessClick(business)}
|
|
208
209
|
text={t('GO_TO_BUSINESSS', 'Go to business')}
|
|
@@ -220,7 +221,7 @@ const PromotionsUI = (props : PromotionParams) => {
|
|
|
220
221
|
)
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
export const Promotions = (props
|
|
224
|
+
export const Promotions = (props: PromotionParams) => {
|
|
224
225
|
const PromotionsProps = {
|
|
225
226
|
...props,
|
|
226
227
|
UIComponent: PromotionsUI
|