ordering-ui-react-native 0.16.94 → 0.16.95-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 (210) 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/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 +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 +2 -3
  19. package/themes/business/src/components/Chat/index.tsx +146 -135
  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 +33 -43
  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 +3 -2
  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 +29 -11
  71. package/themes/original/src/components/AddressForm/index.tsx +152 -116
  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 +125 -82
  77. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -4
  78. package/themes/original/src/components/BusinessController/index.tsx +145 -68
  79. package/themes/original/src/components/BusinessController/styles.tsx +22 -9
  80. package/themes/original/src/components/BusinessFeaturedController/index.tsx +4 -2
  81. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  82. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  83. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -5
  84. package/themes/original/src/components/BusinessListingSearch/index.tsx +52 -24
  85. package/themes/original/src/components/BusinessPreorder/index.tsx +96 -15
  86. package/themes/original/src/components/BusinessProductsList/index.tsx +20 -11
  87. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  88. package/themes/original/src/components/BusinessProductsListing/index.tsx +617 -490
  89. package/themes/original/src/components/BusinessProductsListing/styles.tsx +7 -13
  90. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  91. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -3
  92. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +98 -78
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  95. package/themes/original/src/components/BusinessesListing/index.tsx +6 -6
  96. package/themes/original/src/components/Cart/index.tsx +93 -43
  97. package/themes/original/src/components/CartContent/index.tsx +77 -15
  98. package/themes/original/src/components/CartContent/styles.tsx +11 -1
  99. package/themes/original/src/components/Checkout/index.tsx +294 -175
  100. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  101. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  102. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  103. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  104. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  105. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  106. package/themes/original/src/components/Favorite/index.tsx +7 -4
  107. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  108. package/themes/original/src/components/FavoriteList/index.tsx +70 -80
  109. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  110. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  111. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  112. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  113. package/themes/original/src/components/Help/index.tsx +8 -8
  114. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  115. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  116. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  117. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  118. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  119. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  120. package/themes/original/src/components/Home/index.tsx +13 -4
  121. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  122. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  123. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  124. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  125. package/themes/original/src/components/LoginForm/index.tsx +43 -19
  126. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  127. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  128. package/themes/original/src/components/Messages/index.tsx +32 -10
  129. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  130. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +117 -96
  132. package/themes/original/src/components/MultiCheckout/index.tsx +233 -83
  133. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  134. package/themes/original/src/components/MultiOrdersDetails/index.tsx +67 -20
  135. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  136. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  137. package/themes/original/src/components/NavBar/index.tsx +6 -11
  138. package/themes/original/src/components/NotFoundSource/index.tsx +1 -1
  139. package/themes/original/src/components/Notifications/index.tsx +144 -0
  140. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  141. package/themes/original/src/components/OrderDetails/OrderEta.tsx +59 -0
  142. package/themes/original/src/components/OrderDetails/index.tsx +110 -221
  143. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  144. package/themes/original/src/components/OrderItAgain/index.tsx +47 -43
  145. package/themes/original/src/components/OrderProgress/index.tsx +74 -112
  146. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  147. package/themes/original/src/components/OrderSummary/index.tsx +52 -17
  148. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  149. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +28 -19
  150. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  151. package/themes/original/src/components/OrdersOption/index.tsx +76 -83
  152. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  153. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  154. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  155. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  156. package/themes/original/src/components/PaymentOptions/index.tsx +2 -2
  157. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  158. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  159. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  160. package/themes/original/src/components/ProductForm/index.tsx +247 -269
  161. package/themes/original/src/components/ProductForm/styles.tsx +4 -7
  162. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  163. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  164. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  165. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  166. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  167. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  168. package/themes/original/src/components/Promotions/index.tsx +234 -220
  169. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  170. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  171. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  172. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  173. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  174. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  175. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  176. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  177. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  178. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  179. package/themes/original/src/components/Sessions/index.tsx +11 -8
  180. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  181. package/themes/original/src/components/SignupForm/index.tsx +79 -66
  182. package/themes/original/src/components/SingleOrderCard/index.tsx +126 -57
  183. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  184. package/themes/original/src/components/SingleProductCard/index.tsx +111 -49
  185. package/themes/original/src/components/SingleProductCard/styles.tsx +27 -13
  186. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  187. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  188. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  189. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  190. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -218
  191. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  192. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  193. package/themes/original/src/components/UserFormDetails/index.tsx +53 -54
  194. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  195. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  196. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  197. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  198. package/themes/original/src/components/Wallets/index.tsx +20 -19
  199. package/themes/original/src/components/Wallets/styles.tsx +2 -0
  200. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  201. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  202. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  203. package/themes/original/src/components/shared/OButton.tsx +6 -2
  204. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  205. package/themes/original/src/components/shared/OInput.tsx +10 -1
  206. package/themes/original/src/components/shared/OModal.tsx +3 -3
  207. package/themes/original/src/layouts/Container.tsx +13 -9
  208. package/themes/original/src/types/index.tsx +45 -7
  209. package/themes/original/src/utils/index.tsx +359 -58
  210. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,120 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { formatSeconds } from '../../../utils'
