ordering-ui-react-native 0.14.12 → 0.14.16
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/themes/business/src/components/MessagesOption/index.tsx +0 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +49 -14
- package/themes/business/src/components/OrdersOption/index.tsx +2 -0
- package/themes/doordash/src/components/BusinessProductsListing/index.tsx +4 -0
- package/themes/doordash/src/components/Home/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +2 -1
- package/themes/doordash/src/components/Messages/index.tsx +24 -7
- package/themes/doordash/src/components/SignupForm/index.tsx +2 -1
- package/themes/doordash/src/components/UserFormDetails/index.tsx +2 -1
- package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
- package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +1 -1
- package/themes/original/src/components/OrderSummary/index.tsx +1 -1
- package/themes/original/src/components/ProductItemAccordion/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -12,7 +12,6 @@ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
|
12
12
|
import { OText, OButton } from '../shared';
|
|
13
13
|
import { NotFoundSource } from '../NotFoundSource';
|
|
14
14
|
import { PreviousMessages } from '../PreviousMessages';
|
|
15
|
-
// import { Contacts } from '../Contacts';
|
|
16
15
|
import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
|
|
17
16
|
import { MessagesOptionParams } from '../../types';
|
|
18
17
|
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback } from 'react'
|
|
2
|
-
import { useEvent, useLanguage, useUtils, useSession, useApi } from 'ordering-components/native'
|
|
2
|
+
import { useEvent, useLanguage, useUtils, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
|
|
3
3
|
import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
|
|
4
4
|
import { OText, OIcon } from '../shared'
|
|
5
5
|
import { useTheme } from 'styled-components/native'
|
|
@@ -13,7 +13,7 @@ Sound.setCategory('Playback')
|
|
|
13
13
|
|
|
14
14
|
const windowWidth = Dimensions.get('screen').width
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const NewOrderNotificationUI = (props: any) => {
|
|
17
17
|
const [events] = useEvent()
|
|
18
18
|
const theme = useTheme()
|
|
19
19
|
const [, t] = useLanguage()
|
|
@@ -23,8 +23,10 @@ export const NewOrderNotification = (props: any) => {
|
|
|
23
23
|
const { getCurrentLocation } = useLocation();
|
|
24
24
|
const [modalOpen, setModalOpen] = useState(false)
|
|
25
25
|
const [newOrderId, setNewOrderId] = useState(null)
|
|
26
|
+
const [messageOrderId, setMessageOrderId] = useState(null)
|
|
26
27
|
const [soundTimeout, setSoundTimeout] = useState<any>(null)
|
|
27
28
|
const [isFocused, setIsFocused] = useState(false)
|
|
29
|
+
const [currentChange, setCurrentChange] = useState(1)
|
|
28
30
|
|
|
29
31
|
const notificationSound = new Sound(theme.sounds.notification, error => {
|
|
30
32
|
if (error) {
|
|
@@ -34,7 +36,6 @@ export const NewOrderNotification = (props: any) => {
|
|
|
34
36
|
console.log('loaded successfully');
|
|
35
37
|
});
|
|
36
38
|
|
|
37
|
-
|
|
38
39
|
const handlePlayNotificationSound = () => {
|
|
39
40
|
let times = 0
|
|
40
41
|
const _timeout = setInterval(function () {
|
|
@@ -57,19 +58,33 @@ export const NewOrderNotification = (props: any) => {
|
|
|
57
58
|
const handleCloseModal = () => {
|
|
58
59
|
clearInterval(soundTimeout)
|
|
59
60
|
setModalOpen(false)
|
|
61
|
+
setNewOrderId(null)
|
|
62
|
+
setMessageOrderId(null)
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
const handleNotification = (order: any) => {
|
|
63
66
|
setModalOpen(true)
|
|
64
67
|
clearInterval(soundTimeout)
|
|
68
|
+
setCurrentChange(1)
|
|
65
69
|
handlePlayNotificationSound()
|
|
66
70
|
setNewOrderId(order.id)
|
|
67
71
|
}
|
|
68
72
|
|
|
73
|
+
const handleMessageNotification = (message: any) => {
|
|
74
|
+
const { order_id: orderId } = message;
|
|
75
|
+
if (!modalOpen) setModalOpen(true)
|
|
76
|
+
clearInterval(soundTimeout)
|
|
77
|
+
setCurrentChange(2)
|
|
78
|
+
handlePlayNotificationSound()
|
|
79
|
+
setMessageOrderId(orderId)
|
|
80
|
+
}
|
|
81
|
+
|
|
69
82
|
useEffect(() => {
|
|
70
|
-
events.on('
|
|
83
|
+
events.on('order_added_noification', handleNotification)
|
|
84
|
+
events.on('message_added_noification', handleMessageNotification)
|
|
71
85
|
return () => {
|
|
72
|
-
events.off('
|
|
86
|
+
events.off('order_added_noification', handleNotification)
|
|
87
|
+
events.off('message_added_noification', handleMessageNotification)
|
|
73
88
|
}
|
|
74
89
|
}, [])
|
|
75
90
|
|
|
@@ -97,9 +112,9 @@ export const NewOrderNotification = (props: any) => {
|
|
|
97
112
|
|
|
98
113
|
useEffect(() => {
|
|
99
114
|
if (user?.level !== 4) return
|
|
100
|
-
events.on('
|
|
115
|
+
events.on('order_updated_noification', handleUpdateOrder)
|
|
101
116
|
return () => {
|
|
102
|
-
events.off('
|
|
117
|
+
events.off('order_updated_noification', handleUpdateOrder)
|
|
103
118
|
}
|
|
104
119
|
}, [handleUpdateOrder, user])
|
|
105
120
|
|
|
@@ -142,19 +157,30 @@ export const NewOrderNotification = (props: any) => {
|
|
|
142
157
|
color={theme.colors.textGray}
|
|
143
158
|
weight={600}
|
|
144
159
|
>
|
|
145
|
-
{t('NEW_ORDRES_RECEIVED', 'New orders have been received!')}
|
|
160
|
+
{currentChange === 1 ? t('NEW_ORDRES_RECEIVED', 'New orders have been received!') : t('NEW_MESSAGES_RECEIVED', 'New messages have been received!')}
|
|
146
161
|
</OText>
|
|
147
162
|
<OIcon
|
|
148
163
|
src={theme.images.general.newOrder}
|
|
149
164
|
width={250}
|
|
150
165
|
height={200}
|
|
151
166
|
/>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
167
|
+
{newOrderId !== null && (
|
|
168
|
+
<OText
|
|
169
|
+
color={theme.colors.textGray}
|
|
170
|
+
mBottom={15}
|
|
171
|
+
>
|
|
172
|
+
{t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', newOrderId)}
|
|
173
|
+
</OText>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{messageOrderId !== null && (
|
|
177
|
+
<OText
|
|
178
|
+
color={theme.colors.textGray}
|
|
179
|
+
mBottom={15}
|
|
180
|
+
>
|
|
181
|
+
{t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', messageOrderId)}
|
|
182
|
+
</OText>
|
|
183
|
+
)}
|
|
158
184
|
</View>
|
|
159
185
|
</NotificationContainer>
|
|
160
186
|
</Modal>
|
|
@@ -178,3 +204,12 @@ const styles = StyleSheet.create({
|
|
|
178
204
|
top: 20
|
|
179
205
|
}
|
|
180
206
|
})
|
|
207
|
+
|
|
208
|
+
export const NewOrderNotification = (props: any) => {
|
|
209
|
+
const newOrderNotificationProps = {
|
|
210
|
+
...props,
|
|
211
|
+
UIComponent: NewOrderNotificationUI
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
return <NewOrderNotificationController {...newOrderNotificationProps} />;
|
|
215
|
+
};
|
|
@@ -6,6 +6,7 @@ import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
|
6
6
|
import FontistoIcon from 'react-native-vector-icons/Fontisto'
|
|
7
7
|
import { useTheme } from 'styled-components/native';
|
|
8
8
|
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
9
|
+
import { NewOrderNotification } from '../NewOrderNotification';
|
|
9
10
|
|
|
10
11
|
import { OText, OButton, OModal, OIconButton, OInput, OIcon } from '../shared';
|
|
11
12
|
import { NotFoundSource } from '../NotFoundSource';
|
|
@@ -550,6 +551,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
550
551
|
</View>
|
|
551
552
|
{/* </GestureRecognizer> */}
|
|
552
553
|
|
|
554
|
+
<NewOrderNotification />
|
|
553
555
|
{openModal && (
|
|
554
556
|
<OModal open={openModal} entireModal customClose>
|
|
555
557
|
<ModalContainer
|
|
@@ -204,6 +204,10 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
204
204
|
}
|
|
205
205
|
}, [])
|
|
206
206
|
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
isKeyboardOpen && Platform.OS === 'android' && cartRef?.current?.scrollToEnd()
|
|
209
|
+
}, [isKeyboardOpen, cartRef?.current])
|
|
210
|
+
|
|
207
211
|
return (
|
|
208
212
|
<>
|
|
209
213
|
<Animated.View style={{ flex: 1, backgroundColor: theme.colors.white, position: 'absolute', width: '100%', top: top, zIndex: 1 }}>
|
|
@@ -182,7 +182,7 @@ export const Home = (props: any) => {
|
|
|
182
182
|
</TouchableOpacity>
|
|
183
183
|
</View>
|
|
184
184
|
|
|
185
|
-
<OModal entireModal customClose transition={'pageSheet'} open={isAuth} onClose={() => setAuthState(false)} style={{borderRadius: 7.6}}>
|
|
185
|
+
<OModal overScreen={Platform.OS === 'ios'} entireModal customClose transition={'pageSheet'} open={isAuth} onClose={() => setAuthState(false)} style={{borderRadius: 7.6}}>
|
|
186
186
|
<View style={styles.authHeader}>
|
|
187
187
|
<TouchableOpacity onPress={() => setAuthState(false)} style={{}}>
|
|
188
188
|
<OIcon src={theme.images.general.close} width={16} />
|
|
@@ -410,7 +410,8 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
410
410
|
textInputProps={{
|
|
411
411
|
returnKeyType: 'next',
|
|
412
412
|
onSubmitEditing: () => inputRef?.current?.focus?.(),
|
|
413
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
413
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
414
|
+
maxLength: 10
|
|
414
415
|
}}
|
|
415
416
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
416
417
|
/>
|
|
@@ -9,6 +9,8 @@ import { OIcon, OIconButton, OText, OButton } from '../shared'
|
|
|
9
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
|
+
import { useWindowDimensions } from 'react-native'
|
|
13
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
14
|
|
|
13
15
|
const MessagesUI = (props: MessagesParams) => {
|
|
14
16
|
|
|
@@ -42,6 +44,9 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
42
44
|
|
|
43
45
|
const [formattedMessages, setFormattedMessages] = useState<Array<any>>([])
|
|
44
46
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false)
|
|
47
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
48
|
+
const { height } = useWindowDimensions();
|
|
49
|
+
const { top, bottom } = useSafeAreaInsets();
|
|
45
50
|
|
|
46
51
|
const handleClickQuickMessage = (text: string) => {
|
|
47
52
|
setMessage && setMessage(`${message}${text}`)
|
|
@@ -186,15 +191,22 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
186
191
|
}, [messages.messages.length])
|
|
187
192
|
|
|
188
193
|
useEffect(() => {
|
|
189
|
-
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
|
|
194
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', (e) => {
|
|
190
195
|
setIsKeyboardShow(true)
|
|
196
|
+
setKeyboardHeight(e.endCoordinates.height)
|
|
191
197
|
})
|
|
192
198
|
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
|
|
193
199
|
setIsKeyboardShow(false)
|
|
200
|
+
setKeyboardHeight(0)
|
|
194
201
|
})
|
|
202
|
+
const keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', (e) => {
|
|
203
|
+
setIsKeyboardShow(false)
|
|
204
|
+
setKeyboardHeight(0)
|
|
205
|
+
})
|
|
195
206
|
return () => {
|
|
196
207
|
keyboardDidShowListener.remove()
|
|
197
208
|
keyboardDidHideListener.remove()
|
|
209
|
+
keyboardWillHideListener.remove()
|
|
198
210
|
}
|
|
199
211
|
}, [])
|
|
200
212
|
|
|
@@ -273,7 +285,6 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
273
285
|
containerStyle={{
|
|
274
286
|
padding: Platform.OS === 'ios' && isKeyboardShow ? 0 : 10,
|
|
275
287
|
flexDirection: 'column-reverse',
|
|
276
|
-
marginBottom: Platform.OS === 'ios' && isKeyboardShow ? 500 : 0
|
|
277
288
|
}}
|
|
278
289
|
primaryStyle={{ alignItems: 'center', justifyContent: 'flex-start' }}
|
|
279
290
|
renderAccessory={() => renderAccessory()}
|
|
@@ -362,8 +373,16 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
362
373
|
<MaterialCommunityIcon name='chevron-double-down' size={32} />
|
|
363
374
|
)
|
|
364
375
|
|
|
376
|
+
const getViewHeight = () => {
|
|
377
|
+
if (Platform.OS === 'android') {
|
|
378
|
+
return '100%'
|
|
379
|
+
} else {
|
|
380
|
+
return height - top - bottom - (isKeyboardShow ? keyboardHeight - 240 : 48)
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
365
384
|
return (
|
|
366
|
-
|
|
385
|
+
<View style={{ height: getViewHeight(), width: '100%', paddingTop: 12, backgroundColor: 'white' }}>
|
|
367
386
|
<Wrapper>
|
|
368
387
|
<Header>
|
|
369
388
|
<OIcon
|
|
@@ -396,15 +415,13 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
396
415
|
renderBubble={renderBubble}
|
|
397
416
|
renderMessageImage={renderMessageImage}
|
|
398
417
|
scrollToBottomComponent={() => renderScrollToBottomComponent()}
|
|
399
|
-
|
|
400
|
-
paddingBottom: 55
|
|
401
|
-
}}
|
|
418
|
+
|
|
402
419
|
isLoadingEarlier={messages.loading}
|
|
403
420
|
renderLoading={() => <ActivityIndicator size="small" color="#000" />}
|
|
404
421
|
keyboardShouldPersistTaps='handled'
|
|
405
422
|
/>
|
|
406
423
|
</Wrapper>
|
|
407
|
-
|
|
424
|
+
</View>
|
|
408
425
|
)
|
|
409
426
|
}
|
|
410
427
|
|
|
@@ -452,7 +452,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
452
452
|
textInputProps={{
|
|
453
453
|
returnKeyType: 'next',
|
|
454
454
|
onSubmitEditing: () => passwordRef?.current?.focus?.(),
|
|
455
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
455
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
456
|
+
maxLength: 10
|
|
456
457
|
}}
|
|
457
458
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
458
459
|
/>
|
|
@@ -226,7 +226,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
226
226
|
defaultValue={phoneUpdate ? '' : user?.cellphone}
|
|
227
227
|
defaultCode={user?.country_phone_code || null}
|
|
228
228
|
textInputProps={{
|
|
229
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
229
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
230
|
+
maxLength: 10
|
|
230
231
|
}}
|
|
231
232
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
232
233
|
countryButtonStyle={{ marginStart: -2, justifyContent: 'flex-start', flexBasis: '36%'}}
|
|
@@ -335,7 +335,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
335
335
|
dropdownStyle={{
|
|
336
336
|
borderRadius: 8,
|
|
337
337
|
borderColor: theme.colors.lightGray,
|
|
338
|
-
marginTop: Platform.OS === 'ios' ? 0 : -
|
|
338
|
+
marginTop: Platform.OS === 'ios' ? 0 : -25
|
|
339
339
|
}}
|
|
340
340
|
rowStyle={{
|
|
341
341
|
borderBottomColor: theme.colors.backgroundGray100,
|
|
@@ -227,7 +227,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
|
|
|
227
227
|
</PrincipalWrapView>
|
|
228
228
|
|
|
229
229
|
{reviewsList?.reviews
|
|
230
|
-
.filter((review: any) => searchReview !== '' ? review.comment?.toLowerCase()?.includes(searchReview) : true)
|
|
230
|
+
.filter((review: any) => searchReview !== '' ? review.comment?.toLowerCase()?.includes(searchReview?.toLowerCase()) : true)
|
|
231
231
|
.map((review: any) => (
|
|
232
232
|
<ReviewItem
|
|
233
233
|
key={`review_key_${review.id}`}
|
|
@@ -213,7 +213,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
213
213
|
{((isCartProduct && !isCartPending && product?.valid_menu && !product?.valid_quantity) ||
|
|
214
214
|
(!product?.valid_menu && isCartProduct && !isCartPending)) && (
|
|
215
215
|
<View style={{ alignItems: 'flex-end', width: '100%' }}>
|
|
216
|
-
<OText size={
|
|
216
|
+
<OText size={14} color={theme.colors.red} style={{ textAlign: 'right', bottom: 20 }}>
|
|
217
217
|
{t('NOT_AVAILABLE', 'Not available')}
|
|
218
218
|
</OText>
|
|
219
219
|
</View>
|