ordering-ui-react-native 0.15.79 → 0.15.80-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 (217) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +1 -1
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +16 -8
  8. package/src/components/BusinessInformation/index.tsx +14 -0
  9. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  10. package/src/components/BusinessesListing/index.tsx +1 -1
  11. package/src/components/Checkout/index.tsx +25 -3
  12. package/src/components/DriverTips/index.tsx +11 -6
  13. package/src/components/LanguageSelector/index.tsx +6 -2
  14. package/src/components/LoginForm/index.tsx +120 -30
  15. package/src/components/LoginForm/styles.tsx +6 -0
  16. package/src/components/NotificationSetting/index.tsx +85 -0
  17. package/src/components/OrderDetails/index.tsx +7 -21
  18. package/src/components/PaymentOptions/index.tsx +335 -365
  19. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  20. package/src/components/ReviewDriver/index.tsx +1 -1
  21. package/src/components/ReviewOrder/index.tsx +2 -1
  22. package/src/components/ReviewProducts/index.tsx +11 -0
  23. package/src/components/SignupForm/index.tsx +145 -61
  24. package/src/components/SingleProductCard/index.tsx +16 -4
  25. package/src/components/SingleProductReview/index.tsx +1 -1
  26. package/src/components/StripeElementsForm/index.tsx +25 -16
  27. package/src/components/StripeMethodForm/index.tsx +22 -24
  28. package/src/components/UpsellingProducts/index.tsx +1 -1
  29. package/src/components/UserProfileForm/index.tsx +63 -6
  30. package/src/components/UserProfileForm/styles.tsx +8 -0
  31. package/src/components/VerifyPhone/styles.tsx +1 -2
  32. package/src/components/shared/OBottomPopup.tsx +6 -2
  33. package/src/components/shared/OModal.tsx +1 -1
  34. package/src/hooks/useCountdownTimer.tsx +26 -0
  35. package/src/index.tsx +2 -0
  36. package/src/navigators/CheckoutNavigator.tsx +6 -0
  37. package/src/navigators/HomeNavigator.tsx +6 -0
  38. package/src/pages/BusinessesListing.tsx +7 -6
  39. package/src/pages/MultiCheckout.tsx +31 -0
  40. package/src/pages/MultiOrdersDetails.tsx +27 -0
  41. package/src/pages/OrderDetails.tsx +1 -1
  42. package/src/pages/ReviewDriver.tsx +2 -2
  43. package/src/pages/ReviewOrder.tsx +2 -2
  44. package/src/theme.json +0 -1
  45. package/src/types/index.tsx +18 -11
  46. package/src/utils/index.tsx +28 -29
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +100 -60
  49. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  50. package/themes/business/src/components/Chat/index.tsx +51 -91
  51. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  52. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  53. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  54. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  55. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  56. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  57. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  58. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  59. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  60. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +26 -18
  61. package/themes/business/src/components/OrdersListManager/index.tsx +11 -4
  62. package/themes/business/src/components/OrdersOption/index.tsx +16 -4
  63. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  64. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  65. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  66. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  67. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  68. package/themes/business/src/components/shared/OModal.tsx +41 -38
  69. package/themes/business/src/types/index.tsx +15 -7
  70. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  71. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  72. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  73. package/themes/kiosk/src/components/BusinessMenu/index.tsx +25 -26
  74. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  75. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  76. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  77. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  78. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  79. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  80. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  81. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  82. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  83. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  84. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  85. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  86. package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -3
  87. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  88. package/themes/kiosk/src/components/PaymentOptions/index.tsx +55 -53
  89. package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
  90. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  91. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  92. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  93. package/themes/kiosk/src/types/index.d.ts +1 -0
  94. package/themes/original/index.tsx +24 -0
  95. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  96. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  97. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  98. package/themes/original/src/components/AddressList/index.tsx +2 -2
  99. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  100. package/themes/original/src/components/BusinessBasicInformation/index.tsx +291 -150
  101. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  102. package/themes/original/src/components/BusinessController/index.tsx +201 -96
  103. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  104. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  105. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  106. package/themes/original/src/components/BusinessListingSearch/index.tsx +234 -64
  107. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  108. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  109. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  110. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  111. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  112. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  113. package/themes/original/src/components/BusinessProductsList/index.tsx +65 -73
  114. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  115. package/themes/original/src/components/BusinessProductsListing/index.tsx +315 -176
  116. package/themes/original/src/components/BusinessProductsListing/styles.tsx +11 -0
  117. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  118. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  119. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  120. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  121. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  122. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +661 -0
  123. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  124. package/themes/original/src/components/BusinessesListing/index.tsx +104 -462
  125. package/themes/original/src/components/Cart/index.tsx +84 -39
  126. package/themes/original/src/components/Cart/styles.tsx +4 -0
  127. package/themes/original/src/components/Checkout/index.tsx +117 -58
  128. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  129. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  130. package/themes/original/src/components/Favorite/index.tsx +92 -0
  131. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  132. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  133. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  134. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  135. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  136. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  137. package/themes/original/src/components/Help/index.tsx +21 -4
  138. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  139. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  140. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  141. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  142. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  143. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  144. package/themes/original/src/components/Messages/index.tsx +1 -1
  145. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  146. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  147. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  148. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  149. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  150. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  151. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  152. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  153. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  154. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  155. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  156. package/themes/original/src/components/NavBar/index.tsx +4 -4
  157. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  158. package/themes/original/src/components/OrderDetails/index.tsx +164 -64
  159. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  160. package/themes/original/src/components/OrderItAgain/index.tsx +72 -0
  161. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  162. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  163. package/themes/original/src/components/OrderTypeSelector/index.tsx +77 -35
  164. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  165. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  166. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  167. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  168. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  169. package/themes/original/src/components/OrdersOption/index.tsx +139 -46
  170. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  171. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  172. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -22
  173. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  174. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  175. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  176. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  177. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  178. package/themes/original/src/components/ProductForm/index.tsx +712 -673
  179. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  180. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  181. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  182. package/themes/original/src/components/ProductOptionSubOption/index.tsx +13 -9
  183. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  184. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  185. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  186. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  187. package/themes/original/src/components/Promotions/index.tsx +145 -128
  188. package/themes/original/src/components/Promotions/styles.tsx +2 -0
  189. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  190. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  191. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  192. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  193. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  194. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  195. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  196. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  197. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  198. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  199. package/themes/original/src/components/SingleProductCard/index.tsx +220 -94
  200. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  201. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  202. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  203. package/themes/original/src/components/UpsellingProducts/index.tsx +2 -6
  204. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  205. package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
  206. package/themes/original/src/components/UserProfile/index.tsx +5 -1
  207. package/themes/original/src/components/UserProfileForm/index.tsx +14 -9
  208. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  209. package/themes/original/src/components/Wallets/index.tsx +2 -2
  210. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  211. package/themes/original/src/components/shared/OButton.tsx +2 -0
  212. package/themes/original/src/components/shared/OInput.tsx +3 -2
  213. package/themes/original/src/components/shared/OModal.tsx +4 -2
  214. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  215. package/themes/original/src/types/index.tsx +208 -44
  216. package/themes/original/src/utils/index.tsx +94 -1
  217. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -18,7 +18,6 @@ import { useTheme } from 'styled-components/native';
