ordering-ui-react-native 0.17.2 → 0.17.3-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 (215) hide show
  1. package/package.json +5 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/styles.tsx +8 -14
  4. package/src/components/BusinessInformation/index.tsx +11 -4
  5. package/src/components/BusinessInformation/styles.tsx +2 -2
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/OrderCreating/index.tsx +1 -21
  8. package/src/components/OrdersOption/index.tsx +54 -56
  9. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  10. package/src/components/SingleProductReview/index.tsx +7 -4
  11. package/src/components/StripeMethodForm/index.tsx +1 -1
  12. package/src/components/VerifyPhone/styles.tsx +1 -2
  13. package/src/components/shared/OToast.tsx +4 -4
  14. package/src/utils/index.tsx +7 -1
  15. package/themes/business/index.tsx +2 -0
  16. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  17. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  18. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  19. package/themes/business/src/components/Chat/index.tsx +118 -107
  20. package/themes/business/src/components/DriverMap/index.tsx +22 -9
  21. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  22. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  23. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  24. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  25. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  26. package/themes/business/src/components/MapView/index.tsx +18 -7
  27. package/themes/business/src/components/NewOrderNotification/index.tsx +34 -44
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +96 -50
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  33. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  34. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  35. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  36. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  37. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  38. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  39. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  40. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  41. package/themes/business/src/components/ReviewCustomer/index.tsx +41 -24
  42. package/themes/business/src/components/StoresList/index.tsx +2 -2
  43. package/themes/business/src/components/shared/OLink.tsx +33 -13
  44. package/themes/business/src/components/shared/OModal.tsx +16 -9
  45. package/themes/business/src/components/shared/OText.tsx +8 -2
  46. package/themes/business/src/types/index.tsx +33 -2
  47. package/themes/business/src/utils/index.tsx +51 -0
  48. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  49. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  50. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  52. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  53. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  54. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  55. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  56. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  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/OrderTypeCardSelector/index.tsx +8 -10
  60. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
  61. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  62. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  65. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  66. package/themes/kiosk/src/types/index.d.ts +13 -0
  67. package/themes/kiosk/src/utils/index.tsx +15 -0
  68. package/themes/original/index.tsx +8 -0
  69. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  70. package/themes/original/src/components/AddressForm/index.tsx +41 -16
  71. package/themes/original/src/components/AddressList/index.tsx +26 -21
  72. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  73. package/themes/original/src/components/AnalyticsSegment/index.tsx +189 -9
  74. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +125 -82
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -4
  77. package/themes/original/src/components/BusinessController/index.tsx +145 -68
  78. package/themes/original/src/components/BusinessController/styles.tsx +22 -9
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  81. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  82. package/themes/original/src/components/BusinessItemAccordion/index.tsx +24 -23
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +52 -24
  84. package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +20 -11
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  87. package/themes/original/src/components/BusinessProductsListing/index.tsx +617 -490
  88. package/themes/original/src/components/BusinessProductsListing/styles.tsx +7 -13
  89. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  90. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -3
  91. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +98 -78
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  94. package/themes/original/src/components/BusinessesListing/index.tsx +5 -3
  95. package/themes/original/src/components/Cart/index.tsx +88 -43
  96. package/themes/original/src/components/CartContent/index.tsx +102 -3
  97. package/themes/original/src/components/CartContent/styles.tsx +15 -1
  98. package/themes/original/src/components/Checkout/index.tsx +311 -178
  99. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  100. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  101. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  102. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  103. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  104. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  105. package/themes/original/src/components/Favorite/index.tsx +7 -4
  106. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  107. package/themes/original/src/components/FavoriteList/index.tsx +70 -80
  108. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  109. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  110. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  111. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  112. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  113. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  114. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  115. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +178 -0
  116. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  117. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  118. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  119. package/themes/original/src/components/Help/index.tsx +8 -8
  120. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  121. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  122. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  123. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  124. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  125. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  126. package/themes/original/src/components/Home/index.tsx +13 -4
  127. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  128. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  129. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  130. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  131. package/themes/original/src/components/LoginForm/index.tsx +43 -19
  132. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  133. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  134. package/themes/original/src/components/Messages/index.tsx +32 -10
  135. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  136. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  137. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +117 -96
  138. package/themes/original/src/components/MultiCheckout/index.tsx +248 -83
  139. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  140. package/themes/original/src/components/MultiOrdersDetails/index.tsx +67 -20
  141. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  142. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  143. package/themes/original/src/components/NavBar/index.tsx +6 -11
  144. package/themes/original/src/components/Notifications/index.tsx +144 -0
  145. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  146. package/themes/original/src/components/OrderDetails/OrderEta.tsx +59 -0
  147. package/themes/original/src/components/OrderDetails/index.tsx +262 -347
  148. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  149. package/themes/original/src/components/OrderItAgain/index.tsx +47 -43
  150. package/themes/original/src/components/OrderProgress/index.tsx +74 -112
  151. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  152. package/themes/original/src/components/OrderSummary/index.tsx +68 -29
  153. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  154. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +28 -19
  155. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  156. package/themes/original/src/components/OrdersOption/index.tsx +76 -83
  157. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  158. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  159. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  160. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  161. package/themes/original/src/components/PaymentOptions/index.tsx +3 -3
  162. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  163. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  164. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  165. package/themes/original/src/components/ProductForm/index.tsx +240 -261
  166. package/themes/original/src/components/ProductForm/styles.tsx +4 -7
  167. package/themes/original/src/components/ProductItemAccordion/index.tsx +200 -128
  168. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  169. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  170. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  171. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  172. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  173. package/themes/original/src/components/Promotions/index.tsx +234 -220
  174. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  175. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  176. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  177. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  178. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  179. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  180. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  181. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  182. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  183. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  184. package/themes/original/src/components/Sessions/index.tsx +11 -8
  185. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  186. package/themes/original/src/components/SignupForm/index.tsx +79 -66
  187. package/themes/original/src/components/SingleOrderCard/index.tsx +126 -57
  188. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  189. package/themes/original/src/components/SingleProductCard/index.tsx +111 -56
  190. package/themes/original/src/components/SingleProductCard/styles.tsx +27 -13
  191. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  192. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  193. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  194. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  195. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -218
  196. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  197. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  198. package/themes/original/src/components/UserFormDetails/index.tsx +53 -54
  199. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  200. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  201. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  202. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  203. package/themes/original/src/components/Wallets/index.tsx +31 -17
  204. package/themes/original/src/components/Wallets/styles.tsx +2 -0
  205. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  206. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  207. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  208. package/themes/original/src/components/shared/OButton.tsx +6 -2
  209. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  210. package/themes/original/src/components/shared/OInput.tsx +10 -1
  211. package/themes/original/src/components/shared/OModal.tsx +3 -3
  212. package/themes/original/src/layouts/Container.tsx +13 -9
  213. package/themes/original/src/types/index.tsx +46 -8
  214. package/themes/original/src/utils/index.tsx +364 -58
  215. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -28,7 +28,9 @@ import {
28
28
  TabsContainer,
29
29
  OrSeparator,
30
30
  LineSeparator,
31
- RecaptchaButton
31
+ RecaptchaButton,
32
+ TabBtn,
33
+ OTab
32
34
  } from './styles';
