ordering-ui-react-native 0.12.56 → 0.12.60

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 (183) hide show
  1. package/package.json +1 -1
  2. package/src/components/AppleLogin/index.tsx +14 -8
  3. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -8
  4. package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
  5. package/themes/doordash/src/components/Cart/index.tsx +1 -0
  6. package/themes/doordash/src/components/OrderSummary/index.tsx +1 -0
  7. package/themes/instacart/src/components/OrderDetails/index.tsx +2 -2
  8. package/themes/single-business/src/components/Cart/index.tsx +127 -16
  9. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  10. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  11. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  12. package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
  13. package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
  14. package/themes/franchises/index.tsx +0 -111
  15. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  16. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  17. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  18. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  19. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  20. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  21. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  22. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  23. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  24. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  25. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  26. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  27. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  28. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  29. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  30. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  31. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  32. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  33. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  34. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  35. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  36. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  37. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  38. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  39. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  40. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  41. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  42. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  43. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  44. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  45. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  46. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  47. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  48. package/themes/franchises/src/components/Cart/index.tsx +0 -332
  49. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  50. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  51. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  52. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  53. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  54. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  55. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  56. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  57. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  58. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  59. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  60. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  61. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  62. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  63. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  64. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  65. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  66. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  67. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  68. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  69. package/themes/franchises/src/components/Help/index.tsx +0 -56
  70. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  71. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  72. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  73. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  74. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  75. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  76. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  77. package/themes/franchises/src/components/Home/index.tsx +0 -102
  78. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  79. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  80. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  81. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  82. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  83. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  84. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  85. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  86. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  87. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  88. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  89. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  90. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  91. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  92. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  93. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  94. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  95. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  96. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  97. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
  98. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  99. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
  100. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  101. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  102. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  103. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  104. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  105. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  106. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  107. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  108. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  109. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  110. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  111. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  112. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  113. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  114. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  115. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  116. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  117. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  118. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  119. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  120. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  121. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  122. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  123. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  124. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  125. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  126. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  127. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  128. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  129. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  130. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  131. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  132. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  133. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  134. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  135. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  136. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  137. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  138. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  139. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  140. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  141. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  142. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  143. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  144. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  145. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  146. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  147. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  148. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  149. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  150. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  151. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  152. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  153. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  154. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  155. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  156. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  157. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  158. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  159. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  160. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  161. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  162. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  163. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  164. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  165. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  166. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  167. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  168. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  169. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  170. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  171. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  172. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  173. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  174. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  175. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  176. package/themes/franchises/src/components/shared/index.tsx +0 -29
  177. package/themes/franchises/src/config/constants.tsx +0 -57
  178. package/themes/franchises/src/layouts/Container.tsx +0 -23
  179. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  180. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  181. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  182. package/themes/franchises/src/types/index.tsx +0 -445
  183. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,359 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { Messages as MessagesController, useSession, useUtils, useLanguage, ToastType, useToast } from 'ordering-components/native'
