ordering-ui-react-native 0.12.96 → 0.13.0

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.12.96",
3
+ "version": "0.13.00",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -67,7 +67,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
67
67
  <NavBar
68
68
  title={t('REVIEW_PRODUCT', 'Review product')}
69
69
  titleAlign={'center'}
70
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
70
+ onActionLeft={() => onNavigationRedirect('MyOrders')}
71
71
  showCall={false}
72
72
  btnStyle={{ paddingLeft: 0 }}
73
73
  paddingTop={0}
@@ -2,6 +2,7 @@ import styled from 'styled-components/native';
2
2
 
3
3
  export const FiltersTab = styled.View`
4
4
  margin-bottom: 20px;
5
+ min-height: 30px;
5
6
  max-height: 35px;
6
7
  flex: 1;
7
8
  `;
@@ -60,7 +60,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
60
60
  }
61
61
 
62
62
  const handleClickOrderReview = (order: any) => {
63
- onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo } })
63
+ onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo, products: order?.products } })
64
64
  }
65
65
 
66
66
  const handleReorderClick = (id: number) => {
@@ -8,7 +8,7 @@ import {
8
8
  } from 'ordering-components/native'
9
9
  import { ProductIngredient } from '../ProductIngredient'
10
10
  import { ProductOption } from '../ProductOption'
11
- import { View, TouchableOpacity, StyleSheet, Dimensions, ScrollView, I18nManager, TextStyle, Platform } from 'react-native'
11
+ import { View, TouchableOpacity, StyleSheet, Dimensions, ScrollView, I18nManager, TextStyle, Platform, KeyboardAvoidingView } from 'react-native'
12
12
  import {
13
13
  ProductHeader,
14
14
  WrapHeader,
@@ -137,7 +137,11 @@ export const ProductOptionsUI = (props: any) => {
137
137
  const saveErrors = orderState.loading || maxProductQuantity === 0 || Object.keys(errors).length > 0
138
138
 
139
139
  return (
140
- <>
140
+ <KeyboardAvoidingView
141
+ style={{ flex: 1 }}
142
+ behavior={'height'}
143
+ enabled={Platform.OS === 'ios'}
144
+ >
141
145
  <ScrollView style={styles.mainContainer}>
142
146
  {!error && (
143
147
  <View style={{ paddingBottom: 80 }}>
@@ -286,7 +290,7 @@ export const ProductOptionsUI = (props: any) => {
286
290
  />
287
291
  </ProductComment>
288
292
  {productCart && !isSoldOut && maxProductQuantity > 0 && (
289
- <View style={{ paddingVertical: 4 }}>
293
+ <View style={{ paddingVertical: 4, marginBottom: 10 }}>
290
294
  <SectionTitle>
291
295
  <OText style={theme.labels.middle as TextStyle}>{t('PREFERENCES', 'Preferences')}</OText>
292
296
  </SectionTitle>
@@ -335,6 +339,7 @@ export const ProductOptionsUI = (props: any) => {
335
339
  textSub={`${orderState.loading ? '' : productCart.total ? parsePrice(productCart?.total) : ''}`}
336
340
  textStyle={{ color: saveErrors ? theme.colors.textSecondary : theme.colors.white, fontSize: 14, fontWeight: Platform.OS === 'ios' ? '600' : 'bold' }}
337
341
  style={{
342
+ bottom: 5,
338
343
  backgroundColor: saveErrors ? theme.colors.backgroundGray300 : theme.colors.primary,
339
344
  borderWidth: 1, shadowOpacity: 0, height: 40,
340
345
  borderColor: saveErrors ? theme.colors.backgroundGray300 : theme.colors.primary,
@@ -361,13 +366,13 @@ export const ProductOptionsUI = (props: any) => {
361
366
  text={isSoldOut || maxProductQuantity <= 0 ? t('SOLD_OUT', 'Sold out') : t('LOGIN_SIGNUP', 'Login / Sign Up')}
362
367
  imgRightSrc=''
363
368
  textStyle={{ color: theme.colors.primary, ...theme.labels.middle }}
364
- style={{ height: 40, borderWidth: 1, borderColor: theme.colors.primary, backgroundColor: theme.colors.white }}
369
+ style={{ bottom: 5, marginTop: 2, height: 40, borderWidth: 1, borderColor: theme.colors.primary, backgroundColor: theme.colors.white }}
365
370
  />
366
371
  )}
367
372
  </View>
368
373
  </ProductActions>
369
374
  )}
370
- </>
375
+ </KeyboardAvoidingView>
371
376
  )
372
377
  }
373
378
 
@@ -81,7 +81,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
81
81
  dropdownStyle={{
82
82
  borderRadius: 8,
83
83
  borderColor: theme.colors.lightGray,
84
- marginTop: 5,
84
+ marginTop: -15,
85
85
  maxHeight: 160
86
86
  }}
87
87
  rowStyle={{
@@ -335,7 +335,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
335
335
  dropdownStyle={{
336
336
  borderRadius: 8,
337
337
  borderColor: theme.colors.lightGray,
338
- marginTop: 5
338
+ marginTop: -15
339
339
  }}
340
340
  rowStyle={{
341
341
  borderBottomColor: theme.colors.backgroundGray100,
@@ -149,6 +149,7 @@ const OrderMessageUI = (props: any) => {
149
149
  } = props;
150
150
  const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
151
151
  const [openModalForDriver, setOpenModalForDriver] = useState(false);
152
+ const [openMessages, setOpenMessages] = useState({ business: false, driver: false });
152
153
  const [unreadAlert, setUnreadAlert] = useState({
153
154
  business: false,
154
155
  driver: false,
@@ -163,6 +164,11 @@ const OrderMessageUI = (props: any) => {
163
164
  setOpenMessges(false)
164
165
  }
165
166
 
167
+ const handleOpenMessages = (data: any) => {
168
+ setOpenMessages(data)
169
+ readMessages && readMessages();
170
+ }
171
+
166
172
  useEffect(() => {
167
173
  if (messagesReadList?.length) {
168
174
  openModalForBusiness
@@ -184,19 +190,24 @@ const OrderMessageUI = (props: any) => {
184
190
  };
185
191
  }, []);
186
192
 
193
+ useEffect(() => {
194
+ handleOpenMessages({ driver: false, business: true })
195
+ }, [])
196
+
187
197
  return (
188
198
  <>
189
- {(order?.business && !order?.driver) && (
190
- <Messages
191
- orderId={order?.id}
192
- messages={messages}
193
- order={order}
194
- setMessages={setMessages}
195
- readMessages={readMessages}
196
- isMeesageListing
197
- onClose={() => handleClose()}
198
- />
199
- )}
199
+ <Messages
200
+ orderId={order?.id}
201
+ messages={messages}
202
+ order={order}
203
+ setMessages={setMessages}
204
+ readMessages={readMessages}
205
+ business={openMessages.business}
206
+ driver={openMessages.driver}
207
+ onMessages={setOpenMessages}
208
+ isMeesageListing
209
+ onClose={() => handleClose()}
210
+ />
200
211
  </>
201
212
 
202
213
  )
@@ -212,7 +223,10 @@ export const OrderListing = (props: OrdersOptionParams) => {
212
223
  initialPage: 1,
213
224
  pageSize: 10,
214
225
  controlType: 'infinity'
215
- }
226
+ },
227
+ profileMessages: true,
228
+ orderBy: 'last_direct_message_at',
229
+ orderDirection: 'asc'
216
230
  }
217
231
  return <OrderList {...OrderListingProps} />
218
232
  }
@@ -258,10 +272,6 @@ export const MessageListing = (props: MessageListingParams) => {
258
272
  }
259
273
  }, [orderListStatus, selectedOrderId])
260
274
 
261
- useEffect(() => {
262
-
263
- }, [orderListStatus])
264
-
265
275
  return (
266
276
  <MessageListingWrapper>
267
277
  <NavBar
@@ -7,7 +7,7 @@ import { USER_TYPE } from '../../config/constants'
7
7
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
8
8
  import { OIcon, OIconButton, OText, OButton } from '../shared'
9
9
  import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard } from 'react-native'
10
- import { Header, TitleHeader, Wrapper, QuickMessageContainer, ProfileMessageHeader } from './styles'
10
+ import { Header, TitleHeader, Wrapper, QuickMessageContainer, ProfileMessageHeader, MessageTypeItem } from './styles'
11
11
  import { MessagesParams } from '../../types'
12
12
  import { useWindowDimensions } from 'react-native'
13
13
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -21,11 +21,15 @@ const MessagesUI = (props: MessagesParams) => {
21
21
  message,
22
22
  messagesToShow,
23
23
  sendMessage,
24
+ setCanRead,
24
25
  setMessage,
25
26
  handleSend,
26
27
  setImage,
27
28
  readMessages,
28
29
  onClose,
30
+ business,
31
+ driver,
32
+ onMessages,
29
33
  isMeesageListing
30
34
  } = props
31
35
 
@@ -161,18 +165,18 @@ const MessagesUI = (props: MessagesParams) => {
161
165
 
162
166
  useEffect(() => {
163
167
  let newMessages: Array<any> = []
164
- const console = `${t('ORDER_PLACED_FOR', 'Order placed for')} ${parseDate(order?.created_at)} ${t('VIA', 'Via')} ${order?.app_id ? t(order?.app_id.toUpperCase(), order?.app_id) : t('OTHER', 'Other')}`
168
+ const _console = `${t('ORDER_PLACED_FOR', 'Order placed for')} ${parseDate(order?.created_at)} ${t('VIA', 'Via')} ${order?.app_id ? t(order?.app_id.toUpperCase(), order?.app_id) : t('OTHER', 'Other')}`
165
169
  const firstMessage = {
166
170
  _id: 0,
167
- text: console,
171
+ text: _console,
168
172
  createdAt: order?.created_at,
169
173
  system: true
170
174
  }
175
+ const newMessage: any = [];
171
176
  messages.messages.map((message: any) => {
172
- let newMessage
173
- if (message.type !== 0 && (messagesToShow?.messages?.length || (message?.can_see?.includes('2')) || (message?.can_see?.includes('4') && type === USER_TYPE.DRIVER))) {
174
- newMessage = {
175
- _id: message.id,
177
+ if (business && message.type !== 0 && (messagesToShow?.messages?.length || message?.can_see?.includes('2'))) {
178
+ newMessage.push({
179
+ _id: message?.id,
176
180
  text: message.type === 1 ? messageConsole(message) : message.comment,
177
181
  createdAt: message.type !== 0 && message.created_at,
178
182
  image: message.source,
@@ -182,15 +186,30 @@ const MessagesUI = (props: MessagesParams) => {
182
186
  name: message.author.name,
183
187
  avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
184
188
  }
185
- }
189
+ });
190
+ }
191
+
192
+ if (driver && message.type !== 0 && (messagesToShow?.messages?.length || message?.can_see?.includes('4'))) {
193
+ newMessage.push({
194
+ _id: message?.id,
195
+ text: message.type === 1 ? messageConsole(message) : message.comment,
196
+ createdAt: message.type !== 0 && message.created_at,
197
+ image: message.source,
198
+ system: message.type === 1,
199
+ user: {
200
+ _id: message.author.id,
201
+ name: message.author.name,
202
+ avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
203
+ }
204
+ });
186
205
  }
206
+
187
207
  if (message.type === 0) {
188
- newMessage = firstMessage
208
+ newMessage.push(firstMessage);
189
209
  }
190
- newMessages = [...newMessages, newMessage]
191
210
  })
192
- setFormattedMessages([...newMessages.reverse()])
193
- }, [messages.messages.length])
211
+ setFormattedMessages(newMessage.reverse())
212
+ }, [messages.messages.length, business, driver])
194
213
 
195
214
  useEffect(() => {
196
215
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
@@ -205,6 +224,11 @@ const MessagesUI = (props: MessagesParams) => {
205
224
  }
206
225
  }, [])
207
226
 
227
+ useEffect(() => {
228
+ if (business) setCanRead({ business: true, administrator: true, customer: true, driver: false })
229
+ else if (driver) setCanRead({ business: false, administrator: true, customer: true, driver: true })
230
+ }, [business, driver])
231
+
208
232
  const RenderActions = (props: any) => {
209
233
  return (
210
234
  <Actions
@@ -422,23 +446,39 @@ const MessagesUI = (props: MessagesParams) => {
422
446
  </TouchableOpacity>
423
447
  <OText size={18}>{t('ORDER', theme?.defaultLanguages?.ORDER || 'Order')} #{order?.id}</OText>
424
448
  </View>
425
- <View>
449
+ <View style={{ ...styles.typeWraper }}>
426
450
  {order.business && (
427
- <OIcon
428
- url={order?.business?.logo}
429
- width={32}
430
- height={32}
431
- style={{ borderRadius: 7.6 }}
432
- />
451
+ <TouchableOpacity
452
+ onPress={() => onMessages({ business: true, driver: false })}
453
+ >
454
+ <MessageTypeItem
455
+ active={business}
456
+ >
457
+ <OIcon
458
+ url={order?.business?.logo}
459
+ width={32}
460
+ height={32}
461
+ style={{ borderRadius: 32 }}
462
+ />
463
+ </MessageTypeItem>
464
+ </TouchableOpacity>
433
465
  )}
434
466
 
435
467
  {order?.driver && (
436
- <OIcon
437
- url={order?.driver?.photo}
438
- width={32}
439
- height={32}
440
- style={{ borderRadius: 7.6 }}
441
- />
468
+ <TouchableOpacity
469
+ onPress={() => onMessages({ business: false, driver: true })}
470
+ >
471
+ <MessageTypeItem
472
+ active={driver}
473
+ >
474
+ <OIcon
475
+ url={order?.driver?.photo}
476
+ width={32}
477
+ height={32}
478
+ style={{ borderRadius: 32 }}
479
+ />
480
+ </MessageTypeItem>
481
+ </TouchableOpacity>
442
482
  )}
443
483
  </View>
444
484
  </ProfileMessageHeader>
@@ -509,6 +549,11 @@ const styles = StyleSheet.create({
509
549
  overflow: 'hidden',
510
550
  width: 35,
511
551
  marginVertical: 18,
552
+ },
553
+ typeWraper: {
554
+ flexDirection: 'row',
555
+ height: 45,
556
+ alignItems: 'center'
512
557
  }
513
558
 
514
559
  })
@@ -1,5 +1,6 @@
1
1
 
2
- import styled from 'styled-components/native'
2
+ import styled, { css } from 'styled-components/native'
3
+
3
4
 
4
5
  export const Wrapper = styled.View`
5
6
  flex: 1;
@@ -24,4 +25,18 @@ export const ProfileMessageHeader = styled.View`
24
25
  align-items: center;
25
26
  padding-bottom: 0px;
26
27
  padding-horizontal: 20px;
28
+ `
29
+ export const MessageTypeItem = styled.View`
30
+ justify-content: center;
31
+ align-items: center;
32
+ padding-horizontal: 5px;
33
+ padding-bottom: 5px;
34
+ padding-top: 5px;
35
+ margin-right: 5px;
36
+ border-radius: 7.6px;
37
+ overflow: hidden;
38
+
39
+ ${({ active }: any) => active && css`
40
+ background-color: ${(props: any) => props.theme.colors.whiteGray};
41
+ `}
27
42
  `
@@ -338,7 +338,11 @@ export interface MessagesParams {
338
338
  setMessages?: () => {},
339
339
  readMessages?: () => {},
340
340
  onClose?: () => void,
341
- isMeesageListing?: boolean
341
+ isMeesageListing?: boolean,
342
+ setCanRead?: any,
343
+ business: boolean,
344
+ driver: boolean,
345
+ onMessages?: any
342
346
  }
343
347
  export interface ViewInterface {
344
348
  navigation?: any;