ordering-ui-react-native 0.15.20 → 0.15.22-release

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.
Files changed (152) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessTypeFilter/index.tsx +12 -2
  4. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +0 -1
  7. package/src/components/LanguageSelector/index.tsx +1 -0
  8. package/src/components/OrderDetails/index.tsx +26 -5
  9. package/src/components/PaymentOptions/index.tsx +9 -16
  10. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  11. package/src/components/StripeElementsForm/index.tsx +27 -48
  12. package/src/components/UserProfileForm/index.tsx +63 -6
  13. package/src/components/UserProfileForm/styles.tsx +8 -0
  14. package/src/components/VerifyPhone/styles.tsx +1 -2
  15. package/src/config.json +0 -2
  16. package/src/navigators/HomeNavigator.tsx +6 -0
  17. package/src/pages/BusinessProductsList.tsx +1 -0
  18. package/src/pages/BusinessesListing.tsx +1 -1
  19. package/src/pages/Checkout.tsx +1 -1
  20. package/src/pages/Sessions.tsx +22 -0
  21. package/src/types/index.tsx +3 -9
  22. package/src/utils/index.tsx +68 -1
  23. package/themes/business/index.tsx +2 -0
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
  26. package/themes/business/src/components/Chat/index.tsx +38 -86
  27. package/themes/business/src/components/Home/index.tsx +128 -55
  28. package/themes/business/src/components/Home/styles.tsx +8 -1
  29. package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
  30. package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
  31. package/themes/business/src/components/OrderDetails/Delivery.tsx +22 -13
  32. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
  33. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
  34. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  35. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  36. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  37. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  38. package/themes/business/src/components/OrdersOption/index.tsx +53 -49
  39. package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
  40. package/themes/business/src/types/index.tsx +2 -1
  41. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  42. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  43. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  44. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  45. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  46. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +48 -21
  47. package/themes/kiosk/src/components/Cart/index.tsx +98 -24
  48. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  49. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  50. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  51. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  52. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  53. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  55. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  56. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  57. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  58. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  59. package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
  60. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  61. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  62. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  63. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
  64. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  65. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  66. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  67. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  68. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  69. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +178 -1
  72. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  73. package/themes/original/src/components/AddressList/index.tsx +56 -18
  74. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  77. package/themes/original/src/components/BusinessController/index.tsx +52 -22
  78. package/themes/original/src/components/BusinessController/styles.tsx +22 -0
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  81. package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
  82. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  83. package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
  84. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +127 -20
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  87. package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
  88. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  89. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  90. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  91. package/themes/original/src/components/BusinessesListing/index.tsx +48 -57
  92. package/themes/original/src/components/Cart/index.tsx +18 -14
  93. package/themes/original/src/components/CartContent/index.tsx +2 -2
  94. package/themes/original/src/components/Checkout/index.tsx +42 -27
  95. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  96. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  97. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  98. package/themes/original/src/components/Help/index.tsx +21 -4
  99. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  100. package/themes/original/src/components/Home/index.tsx +1 -1
  101. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  102. package/themes/original/src/components/LoginForm/index.tsx +73 -2
  103. package/themes/original/src/components/LoginForm/styles.tsx +6 -1
  104. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  105. package/themes/original/src/components/Messages/index.tsx +34 -25
  106. package/themes/original/src/components/Messages/styles.tsx +1 -3
  107. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  108. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  109. package/themes/original/src/components/OrderDetails/index.tsx +83 -42
  110. package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
  111. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  112. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  113. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  114. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  115. package/themes/original/src/components/OrdersOption/index.tsx +25 -33
  116. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  117. package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -4
  118. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  119. package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
  120. package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
  121. package/themes/original/src/components/ProductForm/index.tsx +40 -33
  122. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  123. package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
  124. package/themes/original/src/components/Promotions/index.tsx +250 -0
  125. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  126. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  127. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  128. package/themes/original/src/components/Sessions/index.tsx +160 -0
  129. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  130. package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
  131. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  132. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  133. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  134. package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
  135. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  136. package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
  137. package/themes/original/src/components/UserProfile/index.tsx +62 -14
  138. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  139. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  140. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  141. package/themes/original/src/components/Wallets/index.tsx +75 -8
  142. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  143. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  144. package/themes/original/src/components/shared/index.tsx +2 -0
  145. package/themes/original/src/config/constants.tsx +6 -6
  146. package/themes/original/src/types/index.tsx +70 -25
  147. package/themes/original/src/utils/index.tsx +12 -2
  148. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  149. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  150. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  151. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  152. package/src/components/StripeMethodForm/index.tsx +0 -168
