ordering-ui-react-native 0.16.92 → 0.16.93-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 (208) 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 +19 -4
  5. package/src/components/BusinessInformation/styles.tsx +2 -2
  6. package/src/components/BusinessProductsList/index.tsx +1 -1
  7. package/src/components/BusinessesListing/index.tsx +1 -1
  8. package/src/components/OrderCreating/index.tsx +1 -21
  9. package/src/components/OrdersOption/index.tsx +54 -56
  10. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  11. package/src/components/SingleProductReview/index.tsx +7 -4
  12. package/src/components/VerifyPhone/styles.tsx +1 -2
  13. package/src/components/shared/OToast.tsx +4 -4
  14. package/src/utils/index.tsx +2 -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 +2 -3
  19. package/themes/business/src/components/Chat/index.tsx +30 -30
  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 +239 -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 +31 -41
  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/OrdersOption/index.tsx +33 -75
  35. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +1 -1
  36. package/themes/business/src/components/PreviousMessages/index.tsx +16 -18
  37. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  38. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  39. package/themes/business/src/components/PreviousOrders/index.tsx +447 -247
  40. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  41. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  42. package/themes/business/src/components/ReviewCustomer/index.tsx +42 -25
  43. package/themes/business/src/components/StoresList/index.tsx +2 -2
  44. package/themes/business/src/components/shared/OLink.tsx +33 -13
  45. package/themes/business/src/components/shared/OModal.tsx +16 -9
  46. package/themes/business/src/components/shared/OText.tsx +8 -2
  47. package/themes/business/src/types/index.tsx +33 -2
  48. package/themes/business/src/utils/index.tsx +53 -0
  49. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  51. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  54. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  55. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  56. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  57. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  58. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  59. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  60. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  61. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +1 -0
  62. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  63. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  64. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  65. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  66. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  67. package/themes/kiosk/src/types/index.d.ts +13 -0
  68. package/themes/kiosk/src/utils/index.tsx +15 -0
  69. package/themes/original/index.tsx +8 -0
  70. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  71. package/themes/original/src/components/AddressForm/index.tsx +143 -115
  72. package/themes/original/src/components/AddressList/index.tsx +26 -21
  73. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  74. package/themes/original/src/components/AnalyticsSegment/index.tsx +164 -8
  75. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  76. package/themes/original/src/components/BusinessBasicInformation/index.tsx +121 -80
  77. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -4
  78. package/themes/original/src/components/BusinessController/index.tsx +100 -47
  79. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  80. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  81. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -5
  82. package/themes/original/src/components/BusinessListingSearch/index.tsx +52 -24
  83. package/themes/original/src/components/BusinessPreorder/index.tsx +96 -15
  84. package/themes/original/src/components/BusinessProductsList/index.tsx +16 -9
  85. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  86. package/themes/original/src/components/BusinessProductsListing/index.tsx +606 -490
  87. package/themes/original/src/components/BusinessProductsListing/styles.tsx +7 -13
  88. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  89. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  90. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +96 -73
  91. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  92. package/themes/original/src/components/BusinessesListing/index.tsx +6 -6
  93. package/themes/original/src/components/Cart/index.tsx +93 -43
  94. package/themes/original/src/components/CartContent/index.tsx +77 -15
  95. package/themes/original/src/components/CartContent/styles.tsx +11 -1
  96. package/themes/original/src/components/Checkout/index.tsx +294 -175
  97. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  98. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  99. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  100. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  101. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  102. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  103. package/themes/original/src/components/Favorite/index.tsx +7 -4
  104. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  105. package/themes/original/src/components/FavoriteList/index.tsx +70 -80
  106. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  107. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  108. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  109. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  110. package/themes/original/src/components/Help/index.tsx +8 -8
  111. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  112. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  113. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  114. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  115. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  116. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  117. package/themes/original/src/components/Home/index.tsx +13 -4
  118. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  119. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  120. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  121. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  122. package/themes/original/src/components/LoginForm/index.tsx +43 -19
  123. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  124. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  125. package/themes/original/src/components/Messages/index.tsx +31 -10
  126. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  127. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  128. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  129. package/themes/original/src/components/MultiCheckout/index.tsx +210 -79
  130. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  131. package/themes/original/src/components/MultiOrdersDetails/index.tsx +67 -20
  132. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  133. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  134. package/themes/original/src/components/NavBar/index.tsx +6 -11
  135. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  136. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  137. package/themes/original/src/components/Notifications/index.tsx +144 -0
  138. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  139. package/themes/original/src/components/OrderDetails/OrderEta.tsx +59 -0
  140. package/themes/original/src/components/OrderDetails/index.tsx +110 -221
  141. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  142. package/themes/original/src/components/OrderItAgain/index.tsx +47 -43
  143. package/themes/original/src/components/OrderProgress/index.tsx +74 -112
  144. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  145. package/themes/original/src/components/OrderSummary/index.tsx +52 -17
  146. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  147. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +28 -19
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +76 -83
  150. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  151. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  152. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  153. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  154. package/themes/original/src/components/PaymentOptions/index.tsx +2 -2
  155. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  156. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  157. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  158. package/themes/original/src/components/ProductForm/index.tsx +247 -269
  159. package/themes/original/src/components/ProductForm/styles.tsx +4 -7
  160. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  161. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  162. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  163. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  164. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  165. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  166. package/themes/original/src/components/Promotions/index.tsx +234 -220
  167. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  168. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  169. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  170. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  171. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  172. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  173. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  174. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  175. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  176. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  177. package/themes/original/src/components/Sessions/index.tsx +11 -8
  178. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  179. package/themes/original/src/components/SignupForm/index.tsx +79 -66
  180. package/themes/original/src/components/SingleOrderCard/index.tsx +126 -57
  181. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  182. package/themes/original/src/components/SingleProductCard/index.tsx +106 -46
  183. package/themes/original/src/components/SingleProductCard/styles.tsx +19 -13
  184. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  185. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  186. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  187. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  188. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -218
  189. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  190. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  191. package/themes/original/src/components/UserFormDetails/index.tsx +53 -54
  192. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  193. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  194. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  195. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  196. package/themes/original/src/components/Wallets/index.tsx +20 -21
  197. package/themes/original/src/components/Wallets/styles.tsx +2 -0
  198. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  199. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  200. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  201. package/themes/original/src/components/shared/OButton.tsx +6 -2
  202. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  203. package/themes/original/src/components/shared/OInput.tsx +10 -1
  204. package/themes/original/src/components/shared/OModal.tsx +3 -3
  205. package/themes/original/src/layouts/Container.tsx +13 -9
  206. package/themes/original/src/types/index.tsx +45 -7
  207. package/themes/original/src/utils/index.tsx +321 -58
  208. 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) {
@@ -179,6 +197,7 @@ const LoginFormUI = (props: LoginParams) => {
179
197
  'An error occurred while trying to pay by PayPal',
180
198
  ERROR_ADD_PRODUCT_VERY_FAR_FOR_DELIVERY:
181
199
  'Error adding product, very far for delivery',
200
+ ERROR_AUTH_DRIVER_LOGIN_VALIDATION: 'Error auth driver login validation'
182
201
  };
183
202
 
184
203
  return keyList[key] ? t(key, keyList[key]) : t(key);
@@ -208,6 +227,31 @@ const LoginFormUI = (props: LoginParams) => {
208
227
  handleSubmit(onSubmit)();
209
228
  };
210
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
+
211
255
  const onSubmit = (values: any) => {
212
256
  Keyboard.dismiss();
213
257
 
@@ -226,13 +270,26 @@ const LoginFormUI = (props: LoginParams) => {
226
270
  setSubmitted(true)
227
271
  return
228
272
  }
229
-
230
- handleButtonLoginClick({
231
- ...values,
232
- ...phoneInputData.phone
233
- });
273
+ mainLogin(values)
234
274
  };
235
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
+
236
293
  const handleVerifyCodeClick = () => {
237
294
  if (phoneInputData.error) {
238
295
  showToast(ToastType.Error, phoneInputData.error);
@@ -271,27 +328,17 @@ const LoginFormUI = (props: LoginParams) => {
271
328
  showToast(ToastType.Info, t('TRY_AGAIN', 'Please try again'))
272
329
  return
273
330
  }
274
- formState?.result?.result &&
275
- showToast(
276
- ToastType.Error,
277
- loginTab === 'email' && typeof formState.result?.result === 'string'
278
- ? getTraduction(formState.result?.result)
279
- : loginTab === 'email' &&
280
- typeof formState.result?.result !== 'string'
281
- ? getTraduction(formState.result?.result[0])
282
- : loginTab === 'cellphone' &&
283
- typeof formState.result?.result === 'string'
284
- ? getTraduction(formState.result?.result).replace(
285
- t('USER', 'user').toLowerCase(),
286
- t('PHONE_NUMER', 'Phone number'),
287
- )
288
- : getTraduction(formState.result?.result[0]).replace(
289
- t('USER', 'user').toLowerCase(),
290
- t('PHONE_NUMER', 'Phone number'),
291
- ),
292
- );
331
+ formState.result?.result && showToast(
332
+ ToastType.Error,
333
+ typeof formState.result?.result === 'string'
334
+ ? formState.result?.result
335
+ : formState.result?.result[0]
336
+ )
293
337
  setSubmitted(false)
294
338
  }
339
+ if (!formState?.loading && !formState?.result?.error) {
340
+ setWillVerifyOtpState(false)
341
+ }
295
342
  }, [formState]);
