ordering-ui-react-native 0.12.57 → 0.12.58

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 (175) hide show
  1. package/package.json +1 -1
  2. package/themes/single-business/src/components/Cart/index.tsx +91 -15
  3. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  4. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  5. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  6. package/themes/franchises/index.tsx +0 -111
  7. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  8. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  9. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  10. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  11. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  12. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  13. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  14. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  15. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  16. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  17. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  18. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  19. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  20. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  21. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  22. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  23. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  24. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  25. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  26. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  27. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  28. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  29. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  30. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  31. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  32. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  33. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  34. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  35. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  36. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  37. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  38. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  39. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  40. package/themes/franchises/src/components/Cart/index.tsx +0 -332
  41. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  42. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  43. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  44. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  45. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  46. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  47. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  48. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  49. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  50. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  51. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  52. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  53. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  54. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  55. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  56. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  57. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  58. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  59. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  60. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  61. package/themes/franchises/src/components/Help/index.tsx +0 -56
  62. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  63. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  64. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  65. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  66. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  67. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  68. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  69. package/themes/franchises/src/components/Home/index.tsx +0 -102
  70. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  71. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  72. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  73. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  74. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  75. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  76. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  77. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  78. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  79. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  80. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  81. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  82. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  83. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  84. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  85. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  86. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  87. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  88. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  89. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
  90. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  91. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
  92. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  93. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  94. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  95. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  96. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  97. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  98. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  99. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  100. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  101. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  102. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  103. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  104. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  105. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  106. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  107. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  108. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  109. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  110. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  111. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  112. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  113. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  114. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  115. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  116. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  117. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  118. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  119. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  120. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  121. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  122. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  123. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  124. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  125. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  126. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  127. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  128. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  129. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  130. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  131. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  132. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  133. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  134. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  135. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  136. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  137. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  138. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  139. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  140. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  141. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  142. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  143. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  144. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  145. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  146. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  147. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  148. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  149. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  150. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  151. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  152. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  153. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  154. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  155. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  156. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  157. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  158. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  159. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  160. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  161. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  162. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  163. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  164. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  165. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  166. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  167. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  168. package/themes/franchises/src/components/shared/index.tsx +0 -29
  169. package/themes/franchises/src/config/constants.tsx +0 -57
  170. package/themes/franchises/src/layouts/Container.tsx +0 -23
  171. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  172. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  173. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  174. package/themes/franchises/src/types/index.tsx +0 -445
  175. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,253 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import {
3
- UserFormDetails as UserProfileController,
4
- useSession,
5
- useLanguage,
6
- ToastType,
7
- useToast,
8
- } from 'ordering-components/native';
9
- import { useTheme } from 'styled-components/native';
10
- import { useForm } from 'react-hook-form';
11
- import { launchImageLibrary } from 'react-native-image-picker';
12
- import Spinner from 'react-native-loading-spinner-overlay';
13
- import { StyleSheet, View } from 'react-native';
14
- import { ProfileParams } from '../../types';
15
- import { UserFormDetailsUI } from '../UserFormDetails';
16
-
17
- import { OIcon, OIconButton } from '../shared';
18
- import { CenterView } from './styles';
19
- import NavBar from '../NavBar';
20
- import { Container } from '../../layouts/Container';
21
-
22
- const ProfileUI = (props: ProfileParams) => {
23
- const {
24
- navigation,
25
- isEdit,
26
- formState,
27
- validationFields,
28
- showField,
29
- isRequiredField,
30
- toggleIsEdit,
31
- cleanFormState,
32
- handleChangeInput,
33
- handleButtonUpdateClick,
34
- } = props;
35
-
36
- const theme = useTheme();
37
-
38
- const styles = StyleSheet.create({
39
- photo: {
40
- borderRadius: 7.6,
41
- shadowColor: theme.colors.black,
42
- shadowOffset: { width: 0, height: 1 },
43
- shadowRadius: 2,
44
- shadowOpacity: 0.2,
45
- backgroundColor: theme.colors.white,
46
- },
47
- pagePadding: {
48
- paddingLeft: 40,
49
- paddingRight: 40
50
- }
51
- });
52
-
53
- const [{ user }] = useSession();
54
- const [, t] = useLanguage();
55
- const [, { showToast }] = useToast();
56
- const { handleSubmit, errors, setValue, control } = useForm();
57
-
58
- const [phoneInputData, setPhoneInputData] = useState({
59
- error: '',
60
- phone: {
61
- country_phone_code: null,
62
- cellphone: null,
63
- },
64
- });
65
- const [phoneUpdate, setPhoneUpdate] = useState(false);
66
-
67
- const onSubmit = (values: any) => {
68
- if (phoneInputData.error) {
69
- showToast(ToastType.Error, phoneInputData.error);
70
- return;
71
- }
72
- if (
73
- formState.changes.cellphone === '' &&
74
- validationFields?.fields?.checkout?.cellphone?.enabled &&
75
- validationFields?.fields?.checkout?.cellphone?.required
76
- ) {
77
- showToast(
78
- ToastType.Error,
79
- t(
80
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
81
- 'The field Phone Number is required.',
82
- ),
83
- );
84
- return;
85
- }
86
- if (formState.changes.password && formState.changes.password.length < 8) {
87
- showToast(
88
- ToastType.Error,
89
- t(
90
- 'VALIDATION_ERROR_PASSWORD_MIN_STRING',
91
- 'The Password must be at least 8 characters.',
92
- )
93
- .replace('_attribute_', t('PASSWORD', 'Password'))
94
- .replace('_min_', 8),
95
- );
96
- return;
97
- }
98
-
99
- handleButtonUpdateClick(values);
100
- };
101
-
102
- const handleImagePicker = () => {
103
- launchImageLibrary(
104
- {
105
- mediaType: 'photo',
106
- maxHeight: 200,
107
- maxWidth: 200,
108
- includeBase64: true,
109
- },
110
- (response: any) => {
111
- if (response.didCancel) {
112
- console.log('User cancelled image picker');
113
- } else if (response.errorMessage) {
114
- console.log('ImagePicker Error: ', response.errorMessage);
115
- showToast(ToastType.Error, response.errorMessage);
116
- } else {
117
- if (response.uri) {
118
- const url = `data:${response.type};base64,${response.base64}`;
119
- handleButtonUpdateClick(null, true, url);
120
- } else {
121
- showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
122
- }
123
- }
124
- },
125
- );
126
- };
127
-
128
- const handleCancelEdit = () => {
129
- cleanFormState({ changes: {} });
130
- toggleIsEdit();
131
- setPhoneInputData({
132
- error: '',
133
- phone: {
134
- country_phone_code: null,
135
- cellphone: null,
136
- },
137
- });
138
- };
139
-
140
- const handleChangePhoneNumber = (number: any) => {
141
- setPhoneInputData(number);
142
- let phoneNumber = {
143
- country_phone_code: {
144
- name: 'country_phone_code',
145
- value: number.phone.country_phone_code,
146
- },
147
- cellphone: {
148
- name: 'cellphone',
149
- value: number.phone.cellphone,
150
- },
151
- };
152
- handleChangeInput(phoneNumber, true);
153
- };
154
-
155
- const getInputRules = (field: any) => {
156
- const rules: any = {
157
- required: isRequiredField(field.code)
158
- ? t(
159
- `VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`,
160
- `${field.name} is required`,
161
- ).replace('_attribute_', t(field.name, field.code))
162
- : null,
163
- };
164
- if (field.code && field.code === 'email') {
165
- rules.pattern = {
166
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
167
- message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace(
168
- '_attribute_',
169
- t('EMAIL', 'Email'),
170
- ),
171
- };
172
- }
173
- return rules;
174
- };
175
-
176
- useEffect(() => {
177
- if (formState.result.result && !formState.loading) {
178
- if (formState.result?.error) {
179
- showToast(ToastType.Error, formState.result.result);
180
- } else {
181
- showToast(
182
- ToastType.Success,
183
- t('UPDATE_SUCCESSFULLY', 'Update successfully'),
184
- );
185
- }
186
- }
187
- }, [formState.result]);
188
-
189
- useEffect(() => {
190
- if (Object.keys(errors).length > 0) {
191
- // Convert all errors in one string to show in toast provider
192
- const list = Object.values(errors);
193
- let stringError = '';
194
- list.map((item: any, i: number) => {
195
- stringError +=
196
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
197
- });
198
- showToast(ToastType.Error, stringError);
199
- }
200
- }, [errors]);
201
-
202
- useEffect(() => {
203
- if (user?.cellphone && !user?.country_phone_code) {
204
- setPhoneUpdate(true);
205
- } else {
206
- setPhoneUpdate(false);
207
- }
208
- }, [user?.country_phone_code]);
209
-
210
- return (
211
- <Container noPadding>
212
- <NavBar
213
- onActionLeft={() => navigation.goBack()}
214
- btnStyle={{ paddingStart: 0 }}
215
- title={t('ACCOUNT', 'Account')}
216
- isVertical
217
- style={styles.pagePadding}
218
- />
219
- <CenterView style={styles.pagePadding}>
220
- <View style={styles.photo}>
221
- <OIcon
222
- url={user?.photo}
223
- src={!user?.photo && theme.images.general.user}
224
- width={79}
225
- height={79}
226
- />
227
- </View>
228
- <OIconButton
229
- icon={theme.images.general.camera}
230
- borderColor={theme.colors.clear}
231
- iconStyle={{ width: 16, height: 16 }}
232
- style={{ maxWidth: 40, position: 'absolute', bottom: -2, alignSelf: 'center' }}
233
- onClick={() => handleImagePicker()}
234
- />
235
- </CenterView>
236
- <View style={{ height: 8, marginLeft: -40, marginRight: -40, backgroundColor: theme.colors.backgroundGray100, marginVertical: 32, zIndex: 10 }} />
237
- <Spinner visible={formState?.loading} />
238
- <View style={styles.pagePadding}>
239
- <UserFormDetailsUI {...props} isEdit />
240
- </View>
241
-
242
- </Container>
243
- );
244
- };
245
-
246
-
247
- export const UserProfileForm = (props: any) => {
248
- const profileProps = {
249
- ...props,
250
- UIComponent: ProfileUI,
251
- };
252
- return <UserProfileController {...profileProps} />;
253
- };
@@ -1,29 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const CenterView = styled.View`
4
- align-items: center;
5
- `;
6
-
7
- export const UserData = styled.View`
8
- align-items: center;
9
- text-align: center;
10
- `
11
-
12
- export const Names = styled.View`
13
- flex-direction: row;
14
- `
15
-
16
- export const EditButton = styled.View`
17
- align-items: center;
18
- justify-content: center;
19
- flex-direction: row;
20
- flex: 1;
21
- `
22
-
23
- export const Actions = styled.View`
24
- margin-bottom: 20px;
25
- `
26
-
27
- export const WrapperPhone = styled.View`
28
- padding: 8px 0px;
29
- `
@@ -1,188 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { Pressable, StyleSheet, TextInput } from 'react-native';
3
- import { useLanguage } from 'ordering-components/native';
4
- import { useTheme } from 'styled-components/native';
5
- import Spinner from 'react-native-loading-spinner-overlay';
6
- import { getTraduction } from '../../utils'
7
-
8
- import { OText } from '../shared';
9
-
10
- import {
11
- Container,
12
- CountDownContainer,
13
- ResendSection,
14
- WrappCountdown,
15
- InputsSection,
16
- ErrorSection
17
- } from './styles'
18
-
19
- const TIME_COUNTDOWN = 60 * 10 // 10 minutes
20
-
21
- export const VerifyPhone = (props: any) => {
22
- const {
23
- phone,
24
- formValues,
25
- verifyPhoneState,
26
- checkPhoneCodeState,
27
- setCheckPhoneCodeState,
28
- handleCheckPhoneCode,
29
- handleVerifyCodeClick
30
- } = props
31
-
32
- const theme = useTheme();
33
-
34
- const styles = StyleSheet.create({
35
- inputStyle: {
36
- width: 80,
37
- height: 80,
38
- marginBottom: 25,
39
- borderWidth: 1,
40
- borderColor: theme.colors.disabled,
41
- borderRadius: 20,
42
- textAlign: 'center',
43
- fontSize: 40
44
- }
45
- });
46
-
47
-
48
- const [, t] = useLanguage()
49
-
50
- const [timer, setTimer] = useState(`${TIME_COUNTDOWN / 60}:00`)
51
- const [verifyCode, setVerifyCode] = useState({ 0: '', 1: '', 2: '', 3: '' })
52
- const [isSendCodeAgain, setIsSendCodeAgain] = useState(false)
53
-
54
- const lastNumbers = phone?.cellphone &&
55
- `${phone?.cellphone.charAt(phone?.cellphone.length - 2)}${phone?.cellphone.charAt(phone?.cellphone.length - 1)}`
56
-
57
- const handleChangeCode = (val: number, i: number) => {
58
- setVerifyCode({ ...verifyCode, [i]: val })
59
- }
60
-
61
- const checkResult = (result: any) => {
62
- if (!result) return
63
- return typeof result === 'string'
64
- ? [result]
65
- : result
66
- }
67
-
68
- const handleSendCodeAgain = () => {
69
- setCheckPhoneCodeState && setCheckPhoneCodeState()
70
- setTimer(`${TIME_COUNTDOWN / 60}:00`)
71
- setIsSendCodeAgain(true)
72
- handleVerifyCodeClick && handleVerifyCodeClick()
73
- }
74
-
75
- useEffect(() => {
76
- let _timer = TIME_COUNTDOWN - 1;
77
- let minutes = 0;
78
- let seconds = 0;
79
- const interval = setInterval(() => {
80
- minutes = _timer / 60;
81
- seconds = _timer % 60;
82
-
83
- minutes = minutes < 10 ? 0 + minutes : minutes;
84
- seconds = seconds < 10 ? 0 + seconds : seconds;
85
-
86
- const formatMinutes = parseInt(minutes.toString()) < 10
87
- ? `0${parseInt(minutes.toString())}`
88
- : parseInt(minutes.toString());
89
-
90
- const formatseconds = parseInt(seconds.toString()) < 10
91
- ? `0${parseInt(seconds.toString())}`
92
- : parseInt(seconds.toString());
93
-
94
- setTimer(`${formatMinutes}:${formatseconds}`);
95
-
96
- if (--_timer < 0) {
97
- clearInterval(interval);
98
- }
99
-
100
- if (timer === `${TIME_COUNTDOWN / 60}:00` && isSendCodeAgain) {
101
- setIsSendCodeAgain(false)
102
- clearInterval(interval);
103
- }
104
- }, 1000);
105
-
106
- return () => clearInterval(interval)
107
- }, [isSendCodeAgain])
108
-
109
- useEffect(() => {
110
- const codes = Object.keys(verifyCode).length
111
- const isFullInputs = codes && Object.values(verifyCode).every(val => val)
112
- if (codes === 4 && isFullInputs) {
113
- const values = {
114
- ...formValues,
115
- cellphone: phone.cellphone,
116
- country_phone_code: `+${phone.country_phone_code}`,
117
- code: Object.values(verifyCode).join().replace(/,/g, '')
118
- }
119
- handleCheckPhoneCode && handleCheckPhoneCode(values)
120
- }
121
- }, [verifyCode])
122
-
123
- return (
124
- <Container>
125
- <OText size={30} style={{ textAlign: 'left' }}>
126
- {t('VERIFY_PHONE', 'Verify Phone')}
127
- </OText>
128
- {lastNumbers && (
129
- <OText size={20} color={theme.colors.disabled}>
130
- {`${t('MESSAGE_ENTER_VERIFY_CODE', 'Please, enter the verification code we sent to your mobile ending with')} **${lastNumbers}`}
131
- </OText>
132
- )}
133
- <WrappCountdown>
134
- <CountDownContainer color={timer === '00:00' ? theme.colors.error : theme.colors.success}>
135
- <OText
136
- size={30}
137
- color={timer === '00:00' ? theme.colors.error : theme.colors.success}
138
- >
139
- {timer}
140
- </OText>
141
- </CountDownContainer>
142
- </WrappCountdown>
143
- <InputsSection>
144
- {[...Array(4),].map((_: any, i: number) => (
145
- <TextInput
146
- key={i}
147
- keyboardType='number-pad'
148
- placeholder={'0'}
149
- style={styles.inputStyle}
150
- onChangeText={(val: any) => handleChangeCode(val, i)}
151
- maxLength={1}
152
- editable={timer !== '00:00'}
153
- />
154
- ))}
155
- </InputsSection>
156
- {(verifyPhoneState?.result?.error ? verifyPhoneState : checkPhoneCodeState) &&
157
- !(verifyPhoneState?.result?.error ? verifyPhoneState : checkPhoneCodeState)?.loading &&
158
- (verifyPhoneState?.result?.error ? verifyPhoneState : checkPhoneCodeState)?.result?.error &&
159
- (verifyPhoneState?.result?.error ? verifyPhoneState : checkPhoneCodeState).result?.result &&
160
- (
161
- <ErrorSection>
162
- {checkResult((
163
- verifyPhoneState?.result?.error ? verifyPhoneState : checkPhoneCodeState
164
- ).result?.result)?.map((e: any, i: number) => (
165
- <OText
166
- key={i}
167
- size={20}
168
- color={theme.colors.error}
169
- >
170
- {`* ${t(getTraduction(e))}`}
171
- </OText>
172
- ))}
173
- </ErrorSection>
174
- )}
175
- <ResendSection>
176
- <OText size={17} style={{ marginRight: 5 }}>
177
- {t('ARE_YOU_NOT_SEEING_THE_CODE', 'Are you not seeing the code?')}
178
- </OText>
179
- <Pressable onPress={() => handleSendCodeAgain()}>
180
- <OText size={17} color={theme.colors.primary}>
181
- {t('SEND_AGAIN', 'Send Again')}
182
- </OText>
183
- </Pressable>
184
- </ResendSection>
185
- <Spinner visible={checkPhoneCodeState.loading} />
186
- </Container>
187
- )
188
- }
@@ -1,43 +0,0 @@
1
- import styled from 'styled-components/native';
2
-
3
- export const Container = styled.View`
4
- width: 100%;
5
- padding-top: 5px;
6
- padding-left: 20px;
7
- padding-right: 20px;
8
- `
9
-
10
- export const CountDownContainer = styled.View`
11
- background-color: ${(props: any) => `${props.color}4D`};
12
- border-radius: 30px;
13
- padding: 5px 80px 0px;
14
- margin: 0 auto;
15
- display: flex;
16
- justify-content: center;
17
- `
18
-
19
- export const ResendSection = styled.View`
20
- display: flex;
21
- flex-direction: row;
22
- justify-content: center;
23
- margin-bottom: 30px;
24
- `
25
-
26
- export const WrappCountdown = styled.View`
27
- padding-top: 20px;
28
- padding-bottom: 20px;
29
- `
30
-
31
- export const InputsSection = styled.View`
32
- display: flex;
33
- flex-direction: row;
34
- justify-content: space-between;
35
- `
36
-
37
- export const ErrorSection = styled.View`
38
- margin-bottom: 20px;
39
- width: 100%;
40
- display: flex;
41
- justify-content: center;
42
- flex-direction: column;
43
- `
@@ -1,55 +0,0 @@
1
- import * as React from 'react'
2
- import styled, { css } from 'styled-components/native'
3
- import { Alert } from 'react-native'
4
- import { useLanguage } from 'ordering-components/native'
5
-
6
- const Wrapper = styled.TouchableOpacity`
7
-
8
- `
9
-
10
- interface Props {
11
- children: any,
12
- title: string,
13
- message?: string,
14
- onCancel?: any,
15
- onAccept?: any,
16
- onClick?: () => void,
17
- disabled?: boolean
18
- }
19
-
20
- const OAlert = (props: Props) => {
21
-
22
- const [, t] = useLanguage()
23
-
24
- const createTwoButtonAlert = () => {
25
- Alert.alert(
26
- props.title,
27
- props.message,
28
- [
29
- {
30
- text: t('CANCEL', 'cancel'),
31
- onPress: () => props.onCancel && props.onCancel(),
32
- style: 'cancel'
33
- },
34
- {
35
- text: t('ACCEPT', 'Accept'),
36
- onPress: () => props.onAccept && props.onAccept()
37
- }
38
- ],
39
- { cancelable: false }
40
- )
41
- }
42
-
43
- const handleClick = () => {
44
- props.onClick && props.onClick()
45
- createTwoButtonAlert()
46
- }
47
-
48
- return (
49
- <Wrapper onPress={handleClick} disabled={props.disabled}>
50
- {props.children}
51
- </Wrapper>
52
- )
53
- }
54
-
55
- export default OAlert;
@@ -1,73 +0,0 @@
1
- import React from 'react'
2
- import { Modal, TouchableWithoutFeedback, Dimensions, StyleSheet, View, Text } from 'react-native'
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
- const deviceHeight = Dimensions.get('window').height
5
-
6
- interface Props {
7
- open: boolean;
8
- title?: string;
9
- children?: any;
10
- onClose?: any;
11
- }
12
- const OBottomPopup = (props: Props) => {
13
- const {
14
- open,
15
- title,
16
- onClose,
17
- children
18
- } = props
19
- const { top, bottom } = useSafeAreaInsets();
20
- return (
21
- <Modal
22
- animationType='slide'
23
- transparent={false}
24
- visible={open}
25
- onRequestClose={() => onClose()}
26
- presentationStyle={'fullScreen'}
27
- >
28
- <View style={styles.container}>
29
- <TouchableWithoutFeedback
30
- style={styles.touchableOutsideStyle}
31
- onPress={() => onClose()}
32
- >
33
- <View style={styles.touchableOutsideStyle} />
34
- </TouchableWithoutFeedback>
35
- <View style={styles.bottomContainer}>
36
- <View style={{ paddingTop: top, paddingBottom: bottom }}>
37
- {title != '' && (
38
- <Text style={styles.titleStyle}>
39
- {title}
40
- </Text>
41
- )}
42
- {children}
43
- </View>
44
- </View>
45
- </View>
46
- </Modal>
47
- )
48
- }
49
-
50
- const styles = StyleSheet.create({
51
- container: {
52
- flex: 1,
53
- backgroundColor: '#000000AA',
54
- justifyContent: 'flex-end',
55
- },
56
- touchableOutsideStyle: {
57
- flex: 1,
58
- width: '100%'
59
- },
60
- bottomContainer: {
61
- backgroundColor: '#ffffff',
62
- width: '100%',
63
- paddingHorizontal: 0,
64
- height: deviceHeight
65
- },
66
- titleStyle: {
67
- fontSize: 20,
68
- fontWeight: 'bold',
69
- marginVertical: 15
70
- }
71
- })
72
-
73
- export default OBottomPopup
@@ -1,62 +0,0 @@
1
- import React from 'react';
2
- import styled, { useTheme } from 'styled-components/native';
3
- import { OButton, OText } from '.';
4
- import { useLanguage } from 'ordering-components/native';
5
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
6
- import { ViewStyle } from 'react-native';
7
-
8
- const BWrap = styled.View`
9
- position: absolute;
10
- min-height: 69px;
11
- background-color: white;
12
- width: 100%;
13
- flex-direction: row;
14
- justify-content: space-between;
15
- align-items: center;
16
- padding-horizontal: 40px;
17
- padding-vertical: 12px;
18
- border-top-width: 1px;
19
- border-top-color: ${(props: any) => props.theme.colors.border};
20
- `;
21
-
22
- const TxtButton = styled.TouchableOpacity`
23
-
24
- `;
25
-
26
- interface Props {
27
- rightText?: string;
28
- rightAction?: any;
29
- leftText?: string;
30
- leftAction?: any;
31
- customLeftView?: any;
32
- customRightView?: any;
33
- rightBtnStyle?: ViewStyle;
34
- }
35
-
36
- const OBottomStickBar = (props: Props) => {
37
- const [, t] = useLanguage();
38
- const { rightText, rightAction, customRightView, leftText, leftAction, customLeftView, rightBtnStyle } = props;
39
- const { bottom } = useSafeAreaInsets();
40
- const theme = useTheme();
41
-
42
- return (
43
- <BWrap style={{bottom: 0, paddingBottom: bottom}}>
44
- {customLeftView ? customLeftView :
45
- <TxtButton onPress={leftAction ? leftAction : () => {}}>
46
- <OText size={16} weight={'bold'} color={theme.colors.textSecondary}>{leftText || t('SKIP', 'Skip')}</OText>
47
- </TxtButton>
48
- }
49
- {customRightView ? customRightView :
50
- <OButton
51
- onClick={rightAction ? rightAction : () => {}}
52
- text={rightText || t('CONTINUE', 'Continue')} textStyle={{fontSize: 14, color: 'white', marginEnd: 32}}
53
- style={{paddingStart: 10, paddingEnd: 10, ...rightBtnStyle}}
54
- imgRightSrc={theme.images.general.arrow_left}
55
- imgRightStyle={{tintColor: 'white', transform: [{ rotate: '180deg' }]}}
56
- />
57
- }
58
- </BWrap>
59
- )
60
- }
61
-
62
- export default OBottomStickBar;