3
+ import { StyleSheet, TouchableOpacity, Alert } from 'react-native';
4
+ import { useCountdownTimer } from '../../../../../../src/hooks/useCountdownTimer';
5
+ import { useLanguage } from 'ordering-components/native';
6
+ import { OTPContainer } from './styles';
7
+ import { OText, OButton } from '../../shared';
8
+ import OTPInputView from '@twotalltotems/react-native-otp-input'
9
+ import { useTheme } from 'styled-components/native';
10
+ import { otpParams } from '../../../types'
11
+
12
+ export const Otp = (props: otpParams) => {
13
+ const {
14
+ willVerifyOtpState,
15
+ setWillVerifyOtpState,
16
+ onSubmit,
17
+ handleLoginOtp,
18
+ setAlertState,
19
+ pinCount,
20
+ formState
21
+ } = props
22
+
23
+ const theme = useTheme();
24
+ const [, t] = useLanguage();
25
+ const [code, setCode] = useState('')
26
+ const [otpLeftTime, _, resetOtpLeftTime]: any = useCountdownTimer(
27
+ 600, willVerifyOtpState)
28
+
29
+
30
+ const handleOnSubmit = () => {
31
+ setAlertState({
32
+ open: true,
33
+ title: t('CODE_SENT', 'The code has been sent'),
34
+ })
35
+ resetOtpLeftTime()
36
+ onSubmit()
37
+ }
38
+
39
+ useEffect(() => {
40
+ if (otpLeftTime === 0) {
41
+ setAlertState({
42
+ open: true,
43
+ title: t('TIME_IS_UP', 'Time is up'),
44
+ content: t('PLEASE_RESEND_CODE', 'Please resend code again')
45
+ })
46
+ }
47
+ }, [otpLeftTime])
48
+
49
+ useEffect(() => {
50
+ if (!formState?.loading && formState?.result?.error) {
51
+ Alert.alert(
52
+ t('ERROR', 'Error'),
53
+ typeof formState.result?.result === 'string'
54
+ ? formState.result?.result
55
+ : formState.result?.result[0],
56
+ [
57
+ {
58
+ text: t('ACCEPT', 'Accept'),
59
+ onPress: () => {},
60
+ style: 'cancel'
61
+ },
62
+ ],
63
+ { cancelable: false }
64
+ )
65
+
66
+ if (code.length === (pinCount || 6)) {
67
+ setCode('')
68
+ }
69
+
70
+ }
71
+ }, [formState])
72
+
73
+ const loginStyle = StyleSheet.create({
74
+ underlineStyleBase: {
75
+ width: 45,
76
+ height: 60,
77
+ borderWidth: 1,
78
+ fontSize: 16
79
+ },
80
+ underlineStyleHighLighted: {
81
+ borderColor: theme.colors.primary,
82
+ color: theme.colors.primary,
83
+ fontSize: 16
84
+ },
85
+ });
86
+
87
+ return (
88
+ <>
89
+ <OTPContainer>
90
+ <OText size={24}>
91
+ {formatSeconds(otpLeftTime)}
92
+ </OText>
93
+ <OTPInputView
94
+ style={{ width: '100%', height: 150 }}
95
+ pinCount={pinCount || 6}
96
+ codeInputFieldStyle={loginStyle.underlineStyleBase}
97
+ codeInputHighlightStyle={loginStyle.underlineStyleHighLighted}
98
+ onCodeFilled={(code: string) => handleLoginOtp(code)}
99
+ selectionColor={theme.colors.primary}
100
+ editable
101
+ code={code}
102
+ onCodeChanged={(code: string) => setCode(code)}
103
+ />
104
+ <TouchableOpacity onPress={() => handleOnSubmit()} disabled={otpLeftTime > 520}>
105
+ <OText size={16} mBottom={30} color={otpLeftTime > 520 ? theme.colors.disabled : theme.colors.primary}>
106
+ {t('RESEND_CODE', 'Resend code')}
107
+ </OText>
108
+ </TouchableOpacity>
109
+ <OButton
110
+ onClick={() => setWillVerifyOtpState(false)}
111
+ bgColor={theme.colors.white}
112
+ borderColor={theme.colors.primary}
113
+ textStyle={{ color: theme.colors.primary }}
114
+ style={{ borderRadius: 8, width: '100%' }}
115
+ text={t('CANCEL', 'Cancel')}
116
+ />
117
+ </OTPContainer>
118
+ </>
119
+ )
120
+ }
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const OTPContainer = styled.View`
4
+ padding: 20px;
5
+ align-items: center;
6
+ flex: 1
7
+ `
@@ -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]}