296
343
 
297
344
  useEffect(() => {
@@ -359,9 +406,20 @@ const LoginFormUI = (props: LoginParams) => {
359
406
  if (values?.project_name) {
360
407
  delete values.project_name
361
408
  }
362
- handleButtonLoginClick({ ...values })
409
+ mainLogin(values)
410
+ setSubmitted(false)
363
411
  }, [ordering, submitted])
364
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
+
365
423
  Dimensions.addEventListener('change', ({ window: { width, height } }) => {
366
424
  setWindowWidth(
367
425
  parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
@@ -418,6 +476,8 @@ const LoginFormUI = (props: LoginParams) => {
418
476
  borderRadius: 7.6,
419
477
  borderColor: theme.colors.inputSignup,
420
478
  backgroundColor: theme.colors.transparent,
479
+ minHeight: 50,
480
+ maxHeight : 50
421
481
  },
422
482
  btn: {
423
483
  borderRadius: 7.6,
@@ -444,6 +504,25 @@ const LoginFormUI = (props: LoginParams) => {
444
504
  fontWeight: 'normal',
445
505
  fontSize: 16,
446
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
+ },
447
526
  });
448
527
 
449
528
  return (
@@ -460,7 +539,7 @@ const LoginFormUI = (props: LoginParams) => {
460
539
  <OText style={styles.title}>{t('LOGIN', 'Login')}</OText>
461
540
  </View>
462
541
 
463
- {(useLoginByEmail || useLoginByCellphone) && (
542
+ {(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
464
543
  <LoginWith>
465
544
  <ScrollView
466
545
  ref={scrollRefTab}
@@ -521,12 +600,63 @@ const LoginFormUI = (props: LoginParams) => {
521
600
  }}></View>
522
601
  </Pressable>
523
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
+ )}
524
654
  </TabsContainer>
525
655
  </ScrollView>
526
656
  </LoginWith>
527
657
  )}
528
658
 
529
- {(useLoginByCellphone || useLoginByEmail) && (
659
+ {(useLoginByCellphone || useLoginByEmail || useLoginOtp) && (
530
660
  <FormInput>
531
661
  {useRootPoint && (
532
662
  <Controller
@@ -560,7 +690,7 @@ const LoginFormUI = (props: LoginParams) => {
560
690
  />
561
691
  )}
562
692
 
563
- {useLoginByEmail && loginTab === 'email' && (
693
+ {((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
564
694
  <Controller
565
695
  control={control}
566
696
  render={({ onChange, value }: any) => (
@@ -605,7 +735,7 @@ const LoginFormUI = (props: LoginParams) => {
605
735
  />
606
736
  )}
607
737
 
608
- {useLoginByCellphone && loginTab === 'cellphone' && (
738
+ {((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
609
739
  <View style={{ marginBottom: 20 }}>
610
740
  <PhoneInputNumber
611
741
  data={phoneInputData}
@@ -620,54 +750,56 @@ const LoginFormUI = (props: LoginParams) => {
620
750
  </View>
621
751
  )}
622
752
 
623
- <Controller
624
- control={control}
625
- render={({ onChange, value }: any) => (
626
- <OInput
627
- isSecured={!passwordSee ? true : false}
628
- placeholder={t('PASSWORD', 'Password')}
629
- placeholderTextColor={theme.colors.arrowColor}
630
- style={styles.input}
631
- icon={theme.images.logos.passwordInputIcon}
632
- iconColor={theme.colors.arrowColor}
633
- iconCustomRight={
634
- !passwordSee ? (
635
- <MaterialCommunityIcons
636
- name="eye-outline"
637
- size={24}
638
- color={theme.colors.arrowColor}
639
- onPress={() => setPasswordSee(!passwordSee)}
640
- />
641
- ) : (
642
- <MaterialCommunityIcons
643
- name="eye-off-outline"
644
- size={24}
645
- color={theme.colors.arrowColor}
646
- onPress={() => setPasswordSee(!passwordSee)}
647
- />
648
- )
649
- }
650
- selectionColor={theme.colors.primary}
651
- color={theme.colors.textGray}
652
- value={value}
653
- forwardRef={inputRef}
654
- onChange={(val: any) => onChange(val)}
655
- returnKeyType="done"
656
- onSubmitEditing={() => handleLogin()}
657
- blurOnSubmit
658
- />
659
- )}
660
- name="password"
661
- rules={{
662
- required: t(
663
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
664
- 'The field Password is required',
665
- ).replace('_attribute_', t('PASSWORD', 'Password')),
666
- }}
667
- defaultValue=""
668
- />
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
+ )}
669
801
 
670
- {onNavigationRedirect && (
802
+ {onNavigationRedirect && loginTab !== 'otp' && (
671
803
  <Pressable
672
804
  style={{ marginRight: 'auto', marginBottom: 20 }}
673
805
  onPress={() => onNavigationRedirect('Forgot')}>
@@ -722,7 +854,7 @@ const LoginFormUI = (props: LoginParams) => {
722
854
  )}
723
855
  <OButton
724
856
  onClick={handleLogin}
725
- text={t('LOGIN', 'Login')}
857
+ text={loginTab !== 'otp' ? t('LOGIN', 'Login') : t('GET_VERIFY_CODE', 'Get verify code')}
726
858
  bgColor={theme.colors.primary}
727
859
  borderColor={theme.colors.primary}
728
860
  textStyle={styles.btnText}
@@ -762,7 +894,10 @@ const LoginFormUI = (props: LoginParams) => {
762
894
  </>
763
895
  )}
764
896
 
765
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
897
+ <OModal
898
+ open={isModalVisible}
899
+ onClose={() => setIsModalVisible(false)}
900
+ >
766
901
  <VerifyPhone
767
902
  phone={phoneInputData.phone}
768
903
  verifyPhoneState={verifyPhoneState}
@@ -772,6 +907,29 @@ const LoginFormUI = (props: LoginParams) => {
772
907
  handleVerifyCodeClick={handleVerifyCodeClick}
773
908
  />
774
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
+ />
775
933
  </View>
776
934
  );
777
935
  };
@@ -785,3 +943,4 @@ export const LoginForm = (props: any) => {
785
943
 
786
944
  return <LoginFormController {...loginProps} />;
787
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) => {
@@ -79,26 +78,15 @@ const NewOrderNotificationUI = (props: any) => {
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
84
  if (assignedSecondsDiff < 5 && !isBusinessApp) {
88
- handlePlayNotificationSound()
89
- clearInterval(soundTimeout)
90
- currentEvent = { evt: 2, orderId: value?.id }
91
- setCurrentEvent({ evt: 2, orderId: value?.id })
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
91
  orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
104
92
  })
@@ -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>