ordering-ui-react-native 0.14.83 → 0.14.84-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 (149) hide show
  1. package/package.json +6 -3
  2. package/src/DeliveryApp.tsx +34 -2
  3. package/src/assets/images/no-network.png +0 -0
  4. package/src/components/BusinessTypeFilter/index.tsx +9 -2
  5. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Cart/index.tsx +1 -1
  8. package/src/components/Checkout/index.tsx +0 -1
  9. package/src/components/Home/index.tsx +3 -5
  10. package/src/components/LanguageSelector/index.tsx +65 -97
  11. package/src/components/LanguageSelector/styles.tsx +4 -17
  12. package/src/components/Messages/index.tsx +38 -30
  13. package/src/components/MomentOption/index.tsx +3 -1
  14. package/src/components/OrderDetails/index.tsx +29 -6
  15. package/src/components/OrdersOption/index.tsx +4 -2
  16. package/src/components/PaymentOptions/index.tsx +7 -16
  17. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  18. package/src/components/ProductForm/index.tsx +1 -1
  19. package/src/components/ProductForm/styles.tsx +1 -0
  20. package/src/components/StripeElementsForm/index.tsx +27 -48
  21. package/src/components/UserProfileForm/index.tsx +35 -1
  22. package/src/components/VerifyPhone/styles.tsx +1 -2
  23. package/src/config.json +0 -2
  24. package/src/pages/Checkout.tsx +1 -1
  25. package/src/providers/AlertProvider.tsx +4 -1
  26. package/src/theme.json +2 -1
  27. package/src/types/index.tsx +2 -9
  28. package/src/utils/index.tsx +196 -1
  29. package/themes/business/index.tsx +4 -0
  30. package/themes/business/src/components/Chat/index.tsx +32 -31
  31. package/themes/business/src/components/NetworkError/index.tsx +61 -0
  32. package/themes/business/src/components/NetworkError/styles.tsx +11 -0
  33. package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
  34. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
  35. package/themes/business/src/components/OrdersListManager/index.tsx +871 -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 +354 -54
  39. package/themes/business/src/components/OrdersOption/styles.tsx +95 -7
  40. package/themes/business/src/components/PreviousMessages/index.tsx +12 -0
  41. package/themes/business/src/components/PreviousOrders/index.tsx +65 -46
  42. package/themes/business/src/components/PreviousOrders/styles.tsx +5 -10
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +11 -8
  44. package/themes/business/src/types/index.tsx +4 -0
  45. package/themes/business/src/utils/index.tsx +12 -0
  46. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  47. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  48. package/themes/doordash/src/components/OrderDetails/index.tsx +3 -1
  49. package/themes/doordash/src/components/OrdersOption/index.tsx +4 -2
  50. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/instacart/src/components/OrderDetails/index.tsx +3 -1
  52. package/themes/instacart/src/components/OrdersOption/index.tsx +4 -2
  53. package/themes/kiosk/index.tsx +2 -0
  54. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  55. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
  57. package/themes/kiosk/src/components/Cart/index.tsx +1 -1
  58. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  59. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  60. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  61. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  62. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +7 -5
  63. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  64. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  65. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  66. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  67. package/themes/kiosk/src/components/NetworkError/index.tsx +60 -0
  68. package/themes/kiosk/src/components/NetworkError/styles.tsx +11 -0
  69. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  70. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  71. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  72. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  73. package/themes/kiosk/src/components/ProductForm/index.tsx +172 -124
  74. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  75. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  76. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  77. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  78. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  79. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  80. package/themes/kiosk/src/types/index.d.ts +4 -0
  81. package/themes/original/index.tsx +26 -6
  82. package/themes/original/src/components/AnalyticsSegment/index.tsx +127 -0
  83. package/themes/original/src/components/BusinessBasicInformation/index.tsx +12 -39
  84. package/themes/original/src/components/BusinessController/index.tsx +2 -2
  85. package/themes/original/src/components/BusinessMenuList/index.tsx +4 -2
  86. package/themes/original/src/components/BusinessPreorder/index.tsx +3 -2
  87. package/themes/original/src/components/BusinessProductsList/index.tsx +50 -6
  88. package/themes/original/src/components/BusinessProductsListing/index.tsx +13 -10
  89. package/themes/original/src/components/BusinessReviews/index.tsx +4 -3
  90. package/themes/original/src/components/BusinessesListing/index.tsx +20 -11
  91. package/themes/original/src/components/Cart/index.tsx +43 -10
  92. package/themes/original/src/components/Checkout/index.tsx +54 -17
  93. package/themes/original/src/components/Checkout/styles.tsx +7 -0
  94. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  95. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  96. package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
  97. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +9 -2
  98. package/themes/original/src/components/LastOrder/index.tsx +3 -1
  99. package/themes/original/src/components/LoginForm/index.tsx +83 -68
  100. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  101. package/themes/original/src/components/Messages/index.tsx +19 -21
  102. package/themes/original/src/components/MomentOption/index.tsx +127 -152
  103. package/themes/original/src/components/MomentOption/styles.tsx +42 -18
  104. package/themes/original/src/components/NetworkError/index.tsx +61 -0
  105. package/themes/original/src/components/NetworkError/styles.tsx +11 -0
  106. package/themes/original/src/components/OrderDetails/index.tsx +106 -113
  107. package/themes/original/src/components/OrderProgress/index.tsx +6 -5
  108. package/themes/original/src/components/OrderSummary/index.tsx +34 -1
  109. package/themes/original/src/components/OrdersOption/index.tsx +20 -42
  110. package/themes/original/src/components/OrdersOption/styles.tsx +0 -5
  111. package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -1
  112. package/themes/original/src/components/PaymentOptions/index.tsx +20 -23
  113. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
  114. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  115. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  116. package/themes/original/src/components/PreviousOrders/index.tsx +4 -0
  117. package/themes/original/src/components/ProductForm/index.tsx +33 -18
  118. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  119. package/themes/original/src/components/ProductOptionSubOption/index.tsx +81 -74
  120. package/themes/original/src/components/ReviewDriver/index.tsx +315 -0
  121. package/themes/original/src/components/ReviewDriver/styles.tsx +38 -0
  122. package/themes/original/src/components/ReviewOrder/index.tsx +307 -186
  123. package/themes/original/src/components/ReviewOrder/styles.tsx +24 -13
  124. package/themes/original/src/components/ReviewProducts/index.tsx +116 -0
  125. package/themes/original/src/components/ReviewProducts/styles.tsx +16 -0
  126. package/themes/original/src/components/SignupForm/index.tsx +173 -154
  127. package/themes/original/src/components/SingleProductCard/index.tsx +6 -13
  128. package/themes/original/src/components/SingleProductCard/styles.tsx +1 -1
  129. package/themes/original/src/components/SingleProductReview/index.tsx +166 -0
  130. package/themes/original/src/components/SingleProductReview/styles.tsx +27 -0
  131. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  132. package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
  133. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  134. package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
  135. package/themes/original/src/components/UserProfile/index.tsx +13 -6
  136. package/themes/original/src/components/UserProfileForm/index.tsx +16 -8
  137. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  138. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  139. package/themes/original/src/layouts/FloatingBottomContainer.tsx +26 -0
  140. package/themes/original/src/types/index.tsx +47 -10
  141. package/themes/single-business/src/components/LastOrder/index.tsx +3 -1
  142. package/themes/single-business/src/components/OrderDetails/index.tsx +15 -0
  143. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
  144. package/themes/single-business/src/components/OrdersOption/index.tsx +4 -2
  145. package/themes/single-business/src/utils/index.tsx +7 -1
  146. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  147. package/themes/uber-eats/src/components/OrderDetails/index.tsx +3 -1
  148. package/themes/uber-eats/src/components/OrdersOption/index.tsx +4 -2
  149. package/src/components/StripeMethodForm/index.tsx +0 -163