@@ -44,6 +44,35 @@ import { USER_TYPE } from '../../config/constants';
44
44
 
45
45
  import SignatureScreen from 'react-native-signature-canvas';
46
46
 
47
+ const ORDER_STATUS: any = {
48
+ 0: 'ORDER_STATUS_PENDING',
49
+ 1: 'ORDERS_COMPLETED',
50
+ 2: 'ORDER_REJECTED',
51
+ 3: 'ORDER_STATUS_IN_BUSINESS',
52
+ 4: 'ORDER_READY',
53
+ 5: 'ORDER_REJECTED_RESTAURANT',
54
+ 6: 'ORDER_STATUS_CANCELLEDBYDRIVER',
55
+ 7: 'ORDER_STATUS_ACCEPTEDBYRESTAURANT',
56
+ 8: 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER',
57
+ 9: 'ORDER_PICKUP_COMPLETED_BY_DRIVER',
58
+ 10: 'ORDER_PICKUP_FAILED_BY_DRIVER',
59
+ 11: 'ORDER_DELIVERY_COMPLETED_BY_DRIVER',
60
+ 12: 'ORDER_DELIVERY_FAILED_BY_DRIVER',
61
+ 13: 'PREORDER',
62
+ 14: 'ORDER_NOT_READY',
63
+ 15: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
64
+ 16: 'ORDER_STATUS_CANCELLED_BY_CUSTOMER',
65
+ 17: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
66
+ 18: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
67
+ 19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
68
+ 20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
69
+ 21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
70
+ 22: 'ORDER_LOOKING_FOR_DRIVER',
71
+ 23: 'ORDER_DRIVER_ON_WAY'
72
+ }
73
+
74
+ const filterSpecialStatus = ['prepared_in', 'delivered_in', 'delivery_datetime']
75
+
47
76
  const ChatUI = (props: MessagesParams) => {
48
77
  const {
49
78
  type,
@@ -317,71 +346,6 @@ const ChatUI = (props: MessagesParams) => {
317
346
  }
318
347
  };
319
348
 
320
- const getStatus = (status: number, attribute: any) => {
321
- const hour = Math.trunc(status / 60);
322
- const min = Math.round((status / 60 - hour) * 60);
323
-
324
- if (attribute === 'status') {
325
- switch (status) {
326
- case 0:
327
- return 'ORDER_STATUS_PENDING';
328
- case 1:
329
- return 'ORDERS_COMPLETED';
330
- case 2:
331
- return 'ORDER_REJECTED';
332
- case 3:
333
- return 'ORDER_STATUS_IN_BUSINESS';
334
- case 4:
335
- return 'ORDER_READY';
336
- case 5:
337
- return 'ORDER_REJECTED_RESTAURANT';
338
- case 6:
339
- return 'ORDER_STATUS_CANCELLEDBYDRIVER';
340
- case 7:
341
- return 'ORDER_STATUS_ACCEPTEDBYRESTAURANT';
342
- case 8:
343
- return 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER';
344
- case 9:
345
- return 'ORDER_PICKUP_COMPLETED_BY_DRIVER';
346
- case 10:
347
- return 'ORDER_PICKUP_FAILED_BY_DRIVER';
348
- case 11:
349
- return 'ORDER_DELIVERY_COMPLETED_BY_DRIVER';
350
- case 12:
351
- return 'ORDER_DELIVERY_FAILED_BY_DRIVER';
352
- case 13:
353
- return 'PREORDER';
354
- case 14:
355
- return 'ORDER_NOT_READY';
356
- case 15:
357
- return 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER';
358
- case 16:
359
- return 'ORDER_STATUS_CANCELLED_BY_CUSTOMER';
360
- case 17:
361
- return 'ORDER_NOT_PICKEDUP_BY_CUSTOMER';
362
- case 18:
363
- return 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS';
364
- case 19:
365
- return 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER';
366
- case 20:
367
- return 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS';
368
- case 21:
369
- return 'ORDER_CUSTOMER_ARRIVED_BUSINESS';
370
- case 22:
371
- return 'ORDER_LOOKING_FOR_DRIVER'
372
- case 23:
373
- return 'ORDER_DRIVER_ON_WAY'
374
- default:
375
- return ``;
376
- }
377
- }
378
-
379
- if (attribute === 'prepared_in' || attribute === 'delivered_in') {
380
- return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min} ${status > 60 ? 'hours' : 'minutes'
381
- }`;
382
- }
383
- };
384
-
385
349
  const onSubmit = (values: any) => {
386
350
  handleSend && handleSend();
387
351
  setImage && setImage(null);
@@ -403,28 +367,16 @@ const ChatUI = (props: MessagesParams) => {
403
367
  numberOfLines={3}
404
368
  style={{ ...styles.firstMessageText, textAlign: 'center' }}>
405
369
  {message.change?.attribute !== 'driver_id'
406
- ? `${t('ORDER', 'Order')} ${t(
407
- message.change.attribute.toUpperCase(),
408
- message.change.attribute,
409
- )} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null
410
- ? t(
411
- getStatus(
412
- parseInt(message.change.old, 10),
413
- message.change?.attribute,
414
- ),
415
- )
416
- : '0'
417
- } ${t('TO', 'to')} ${t(
418
- getStatus(
419
- parseInt(message.change.new, 10),
420
- message.change?.attribute,
421
- ),
422
- )}`
370
+ ?
371
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute) ?
372
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
373
+ `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
374
+ }`
423
375
  : message.change.new
424
- ? `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''
425
- } ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''
426
- }`
427
- : `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`}
376
+ ?
377
+ `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
378
+ :
379
+ `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`}
428
380
  </OText>
