ordering-ui-react-native 0.15.73 → 0.15.76
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/kiosk/src/components/ProductForm/index.tsx +1 -1
- package/themes/original/src/components/Wallets/index.tsx +6 -6
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
|
|
@@ -446,7 +446,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
446
446
|
</WrapperIngredients>
|
|
447
447
|
</View>
|
|
448
448
|
)}
|
|
449
|
-
{product?.extras.map((extra: any) => extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
449
|
+
{product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) => extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
450
450
|
const currentState = productCart.options[`id:${option.id}`] || {}
|
|
451
451
|
return (
|
|
452
452
|
<React.Fragment key={option.id}>
|
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
WalletList,
|
|
8
8
|
useLanguage,
|
|
9
9
|
useUtils,
|
|
10
|
-
useConfig
|
|
11
|
-
useSession
|
|
10
|
+
useConfig
|
|
12
11
|
} from 'ordering-components/native'
|
|
13
12
|
|
|
14
13
|
import {
|
|
@@ -32,6 +31,7 @@ const WalletsUI = (props: any) => {
|
|
|
32
31
|
const {
|
|
33
32
|
navigation,
|
|
34
33
|
walletList,
|
|
34
|
+
userLoyaltyLevel,
|
|
35
35
|
transactionsList,
|
|
36
36
|
setWalletSelected,
|
|
37
37
|
isWalletCashEnabled,
|
|
@@ -42,7 +42,6 @@ const WalletsUI = (props: any) => {
|
|
|
42
42
|
} = props
|
|
43
43
|
|
|
44
44
|
const [, t] = useLanguage()
|
|
45
|
-
const [{ user }] = useSession()
|
|
46
45
|
const theme = useTheme()
|
|
47
46
|
const [{ parsePrice }] = useUtils()
|
|
48
47
|
const [{ configs }] = useConfig()
|
|
@@ -66,7 +65,7 @@ const WalletsUI = (props: any) => {
|
|
|
66
65
|
|
|
67
66
|
const currentWalletSelected = (walletList.wallets?.length > 0 && walletList.wallets?.find((w: any) => w.type === tabSelected)) ?? null
|
|
68
67
|
|
|
69
|
-
const loyaltyLevel = Object.keys(
|
|
68
|
+
const loyaltyLevel = Object.keys(userLoyaltyLevel.loyaltyLevel ?? {}).length > 0 && userLoyaltyLevel.loyaltyLevel
|
|
70
69
|
|
|
71
70
|
const walletName: any = {
|
|
72
71
|
cash: {
|
|
@@ -117,6 +116,7 @@ const WalletsUI = (props: any) => {
|
|
|
117
116
|
/>
|
|
118
117
|
|
|
119
118
|
{!walletList.loading &&
|
|
119
|
+
!userLoyaltyLevel.loading &&
|
|
120
120
|
!walletList.error &&
|
|
121
121
|
walletList.wallets?.length > 0 &&
|
|
122
122
|
(
|
|
@@ -239,7 +239,7 @@ const WalletsUI = (props: any) => {
|
|
|
239
239
|
</>
|
|
240
240
|
)}
|
|
241
241
|
|
|
242
|
-
{walletList?.loading && (
|
|
242
|
+
{(walletList?.loading || userLoyaltyLevel.loading) && (
|
|
243
243
|
<>
|
|
244
244
|
<View>
|
|
245
245
|
<Placeholder Animation={Fade}>
|
|
@@ -263,7 +263,7 @@ const WalletsUI = (props: any) => {
|
|
|
263
263
|
</>
|
|
264
264
|
)}
|
|
265
265
|
|
|
266
|
-
{!walletList?.loading && (walletList?.error || !walletList?.wallets?.length) && (
|
|
266
|
+
{!walletList?.loading && !userLoyaltyLevel.loading && (walletList?.error || !walletList?.wallets?.length) && (
|
|
267
267
|
<NotFoundSource
|
|
268
268
|
content={walletList?.error
|
|
269
269
|
? t('ERROR_NOT_FOUND_WALLETS', 'Sorry, an error has occurred')
|