@@ -67,7 +67,7 @@ const LoginFormUI = (props: LoginParams) => {
67
67
  const [, t] = useLanguage();
68
68
  const [{ configs }] = useConfig();
69
69
  const [, { login }] = useSession();
70
- const { control, handleSubmit, errors } = useForm();
70
+ const { control, handleSubmit, errors, reset, register, setValue } = useForm();
71
71
  const [passwordSee, setPasswordSee] = useState(false);
72
72
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
73
73
  const [isModalVisible, setIsModalVisible] = useState(false);
@@ -91,7 +91,7 @@ const LoginFormUI = (props: LoginParams) => {
91
91
  inputStyle: {
92
92
  marginBottom: 28,
93
93
  borderWidth: 1,
94
- borderColor: theme.colors.border,
94
+ // borderColor: theme.colors.border,
95
95
  borderRadius: 7.6,
96
96
  },
97
97
  line: {
@@ -189,33 +189,21 @@ const LoginFormUI = (props: LoginParams) => {
189
189
  }, [verifyPhoneState]);
190
190
 
191
191
  useEffect(() => {
192
- if (Object.keys(errors).length > 0) {
193
- // Convert all errors in one string to show in toast provider
194
- const list = Object.values(errors);
195
- let stringError = '';
196
- if (phoneInputData.error) {
197
- list.unshift({ message: phoneInputData.error });
198
- }
199
- if (
200
- loginTab === 'cellphone' &&
201
- !phoneInputData.error &&
202
- !phoneInputData.phone.country_phone_code &&
203
- !phoneInputData.phone.cellphone
204
- ) {
205
- list.unshift({
206
- message: t(
207
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
208
- 'The field Mobile phone is required.',
209
- ),
210
- });
211
- }
212
- list.map((item: any, i: number) => {
213
- stringError +=
214
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
215
- });
216
- showToast(ToastType.Error, stringError);
217
- }
218
- }, [errors]);
192
+ if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
193
+ else setValue('cellphone', '')
194
+ }, [phoneInputData?.phone?.cellphone])
195
+
196
+ useEffect(() => {
197
+ register('cellphone', {
198
+ required: loginTab === 'cellphone'
199
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
200
+ : null
201
+ })
202
+ }, [register])
203
+
204
+ useEffect(() => {
205
+ reset()
206
+ }, [loginTab])
219
207
 