429
381
  <OText size={10} color={'#aaa'} style={{ alignSelf: 'flex-start' }}>
430
382
  {parseTime(message?.created_at, { outputFormat: 'hh:mma' })}
@@ -1,18 +1,66 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, View, Dimensions, Platform } from 'react-native';
3
- import { useLanguage } from 'ordering-components/native';
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import { useLanguage, useApi } from 'ordering-components/native';
4
5
  import { useTheme } from 'styled-components/native';
5
- import { LogoWrapper, Container, BackgroundImage } from './styles';
6
- import { OButton, OIcon, OText } from '../shared';
6
+ import { LogoWrapper, Container, BackgroundImage, FormInput } from './styles';
7
+ import { OButton, OIcon, OText, OInput } from '../shared';
7
8
  import { _setStoreData } from '../../providers/StoreUtil';
8
9
 
9
10
  export const Home = (props: any) => {
10
- const { onNavigationRedirect } = props;
11
+ const { onNavigationRedirect, useRootPoint } = props;
11
12
  const safeHeight = Platform.OS === 'ios' ? 80 : 40;
12
13
 
13
14
  const theme = useTheme();
15
+ const [ordering, { setOrdering }] = useApi();
14
16
  const [, t] = useLanguage();
17
+ const { control, handleSubmit, errors } = useForm();
15
18
 
19
+
20
+ const styles = StyleSheet.create({
21
+ logo: {
22
+ height: 65,
23
+ width: 300,
24
+ },
25
+ wrapperContent: {
26
+ width: '100%',
27
+ },
28
+ wrapperText: {
29
+ marginBottom: 20,
30
+ },
31
+ textTitle: {
32
+ fontWeight: '600',
33
+ fontStyle: 'normal',
34
+ fontSize: 50,
35
+ },
36
+ textSubtitle: {
37
+ fontWeight: 'normal',
38
+ fontStyle: 'normal',
39
+ fontSize: 14,
40
+ },
41
+ wrapperBtn: {
42
+ marginBottom: 20
43
+ },
44
+ btn: {
45
+ borderRadius: 7.6,
46
+ marginTop: 20,
47
+ },
48
+ btnText: {
49
+ fontFamily: 'Poppins',
50
+ fontStyle: 'normal',
51
+ fontWeight: 'normal',
52
+ fontSize: 18,
53
+ },
54
+ input: {
55
+ borderWidth: 1,
56
+ borderRadius: 7.6,
57
+ borderColor: Object.keys(errors).length > 0 ? theme.colors.error : theme.colors.inputSignup,
58
+ backgroundColor: theme.colors.transparent,
59
+ },
60
+ });
61
+
62
+ const [projectName, setProjectName] = useState<any>(null)
63
+ const [isLoadingProject, setLoadingProject] = useState(false)
16
64
  const [orientation, setOrientation] = useState(
17
65
  Dimensions.get('window').width < Dimensions.get('window').height
18
66
  ? 'Portrait'
@@ -34,6 +82,27 @@ export const Home = (props: any) => {
34
82
  }
35
83
  });