33
35
  import { _setStoreData } from '../../providers/StoreUtil'
34
36
  import { OText, OButton, OInput, OIconButton, OModal } from '../shared';
@@ -36,6 +38,9 @@ import { PhoneInputNumber } from '../PhoneInputNumber';
36
38
  import { VerifyPhone } from '../VerifyPhone';
37
39
  import { LoginParams } from '../../types';
38
40
 
41
+ import { Otp } from './Otp'
42
+ import Alert from '../../../../../src/providers/AlertProvider'
43
+
39
44
  const LoginFormUI = (props: LoginParams) => {
40
45
  const {
41
46
  navigation,
@@ -54,7 +59,14 @@ const LoginFormUI = (props: LoginParams) => {
54
59
  useRootPoint,
55
60
  notificationState,
56
61
  handleReCaptcha,
57
- enableReCaptcha
62
+ enableReCaptcha,
63
+
64
+ useLoginOtp,
65
+ otpType,
66
+ setOtpType,
67
+ generateOtpCode,
68
+ useLoginOtpEmail,
69
+ useLoginOtpCellphone,
58
70
  } = props;
59
71
 
60
72
  const [ordering, { setOrdering }] = useApi();
@@ -97,6 +109,12 @@ const LoginFormUI = (props: LoginParams) => {
97
109
 
98
110
  const recaptchaRef = useRef<any>({});
99
111
 
112
+ const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
113
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
114
+ const isOtpEmail = loginTab === 'otp' && otpType === 'email'
115
+ const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
116
+
117
+
100
118
  const handleOpenRecaptcha = () => {
101
119
  setRecaptchaVerified(false)
102
120
  if (!recaptchaConfig?.siteKey) {
@@ -209,6 +227,31 @@ const LoginFormUI = (props: LoginParams) => {
209
227
  handleSubmit(onSubmit)();
210
228
  };
211
229
 
230
+ const mainLogin = (values) => {
231
+ if (loginTab === 'otp') {
232
+ if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
233
+ showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
234
+ return
235
+ }
236
+ if (loginTab === 'otp') {
237
+ generateOtpCode({
238
+ ...values,
239
+ ...phoneInputData.phone
240
+ })
241
+ }
242
+ setWillVerifyOtpState(true)
243
+ } else {
244
+ if (phoneInputData.error) {
245
+ showToast(ToastType.Error, phoneInputData.error);
246
+ return;
247
+ }
248
+ handleButtonLoginClick({
249
+ ...values,
250
+ ...phoneInputData.phone,
251
+ });
252
+ }
253
+ }
254
+
212
255
  const onSubmit = (values: any) => {
213
256
  Keyboard.dismiss();
214
257
 
@@ -227,13 +270,26 @@ const LoginFormUI = (props: LoginParams) => {
227
270
  setSubmitted(true)
228
271
  return
229
272
  }
230
-
231
- handleButtonLoginClick({
232
- ...values,
233
- ...phoneInputData.phone
234
- });
273
+ mainLogin(values)
235
274
  };
236
275
 
276
+ const handleChangeOtpType = (type: string) => {
277
+ handleChangeTab('otp', type)
278
+ setOtpType(type)
279
+ }
280
+
281
+ const handleLoginOtp = (code: string) => {
282
+ handleButtonLoginClick({ code })
283
+ }
284
+
285
+ const closeAlert = () => {
286
+ setAlertState({
287
+ open: false,
288
+ title: '',
289
+ content: []
290
+ })
291
+ }
292
+
237
293
  const handleVerifyCodeClick = () => {
238
294
  if (phoneInputData.error) {
239
295
  showToast(ToastType.Error, phoneInputData.error);
@@ -272,27 +328,17 @@ const LoginFormUI = (props: LoginParams) => {
272
328
  showToast(ToastType.Info, t('TRY_AGAIN', 'Please try again'))
273
329
  return
274
330
  }
275
- formState?.result?.result &&
276
- showToast(
277
- ToastType.Error,
278
- loginTab === 'email' && typeof formState.result?.result === 'string'
279
- ? getTraduction(formState.result?.result)
280
- : loginTab === 'email' &&
281
- typeof formState.result?.result !== 'string'
282
- ? getTraduction(formState.result?.result[0])
283
- : loginTab === 'cellphone' &&
284
- typeof formState.result?.result === 'string'
285
- ? getTraduction(formState.result?.result).replace(
286
- t('USER', 'user').toLowerCase(),
287
- t('PHONE_NUMER', 'Phone number'),
288
- )
289
- : getTraduction(formState.result?.result[0]).replace(
290
- t('USER', 'user').toLowerCase(),
291
- t('PHONE_NUMER', 'Phone number'),
292
- ),
293
- );
331
+ formState.result?.result && showToast(
332
+ ToastType.Error,
333
+ typeof formState.result?.result === 'string'
334
+ ? formState.result?.result
335
+ : formState.result?.result[0]
336
+ )
294
337
  setSubmitted(false)
295
338
  }
339
+ if (!formState?.loading && !formState?.result?.error) {
340
+ setWillVerifyOtpState(false)
341
+ }
296
342
  }, [formState]);
297
343
 
298
344
  useEffect(() => {
@@ -360,9 +406,20 @@ const LoginFormUI = (props: LoginParams) => {
360
406
  if (values?.project_name) {
361
407
  delete values.project_name
362
408
  }
363
- handleButtonLoginClick({ ...values })
409
+ mainLogin(values)
410
+ setSubmitted(false)
364
411
  }, [ordering, submitted])
365
412
 
413
+ useEffect(() => {
414
+ if (checkPhoneCodeState?.result?.error) {
415
+ setAlertState({
416
+ open: true,
417
+ content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
418
+ title: ''
419
+ })
420
+ }
421
+ }, [checkPhoneCodeState])
422
+
366
423
  Dimensions.addEventListener('change', ({ window: { width, height } }) => {
367
424
  setWindowWidth(
368
425
  parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
@@ -419,6 +476,8 @@ const LoginFormUI = (props: LoginParams) => {
419
476
  borderRadius: 7.6,
420
477
  borderColor: theme.colors.inputSignup,
421
478
  backgroundColor: theme.colors.transparent,
479
+ minHeight: 50,
480
+ maxHeight : 50
422
481
  },
423
482
  btn: {
424
483
  borderRadius: 7.6,
@@ -445,6 +504,25 @@ const LoginFormUI = (props: LoginParams) => {
445
504
  fontWeight: 'normal',
446
505
  fontSize: 16,
447
506
  },
507
+
508
+ borderStyleBase: {
509
+ width: 30,
510
+ height: 45
511
+ },
512
+ borderStyleHighLighted: {
513
+ borderColor: "#03DAC6",
514
+ },
515
+ underlineStyleBase: {
516
+ width: 45,
517
+ height: 60,
518
+ borderWidth: 1,
519
+ fontSize: 16
520
+ },
521
+ underlineStyleHighLighted: {
522
+ borderColor: theme.colors.primary,
523
+ color: theme.colors.primary,
524
+ fontSize: 16
525
+ },
448
526
  });
449
527
 
450
528
  return (
@@ -461,7 +539,7 @@ const LoginFormUI = (props: LoginParams) => {
461
539
  <OText style={styles.title}>{t('LOGIN', 'Login')}</OText>
462
540
  </View>
463
541
 
464
- {(useLoginByEmail || useLoginByCellphone) && (
542
+ {(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
465
543
  <LoginWith>
466
544
  <ScrollView
467
545
  ref={scrollRefTab}
@@ -522,12 +600,63 @@ const LoginFormUI = (props: LoginParams) => {
522
600
  }}></View>
523
601
  </Pressable>
524
602
  )}
603
+
604
+ {useLoginOtpEmail && (
605
+ <Pressable
606
+ style={styles.btnTab}
607
+ onPress={() => handleChangeOtpType('email')}>
608
+ <OText
609
+ style={styles.btnTabText}
610
+ color={
611
+ isOtpEmail
612
+ ? theme.colors.textNormal
613
+ : theme.colors.disabled
614
+ }
615
+ weight={isOtpEmail ? 'bold' : 'normal'}>
616
+ {t('BY_OTP_EMAIL', 'By Otp Email')}
617
+ </OText>
618
+ <View
619
+ style={{
620
+ width: '100%',
621
+ borderBottomColor:
622
+ isOtpEmail
623
+ ? theme.colors.textGray
624
+ : theme.colors.tabBar,
625
+ borderBottomWidth: 2,
626
+ }} />
627
+ </Pressable>
628
+ )}
629
+ {useLoginOtpCellphone && (
630
+ <Pressable
631
+ style={styles.btnTab}
632
+ onPress={() => handleChangeOtpType('cellphone')}>
633
+ <OText
634
+ style={styles.btnTabText}
635
+ color={
636
+ isOtpCellphone
637
+ ? theme.colors.textNormal
638
+ : theme.colors.disabled
639
+ }
640
+ weight={isOtpCellphone ? 'bold' : 'normal'}>
641
+ {t('BY_OTP_PHONE', 'By Otp Phone')}
642
+ </OText>
643
+ <View
644
+ style={{
645
+ width: '100%',
646
+ borderBottomColor:
647
+ isOtpCellphone
648
+ ? theme.colors.textGray
649
+ : theme.colors.tabBar,
650
+ borderBottomWidth: 2,
651
+ }} />
652
+ </Pressable>
653
+ )}
525
654
  </TabsContainer>
526
655
  </ScrollView>
527
656
  </LoginWith>
528
657
  )}
529
658
 
530
- {(useLoginByCellphone || useLoginByEmail) && (
659
+ {(useLoginByCellphone || useLoginByEmail || useLoginOtp) && (
531
660
  <FormInput>
532
661
  {useRootPoint && (
533
662
  <Controller
@@ -561,7 +690,7 @@ const LoginFormUI = (props: LoginParams) => {
561
690
  />
562
691
  )}
563
692
 
564
- {useLoginByEmail && loginTab === 'email' && (
693
+ {((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
565
694
  <Controller
566
695
  control={control}
567
696
  render={({ onChange, value }: any) => (
@@ -606,7 +735,7 @@ const LoginFormUI = (props: LoginParams) => {
606
735
  />
607
736
  )}
608
737
 
609
- {useLoginByCellphone && loginTab === 'cellphone' && (
738
+ {((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
610
739
  <View style={{ marginBottom: 20 }}>
611
740
  <PhoneInputNumber
612
741
  data={phoneInputData}
@@ -621,54 +750,56 @@ const LoginFormUI = (props: LoginParams) => {
621
750
  </View>
622
751
  )}
623
752
 
624
- <Controller
625
- control={control}
626
- render={({ onChange, value }: any) => (
627
- <OInput
628
- isSecured={!passwordSee ? true : false}
629
- placeholder={t('PASSWORD', 'Password')}
630
- placeholderTextColor={theme.colors.arrowColor}
631
- style={styles.input}
632
- icon={theme.images.logos.passwordInputIcon}
633
- iconColor={theme.colors.arrowColor}
634
- iconCustomRight={
635
- !passwordSee ? (
636
- <MaterialCommunityIcons
637
- name="eye-outline"
638
- size={24}
639
- color={theme.colors.arrowColor}
640
- onPress={() => setPasswordSee(!passwordSee)}
641
- />
642
- ) : (
643
- <MaterialCommunityIcons
644
- name="eye-off-outline"
645
- size={24}
646
- color={theme.colors.arrowColor}
647
- onPress={() => setPasswordSee(!passwordSee)}
648
- />
649
- )
650
- }
651
- selectionColor={theme.colors.primary}
652
- color={theme.colors.textGray}
653
- value={value}
654
- forwardRef={inputRef}
655
- onChange={(val: any) => onChange(val)}
656
- returnKeyType="done"
657
- onSubmitEditing={() => handleLogin()}
658
- blurOnSubmit
659
- />
660
- )}
661
- name="password"
662
- rules={{
663
- required: t(
664
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
665
- 'The field Password is required',
666
- ).replace('_attribute_', t('PASSWORD', 'Password')),
667
- }}
668
- defaultValue=""
669
- />
753
+ {loginTab !== 'otp' && (
754
+ <Controller
755
+ control={control}
756
+ render={({ onChange, value }: any) => (
757
+ <OInput
758
+ isSecured={!passwordSee ? true : false}
759
+ placeholder={t('PASSWORD', 'Password')}
760
+ placeholderTextColor={theme.colors.arrowColor}
761
+ style={styles.input}
762
+ icon={theme.images.logos.passwordInputIcon}
763
+ iconColor={theme.colors.arrowColor}
764
+ iconCustomRight={
765
+ !passwordSee ? (
766
+ <MaterialCommunityIcons
767
+ name="eye-outline"
768
+ size={24}
769
+ color={theme.colors.arrowColor}
770
+ onPress={() => setPasswordSee(!passwordSee)}
771
+ />
772
+ ) : (
773
+ <MaterialCommunityIcons
774
+ name="eye-off-outline"
775
+ size={24}
776
+ color={theme.colors.arrowColor}
777
+ onPress={() => setPasswordSee(!passwordSee)}
778
+ />
779
+ )
780
+ }
781
+ selectionColor={theme.colors.primary}
782
+ color={theme.colors.textGray}
783
+ value={value}
784
+ forwardRef={inputRef}
785
+ onChange={(val: any) => onChange(val)}
786
+ returnKeyType="done"
787
+ onSubmitEditing={() => handleLogin()}
788
+ blurOnSubmit
789
+ />
790
+ )}
791
+ name="password"
792
+ rules={{
793
+ required: t(
794
+ 'VALIDATION_ERROR_PASSWORD_REQUIRED',
795
+ 'The field Password is required',
796
+ ).replace('_attribute_', t('PASSWORD', 'Password')),
797
+ }}
798
+ defaultValue=""
799
+ />
800
+ )}
670
801
 
671
- {onNavigationRedirect && (
802
+ {onNavigationRedirect && loginTab !== 'otp' && (
672
803
  <Pressable
673
804
  style={{ marginRight: 'auto', marginBottom: 20 }}
674
805
  onPress={() => onNavigationRedirect('Forgot')}>
@@ -723,7 +854,7 @@ const LoginFormUI = (props: LoginParams) => {
723
854
  )}
724
855
  <OButton
725
856
  onClick={handleLogin}
726
- text={t('LOGIN', 'Login')}
857
+ text={loginTab !== 'otp' ? t('LOGIN', 'Login') : t('GET_VERIFY_CODE', 'Get verify code')}
727
858
  bgColor={theme.colors.primary}
728
859
  borderColor={theme.colors.primary}
729
860
  textStyle={styles.btnText}
@@ -763,7 +894,10 @@ const LoginFormUI = (props: LoginParams) => {
763
894
  </>
764
895
  )}
765
896
 
766
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
897
+ <OModal
898
+ open={isModalVisible}
899
+ onClose={() => setIsModalVisible(false)}
900
+ >
767
901
  <VerifyPhone
768
902
  phone={phoneInputData.phone}
769
903
  verifyPhoneState={verifyPhoneState}
@@ -773,6 +907,29 @@ const LoginFormUI = (props: LoginParams) => {
773
907
  handleVerifyCodeClick={handleVerifyCodeClick}
774
908
  />
775
909
  </OModal>
910
+ <OModal
911
+ open={willVerifyOtpState}
912
+ onClose={() => setWillVerifyOtpState(false)}
913
+ entireModal
914
+ hideIcons
915
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
916
+ >
917
+ <Otp
918
+ willVerifyOtpState={willVerifyOtpState}
919
+ setWillVerifyOtpState={setWillVerifyOtpState}
920
+ handleLoginOtp={handleLoginOtp}
921
+ onSubmit={handleLogin}
922
+ setAlertState={setAlertState}
923
+ formState={formState}
924
+ />
925
+ </OModal>
926
+ <Alert
927
+ open={alertState.open}
928
+ content={alertState.content}
929
+ title={alertState.title || ''}
930
+ onAccept={closeAlert}
931
+ onClose={closeAlert}
932
+ />
776
933
  </View>
777
934
  );
778
935
  };
@@ -786,3 +943,4 @@ export const LoginForm = (props: any) => {
786
943
 
787
944
  return <LoginFormController {...loginProps} />;
788
945
  };
946
+
@@ -52,3 +52,13 @@ export const RecaptchaButton = styled.View`
52
52
  align-items: center;
53
53
  margin-bottom: 10px;
54
54
  `
55
+ export const OTab = styled.View`
56
+ padding-bottom: 10px;
57
+ border-bottom-width: 1px;
58
+ margin-end: 14px;
59
+ `;
60
+
61
+ export const TabBtn = styled.TouchableOpacity`
62
+ min-height: 30px;
63
+ height: 30px;
64
+ `;
@@ -21,6 +21,7 @@ const MapViewComponent = (props: MapViewParams) => {
21
21
  customerMarkerGroups,
22
22
  alertState,
23
23
  setAlertState,
24
+ setDriverLocation,
24
25
  onNavigationRedirect,
25
26
  getBusinessLocations,
26
27
  } = props;
@@ -41,7 +42,7 @@ const MapViewComponent = (props: MapViewParams) => {
41
42
  followUserLocation
42
43
  } = useLocation();
43
44
 
44
- const location = { lat: userLocation.latitude, lng: userLocation.longitude }
45
+ const location = { lat: userLocation?.latitude, lng: userLocation?.longitude }
45
46
  const haveOrders = Object.values(markerGroups)?.length > 0 && Object.values(customerMarkerGroups)?.length > 0
46
47
  const closeAlert = () => {
47
48
  setAlertState({
@@ -56,8 +57,8 @@ const MapViewComponent = (props: MapViewParams) => {
56
57
  [
57
58
  { latitude: location.latitude, longitude: location.longitude },
58
59
  {
59
- latitude: userLocation.latitude,
60
- longitude: userLocation.longitude,
60
+ latitude: userLocation?.latitude,
61
+ longitude: userLocation?.longitude,
61
62
  },
62
63
  ],
63
64
  {
@@ -102,7 +103,7 @@ const MapViewComponent = (props: MapViewParams) => {
102
103
  return () => {
103
104
  stopFollowUserLocation();
104
105
  };
105
- }, []);
106
+ }, [isFocused]);
106
107
 
107
108
  useFocusEffect(
108
109
  useCallback(() => {
@@ -211,6 +212,16 @@ const MapViewComponent = (props: MapViewParams) => {
211
212
  )
212
213
  }
213
214
 
215
+ useEffect(() => {
216
+ if (userLocation?.latitude !== 0 && userLocation?.longitude !== 0) {
217
+ const location = {
218
+ lat: userLocation?.latitude,
219
+ lng: userLocation?.longitude
220
+ }
221
+ setDriverLocation({ location })
222
+ }
223
+ }, [userLocation])
224
+
214
225
  return (
215
226
  <SafeAreaView style={{ flex: 1 }}>
216
227
  <View style={{ flex: 1 }}>
@@ -220,8 +231,8 @@ const MapViewComponent = (props: MapViewParams) => {
220
231
  ref={mapRef}
221
232
  provider={PROVIDER_GOOGLE}
222
233
  initialRegion={{
223
- latitude: initialPosition.latitude,
224
- longitude: initialPosition.longitude,
234
+ latitude: initialPosition?.latitude,
235
+ longitude: initialPosition?.longitude,
225
236
  latitudeDelta: haveOrders ? 0.01 : 0.1,
226
237
  longitudeDelta: haveOrders ? 0.01 * ASPECT_RATIO : 0.1 * ASPECT_RATIO,
227
238
  }}
@@ -241,7 +252,7 @@ const MapViewComponent = (props: MapViewParams) => {
241
252
  orderIds={marker.map((order: any) => order.id).join(', ')}
242
253
  />
243
254
  ))}
244
- {Object.values(customerMarkerGroups).map((marker: any) => (
255
+ {Object.values(customerMarkerGroups).map((marker: any) => (
245
256
  <RenderMarker
246
257
  key={marker[0]?.customer_id}
247
258
  marker={marker[0]}
@@ -14,6 +14,8 @@ Sound.setCategory('Playback')
14
14
 
15
15
  const windowWidth = Dimensions.get('screen').width
16
16
 
17
+ const SOUND_LOOP = 3
18
+
17
19
  const NewOrderNotificationUI = (props: any) => {
18
20
  const { isBusinessApp } = props
19
21
  const [events] = useEvent()
@@ -22,8 +24,7 @@ const NewOrderNotificationUI = (props: any) => {
22
24
  const [{ user, token }] = useSession()
23
25
  const [ordering] = useApi()
24
26
  const { getCurrentLocation } = useLocation();
25
- const [soundTimeout, setSoundTimeout] = useState<any>(null)
26
- let [currentEvent, setCurrentEvent] = useState<any>(null)
27
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
27
28
 
28
29
  const evtList: any = {
29
30
  1: {
@@ -43,29 +44,27 @@ const NewOrderNotificationUI = (props: any) => {
43
44
  },
44
45
  }
45
46
 
46
- const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
47
+ const notificationSound = new Sound(theme.sounds.notification, '', () => { });
47
48
 
48
- const handlePlayNotificationSound = () => {
49
- if (currentEvent) return
50
- let times = 0
51
- const _timeout = setInterval(function () {
52
- notificationSound.play(success => {
53
- if (success) {
54
- times = times + 1
55
- }
56
- })
57
- setSoundTimeout(_timeout)
58
- if (times === 3) {
59
- clearInterval(_timeout)
60
- clearInterval(soundTimeout)
61
- }
62
- }, 2500)
49
+ let _timeout: any = null
50
+
51
+ const handleCloseEvents = () => {
52
+ notificationSound.stop()
53
+ setCurrentEvent(null)
54
+ clearInterval(_timeout)
63
55
  }
64
56
 
65
- const handleCloseModal = () => {
66
- clearInterval(soundTimeout)
67
- currentEvent = null
68
- setCurrentEvent({ evt: null })
57
+ const handlePlayNotificationSound = (eventObj: any = null) => {
58
+ setCurrentEvent(eventObj)
59
+ let times = 1
60
+ if (times < SOUND_LOOP) {
61
+ _timeout = setInterval(() => {
62
+ notificationSound.setVolume(1).play(success => success && (times = times + 1))
63
+ if (times === SOUND_LOOP) {
64
+ clearInterval(_timeout)
65
+ }
66
+ }, 2500)
67
+ }
69
68
  }
70
69
 
71
70
  const handleEventNotification = async (evtType: number, value: any) => {
@@ -75,32 +74,21 @@ const NewOrderNotificationUI = (props: any) => {
75
74
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
76
75
  method: 'POST',
77
76
  body: JSON.stringify({
78
- location: JSON.stringify({location: `{lat: ${location.latitude}, lng: ${location.longitude}}`})
77
+ location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
79
78
  }),
80
79
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
81
80
  })
82
- } catch (error) {
83
- console.log(error)
84
- }
81
+ } catch { }
85
82
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
86
83
  const assignedSecondsDiff = duration.asSeconds()
87
- if (assignedSecondsDiff < 5 && !isBusinessApp) {
88
- handlePlayNotificationSound()
89
- clearInterval(soundTimeout)
90
- currentEvent = { evt: 2, orderId: value?.id }
91
- setCurrentEvent({ evt: 2, orderId: value?.id })
84
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
85
+ handlePlayNotificationSound({ evt: 2, orderId: value?.id })
92
86
  }
93
87
  }
94
88
  if (evtType === 3 || value.author_id === user.id) return
95
- handlePlayNotificationSound()
96
- clearInterval(soundTimeout)
97
- currentEvent = {
98
- evt: evtType,
99
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
100
- }
101
- setCurrentEvent({
89
+ handlePlayNotificationSound({
102
90
  evt: evtType,
103
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
91
+ orderId: value?.order_id
104
92
  })
105
93
  }
106
94
 
@@ -108,18 +96,20 @@ const NewOrderNotificationUI = (props: any) => {
108
96
  events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
109
97
  events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
110
98
  events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
99
+ events.on('request_register_notification', (o: any) => handleEventNotification(2, o))
100
+ events.on('request_update_notification', (o: any) => handleEventNotification(3, o))
101
+
111
102
  return () => {
112
103
  events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
113
104
  events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
114
105
  events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
106
+ events.off('request_register_notification', (o: any) => handleEventNotification(2, o))
107
+ events.off('request_update_notification', (o: any) => handleEventNotification(3, o))
115
108
  }
116
109
  }, [])
117
110
 
118
111
  useEffect(() => {
119
- notificationSound.setVolume(1);
120
- return () => {
121
- notificationSound.release();
122
- }
112
+ return () => handleCloseEvents()
123
113
  }, [])
124
114
 
125
115
  return (
@@ -133,7 +123,7 @@ const NewOrderNotificationUI = (props: any) => {
133
123
  <View style={styles.modalView}>
134
124
  <TouchableOpacity
135
125
  style={styles.wrapperIcon}
136
- onPress={() => handleCloseModal()}
126
+ onPress={() => handleCloseEvents()}
137
127
  >
138
128
  <Icon name="x" size={30} />
139
129
  </TouchableOpacity>