ordering-ui-react-native 0.12.14 → 0.12.18

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 (105) hide show
  1. package/package.json +1 -1
  2. package/src/components/AddressList/index.tsx +3 -1
  3. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
  4. package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
  5. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
  6. package/themes/business/src/components/OrdersOption/index.tsx +19 -15
  7. package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
  8. package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
  9. package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
  10. package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
  11. package/themes/business/src/components 2/Chat/index.tsx +1152 -0
  12. package/themes/business/src/components 2/Chat/styles.tsx +12 -0
  13. package/themes/business/src/components 2/Contacts/index.tsx +299 -0
  14. package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
  15. package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
  16. package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
  17. package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
  18. package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
  19. package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
  20. package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
  21. package/themes/business/src/components 2/Home/index.tsx +111 -0
  22. package/themes/business/src/components 2/Home/styles.tsx +27 -0
  23. package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
  24. package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
  25. package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
  26. package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
  27. package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
  28. package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
  29. package/themes/business/src/components 2/MapView/index.tsx +317 -0
  30. package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
  31. package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
  32. package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
  33. package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
  34. package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
  35. package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
  36. package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
  37. package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
  38. package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
  39. package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
  40. package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
  41. package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
  42. package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
  43. package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
  44. package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
  45. package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
  46. package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
  47. package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
  48. package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
  49. package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
  50. package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
  51. package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
  52. package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
  53. package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
  54. package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
  55. package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
  56. package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
  57. package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
  58. package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
  59. package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
  60. package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
  61. package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
  62. package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
  63. package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
  64. package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
  65. package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
  66. package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
  67. package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
  68. package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
  69. package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
  70. package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
  71. package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
  72. package/themes/business/src/components 2/StoresList/index.tsx +208 -0
  73. package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
  74. package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
  75. package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
  76. package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
  77. package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
  78. package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
  79. package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
  80. package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
  81. package/themes/business/src/components 2/shared/OButton.tsx +149 -0
  82. package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
  83. package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
  84. package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
  85. package/themes/business/src/components 2/shared/OFab.tsx +54 -0
  86. package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
  87. package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
  88. package/themes/business/src/components 2/shared/OInput.tsx +144 -0
  89. package/themes/business/src/components 2/shared/OLink.tsx +76 -0
  90. package/themes/business/src/components 2/shared/OModal.tsx +275 -0
  91. package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
  92. package/themes/business/src/components 2/shared/OText.tsx +55 -0
  93. package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
  94. package/themes/business/src/components 2/shared/OToast.tsx +92 -0
  95. package/themes/business/src/components 2/shared/index.tsx +27 -0
  96. package/themes/business/src/types/index.tsx +4 -1
  97. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
  98. package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
  99. package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
  100. package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
  101. package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
  102. package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
  103. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  104. package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
  105. package/themes/original/src/components/OrderProgress/index.tsx +32 -18