18
18
  import { FacebookLogin } from '../FacebookLogin';
19
19
  import { VerifyPhone } from '../../../../../src/components/VerifyPhone';
20
20
  import { OModal } from '../../../../../src/components/shared';
21
-
22
21
  import {
23
22
  Container,
24
23
  ButtonsWrapper,
@@ -32,17 +31,19 @@ import {
32
31
  LineSeparator,
33
32
  SkeletonWrapper,
34
33
  TabBtn,
35
- RecaptchaButton
34
+ RecaptchaButton
36
35
  } from './styles';
37
36
 
38
37
  import NavBar from '../NavBar';
39
38
 
40
- import { OText, OButton, OInput, OIcon } from '../shared';
39
+ import { OText, OButton, OInput } from '../shared';
41
40
  import { LoginParams } from '../../types';
42
41
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
43
42
  import { GoogleLogin } from '../GoogleLogin';
44
43
  import { AppleLogin } from '../AppleLogin';
44
+ import { Otp } from './Otp'
45
45
  import { TouchableOpacity } from 'react-native-gesture-handler';
46
+ import Alert from '../../../../../src/providers/AlertProvider'
46
47
 
47
48
  const LoginFormUI = (props: LoginParams) => {
48
49
  const {
@@ -51,6 +52,7 @@ const LoginFormUI = (props: LoginParams) => {
51
52
  navigation,
52
53
  useLoginByEmail,
53
54
  useLoginByCellphone,
55
+ useLoginOtp,
54
56
  loginButtonText,
55
57
  forgotButtonText,
56
58
  verifyPhoneState,
@@ -63,7 +65,12 @@ const LoginFormUI = (props: LoginParams) => {
63
65
  onNavigationRedirect,
64
66
  notificationState,
65
67
  handleReCaptcha,
66
- enableReCaptcha
68
+ enableReCaptcha,
69
+ otpType,
70
+ setOtpType,
71
+ generateOtpCode,
72
+ useLoginOtpEmail,
73
+ useLoginOtpCellphone,
67
74
  } = props;
68
75
 
69
76
  const [, { showToast }] = useToast();
@@ -75,6 +82,7 @@ const LoginFormUI = (props: LoginParams) => {
75
82
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
76
83
  const [isModalVisible, setIsModalVisible] = useState(false);
77
84
  const [isFBLoading, setIsFBLoading] = useState(false);
85
+ const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
78
86
  const [phoneInputData, setPhoneInputData] = useState({
79
87
  error: '',
80
88
  phone: {
@@ -84,8 +92,17 @@ const LoginFormUI = (props: LoginParams) => {
84
92
  });
85
93
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
86
94
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
95
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
96
+ const [tabLayouts, setTabLayouts] = useState<any>({})
97
+ const tabsRef = useRef<any>(null)
87
98
 
88
99
  const theme = useTheme();
100
+ const isOtpEmail = loginTab === 'otp' && otpType === 'email'
101
+ const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
102
+
103
+ const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
104
+ const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
105
+ const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
89
106
 
90
107
  const loginStyle = StyleSheet.create({
91
108
  btnOutline: {
@@ -106,32 +123,68 @@ const LoginFormUI = (props: LoginParams) => {
106
123
  marginBottom: 7,
107
124
  },
108
125
  recaptchaIcon: {
109
- width: 100,
110
- height: 100,
111
- }
126
+ width: 100,
127
+ height: 100,
128
+ },
129
+ borderStyleBase: {
130
+ width: 30,
131
+ height: 45
132
+ },
133
+
134
+ borderStyleHighLighted: {
135
+ borderColor: "#03DAC6",
136
+ },
137
+
138
+ underlineStyleBase: {
139
+ width: 45,
140
+ height: 60,
141
+ borderWidth: 1,
142
+ fontSize: 16
143
+ },
144
+
145
+ underlineStyleHighLighted: {
146
+ borderColor: theme.colors.primary,
147
+ color: theme.colors.primary,
148
+ fontSize: 16
149
+ },
112
150
  });
113
151
 
114
152
  const emailRef = useRef<any>({});
115
153
  const passwordRef = useRef<any>({});
116
- const recaptchaRef = useRef<any>({});
154
+ const recaptchaRef = useRef<any>({});
117
155
 
118
- const handleChangeTab = (val: string) => {
156
+ const handleChangeTab = (val: string, otpType?: string) => {
119
157
  props.handleChangeTab(val);
120
158
  setPasswordSee(false);
159
+ handleCategoryScroll(otpType ? `${val}_${otpType}` : val)
121
160
  };
122
161
 
123
- const onSubmit = (values: any) => {
162
+ const onSubmit = (values?: any) => {
124
163
  Keyboard.dismiss();
125
- if (phoneInputData.error) {
126
- showToast(ToastType.Error, phoneInputData.error);
127
- return;
164
+ if (loginTab === 'otp') {
165
+ if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
166
+ showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
167
+ return
168
+ }
169
+ if (loginTab === 'otp') {
170
+ generateOtpCode({
171
+ ...values,
172
+ ...phoneInputData.phone
173
+ })
174
+ }
175
+ setWillVerifyOtpState(true)
176
+ } else {
177
+ if (phoneInputData.error) {
178
+ showToast(ToastType.Error, phoneInputData.error);
179
+ return;
180
+ }
181
+ handleButtonLoginClick({
182
+ ...values,
183
+ ...phoneInputData.phone,
184
+ });
128
185
  }
129
- handleButtonLoginClick({
130
- ...values,
131
- ...phoneInputData.phone,
132
- });
133
- };
134
186
 
187
+ };
135
188
  const handleVerifyCodeClick = () => {
136
189
  if (phoneInputData.error) {
137
190
  showToast(ToastType.Error, phoneInputData.error);
@@ -166,9 +219,9 @@ const LoginFormUI = (props: LoginParams) => {
166
219
  onChange(value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''));
167
220
  };
168
221
 
169
- const handleOpenRecaptcha = () => {
222
+ const handleOpenRecaptcha = () => {
170
223
  setRecaptchaVerified(false)
171
- if (!recaptchaConfig?.siteKey) {
224
+ if (!recaptchaConfig?.siteKey) {
172
225
  showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
173
226
  return
174
227
  }
@@ -176,14 +229,47 @@ const LoginFormUI = (props: LoginParams) => {
176
229
  showToast(ToastType.Error, t('NO_RECAPTCHA_BASE_URL', 'The config doesn\'t have recaptcha base url'));
177
230
  return
178
231
  }
232
+
179
233
  recaptchaRef.current.open()
180
- }
234
+ }
181
235
 
182
236
  const onRecaptchaVerify = (token: any) => {
183
237
  setRecaptchaVerified(true)
184
238
  handleReCaptcha(token)
185
239
  }
186
240
 
241
+ const handleChangeOtpType = (type: string) => {
242
+ handleChangeTab('otp', type)
243
+ setOtpType(type)
244
+ }
245
+
246
+ const handleLoginOtp = (code: string) => {
247
+ handleButtonLoginClick({ code })
248
+ setWillVerifyOtpState(false)
249
+ }
250
+
251
+ const closeAlert = () => {
252
+ setAlertState({
253
+ open: false,
254
+ title: '',
255
+ content: []
256
+ })
257
+ }
258
+
259
+ const handleCategoryScroll = (opc: string) => {
260
+ tabsRef.current.scrollTo({
261
+ x: tabLayouts?.[opc]?.x - 40,
262
+ animated: true
263
+ })
264
+ }
265
+
266
+ const handleOnLayout = (event: any, opc: string) => {
267
+ const _tabLayouts = { ...tabLayouts }
268
+ const categoryKey = opc
269
+ _tabLayouts[categoryKey] = event.nativeEvent.layout
270
+ setTabLayouts(_tabLayouts)
271
+ }
272
+
187
273
  useEffect(() => {
188
274
  if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
189
275
  setRecaptchaConfig({
@@ -231,16 +317,26 @@ const LoginFormUI = (props: LoginParams) => {
231
317
  }, [phoneInputData?.phone?.cellphone])
232
318
 
233
319
  useEffect(() => {
234
- register('cellphone', {
235
- required: loginTab === 'cellphone'
236
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
237
- : null
238
- })
239
- }, [register])
320
+ register('cellphone', {
321
+ required: loginTab === 'cellphone'
322
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
323
+ : null
324
+ })
325
+ }, [register])
326
+
327
+ useEffect(() => {
328
+ reset()
329
+ }, [loginTab])
240
330
 
241
331
  useEffect(() => {
242
- reset()
243
- }, [loginTab])
332
+ if (checkPhoneCodeState?.result?.error) {
333
+ setAlertState({
334
+ open: true,
335
+ content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
336
+ title: ''
337
+ })
338
+ }
339
+ }, [checkPhoneCodeState])
244
340
 
245
341
  return (
246
342
  <Container>
@@ -255,11 +351,18 @@ const LoginFormUI = (props: LoginParams) => {
255
351
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
256
352
  />
257
353
  <FormSide>
258
- {useLoginByEmail && useLoginByCellphone && (
354
+ {(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
259
355
  <LoginWith>
260
- <OTabs>
356
+ <OTabs
357
+ horizontal
358
+ showsHorizontalScrollIndicator={false}
359
+ ref={tabsRef}
360
+ >
261
361
  {useLoginByEmail && (
262
- <TabBtn onPress={() => handleChangeTab('email')}>
362
+ <TabBtn
363
+ onPress={() => handleChangeTab('email')}
364
+ onLayout={(event: any) => handleOnLayout(event, 'email')}
365
+ >
263
366
  <OTab
264
367
  style={{
265
368
  borderBottomColor:
@@ -281,7 +384,10 @@ const LoginFormUI = (props: LoginParams) => {
281
384
  </TabBtn>
282
385
  )}
283
386
  {useLoginByCellphone && (
284
- <TabBtn onPress={() => handleChangeTab('cellphone')}>
387
+ <TabBtn
388
+ onPress={() => handleChangeTab('cellphone')}
389
+ onLayout={(event: any) => handleOnLayout(event, 'cellphone')}
390
+ >
285
391
  <OTab
286
392
  style={{
287
393
  borderBottomColor:
@@ -302,13 +408,63 @@ const LoginFormUI = (props: LoginParams) => {
302
408
  </OTab>
303
409
  </TabBtn>
304
410
  )}
411
+ {useLoginOtpEmail && (
412
+ <TabBtn
413
+ onPress={() => handleChangeOtpType('email')}
414
+ onLayout={(event: any) => handleOnLayout(event, 'otp_email')}
415
+ >
416
+ <OTab
417
+ style={{
418
+ borderBottomColor:
419
+ isOtpEmail
420
+ ? theme.colors.textNormal
421
+ : theme.colors.border,
422
+ }}>
423
+ <OText
424
+ size={14}
425
+ color={
426
+ isOtpEmail
427
+ ? theme.colors.textNormal
428
+ : theme.colors.disabled
429
+ }
430
+ weight={isOtpEmail ? 'bold' : 'normal'}>
431
+ {t('BY_OTP_EMAIL', 'By Otp Email')}
432
+ </OText>
433
+ </OTab>
434
+ </TabBtn>
435
+ )}
436
+ {useLoginOtpCellphone && (
437
+ <TabBtn
438
+ onPress={() => handleChangeOtpType('cellphone')}
439
+ onLayout={(event: any) => handleOnLayout(event, 'otp_cellphone')}
440
+ >
441
+ <OTab
442
+ style={{
443
+ borderBottomColor:
444
+ isOtpCellphone
445
+ ? theme.colors.textNormal
446
+ : theme.colors.border,
447
+ }}>
448
+ <OText
449
+ size={14}
450
+ color={
451
+ isOtpCellphone
452
+ ? theme.colors.textNormal
453
+ : theme.colors.disabled
454
+ }
455
+ weight={isOtpCellphone ? 'bold' : 'normal'}>
456
+ {t('BY_OTP_PHONE', 'By Otp Phone')}
457
+ </OText>
458
+ </OTab>
459
+ </TabBtn>
460
+ )}
305
461
  </OTabs>
306
462
  </LoginWith>
307
463
  )}
308
464
 
309
- {(useLoginByCellphone || useLoginByEmail) && (
465
+ {(useLoginByCellphone || useLoginByEmail || useLoginOtp) && (
310
466
  <FormInput>
311
- {useLoginByEmail && loginTab === 'email' && (
467
+ {((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
312
468
  <>
313
469
  {errors?.email && (
314
470
  <OText
@@ -344,10 +500,10 @@ const LoginFormUI = (props: LoginParams) => {
344
500
  rules={{
345
501
  required: {
346
502
  value: true,
347
- message: t(
348
- 'VALIDATION_ERROR_EMAIL_REQUIRED',
349
- 'The field Email is required',
350
- ).replace('_attribute_', t('EMAIL', 'Email'))
503
+ message: t(
504
+ 'VALIDATION_ERROR_EMAIL_REQUIRED',
505
+ 'The field Email is required',
506
+ ).replace('_attribute_', t('EMAIL', 'Email'))
351
507
  },
352
508
  pattern: {
353
509
  value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
@@ -362,7 +518,7 @@ const LoginFormUI = (props: LoginParams) => {
362
518
  </>
363
519
 
364
520
  )}
365
- {useLoginByCellphone && loginTab === 'cellphone' && (
521
+ {((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
366
522
  <View style={{ marginBottom: 28 }}>
367
523
  <PhoneInputNumber
368
524
  data={phoneInputData}
@@ -383,53 +539,56 @@ const LoginFormUI = (props: LoginParams) => {
383
539
  {errors?.password?.message}{errors?.password?.type === 'required' && '*'}
384
540
  </OText>
385
541
  )}
386
- <Controller
387
- control={control}
388
- render={({ onChange, value }: any) => (
389
- <OInput
390
- isSecured={!passwordSee ? true : false}
391
- placeholder={t('PASSWORD', 'Password')}
392
- style={{...loginStyle.inputStyle, marginBottom: 14}}
393
- icon={theme.images.general.lock}
394
- iconCustomRight={
395
- !passwordSee ? (
396
- <MaterialCommunityIcons
397
- name="eye-outline"
398
- size={24}
399
- onPress={() => setPasswordSee(!passwordSee)}
400
- color={theme.colors.disabled}
401
- />
402
- ) : (
403
- <MaterialCommunityIcons
404
- name="eye-off-outline"
405
- size={24}
406
- onPress={() => setPasswordSee(!passwordSee)}
407
- color={theme.colors.disabled}
408
- />
409
- )
542
+ {loginTab !== 'otp' && (
543
+
544
+ <Controller
545
+ control={control}
546
+ render={({ onChange, value }: any) => (
547
+ <OInput
548
+ isSecured={!passwordSee ? true : false}
549
+ placeholder={t('PASSWORD', 'Password')}
550
+ style={{ ...loginStyle.inputStyle, marginBottom: 14 }}
551
+ icon={theme.images.general.lock}
552
+ iconCustomRight={
553
+ !passwordSee ? (
554
+ <MaterialCommunityIcons
555
+ name="eye-outline"
556
+ size={24}
557
+ onPress={() => setPasswordSee(!passwordSee)}
558
+ color={theme.colors.disabled}
559
+ />
560
+ ) : (
561
+ <MaterialCommunityIcons
562
+ name="eye-off-outline"
563
+ size={24}
564
+ onPress={() => setPasswordSee(!passwordSee)}
565
+ color={theme.colors.disabled}
566
+ />
567
+ )
568
+ }
569
+ value={value}
570
+ forwardRef={passwordRef}
571
+ onChange={(val: any) => onChange(val)}
572
+ returnKeyType="done"
573
+ onSubmitEditing={handleSubmit(onSubmit)}
574
+ blurOnSubmit
575
+ borderColor={errors?.password ? theme.colors.danger5 : theme.colors.border}
576
+ />
577
+ )}
578
+ name="password"
579
+ rules={{
580
+ required: {
581
+ value: true,
582
+ message: t(
583
+ 'VALIDATION_ERROR_PASSWORD_REQUIRED',
584
+ 'The field Password is required',
585
+ ).replace('_attribute_', t('PASSWORD', 'Password'))
410
586
  }
411
- value={value}
412
- forwardRef={passwordRef}
413
- onChange={(val: any) => onChange(val)}
414
- returnKeyType="done"
415
- onSubmitEditing={handleSubmit(onSubmit)}
416
- blurOnSubmit
417
- borderColor={errors?.password ? theme.colors.danger5 : theme.colors.border}
418
- />
419
- )}
420
- name="password"
421
- rules={{
422
- required: {
423
- value: true,
424
- message: t(
425
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
426
- 'The field Password is required',
427
- ).replace('_attribute_', t('PASSWORD', 'Password'))
428
- }
429
- }}
430
- defaultValue=""
431
- />
432
- {onNavigationRedirect && forgotButtonText && (
587
+ }}
588
+ defaultValue=""
589
+ />
590
+ )}
591
+ {onNavigationRedirect && forgotButtonText && loginTab !== 'otp' && (
433
592
  <TouchableOpacity onPress={() => onNavigationRedirect('Forgot')}>
434
593
  <OText size={14} mBottom={18}>
435
594
  {forgotButtonText}
@@ -468,10 +627,9 @@ const LoginFormUI = (props: LoginParams) => {
468
627
  />
469
628
  </>
470
629
  )}
471
-
472
630
  <OButton
473
631
  onClick={handleSubmit(onSubmit)}
474
- text={loginButtonText}
632
+ text={loginTab !== 'otp' ? loginButtonText : t('GET_VERIFY_CODE', 'Get verify code')}
475
633
  bgColor={theme.colors.primary}
476
634
  borderColor={theme.colors.primary}
477
635
  textStyle={{ color: 'white' }}
@@ -480,11 +638,11 @@ const LoginFormUI = (props: LoginParams) => {
480
638
  style={{ borderRadius: 7.6, marginTop: 10, marginBottom: 25 }}
481
639
  />
482
640
  {onNavigationRedirect && registerButtonText && (
483
- <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center'}}>
641
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center' }}>
484
642
  <OText size={14}>
485
643
  {t('NEW_ON_PLATFORM', 'New on Ordering?')}
486
644
  </OText>
487
- <TouchableOpacity onPress={() => onNavigationRedirect('Signup')}>
645
+ <TouchableOpacity onPress={() => onNavigationRedirect('Signup')}>
488
646
  <OText size={14} mLeft={5} color={theme.colors.skyBlue}>
489
647
  {t('CREATE_ACCOUNT', 'Create account')}
490
648
  </OText>
@@ -495,11 +653,11 @@ const LoginFormUI = (props: LoginParams) => {
495
653
  )}
496
654
 
497
655
  {useLoginByCellphone &&
498
- loginTab === 'cellphone' &&
499
- configs && Object.keys(configs).length > 0 &&
500
- (configs?.twilio_service_enabled?.value === 'true' ||
501
- configs?.twilio_service_enabled?.value === '1') &&
502
- configs?.twilio_module?.value && (
656
+ loginTab === 'cellphone' &&
657
+ configs && Object.keys(configs).length > 0 &&
658
+ (configs?.twilio_service_enabled?.value === 'true' ||
659
+ configs?.twilio_service_enabled?.value === '1') &&
660
+ configs?.twilio_module?.value && (
503
661
  <>
504
662
  <OrSeparator>
505
663
  <LineSeparator />
@@ -524,59 +682,60 @@ const LoginFormUI = (props: LoginParams) => {
524
682
  )}
525
683
 
526
684
  {configs && Object.keys(configs).length > 0 ? (
527
- (((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value) ||
528
- (configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null)) &&
529
- (
530
- <>
531
- <View
532
- style={{
533
- flexDirection: 'row',
534
- width: '100%',
535
- justifyContent: 'space-between',
536
- alignItems: 'center',
537
- marginVertical: 15
538
- }}>
539
- <View style={loginStyle.line} />
540
- <OText
541
- size={14}
542
- mBottom={10}
543
- style={{ paddingHorizontal: 19 }}
544
- color={theme.colors.disabled}>
545
- {t('OR', 'or')}
546
- </OText>
547
- <View style={loginStyle.line} />
548
- </View>
549
- <ButtonsWrapper>
550
- <SocialButtons>
551
- {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
552
- configs?.facebook_id?.value && (
553
- <FacebookLogin
554
- notificationState={notificationState}
555
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
556
- handleLoading={(val: boolean) => setIsFBLoading(val)}
557
- handleSuccessFacebookLogin={handleSuccessFacebook}
558
- />
559
- )}
560
- {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
561
- <GoogleLogin
562
- notificationState={notificationState}
563
- webClientId={configs?.google_login_client_id?.value}
564
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
565
- handleLoading={(val: boolean) => setIsFBLoading(val)}
566
- handleSuccessGoogleLogin={handleSuccessFacebook}
567
- />
568
- )}
569
- {(configs?.apple_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
570
- <AppleLogin
571
- notificationState={notificationState}
572
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
573
- handleLoading={(val: boolean) => setIsFBLoading(val)}
574
- handleSuccessAppleLogin={handleSuccessFacebook}
575
- />
576
- )}
577
- </SocialButtons>
578
- </ButtonsWrapper>
579
- </>
685
+ (((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value) ||
686
+ (configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null)) &&
687
+ (
688
+ <>
689
+ <View
690
+ style={{
691
+ flexDirection: 'row',
692
+ width: '100%',
693
+ justifyContent: 'space-between',
694
+ alignItems: 'center',
695
+ marginVertical: 15
696
+ }}>
697
+ <View style={loginStyle.line} />
698
+ <OText
699
+ size={14}
700
+ mBottom={10}
701
+ style={{ paddingHorizontal: 19 }}
702
+ color={theme.colors.disabled}>
703
+ {t('OR', 'or')}
704
+ </OText>
705
+ <View style={loginStyle.line} />
706
+ </View>
707
+ <ButtonsWrapper>
708
+ <SocialButtons>
709
+ {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
710
+ configs?.facebook_id?.value &&
711
+ facebookLoginEnabled && (
712
+ <FacebookLogin
713
+ notificationState={notificationState}
714
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
715
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
716
+ handleSuccessFacebookLogin={handleSuccessFacebook}
717
+ />
718
+ )}
719
+ {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
720
+ <GoogleLogin
721
+ notificationState={notificationState}
722
+ webClientId={configs?.google_login_client_id?.value}
723
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
724
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
725
+ handleSuccessGoogleLogin={handleSuccessFacebook}
726
+ />
727
+ )}
728
+ {(configs?.apple_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && appleLoginEnabled && (
729
+ <AppleLogin
730
+ notificationState={notificationState}
731
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
732
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
733
+ handleSuccessAppleLogin={handleSuccessFacebook}
734
+ />
735
+ )}
736
+ </SocialButtons>
737
+ </ButtonsWrapper>
738
+ </>
580
739
  )
581
740
  ) : (
582
741
  <SkeletonWrapper>
@@ -592,24 +751,12 @@ const LoginFormUI = (props: LoginParams) => {
592
751
  </Placeholder>
593
752
  </SkeletonWrapper>
594
753
  )}
595
-
596
- {/* {onNavigationRedirect && registerButtonText && (
597
- <ButtonsWrapper>
598
- <OButton
599
- onClick={() => onNavigationRedirect('Signup')}
600
- text={registerButtonText}
601
- style={loginStyle.btnOutline}
602
- borderColor={theme.colors.primary}
603
- imgRightSrc={null}
604
- />
605
- </ButtonsWrapper>
606
- )} */}
607
754
  </FormSide>
608
755
  <OModal
609
756
  open={isModalVisible}
610
757
  onClose={() => setIsModalVisible(false)}
611
- entireModal
612
- title={t('VERIFY_PHONE', 'Verify Phone')}
758
+ entireModal
759
+ title={t('VERIFY_PHONE', 'Verify Phone')}
613
760
  >
614
761
  <VerifyPhone
615
762
  phone={phoneInputData.phone}
@@ -618,9 +765,30 @@ const LoginFormUI = (props: LoginParams) => {
618
765
  handleCheckPhoneCode={handleCheckPhoneCode}
619
766
  setCheckPhoneCodeState={setCheckPhoneCodeState}
620
767
  handleVerifyCodeClick={handleVerifyCodeClick}
621
- onClose={() => setIsModalVisible(false)}
768
+ onClose={() => setIsModalVisible(false)}
769
+ />
770
+ </OModal>
771
+ <OModal
772
+ open={willVerifyOtpState}
773
+ onClose={() => setWillVerifyOtpState(false)}
774
+ entireModal
775
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
776
+ >
777
+ <Otp
778
+ willVerifyOtpState={willVerifyOtpState}
779
+ setWillVerifyOtpState={setWillVerifyOtpState}
780
+ handleLoginOtp={handleLoginOtp}
781
+ onSubmit={onSubmit}
782
+ setAlertState={setAlertState}
622
783
  />
623
784
  </OModal>
785
+ <Alert
786
+ open={alertState.open}
787
+ content={alertState.content}
788
+ title={alertState.title || ''}
789
+ onAccept={closeAlert}
790
+ onClose={closeAlert}
791
+ />
624
792
  <Spinner visible={isFBLoading} />
625
793
  </Container>
626
794
  );
@@ -629,7 +797,7 @@ const LoginFormUI = (props: LoginParams) => {
629
797
  export const LoginForm = (props: any) => {
630
798
  const loginProps = {
631
799
  ...props,
632
- isRecaptchaEnable: true,
800
+ isRecaptchaEnable: true,
633
801
  UIComponent: LoginFormUI,
634
802
  };
635
803
  return <LoginFormController {...loginProps} />;