3
- import { useTheme } from 'styled-components/native';
4
- import { launchImageLibrary } from 'react-native-image-picker'
5
- import { GiftedChat, Actions, InputToolbar, Composer, Send, Bubble, MessageImage, InputToolbarProps, ComposerProps } from 'react-native-gifted-chat'
6
- import { USER_TYPE } from '../../config/constants'
7
- import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
8
- import { OIcon, OIconButton, OText } from '../shared'
9
- import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard, I18nManager } from 'react-native'
10
- import { Header, TitleHeader, Wrapper } from './styles'
11
- import { MessagesParams } from '../../types'
12
- import { useWindowDimensions } from 'react-native'
13
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
14
- import { getOrderStatus } from '../../utils';
15
-
16
- const MessagesUI = (props: MessagesParams) => {
17
-
18
- const {
19
- type,
20
- order,
21
- messages,
22
- image,
23
- message,
24
- messagesToShow,
25
- sendMessage,
26
- setMessage,
27
- handleSend,
28
- setImage,
29
- readMessages,
30
- onClose,
31
- } = props
32
-
33
- const [{ user }] = useSession()
34
- const [{ parseDate }] = useUtils()
35
- const [, t] = useLanguage()
36
- const [, { showToast }] = useToast();
37
-
38
- const [formattedMessages, setFormattedMessages] = useState<Array<any>>([])
39
- const [isKeyboardShow, setIsKeyboardShow] = useState(false)
40
- const { height } = useWindowDimensions();
41
- const { top, bottom } = useSafeAreaInsets();
42
-
43
- const theme = useTheme();
44
-
45
- const onChangeMessage = (val: string) => {
46
- setMessage && setMessage(val)
47
- }
48
-
49
- const removeImage = () => {
50
- setImage && setImage(null)
51
- }
52
-
53
- const imgOptions = {
54
- mediaType: 'photo',
55
- maxHeight: 300,
56
- maxWidth: 300,
57
- includeBase64: true,
58
- }
59
-
60
- const handleImagePicker = () => {
61
- launchImageLibrary(imgOptions, (response: any) => {
62
- if (response.didCancel) {
63
- console.log('User cancelled image picker');
64
- } else if (response.errorMessage) {
65
- console.log('ImagePicker Error: ', response.errorMessage);
66
- showToast(ToastType.Error, response.errorMessage);
67
- } else {
68
- if (Platform.OS === 'android') {
69
- if (response.uri) {
70
- const url = `data:${response.type};base64,${response.base64}`
71
- setImage && setImage(url);
72
- } else {
73
- showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
74
- }
75
- } else {
76
- if (response?.assets?.length > 0) {
77
- const image = response?.assets[0]
78
- const url = `data:${image.type};base64,${image.base64}`
79
- setImage && setImage(url);
80
- } else {
81
- showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
82
- }
83
- }
84
- }
85
- });
86
- };
87
-
88
- const onSubmit = (values: any) => {
89
- handleSend && handleSend()
90
- setImage && setImage(null)
91
- setMessage && setMessage('')
92
- }
93
-
94
- const messageConsole = (message: any) => {
95
- return message.change?.attribute !== 'driver_id'
96
- ?
97
- `${t('ORDER', 'Order')} ${message.change.attribute} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(getOrderStatus(parseInt(message.change.old, 10)))} ${t('TO', 'to')} ${t(getOrderStatus(parseInt(message.change.new, 10)))}`
98
- : message.change.new
99
- ?
100
- `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
101
- :
102
- `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
103
- }
104
-
105
- useEffect(() => {
106
- let newMessages: Array<any> = []
107
- 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')}`
108
- const firstMessage = {
109
- _id: 0,
110
- text: console,
111
- createdAt: order?.created_at,
112
- system: true
113
- }
114
- messages.messages.map((message: any) => {
115
- let newMessage
116
- if (message.type !== 0 && (messagesToShow?.messages?.length || (message?.can_see?.includes('2')) || (message?.can_see?.includes('4') && type === USER_TYPE.DRIVER))) {
117
- newMessage = {
118
- _id: message.id,
119
- text: message.type === 1 ? messageConsole(message) : message.comment,
120
- createdAt: message.type !== 0 && message.created_at,
121
- image: message.source,
122
- system: message.type === 1,
123
- user: {
124
- _id: message.author.id,
125
- name: message.author.name,
126
- avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
127
- }
128
- }
129
- }
130
- if (message.type === 0) {
131
- newMessage = firstMessage
132
- }
133
- newMessages = [...newMessages, newMessage]
134
- })
135
- setFormattedMessages([...newMessages.reverse()])
136
- }, [messages.messages.length])
137
-
138
- useEffect(() => {
139
- const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
140
- setIsKeyboardShow(true)
141
- })
142
- const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
143
- setIsKeyboardShow(false)
144
- })
145
- return () => {
146
- keyboardDidShowListener.remove()
147
- keyboardDidHideListener.remove()
148
- }
149
- }, [])
150
-
151
- const RenderActions = (props: any) => {
152
- return (
153
- <Actions
154
- {...props}
155
- options={{
156
- 'Send Image': () => handleImagePicker(),
157
- }}
158
- containerStyle={styles.containerActions}
159
- optionTintColor='#222845'
160
- icon={() => (
161
- <>
162
- <OIconButton
163
- borderColor={theme.colors.white}
164
- style={{ width: 32, height: 44, borderRadius: 10, backgroundColor: theme.colors.clear, borderColor: theme.colors.clear }}
165
- icon={image ? { uri: image } : theme.images.general.image}
166
- iconStyle={{ borderRadius: image ? 10 : 0, width: image ? 32 : 16, height: image ? 32 : 16 }}
167
- onClick={handleImagePicker}
168
- iconCover
169
- />
170
- {image && (
171
- <TouchableOpacity
172
- style={{ position: 'absolute', top: -3, right: -3, borderColor: theme.colors.backgroundDark, backgroundColor: theme.colors.white, borderRadius: 10 }}
173
- onPress={() => removeImage()}
174
- >
175
- <MaterialCommunityIcon name='close-circle-outline' color={theme.colors.backgroundDark} size={20} />
176
- </TouchableOpacity>
177
- )}
178
- </>
179
- )}
180
- />
181
- )
182
- }
183
-
184
- const renderInputToolbar = (props: typeof InputToolbarProps) => (
185
- <InputToolbar
186
- {...props}
187
- containerStyle={{
188
- padding: Platform.OS === 'ios' && isKeyboardShow ? 0 : 10,
189
- paddingHorizontal: 40
190
- }}
191
- primaryStyle={{ alignItems: 'center', justifyContent: 'flex-start' }}
192
- />
193
- )
194
-
195
- const renderComposer = (props: typeof ComposerProps) => (
196
- <View style={{
197
- flexDirection: 'row', width: '80%', alignItems: 'center', backgroundColor: theme.colors.backgroundGray100,
198
- borderRadius: 7.6,
199
- }}>
200
- <Composer
201
- {...props}
202
- textInputStyle={{
203
- height: 32,
204
- minHeight: 32,
205
- alignItems: 'center',
206
- justifyContent: 'center',
207
- paddingHorizontal: 12,
208
- borderColor: '#DBDCDB',
209
- color: '#010300',
210
- fontSize: 12,
211
- textAlign: I18nManager.isRTL ? 'right' : 'left'
212
- }}
213
- textInputProps={{
214
- value: message,
215
- onSubmitEditing: onSubmit,
216
- returnKeyType: message ? 'send' : 'done',
217
- blurOnSubmit: true,
218
- multiline: false,
219
- numberOfLines: 1,
220
- autoCorrect: false,
221
- autoCompleteType: 'off',
222
- enablesReturnKeyAutomatically: false,
223
-
224
- }}
225
- placeholder={t('TYPE_YOUR_MESSAGE_HERE', 'Type your message here')}
226
- />
227
- <RenderActions {...props} />
228
- </View>
229
- )
230
-
231
- const renderSend = (props: any) => (
232
- <Send
233
- {...props}
234
- disabled={(sendMessage?.loading || (message === '' && !image) || messages?.loading)}
235
- alwaysShowSend
236
- containerStyle={styles.containerSend}
237
- >
238
- <OIconButton
239
- onClick={onSubmit}
240
- style={{
241
- height: 44,
242
- width: 44,
243
- borderRadius: 7.6,
244
- opacity: (sendMessage?.loading || (message === '' && !image) || messages?.loading) ? 0.4 : 1,
245
- borderColor: theme.colors.primary,
246
- backgroundColor: theme.colors.primary,
247
- }}
248
- iconStyle={{ marginTop: 3, marginRight: 2 }}
249
- icon={theme.images.general.enter}
250
- // RenderIcon={sendMessage?.loading ? <ActivityIndicator size='small' color={theme.colors.primary} /> : <View />}
251
- disabled={(sendMessage?.loading || (message === '' && !image) || messages?.loading)}
252
- disabledColor={theme.colors.white}
253
- />
254
- </Send>
255
- )
256
-
257
- const renderBubble = (props: any) => (
258
- <Bubble
259
- {...props}
260
- textStyle={{
261
- left: {},
262
- right: { color: theme.colors.white }
263
- }}
264
- containerStyle={{
265
- left: { marginVertical: 5, borderBottomRightRadius: 7.6 },
266
- right: { marginVertical: 5, borderBottomRightRadius: 7.6 }
267
- }}
268
- wrapperStyle={{
269
- left: { backgroundColor: '#f7f7f7', padding: 5, borderBottomLeftRadius: 0 },
270
- right: { backgroundColor: theme.colors.primary, padding: 5, borderBottomRightRadius: 0 }
271
- }}
272
- />
273
- )
274
-
275
- const renderMessageImage = (props: any) => (
276
- <MessageImage
277
- {...props}
278
- />
279
- )
280
-
281
- const renderScrollToBottomComponent = () => (
282
- <MaterialCommunityIcon name='chevron-double-down' size={32} />
283
- )
284
-
285
- return (
286
- <View style={{ height: height - top - bottom, width: '100%' }}>
287
- <Wrapper>
288
- <Header>
289
- <OIconButton icon={theme.images.general.arrow_left} style={{ paddingStart: 10, borderColor: theme.colors.clear }} onClick={onClose} />
290
- <View style={{ marginRight: 10, shadowColor: theme.colors.black, shadowOpacity: 0.1, shadowOffset: { width: 0, height: 1 }, shadowRadius: 2 }}>
291
- <OIcon
292
- url={type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo}
293
- width={40}
294
- height={40}
295
- style={{ borderRadius: 7.6 }}
296
- />
297
- </View>
298
- <TitleHeader>
299
- <OText size={14} lineHeight={21} weight={'600'}>{type === USER_TYPE.DRIVER ? order?.driver?.name : order?.business?.name}</OText>
300
- <OText size={12} color={theme.colors.textSecondary}>{type === USER_TYPE.DRIVER ? t('DRIVER', 'Driver') : t('BUSINESS', 'Business')}</OText>
301
- </TitleHeader>
302
- </Header>
303
- <GiftedChat
304
- messages={formattedMessages}
305
- user={{
306
- _id: user.id,
307
- name: user.name,
308
- avatar: user.photo
309
- }}
310
- onSend={onSubmit}
311
- onInputTextChanged={onChangeMessage}
312
- alignTop
313
- scrollToBottom
314
- renderAvatarOnTop
315
- renderUsernameOnMessage
316
- renderInputToolbar={renderInputToolbar}
317
- renderComposer={renderComposer}
318
- renderSend={renderSend}
319
- renderBubble={renderBubble}
320
- renderMessageImage={renderMessageImage}
321
- scrollToBottomComponent={() => renderScrollToBottomComponent()}
322
- messagesContainerStyle={{
323
- paddingVertical: 18,
324
- paddingHorizontal: 28,
325
- }}
326
- isLoadingEarlier={messages.loading}
327
- renderLoading={() => <ActivityIndicator size="small" color="#000" />}
328
- keyboardShouldPersistTaps='handled'
329
- />
330
- </Wrapper>
331
- </View>
332
- )
333
- }
334
-
335
- const styles = StyleSheet.create({
336
- containerActions: {
337
- width: 44,
338
- height: 44,
339
- alignItems: 'center',
340
- justifyContent: 'center',
341
- marginHorizontal: 4,
342
- marginBottom: 0,
343
- },
344
- containerSend: {
345
- width: 64,
346
- height: 44,
347
- alignItems: 'center',
348
- justifyContent: 'center',
349
- marginHorizontal: 4
350
- }
351
- })
352
-
353
- export const Messages = (props: MessagesParams) => {
354
- const MessagesProps = {
355
- ...props,
356
- UIComponent: MessagesUI
357
- }
358
- return <MessagesController {...MessagesProps} />
359
- }
@@ -1,20 +0,0 @@
1
-
2
- import styled from 'styled-components/native'
3
-
4
- export const Wrapper = styled.View`
5
- flex: 1;
6
- background-color: ${(props: any) => props.theme.colors.white};
7
- `
8
- export const Header = styled.View`
9
- flex-direction: row;
10
- align-items: center;
11
- background-color: ${(props: any) => props.theme.colors.white};
12
- box-shadow: 0 2px 2px #0000001A;
13
- padding-bottom: 10px;
14
- padding-top: 14px;
15
- padding-horizontal: 30px;
16
- `
17
-
18
- export const TitleHeader = styled.View`
19
-
20
- `
@@ -1,321 +0,0 @@
1
- import React, { useState, useEffect, useCallback } from 'react';
2
- import moment, { Moment } from 'moment';
3
- import {
4
- useLanguage,
5
- useConfig,
6
- useUtils,
7
- useOrder,
8
- MomentOption as MomentOptionController,
9
- } from 'ordering-components/native';
10
- import { useTheme } from 'styled-components/native';
11
- import {
12
- ImageStore,
13
- StyleSheet,
14
- useWindowDimensions,
15
- View,
16
- } from 'react-native';
17
- import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
18
- import Spinner from 'react-native-loading-spinner-overlay';
19
- import { MomentOptionParams } from '../../types';
20
- import NavBar from '../NavBar';
21
- import { OIcon, OText } from '../shared';
22
- import { Container } from '../../layouts/Container';
23
- import {
24
- HeaderTitle,
25
- WrapSelectOption,
26
- Days,
27
- Day,
28
- WrapHours,
29
- Hours,
30
- Hour,
31
- WrapDelveryTime,
32
- } from './styles';
33
- import CalendarPicker from 'react-native-calendar-picker';
34
- import { TouchableRipple } from 'react-native-paper';
35
-
36
- const MomentOptionUI = (props: MomentOptionParams) => {
37
- const {
38
- navigation,
39
- nopadding,
40
- datesList,
41
- hoursList,
42
- dateSelected,
43
- timeSelected,
44
- handleAsap,
45
- handleChangeDate,
46
- handleChangeTime,
47
- } = props;
48
-
49
- const theme = useTheme();
50
-
51
- const styles = StyleSheet.create({
52
- icon: {
53
- marginRight: 10,
54
- },
55
- dayNameStyle: {
56
- textTransform: 'uppercase',
57
- },
58
- selectStyle: {
59
- zIndex: 10,
60
- },
61
- dateLabel: {
62
- borderWidth: 1,
63
- borderColor: theme.colors.border,
64
- borderRadius: 7.6,
65
- paddingHorizontal: 12,
66
- paddingVertical: 9,
67
- marginBottom: 12,
68
- },
69
- dateWrap: {
70
- marginTop: 40,
71
- borderRadius: 7.6,
72
- borderColor: theme.colors.border,
73
- borderWidth: 1,
74
- padding: 17,
75
- marginBottom: 23,
76
- },
77
- timeLabel: {
78
- borderWidth: 1,
79
- borderColor: theme.colors.border,
80
- borderRadius: 7.6,
81
- height: 44,
82
- paddingHorizontal: 16,
83
- flexDirection: 'row',
84
- alignItems: 'center'
85
- }
86
- });
87
-
88
- const [, t] = useLanguage();
89
- const [{ configs }] = useConfig();
90
- const [{ parseTime }] = useUtils();
91
- const [orderState] = useOrder();
92
- const [optionSelected, setOptionSelected] = useState({
93
- isAsap: false,
94
- isSchedule: false,
95
- });
96
- const [momentState, setMomentState] = useState({
97
- isLoading: 0,
98
- isEditing: false,
99
- });
100
- const { width } = useWindowDimensions();
101
-
102
- const [toggleTime, setToggleTime] = useState(false);
103
-
104
- const goToBack = () => navigation?.canGoBack() && navigation.goBack();
105
-
106
- const _handleAsap = () => {
107
- setMomentState({ isLoading: 1, isEditing: true });
108
- handleAsap();
109
- setOptionSelected({ isAsap: true, isSchedule: false });
110
- if (!orderState.options?.moment) {
111
- setMomentState({ isLoading: 2, isEditing: false });
112
- }
113
- };
114
-
115
- const handleChangeMoment = (time: any) => {
116
- setMomentState({ isLoading: 1, isEditing: true });
117
- handleChangeTime(time);
118
- };
119
-
120
- const momento = moment(
121
- `${dateSelected} ${timeSelected}`,
122
- 'YYYY-MM-DD HH:mm',
123
- ).toDate();
124
- const momentUnix = momento.getTime() / 1000;
125
- const momentFormat = moment
126
- .unix(momentUnix)
127
- .utc()
128
- .format('YYYY-MM-DD HH:mm:ss');
129
-
130
- const getTwoChar = (ori: string) => {
131
- return ori.substring(0, 2);
132
- };
133
- const weekDays = [
134
- getTwoChar(t('SUNDAY_ABBREVIATION', 'Su')),
135
- getTwoChar(t('MONDAY_ABBREVIATION', 'Mo')),
136
- getTwoChar(t('TUESDAY_ABBREVIATION', 'Tu')),
137
- getTwoChar(t('WEDNESDAY_ABBREVIATION', 'We')),
138
- getTwoChar(t('THURSDAY_ABBREVIATION', 'Th')),
139
- getTwoChar(t('FRIDAY_ABBREVIATION', 'Fr')),
140
- getTwoChar(t('SATURDAY_ABBREVIATION', 'Sa')),
141
- ];
142
-
143
- useEffect(() => {
144
- if (orderState.options?.moment) {
145
- setOptionSelected({ isAsap: false, isSchedule: true });
146
- } else {
147
- setOptionSelected({ isAsap: true, isSchedule: false });
148
- }
149
-
150
- if (
151
- momentState.isEditing &&
152
- (momentFormat === orderState.options?.moment || timeSelected === null)
153
- ) {
154
- setMomentState({ isLoading: 2, isEditing: false });
155
- }
156
- }, [orderState.options?.moment]);
157
-
158
- useEffect(() => {
159
- if (momentState.isLoading === 2 && !orderState?.loading) {
160
- goToBack();
161
- }
162
- }, [momentState.isLoading]);
163
-
164
- const customDayHeaderStylesCallback = () => {
165
- return {
166
- textStyle: {
167
- color: theme.colors.disabled,
168
- fontSize: 12,
169
- },
170
- };
171
- };
172
-
173
- return (
174
- <Container style={{ paddingLeft: 40, paddingRight: 40 }}>
175
- <View style={{ paddingBottom: 10 }}>
176
- <NavBar
177
- onActionLeft={() => goToBack()}
178
- btnStyle={{ paddingLeft: 0 }}
179
- paddingTop={0}
180
- style={{ paddingBottom: 0 }}
181
- title={t('WHEN_DO_WE_DELIVERY', 'When do we delivery?')}
182
- titleAlign={'center'}
183
- titleStyle={{ fontSize: 14 }}
184
- titleWrapStyle={{ flexBasis: '80%' }}
185
- />
186
-
187
- <WrapSelectOption
188
- onPress={() => _handleAsap()}
189
- disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
190
- {optionSelected.isAsap ? (
191
- <OIcon
192
- src={theme.images.general.option_checked}
193
- width={16}
194
- style={{ marginEnd: 24 }}
195
- />
196
- ) : (
197
- <OIcon
198
- src={theme.images.general.option_normal}
199
- width={16}
200
- style={{ marginEnd: 24 }}
201
- />
202
- )}
203
- <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${moment().format('dddd, MMM d, yyyy h:mm A')} + delivery time)`}</OText>
204
- </WrapSelectOption>
205
- <WrapSelectOption
206
- onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}
207
- disabled={orderState.loading}>
208
- {optionSelected.isSchedule ? (
209
- <OIcon
210
- src={theme.images.general.option_checked}
211
- width={16}
212
- style={{ marginEnd: 24 }}
213
- />
214
- ) : (
215
- <OIcon
216
- src={theme.images.general.option_normal}
217
- width={16}
218
- style={{ marginEnd: 24 }}
219
- />
220
- )}
221
- <OText color={optionSelected.isSchedule ? theme.colors.textNormal : theme.colors.disabled}>{t('SCHEDULE_FOR_LATER', 'Schedule for later')}</OText>
222
- </WrapSelectOption>
223
-
224
- {optionSelected.isSchedule && (
225
- <WrapDelveryTime>
226
- {datesList.length > 0 && (
227
- <View style={styles.dateWrap}>
228
- <View style={styles.dateLabel}>
229
- <OText size={12} color={theme.colors.disabled}>{dateSelected}</OText>
230
- </View>
231
- <CalendarPicker
232
- nextTitle=">"
233
- width={width - 80}
234
- previousTitle="<"
235
- nextComponent={
236
- <OIcon
237
- src={theme.images.general.chevron_right}
238
- color={theme.colors.disabled}
239
- width={12}
240
- style={{ marginHorizontal: 4 }}
241
- />
242
- }
243
- previousComponent={
244
- <OIcon
245
- src={theme.images.general.chevron_left}
246
- color={theme.colors.disabled}
247
- width={12}
248
- style={{ marginHorizontal: 4 }}
249
- />
250
- }
251
- onDateChange={(date: moment.Moment) =>
252
- handleChangeDate(date.format('YYYY-MM-DD'))
253
- }
254
- selectedDayColor={theme.colors.primaryContrast}
255
- todayBackgroundColor={theme.colors.border}
256
- dayLabelsWrapper={{ borderColor: theme.colors.clear }}
257
- customDayHeaderStyles={customDayHeaderStylesCallback}
258
- weekdays={weekDays}
259
- selectedStartDate={momento}
260
- />
261
- </View>
262
- )}
263
-
264
- {hoursList.length > 0 && optionSelected.isSchedule && (
265
- <>
266
- <TouchableRipple style={styles.timeLabel} onPress={() => { setToggleTime(!toggleTime) }}>
267
- <>
268
- <OIcon src={theme.images.general.clock} width={16} />
269
- <OText style={{ flexGrow: 1, paddingHorizontal: 12 }} color={theme.colors.disabled}>{timeSelected ? timeSelected : t('DELIVERY_TIME', 'Delivery Time')}</OText>
270
- <OIcon src={theme.images.general.arrow_down} width={16} style={{ transform: [{ rotate: toggleTime ? '180deg' : '0deg' }] }} />
271
- </>
272
- </TouchableRipple>
273
- {toggleTime ? (
274
-
275
- <WrapHours nestedScrollEnabled={true}>
276
- <Hours name="hours">
277
- {hoursList.map((hour: any, i: any) => (
278
- <Hour
279
- key={i}
280
- onPress={() => handleChangeMoment(hour.startTime)}
281
- disabled={orderState.loading}
282
- style={{ borderColor: timeSelected === hour.startTime ? theme.colors.primary : theme.colors.border }}
283
- >
284
- <OText
285
- color={
286
- timeSelected === hour.startTime
287
- ? theme.colors.primary
288
- : theme.colors.textSecondary
289
- }>
290
- {configs?.format_time?.value === '12'
291
- ? hour.startTime.includes('12')
292
- ? `${hour.startTime}PM`
293
- : parseTime(moment(hour.startTime, 'HH:mm'), {
294
- outputFormat: 'hh:mma',
295
- })
296
- : parseTime(moment(hour.startTime, 'HH:mm'), {
297
- outputFormat: 'HH:mm',
298
- })}
299
- </OText>
300
- </Hour>
301
- ))}
302
- </Hours>
303
- </WrapHours>
304
- ) : null}
305
- </>
306
- )}
307
- </WrapDelveryTime>
308
- )}
309
- </View>
310
- <Spinner visible={momentState.isLoading === 1} />
311
- </Container>
312
- );
313
- };
314
-
315
- export const MomentOption = (props: any) => {
316
- const momentOptionProps = {
317
- ...props,
318
- UIComponent: MomentOptionUI,
319
- };
320
- return <MomentOptionController {...momentOptionProps} />;
321
- };