36
84
 
85
+ const onSubmit = (values: any) => {
86
+ setLoadingProject(true)
87
+ setProjectName(values)
88
+ setOrdering({ ...ordering, project: values?.project_name })
89
+ _setStoreData('project_name', values?.project_name)
90
+ };
91
+
92
+ useEffect(() => {
93
+ if (Object.keys(errors).length > 0) {
94
+ setProjectName(null)
95
+ setLoadingProject(false)
96
+ }
97
+ }, [errors])
98
+
99
+ useEffect(() => {
100
+ if (ordering?.project === projectName?.project_name) {
101
+ setLoadingProject(false)
102
+ onNavigationRedirect('Login')
103
+ }
104
+ }, [ordering])
105
+
37
106
  return (
38
107
  <Container height={windowHeight - safeHeight} orientation={orientation}>
39
108
  <BackgroundImage
@@ -54,58 +123,62 @@ export const Home = (props: any) => {
54
123
  </OText>
55
124
  </View>
56
125
 
57
- <View style={styles.wrapperBtn}>
58
- <OButton
59
- text={t('LOGIN', 'Login')}
60
- textStyle={{
61
- ...styles.btnText,
62
- color: theme.colors.inputTextColor,
63
- }}
64
- bgColor={theme.colors.primary}
65
- borderColor={theme.colors.primary}
66
- style={styles.btn}
67
- imgRightSrc={false}
68
- onClick={() => onNavigationRedirect('Login')}
69
- />
70
- </View>
126
+ <>
127
+ {useRootPoint && (
128
+ <FormInput>
129
+ <Controller
130
+ control={control}
131
+ name='project_name'
132
+ rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
133
+ defaultValue=""
134
+ render={({ onChange, value }: any) => (
135
+ <OInput
136
+ name='project_name'
137
+ placeholderTextColor={theme.colors.arrowColor}
138
+ placeholder={t('PROJECT_NAME', 'Project Name')}
139
+ icon={theme.images.general.project}
140
+ iconColor={theme.colors.arrowColor}
141
+ onChange={(e: any) => onChange(e?.target?.value)}
142
+ selectionColor={theme.colors.primary}
143
+ color={theme.colors.white}
144
+ value={value}
145
+ style={styles.input}
146
+ returnKeyType='done'
147
+ autoCorrect={false}
148
+ autoCapitalize='none'
149
+ blurOnSubmit={false}
150
+ onSubmitEditing={() => handleSubmit(onSubmit)()}
151
+ />
152
+ )}
153
+ />
154
+ </FormInput>
155
+ )}
156
+ {Object.keys(errors).length > 0 && (
157
+ <OText
158
+ color={theme.colors.white}
159
+ style={{ alignSelf: 'center', marginTop: 5 }}
160
+ >
161
+ {errors['project_name'].message}
162
+ </OText>
163
+ )}
164
+ <View style={styles.wrapperBtn}>
165
+ <OButton
166
+ text={useRootPoint ? t('SET_PROJECT', 'Set project') : t('LOGIN', 'Login')}
167
+ textStyle={{
168
+ ...styles.btnText,
169
+ color: theme.colors.inputTextColor,
170
+ }}
171
+ bgColor={theme.colors.primary}
172
+ borderColor={theme.colors.primary}
173
+ isLoading={isLoadingProject}
174
+ style={styles.btn}
175
+ imgRightSrc={false}
176
+ onClick={() => useRootPoint ? handleSubmit(onSubmit)() : onNavigationRedirect('Login')}
177
+ />
178
+ </View>
179
+ </>
71
180
  </View>
72
181
  </BackgroundImage>
73
182
  </Container>
74
183
  );
75
184
  };