@@ -0,0 +1,27 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const FiltersTab = styled.View`
4
+ margin-bottom: 20px;
5
+ `;
6
+
7
+ export const TabsContainer = styled.View`
8
+ display: flex;
9
+ flex-direction: row;
10
+ justify-content: space-between;
11
+ border-bottom-width: 1px;
12
+ border-bottom-color: #e9ecef;
13
+ `;
14
+
15
+ export const TagsContainer = styled.ScrollView`
16
+ margin-bottom: 10px;
17
+ `;
18
+
19
+ export const Tag = styled.Pressable`
20
+ background-color: ${({ isSelected }: { isSelected: string }) => isSelected};
21
+ justify-content: center;
22
+ align-items: center;
23
+ min-height: 34px;
24
+ padding: 4px 10px;
25
+ border-radius: 50px;
26
+ margin-right: 15px;
27
+ `;
@@ -0,0 +1,167 @@
1
+ import React, { useState, useEffect, useCallback } from 'react'
2
+ import { useEvent, useLanguage, useUtils, useSession, useApi } from 'ordering-components/native'
3
+ import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
4
+ import { OText, OIcon } from '../shared'
5
+ import { useTheme } from 'styled-components/native'
6
+ import Icon from 'react-native-vector-icons/Feather'
7
+ import { NotificationContainer } from './styles'
8
+ import Sound from 'react-native-sound'
9
+ import moment from 'moment'
10
+ import { useLocation } from '../../hooks/useLocation'
11
+ Sound.setCategory('Playback')
12
+
13
+ const windowWidth = Dimensions.get('screen').width
14
+
15
+ export const NewOrderNotification = (props: any) => {
16
+ const [events] = useEvent()
17
+ const theme = useTheme()
18
+ const [, t] = useLanguage()
19
+ const [{ user, token }] = useSession()
20
+ const [ordering] = useApi()
21
+ const [{ getTimeAgo }] = useUtils()
22
+ const { getCurrentLocation } = useLocation();
23
+ const [modalOpen, setModalOpen] = useState(false)
24
+ const [newOrderId, setNewOrderId] = useState(null)
25
+ const [soundTimeout, setSoundTimeout] = useState<any>(null)
26
+
27
+ const notificationSound = new Sound(theme.sounds.notification, error => {
28
+ if (error) {
29
+ console.log('failed to load the sound', error);
30
+ return
31
+ }
32
+ console.log('loaded successfully');
33
+ });
34
+
35
+
36
+ const handlePlayNotificationSound = () => {
37
+ let times = 0
38
+ const _timeout = setInterval(function () {
39
+ notificationSound.play(success => {
40
+ if (success) {
41
+ console.log('successfully finished playing');
42
+ times = times + 1
43
+ } else {
44
+ console.log('playback failed due to audio decoding errors');
45
+ }
46
+ })
47
+ setSoundTimeout(_timeout)
48
+ if (times === 3) {
49
+ clearInterval(_timeout)
50
+ clearInterval(soundTimeout)
51
+ }
52
+ }, 2500)
53
+ }
54
+
55
+ const handleCloseModal = () => {
56
+ clearInterval(soundTimeout)
57
+ setModalOpen(false)
58
+ }
59
+
60
+ const handleNotification = useCallback((order: any) => {
61
+ clearInterval(soundTimeout)
62
+ handlePlayNotificationSound()
63
+ setNewOrderId(order.id)
64
+ setModalOpen(true)
65
+ }, [newOrderId, notificationSound, soundTimeout])
66
+
67
+ useEffect(() => {
68
+ events.on('order_added', handleNotification)
69
+ return () => {
70
+ events.off('order_added', handleNotification)
71
+ }
72
+ }, [handleNotification])
73
+
74
+ const handleUpdateOrder = useCallback(async (order: any) => {
75
+ if (order?.driver) {
76
+ const location = await getCurrentLocation()
77
+ await fetch(`${ordering.root}/users/${user.id}/locations`, {
78
+ method: 'POST',
79
+ body: JSON.stringify({
80
+ location: JSON.stringify({location: `{lat: ${location.latitude}, lng: ${location.longitude}}`})
81
+ }),
82
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
83
+ })
84
+ const assignedTimeDiff = moment.utc(order?.driver?.last_order_assigned_at).local().fromNow()
85
+ if (assignedTimeDiff === 'a few seconds ago') {
86
+ clearInterval(soundTimeout)
87
+ handlePlayNotificationSound()
88
+ setNewOrderId(order.id)
89
+ setModalOpen(true)
90
+ }
91
+ }
92
+ }, [newOrderId, notificationSound, soundTimeout])
93
+
94
+ useEffect(() => {
95
+ if (user?.level !== 4) return
96
+ events.on('order_updated', handleUpdateOrder)
97
+ return () => {
98
+ events.off('order_updated', handleUpdateOrder)
99
+ }
100
+ }, [handleUpdateOrder, user])
101
+
102
+ useEffect(() => {
103
+ notificationSound.setVolume(1);
104
+ return () => {
105
+ notificationSound.release();
106
+ }
107
+ }, [])
108
+
109
+ return (
110
+ <>
111
+ <Modal
112
+ animationType='slide'
113
+ transparent={true}
114
+ visible={modalOpen}
115
+ >
116
+ <NotificationContainer>
117
+ <View style={styles.modalView}>
118
+ <TouchableOpacity
119
+ style={styles.wrapperIcon}
120
+ onPress={() => handleCloseModal()}
121
+ >
122
+ <Icon
123
+ name="x"
124
+ size={30}
125
+ />
126
+ </TouchableOpacity>
127
+ <OText
128
+ size={18}
129
+ color={theme.colors.textGray}
130
+ weight={600}
131
+ >
132
+ {t('NEW_ORDRES_RECEIVED', 'New orders have been received!')}
133
+ </OText>
134
+ <OIcon
135
+ src={theme.images.general.newOrder}
136
+ width={250}
137
+ height={200}
138
+ />
139
+ <OText
140
+ color={theme.colors.textGray}
141
+ mBottom={15}
142
+ >
143
+ {t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', newOrderId)}
144
+ </OText>
145
+ </View>
146
+ </NotificationContainer>
147
+ </Modal>
148
+ </>
149
+ )
150
+ }
151
+
152
+ const styles = StyleSheet.create({
153
+ modalView: {
154
+ backgroundColor: '#FFF',
155
+ alignItems: 'center',
156
+ borderRadius: 8,
157
+ paddingHorizontal: 20,
158
+ paddingTop: 65,
159
+ paddingBottom: 20,
160
+ maxWidth: windowWidth - 60,
161
+ },
162
+ wrapperIcon: {
163
+ position: 'absolute',
164
+ right: 20,
165
+ top: 20
166
+ }
167
+ })
@@ -0,0 +1,8 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const NotificationContainer = styled.SafeAreaView`
4
+ flex: 1;
5
+ justify-content: center;
6
+ align-items: center;
7
+ background-color: rgba(0, 0, 0, 0.4);
8
+ `
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { OButton, OIcon, OText } from '../shared';
4
+ import { NotFoundSourceParams } from '../../types';
5
+ import { useTheme } from 'styled-components/native';
6
+ import { NotFound, NotFoundImage } from './styles';
7
+
8
+ export const NotFoundSource = (props: NotFoundSourceParams) => {
9
+ const { image, content, btnTitle, conditioned, onClickButton } = props;
10
+ const theme = useTheme();
11
+
12
+ const errorImage = image || theme.images.general.notFound;
13
+
14
+ return (
15
+ <NotFound>
16
+ {errorImage && (
17
+ <NotFoundImage>
18
+ <OIcon src={errorImage} width={260} height={220} />
19
+ </NotFoundImage>
20
+ )}
21
+ {content && conditioned && !errorImage && (
22
+ <OText
23
+ color={theme.colors.textSecondary}
24
+ size={18}
25
+ style={{ textAlign: 'center' }}>
26
+ {content}
27
+ </OText>
28
+ )}
29
+ {content && !conditioned && (
30
+ <OText
31
+ color={theme.colors.textSecondary}
32
+ size={18}
33
+ style={{ textAlign: 'center' }}>
34
+ {content}
35
+ </OText>
36
+ )}
37
+ {!onClickButton && props.children && props.children}
38
+ {onClickButton && (
39
+ <View style={{ marginTop: 10, width: '100%' }}>
40
+ <OButton
41
+ style={{ width: '100%', height: 50, borderRadius: 7.6 }}
42
+ bgColor={theme.colors.primary}
43
+ borderColor={theme.colors.primary}
44
+ onClick={() => onClickButton()}
45
+ text={btnTitle}
46
+ textStyle={{ color: theme.colors.white }}
47
+ />
48
+ </View>
49
+ )}
50
+ </NotFound>
51
+ );
52
+ };
@@ -0,0 +1,17 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const NotFound = styled.View`
4
+ display: flex;
5
+ flex-direction: column;
6
+ justify-content: center;
7
+ align-items: center;
8
+ width: 100%;
9
+ height: auto;
10
+ margin: 30px auto;
11
+ padding: 10px;
12
+ background-color: #f7f7f7;
13
+ `;
14
+
15
+ export const NotFoundImage = styled.View`
16
+ max-width: 300px;
17
+ `;