220
208
  return (
221
209
  <Container>
@@ -284,43 +272,58 @@ const LoginFormUI = (props: LoginParams) => {
284
272
  {(useLoginByCellphone || useLoginByEmail) && (
285
273
  <FormInput>
286
274
  {useLoginByEmail && loginTab === 'email' && (
287
- <Controller
288
- control={control}
289
- render={({ onChange, value }: any) => (
290
- <OInput
291
- placeholder={t('EMAIL', 'Email')}
292
- style={loginStyle.inputStyle}
293
- icon={theme.images.general.email}
294
- onChange={(e: any) => {
295
- handleChangeInputEmail(e, onChange);
296
- }}
297
- value={value}
298
- autoCapitalize="none"
299
- autoCorrect={false}
300
- type="email-address"
301
- autoCompleteType="email"
302
- returnKeyType="next"
303
- onSubmitEditing={() => passwordRef.current?.focus()}
304
- blurOnSubmit={false}
305
- forwardRef={emailRef}
306
- />
275
+ <>
276
+ {errors?.email && (
277
+ <OText
278
+ size={14}
279
+ color={theme.colors.danger5}
280
+ weight={'normal'}>
281
+ {errors?.email?.message}{errors?.email?.type === 'required' && '*'}
282
+ </OText>
307
283
  )}
308
- name="email"
309
- rules={{
310
- required: t(
311
- 'VALIDATION_ERROR_EMAIL_REQUIRED',
312
- 'The field Email is required',
313
- ).replace('_attribute_', t('EMAIL', 'Email')),
314
- pattern: {
315
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
316
- message: t(
317
- 'INVALID_ERROR_EMAIL',
318
- 'Invalid email address',
319
- ).replace('_attribute_', t('EMAIL', 'Email')),
320
- },
321
- }}
322
- defaultValue=""
323
- />
284
+ <Controller
285
+ control={control}
286
+ render={({ onChange, value }: any) => (
287
+ <OInput
288
+ placeholder={t('EMAIL', 'Email')}
289
+ style={loginStyle.inputStyle}
290
+ icon={theme.images.general.email}
291
+ onChange={(e: any) => {
292
+ handleChangeInputEmail(e, onChange);
293
+ }}
294
+ value={value}
295
+ autoCapitalize="none"
296
+ autoCorrect={false}
297
+ type="email-address"
298
+ autoCompleteType="email"
299
+ returnKeyType="next"
300
+ onSubmitEditing={() => passwordRef.current?.focus()}
301
+ blurOnSubmit={false}
302
+ forwardRef={emailRef}
303
+ borderColor={errors?.email ? theme.colors.danger5 : theme.colors.border}
304
+ />
305
+ )}
306
+ name="email"
307
+ rules={{
308
+ required: {
309
+ value: true,
310
+ message: t(
311
+ 'VALIDATION_ERROR_EMAIL_REQUIRED',
312
+ 'The field Email is required',
313
+ ).replace('_attribute_', t('EMAIL', 'Email'))
314
+ },
315
+ pattern: {
316
+ value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
317
+ message: t(
318
+ 'INVALID_ERROR_EMAIL',
319
+ 'Invalid email address',
320
+ ).replace('_attribute_', t('EMAIL', 'Email')),
321
+ }
322
+ }}
323
+ defaultValue=""
324
+ />
325
+ </>
326
+
324
327
  )}
325
328
  {useLoginByCellphone && loginTab === 'cellphone' && (
326
329
  <View style={{ marginBottom: 28 }}>
@@ -331,10 +334,18 @@ const LoginFormUI = (props: LoginParams) => {
331
334
  returnKeyType: 'next',
332
335
  onSubmitEditing: () => passwordRef?.current?.focus?.(),
333
336
  }}
337
+ isStartValidation={errors?.cellphone}
334
338
  />
335
339
  </View>
336
340
  )}
337
-
341
+ {errors?.password && (
342
+ <OText
343
+ size={14}
344
+ color={theme.colors.danger5}
345
+ weight={'normal'}>
346
+ {errors?.password?.message}{errors?.password?.type === 'required' && '*'}
347
+ </OText>
348
+ )}
338
349
  <Controller
339
350
  control={control}
340
351
  render={({ onChange, value }: any) => (
@@ -366,14 +377,18 @@ const LoginFormUI = (props: LoginParams) => {
366
377
  returnKeyType="done"
367
378
  onSubmitEditing={handleSubmit(onSubmit)}
368
379
  blurOnSubmit
380
+ borderColor={errors?.password ? theme.colors.danger5 : theme.colors.border}
369
381
  />
370
382
  )}
371
383
  name="password"
372
384
  rules={{
373
- required: t(
385
+ required: {
386
+ value: true,
387
+ message: t(
374
388
  'VALIDATION_ERROR_PASSWORD_REQUIRED',
375
389
  'The field Password is required',
376
- ).replace('_attribute_', t('PASSWORD', 'Password')),
390
+ ).replace('_attribute_', t('PASSWORD', 'Password'))
391
+ }
377
392
  }}
378
393
  defaultValue=""
379
394
  />
@@ -73,7 +73,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
73
73
  { key: 18, value: t('DRIVER_ALMOST_ARRIVED_TO_BUSINESS', 'Driver almost arrived to business') },
74
74
  { key: 19, value: t('DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', 'Driver almost arrived to customer') },
75
75
  { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
76
- { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') }
76
+ { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') },
77
+ { key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver') },
78
+ { key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
77
79
  ]
78
80
 
79
81
  const objectStatus = orderStatus.find((o) => o.key === status)
@@ -218,7 +220,7 @@ export const OrderListing = (props: OrdersOptionParams) => {
218
220
  const OrderListingProps = {
219
221
  ...props,
220
222
  UIComponent: OrdersOptionUI,
221
- orderStatus: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
223
+ orderStatus: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
222
224
  useDefualtSessionManager: true,
223
225
  paginationSettings: {
224
226
  initialPage: 1,
@@ -35,6 +35,8 @@ const ORDER_STATUS: any = {
35
35
  19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
36
36
  20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
37
37
  21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
38
+ 22: 'ORDER_LOOKING_FOR_DRIVER',
39
+ 23: 'ORDER_DRIVER_ON_WAY'
38
40
  }
39
41
 
40
42
  const filterSpecialStatus = ['prepared_in', 'delivered_in']
@@ -95,28 +97,18 @@ const MessagesUI = (props: MessagesParams) => {
95
97
  }
96
98
 
97
99
  const handleImagePicker = () => {
98
- launchImageLibrary({ mediaType: 'photo', maxHeight: 300, maxWidth: 300, includeBase64: true }, (response: any) => {
99
- if (response.didCancel) {
100
- console.log('User cancelled image picker');
101
- } else if (response.errorMessage) {
102
- console.log('ImagePicker Error: ', response.errorMessage);
100
+ launchImageLibrary({ mediaType: 'photo', maxHeight: 2048, maxWidth: 2048, includeBase64: true }, (response: any) => {
101
+ if (response?.didCancel) {
102
+ showToast(ToastType.Error, t('IMAGE_CANCELLED', 'User cancelled image picker'));
103
+ } else if (response?.errorMessage) {
103
104
  showToast(ToastType.Error, response.errorMessage);
104
105
  } else {
105
- if (Platform.OS === 'ios') {
106
- if (response.uri) {
107
- const url = `data:${response.type};base64,${response.base64}`
108
- setImage && setImage(url);
109
- } else {
110
- showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
111
- }
106
+ if (response?.assets?.length > 0) {
107
+ const image = response?.assets[0]
108
+ const url = `data:${image.type};base64,${image.base64}`
109
+ setImage && setImage(url);
112
110
  } else {
113
- if (response?.assets?.length > 0) {
114
- const image = response?.assets[0]
115
- const url = `data:${image.type};base64,${image.base64}`
116
- setImage && setImage(url);
117
- } else {
118
- showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
119
- }
111
+ showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
120
112
  }
121
113
  }
122
114
  });
@@ -235,7 +227,7 @@ const MessagesUI = (props: MessagesParams) => {
235
227
  {image && (
236
228
  <TouchableOpacity
237
229
  style={{ position: 'absolute', top: -5, right: -5, borderColor: theme.colors.backgroundDark, backgroundColor: theme.colors.white, borderRadius: 25 }}
238
- onPress={() => removeImage()}
230
+ onPress={removeImage}
239
231
  >
240
232
  <MaterialCommunityIcon name='close-circle-outline' color={theme.colors.backgroundDark} size={24} />
241
233
  </TouchableOpacity>
@@ -543,9 +535,15 @@ const styles = StyleSheet.create({
543
535
  })
544
536
 
545
537
  export const Messages = (props: MessagesParams) => {
538
+ const [allMessages, setAllMessages] = useState(props.messages)
546
539
  const MessagesProps = {
547
540
  ...props,
548
- UIComponent: MessagesUI
541
+ UIComponent: MessagesUI,
542
+ messages: allMessages,
543
+ setMessages: (values: any) => {
544
+ props.setMessages && props.setMessages(values)
545
+ setAllMessages(values)
546
+ }
549
547
  }
550
548
  return <MessagesController {...MessagesProps} />
551
549
  }
@@ -1,18 +1,18 @@
1
- import React, { useState, useEffect } from 'react';
2
- import moment from 'moment';
3
- import CalendarStrip from 'react-native-calendar-strip'
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import moment, { Moment } from 'moment';
4
3
  import {
5
4
  useLanguage,
6
5
  useConfig,
6
+ useUtils,
7
7
  useOrder,
8
8
  MomentOption as MomentOptionController,
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
11
- import IconAntDesign from 'react-native-vector-icons/AntDesign'
12
11
  import {
12
+ ImageStore,
13
13
  StyleSheet,
14
+ useWindowDimensions,
14
15
  View,
15
- TouchableOpacity
16
16
  } from 'react-native';
17
17
  import Spinner from 'react-native-loading-spinner-overlay';
18
18
  import { MomentOptionParams } from '../../types';
@@ -21,16 +21,16 @@ import { OButton, OIcon, OText } from '../shared';
21
21
  import { Container } from '../../layouts/Container';
22
22
  import {
23
23
  WrapSelectOption,
24
- OrderTimeWrapper,
25
- TimeListWrapper,
26
- TimeContentWrapper,
27
- TimeItem
24
+ WrapDelveryTime,
28
25
  } from './styles';
26
+ import CalendarPicker from 'react-native-calendar-picker';
29
27
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
28
+ import SelectDropdown from 'react-native-select-dropdown';
30
29
 
31
30
  const MomentOptionUI = (props: MomentOptionParams) => {
32
31
  const {
33
32
  navigation,
33
+ nopadding,
34
34
  datesList,
35
35
  hoursList,
36
36
  dateSelected,
@@ -76,62 +76,12 @@ const MomentOptionUI = (props: MomentOptionParams) => {
76
76
  paddingHorizontal: 16,
77
77
  flexDirection: 'row',
78
78
  alignItems: 'center'
79
- },
80
- calendar: {
81
- paddingBottom: 15,
82
- borderBottomWidth: 1,
83
- borderColor: theme.colors.backgroundGray200,
84
- height: 100
85
- },
86
- calendarHeaderContainer: {
87
- flex: 1,
88
- justifyContent: 'flex-start',
89
- textAlign: 'left',
90
- marginBottom: 17,
91
- borderBottomWidth: 1,
92
- borderColor: theme.colors.backgroundGray200
93
- },
94
- calendarHeader: {
95
- color: '#344050',
96
- alignSelf: 'flex-start',
97
- fontSize: 14,
98
- fontWeight: '400'
99
- },
100
- dateNumber: {
101
- color: '#B1BCCC',
102
- fontSize: 16,
103
- fontWeight: '500',
104
- },
105
- dateName: {
106
- color: '#B1BCCC',
107
- fontSize: 12,
108
- textTransform: 'capitalize',
109
- },
110
- highlightDateName: {
111
- color: '#344050',
112
- fontSize: 12,
113
- textTransform: 'capitalize',
114
- },
115
- highlightDateNumber: {
116
- color: '#344050',
117
- fontSize: 16,
118
- textTransform: 'capitalize',
119
- },
120
- disabledDateName: {
121
- color: '#B1BCCC',
122
- fontSize: 10,
123
- textTransform: 'capitalize',
124
- opacity: 1,
125
- },
126
- disabledDateNumber: {
127
- color: '#B1BCCC',
128
- fontSize: 14,
129
- fontWeight: '500'
130
79
  }
131
80
  });
132
81
 
133
82
  const [, t] = useLanguage();
134
83
  const [{ configs }] = useConfig();
84
+ const [{ parseTime }] = useUtils();
135
85
  const [orderState] = useOrder();
136
86
  const [optionSelected, setOptionSelected] = useState({
137
87
  isAsap: false,
@@ -141,11 +91,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
141
91
  isLoading: 0,
142
92
  isEditing: false,
143
93
  });
94
+ const { width } = useWindowDimensions();
144
95
  const { bottom } = useSafeAreaInsets();
145
96
 
146
- const [selectedTime, setSelectedTime] = useState(null);
147
- const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
148
- const [selectDate, setSelectedDate] = useState<any>(null)
97
+ const [toggleTime, setToggleTime] = useState(false);
98
+ const [selectedTime, setSelectedTime] = useState(timeSelected);
99
+ const [minDate, setMinDate] = useState(new Date())
100
+ const [maxDate, setMaxDate] = useState(new Date)
101
+ const [alert, setAlert] = useState<any>({ show: false })
149
102
 
150
103
  const goToBack = () => navigation?.canGoBack() && navigation.goBack();
151
104
 
@@ -173,6 +126,19 @@ const MomentOptionUI = (props: MomentOptionParams) => {
173
126
  .utc()
174
127
  .format('YYYY-MM-DD HH:mm:ss');
175
128
 
129
+ const getTwoChar = (ori: string) => {
130
+ return ori.substring(0, 2);
131
+ };
132
+ const weekDays = [
133
+ getTwoChar(t('SUNDAY_ABBREVIATION', 'Su')),
134
+ getTwoChar(t('MONDAY_ABBREVIATION', 'Mo')),
135
+ getTwoChar(t('TUESDAY_ABBREVIATION', 'Tu')),
136
+ getTwoChar(t('WEDNESDAY_ABBREVIATION', 'We')),
137
+ getTwoChar(t('THURSDAY_ABBREVIATION', 'Th')),
138
+ getTwoChar(t('FRIDAY_ABBREVIATION', 'Fr')),
139
+ getTwoChar(t('SATURDAY_ABBREVIATION', 'Sa')),
140
+ ];
141
+
176
142
  useEffect(() => {
177
143
  if (orderState.options?.moment) {
178
144
  setOptionSelected({ isAsap: false, isSchedule: true });
@@ -194,34 +160,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
194
160
  }
195
161
  }, [momentState.isLoading]);
196
162
 
197
- const onSelectDate = (val: any) => {
198
- setSelectedDate(val)
199
- if (handleChangeDate) handleChangeDate(moment(val).format('YYYY-MM-DD'))
200
- }
201
-
202
- const LeftSelector = () => {
203
- return (
204
- <View style={{ height: '100%', justifyContent: 'flex-end' }}>
205
- <IconAntDesign
206
- name='caretleft'
207
- color={theme.colors.textNormal}
208
- size={16}
209
- />
210
- </View>
211
- )
212
- }
213
-
214
- const RightSelector = () => {
215
- return (
216
- <View style={{ height: '100%', justifyContent: 'flex-end' }}>
217
- <IconAntDesign
218
- name='caretright'
219
- color={theme.colors.textNormal}
220
- size={16}
221
- />
222
- </View>
223
- )
224
- }
163
+ const customDayHeaderStylesCallback = () => {
164
+ return {
165
+ textStyle: {
166
+ color: theme.colors.disabled,
167
+ fontSize: 12,
168
+ },
169
+ };
170
+ };
225
171
 
226
172
  useEffect(() => {
227
173
  if (datesList?.length > 0) {
@@ -230,22 +176,11 @@ const MomentOptionUI = (props: MomentOptionParams) => {
230
176
  const maxDateParts = _datesList[_datesList.length - 1].split('-')
231
177
  const _minDate = new Date(minDateParts[0], minDateParts[1] - 1, minDateParts[2])
232
178
  const _maxDate = new Date(maxDateParts[0], maxDateParts[1] - 1, maxDateParts[2])
233
- setDateWhitelist([{ start: _minDate, end: _maxDate }])
179
+ setMinDate(_minDate)
180
+ setMaxDate(_maxDate)
234
181
  }
235
182
  }, [datesList])
236
183
 
237
- useEffect(() => {
238
- if (dateSelected) {
239
- const dateParts = dateSelected.split('-')
240
- const _dateSelected = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
241
- setSelectedDate(_dateSelected)
242
- }
243
- }, [dateSelected])
244
-
245
- useEffect(() => {
246
- setSelectedTime(timeSelected)
247
- }, [timeSelected])
248
-
249
184
  return (
250
185
  <>
251
186
  <Container style={{ paddingLeft: 40, paddingRight: 40 }}>
@@ -299,55 +234,95 @@ const MomentOptionUI = (props: MomentOptionParams) => {
299
234
  </WrapSelectOption>
300
235
 
301
236
  {optionSelected.isSchedule && (
302
- <OrderTimeWrapper>
303
- <View style={{ flex: 1 }}>
304
- {selectDate && datesWhitelist[0]?.start !== null && (
305
- <CalendarStrip
306
- scrollable
307
- style={styles.calendar}
308
- calendarHeaderContainerStyle={styles.calendarHeaderContainer}
309
- calendarHeaderStyle={styles.calendarHeader}
310
- dateNumberStyle={styles.dateNumber}
311
- dateNameStyle={styles.dateName}
312
- iconContainer={{ flex: 0.1 }}
313
- highlightDateNameStyle={styles.highlightDateName}
314
- highlightDateNumberStyle={styles.highlightDateNumber}
315
- dayContainerStyle={{ height: '100%' }}
316
- highlightDateContainerStyle={{ height: '100%' }}
317
- calendarHeaderFormat='MMMM, YYYY'
318
- iconStyle={{ borderWidth: 1 }}
319
- selectedDate={selectDate}
320
- datesWhitelist={datesWhitelist}
321
- disabledDateNameStyle={styles.disabledDateName}
322
- disabledDateNumberStyle={styles.disabledDateNumber}
323
- disabledDateOpacity={0.6}
324
- onDateSelected={(date) => onSelectDate(date)}
325
- leftSelector={<LeftSelector />}
326
- rightSelector={<RightSelector />}
237
+ <WrapDelveryTime>
238
+ {datesList.length > 0 && (
239
+ <View style={styles.dateWrap}>
240
+ <View style={styles.dateLabel}>
241
+ <OText size={12} color={theme.colors.textNormal}>{dateSelected}</OText>
242
+ </View>
243
+ <SelectDropdown
244
+ defaultButtonText={timeSelected ? timeSelected : t('DELIVERY_TIME', 'Delivery Time')}
245
+ defaultValue={74}
246
+ data={hoursList}
247
+ disabled={orderState.loading}
248
+ onSelect={(selectedItem, index) => {
249
+ setSelectedTime(selectedItem.startTime)
250
+ }}
251
+ buttonTextAfterSelection={(selectedItem, index) => {
252
+ return `${selectedItem.startTime} - ${selectedItem.endTime}`
253
+ }}
254
+ rowTextForSelection={(item, index) => {
255
+ return `${item.startTime} - ${item.endTime}`
256
+ }}
257
+ buttonStyle={{
258
+ backgroundColor: theme.colors.white,
259
+ borderColor: theme.colors.border,
260
+ borderWidth: 1,
261
+ borderRadius: 8,
262
+ height: 40,
263
+ width: '100%',
264
+ flexDirection: 'column',
265
+ alignItems: 'flex-start',
266
+ marginBottom: 20
267
+ }}
268
+ buttonTextStyle={{
269
+ color: theme.colors.textNormal,
270
+ fontSize: 12,
271
+ paddingTop: 10
272
+ }}
273
+ dropdownStyle={{
274
+ borderRadius: 8,
275
+ borderColor: theme.colors.lightGray,
276
+ }}
277
+ rowStyle={{
278
+ borderBottomColor: theme.colors.white,
279
+ backgroundColor: theme.colors.white,
280
+ height: 40,
281
+ flexDirection: 'column',
282
+ alignItems: 'flex-start',
283
+ paddingTop: 8,
284
+ paddingLeft: 22
285
+ }}
286
+ rowTextStyle={{
287
+ color: theme.colors.textNormal,
288
+ fontSize: 14,
289
+ }}
290
+ />
291
+ <CalendarPicker
292
+ nextTitle=">"
293
+ width={width - 80}
294
+ previousTitle="<"
295
+ nextComponent={
296
+ <OIcon
297
+ src={theme.images.general.chevron_right}
298
+ color={theme.colors.disabled}
299
+ width={12}
300
+ style={{ marginHorizontal: 4 }}
301
+ />
302
+ }
303
+ previousComponent={
304
+ <OIcon
305
+ src={theme.images.general.chevron_left}
306
+ color={theme.colors.disabled}
307
+ width={12}
308
+ style={{ marginHorizontal: 4 }}
309
+ />
310
+ }
311
+ onDateChange={(date: moment.Moment) =>
312
+ handleChangeDate(date.format('YYYY-MM-DD'))
313
+ }
314
+ selectedDayColor={theme.colors.primaryContrast}
315
+ todayBackgroundColor={theme.colors.border}
316
+ dayLabelsWrapper={{ borderColor: theme.colors.clear }}
317
+ customDayHeaderStyles={customDayHeaderStylesCallback}
318
+ weekdays={weekDays}
319
+ selectedStartDate={momento}
320
+ minDate={minDate}
321
+ maxDate={maxDate}
327
322
  />
328
- )}
329
- </View>
330
- <TimeListWrapper nestedScrollEnabled={true}>
331
- <TimeContentWrapper>
332
- {hoursList.map((time: any, i: number) => (
333
- <TouchableOpacity key={i} onPress={() => setSelectedTime(time.startTime)}>
334
- <TimeItem active={selectedTime === time.startTime}>
335
- <OText
336
- size={14}
337
- color={selectedTime === time.startTime ? theme.colors.primary : theme.colors.textNormal}
338
- style={{
339
- lineHeight: 24
340
- }}
341
- >{time.startTime}</OText>
342
- </TimeItem>
343
- </TouchableOpacity>
344
- ))}
345
- {hoursList.length % 3 === 2 && (
346
- <TimeItem style={{ backgroundColor: 'transparent' }} />
347
- )}
348
- </TimeContentWrapper>
349
- </TimeListWrapper>
350
- </OrderTimeWrapper>
323
+ </View>
324
+ )}
325
+ </WrapDelveryTime>
351
326
  )}
352
327
  </View>
353
328
  <Spinner visible={momentState.isLoading === 1} />