76
-
77
- const styles = StyleSheet.create({
78
- logo: {
79
- height: 65,
80
- width: 300,
81
- },
82
- wrapperContent: {
83
- width: '100%',
84
- },
85
- wrapperText: {
86
- marginBottom: 20,
87
- },
88
- textTitle: {
89
- fontWeight: '600',
90
- fontStyle: 'normal',
91
- fontSize: 50,
92
- },
93
- textSubtitle: {
94
- fontWeight: 'normal',
95
- fontStyle: 'normal',
96
- fontSize: 14,
97
- },
98
- wrapperBtn: {
99
- marginBottom: 20,
100
- },
101
- btn: {
102
- borderRadius: 7.6,
103
- marginTop: 20,
104
- },
105
- btnText: {
106
- fontFamily: 'Poppins',
107
- fontStyle: 'normal',
108
- fontWeight: 'normal',
109
- fontSize: 18,
110
- },
111
- });
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native';
1
+ import styled, { css } from 'styled-components/native';
2
2
 
3
3
  export const Container = styled.View`
4
4
  width: 100%;
@@ -25,3 +25,10 @@ export const BackgroundImage = styled.ImageBackground`
25
25
  align-items: center;
26
26
  padding: 20px 40px;
27
27
  `;
28
+
29
+ export const FormInput = styled.View`
30
+ display: flex;
31
+ flex-direction: column;
32
+ width: 100%;
33
+ min-height: 50px;
34
+ `;
@@ -1,50 +1,55 @@
1
- import React, { useState, useEffect, useCallback } from 'react'
2
- import { useEvent, useLanguage, useUtils, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
1
+ import React, { useState, useEffect } from 'react'
2
+ import moment from 'moment'
3
3
  import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
4
- import { OText, OIcon } from '../shared'
5
- import { useTheme } from 'styled-components/native'
4
+ import Sound from 'react-native-sound'
6
5
  import Icon from 'react-native-vector-icons/Feather'
6
+ import { useTheme } from 'styled-components/native'
7
+ import { useEvent, useLanguage, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
8
+
9
+ import { OText, OIcon } from '../shared'
7
10
  import { NotificationContainer } from './styles'
8
- import Sound from 'react-native-sound'
9
- import moment from 'moment'
10
11
  import { useLocation } from '../../hooks/useLocation'
11
- import { useFocusEffect } from '@react-navigation/core'
12
+
12
13
  Sound.setCategory('Playback')
13
14
 
14
15
  const windowWidth = Dimensions.get('screen').width
15
16
 
16
- const NewOrderNotificationUI = (props: any) => {
17
+ const NewOrderNotificationUI = () => {
17
18
  const [events] = useEvent()
18
19
  const theme = useTheme()
19
20
  const [, t] = useLanguage()
20
21
  const [{ user, token }] = useSession()
21
22
  const [ordering] = useApi()
22
- const [{ getTimeAgo }] = useUtils()
23
23
  const { getCurrentLocation } = useLocation();
24
- const [modalOpen, setModalOpen] = useState(false)
25
- const [newOrderId, setNewOrderId] = useState(null)
26
- const [messageOrderId, setMessageOrderId] = useState(null)
27
24
  const [soundTimeout, setSoundTimeout] = useState<any>(null)
28
- const [isFocused, setIsFocused] = useState(false)
29
- const [currentChange, setCurrentChange] = useState(1)
25
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
26
+
27
+ const evtList: any = {
28
+ 1: {
29
+ event: 'messages',
30
+ message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
31
+ message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
32
+ },
33
+ 2: {
34
+ event: 'order_added',
35
+ message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
36
+ message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
37
+ },
38
+ 3: {
39
+ event: 'order_updated',
40
+ message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
41
+ message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
42
+ },
43
+ }
30
44
 
31
- const notificationSound = new Sound(theme.sounds.notification, error => {
32
- if (error) {
33
- console.log('failed to load the sound', error);
34
- return
35
- }
36
- console.log('loaded successfully');
37
- });
45
+ const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
38
46
 
39
47
  const handlePlayNotificationSound = () => {
40
48
  let times = 0
41
49
  const _timeout = setInterval(function () {
42
50
  notificationSound.play(success => {
43
51
  if (success) {
44
- console.log('successfully finished playing');
45
52
  times = times + 1
46
- } else {
47
- console.log('playback failed due to audio decoding errors');
48
53
  }
49
54
  })
50
55
  setSoundTimeout(_timeout)
@@ -57,39 +62,11 @@ const NewOrderNotificationUI = (props: any) => {
57
62
 
58
63
  const handleCloseModal = () => {
59
64
  clearInterval(soundTimeout)
60
- setModalOpen(false)
61
- setNewOrderId(null)
62
- setMessageOrderId(null)
63
- }
64
-
65
- const handleNotification = (order: any) => {
66
- setModalOpen(true)
67
- clearInterval(soundTimeout)
68
- setCurrentChange(1)
69
- handlePlayNotificationSound()
70
- setNewOrderId(order.id)
71
- }
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)
65
+ setCurrentEvent({ evt: null })
80
66
  }
81
67
 
82
- useEffect(() => {
83
- events.on('order_added_noification', handleNotification)
84
- events.on('message_added_noification', handleMessageNotification)
85
- return () => {
86
- events.off('order_added_noification', handleNotification)
87
- events.off('message_added_noification', handleMessageNotification)
88
- }
89
- }, [])
90
-
91
- const handleUpdateOrder = useCallback(async (order: any) => {
92
- if (order?.driver) {
68
+ const handleEventNotification = async (evtType: number, value: any) => {
69
+ if (value?.driver) {
93
70
  const location = await getCurrentLocation()
94
71
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
95
72
  method: 'POST',
@@ -98,25 +75,32 @@ const NewOrderNotificationUI = (props: any) => {
98
75
  }),
99
76
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
100
77
  })
101
- const assignedTimeDiff = moment.utc(order?.driver?.last_order_assigned_at).local().fromNow()
78
+ const assignedTimeDiff = moment.utc(value?.driver?.last_order_assigned_at).local().fromNow()
102
79
  if (assignedTimeDiff === 'a few seconds ago') {
103
- clearInterval(soundTimeout)
104
80
  handlePlayNotificationSound()
105
- setNewOrderId(order.id)
106
- if(isFocused){
107
- setModalOpen(true)
108
- }
81
+ clearInterval(soundTimeout)
82
+ setCurrentEvent({ evt: 2, orderId: value?.id })
109
83
  }
84
+ return
110
85
  }
111
- }, [newOrderId, notificationSound, soundTimeout])
86
+ handlePlayNotificationSound()
87
+ clearInterval(soundTimeout)
88
+ setCurrentEvent({
89
+ evt: evtType,
90
+ orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
91
+ })
92
+ }
112
93
 
113
94
  useEffect(() => {
114
- if (user?.level !== 4) return
115
- events.on('order_updated_noification', handleUpdateOrder)
95
+ events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
96
+ events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
97
+ events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
116
98
  return () => {
117
- events.off('order_updated_noification', handleUpdateOrder)
99
+ events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
100
+ events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
101
+ events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
118
102
  }
119
- }, [handleUpdateOrder, user])
103
+ }, [])
120
104
 
121
105
  useEffect(() => {
122
106
  notificationSound.setVolume(1);
@@ -125,21 +109,12 @@ const NewOrderNotificationUI = (props: any) => {
125
109
  }
126
110
  }, [])
127
111
 
128
- useFocusEffect(
129
- useCallback(() => {
130
- setIsFocused(true)
131
- return () => {
132
- setIsFocused(false)
133
- }
134
- }, [])
135
- )
136
-
137
112
  return (
138
113
  <>
139
114
  <Modal
140
115
  animationType='slide'
141
116
  transparent={true}
142
- visible={modalOpen}
117
+ visible={!!currentEvent?.orderId}
143
118
  >
144
119
  <NotificationContainer>
145
120
  <View style={styles.modalView}>
@@ -147,40 +122,26 @@ const NewOrderNotificationUI = (props: any) => {
147
122
  style={styles.wrapperIcon}
148
123
  onPress={() => handleCloseModal()}
149
124
  >
150
- <Icon
151
- name="x"
152
- size={30}
153
- />
125
+ <Icon name="x" size={30} />
154
126
  </TouchableOpacity>
155
127
  <OText
156
128
  size={18}
157
129
  color={theme.colors.textGray}
158
130
  weight={600}
159
131
  >
160
- {currentChange === 1 ? t('NEW_ORDRES_RECEIVED', 'New orders have been received!') : t('NEW_MESSAGES_RECEIVED', 'New messages have been received!')}
132
+ {evtList[currentEvent?.evt]?.message}
161
133
  </OText>
162
134
  <OIcon
163
135
  src={theme.images.general.newOrder}
164
136
  width={250}
165
137
  height={200}
166
138
  />
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
- )}
139
+ <OText
140
+ color={theme.colors.textGray}
141
+ mBottom={15}
142
+ >
143
+ {evtList[currentEvent?.evt]?.message2}
144
+ </OText>
184
145
  </View>
185
146
  </NotificationContainer>
186
147
  </Modal>
@@ -335,7 +335,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
335
335
  addressName: order?.business?.address,
336
336
  zipcode: order?.business?.zipcode
337
337
  },
338
- icon: order?.business?.logo || theme.images.dummies.businessLogo,
338
+ icon: order?.business?.logo || 'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://res.cloudinary.com/ordering2/image/upload/v1654619525/hzegwosnplvrbtjkpfi6.png',
339
339
  level: 2,
340
340
  },
341
341
  {
@@ -431,6 +431,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
431
431
  handleViewSummaryOrder={handleViewSummaryOrder}
432
432
  handleCopyClipboard={handleCopyClipboard}
433
433
  handleArrowBack={handleArrowBack}
434
+ isCustomView={props.isCustomView}
434
435
  />
435
436
  <OrderDetailsContainer
436
437
  keyboardShouldPersistTaps="handled"