ordering-ui-react-native 0.12.55 → 0.12.59

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 (202) hide show
  1. package/package.json +1 -1
  2. package/src/components/Cart/index.tsx +50 -16
  3. package/src/components/OrderDetails/index.tsx +8 -0
  4. package/src/components/OrderSummary/index.tsx +38 -3
  5. package/src/layouts/Container.tsx +1 -1
  6. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -0
  7. package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
  8. package/themes/business/src/layouts/Container.tsx +3 -1
  9. package/themes/doordash/src/components/Cart/index.tsx +37 -2
  10. package/themes/doordash/src/components/OrderDetails/index.tsx +8 -0
  11. package/themes/doordash/src/components/OrderSummary/index.tsx +37 -3
  12. package/themes/doordash/src/layouts/Container.tsx +1 -1
  13. package/themes/instacart/src/components/Cart/index.tsx +37 -3
  14. package/themes/instacart/src/components/OrderDetails/index.tsx +8 -0
  15. package/themes/instacart/src/components/OrderSummary/index.tsx +37 -4
  16. package/themes/instacart/src/layouts/Container.tsx +1 -1
  17. package/themes/kiosk/src/layouts/Container.tsx +2 -1
  18. package/themes/original/src/components/Cart/index.tsx +268 -234
  19. package/themes/original/src/components/OrderDetails/index.tsx +723 -715
  20. package/themes/original/src/components/OrderSummary/index.tsx +37 -3
  21. package/themes/original/src/layouts/Container.tsx +1 -1
  22. package/themes/single-business/src/components/Cart/index.tsx +127 -16
  23. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  24. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  25. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  26. package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
  27. package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
  28. package/themes/single-business/src/layouts/Container.tsx +1 -1
  29. package/themes/uber-eats/src/components/Cart/index.tsx +37 -3
  30. package/themes/uber-eats/src/components/OrderDetails/index.tsx +8 -0
  31. package/themes/uber-eats/src/components/OrderSummary/index.tsx +40 -6
  32. package/themes/uber-eats/src/layouts/Container.tsx +1 -1
  33. package/themes/franchises/index.tsx +0 -111
  34. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  35. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  36. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  37. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  38. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  39. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  40. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  41. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  42. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  43. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  44. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  45. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  46. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  47. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  48. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  49. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  50. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  51. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  52. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  53. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  54. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  55. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  56. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  57. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  58. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  59. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  60. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  61. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  62. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  63. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  64. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  65. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  66. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  67. package/themes/franchises/src/components/Cart/index.tsx +0 -298
  68. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  69. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  70. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  71. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  72. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  73. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  74. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  75. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  76. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  77. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  78. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  79. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  80. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  81. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  82. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  83. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  84. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  85. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  86. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  87. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  88. package/themes/franchises/src/components/Help/index.tsx +0 -56
  89. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  90. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  91. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  92. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  93. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  94. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  95. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  96. package/themes/franchises/src/components/Home/index.tsx +0 -102
  97. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  98. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  99. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  100. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  101. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  102. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  103. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  104. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  105. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  106. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  107. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  108. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  109. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  110. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  111. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  112. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  113. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  114. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  115. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  116. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -820
  117. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  118. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -232
  119. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  120. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  121. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  122. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  123. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  124. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  125. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  126. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  127. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  128. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  129. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  130. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  131. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  132. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  133. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  134. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  135. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  136. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  137. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  138. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  139. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  140. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  141. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  142. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  143. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  144. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  145. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  146. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  147. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  148. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  149. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  150. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  151. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  152. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  153. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  154. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  155. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  156. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  157. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  158. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  159. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  160. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  161. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  162. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  163. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  164. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  165. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  166. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  167. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  168. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  169. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  170. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  171. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  172. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  173. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  174. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  175. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  176. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  177. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  178. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  179. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  180. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  181. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  182. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  183. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  184. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  185. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  186. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  187. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  188. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  189. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  190. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  191. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  192. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  193. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  194. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  195. package/themes/franchises/src/components/shared/index.tsx +0 -29
  196. package/themes/franchises/src/config/constants.tsx +0 -57
  197. package/themes/franchises/src/layouts/Container.tsx +0 -23
  198. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  199. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  200. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  201. package/themes/franchises/src/types/index.tsx +0 -445
  202. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,351 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { StyleSheet, View } from 'react-native';
3
- import { useSession, useLanguage, ToastType, useToast } from 'ordering-components/native';
4
- import { useTheme } from 'styled-components/native';
5
- import { useForm, Controller } from 'react-hook-form';
6
-
7
- import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
8
-
9
- import { OText, OButton, OInput } from '../shared';
10
-
11
- import { PhoneInputNumber } from '../PhoneInputNumber';
12
- import { sortInputFields } from '../../utils';
13
-
14
- export const UserFormDetailsUI = (props: any) => {
15
- const {
16
- isEdit,
17
- formState,
18
- showField,
19
- cleanFormState,
20
- onCloseProfile,
21
- isRequiredField,
22
- validationFields,
23
- handleChangeInput,
24
- handleButtonUpdateClick,
25
- phoneUpdate,
26
- hideUpdateButton,
27
- } = props;
28
-
29
- const theme = useTheme();
30
-
31
-
32
- const styles = StyleSheet.create({
33
- btnOutline: {
34
- backgroundColor: '#FFF',
35
- color: theme.colors.primary,
36
- },
37
- inputStyle: {
38
- borderRadius: 0,
39
- marginBottom: 25,
40
- borderBottomWidth: 1,
41
- borderBottomColor: theme.colors.border,
42
- color: theme.colors.textNormal,
43
- fontSize: 12,
44
- padding: 0,
45
- },
46
- phoneSelect: {
47
- borderWidth: 0,
48
- marginStart: -5,
49
- marginEnd: 0,
50
- marginTop: -3,
51
- height: 32,
52
- width: 44
53
- },
54
- phoneInputStyle: {
55
- height: 30,
56
- borderWidth: 0,
57
- fontSize: 12,
58
- paddingStart: 0,
59
- paddingBottom: 0,
60
- marginBottom: -0,
61
- }
62
- });
63
-
64
- const [, t] = useLanguage();
65
- const [, { showToast }] = useToast();
66
- const { handleSubmit, control, errors, setValue } = useForm();
67
-
68
- const [{ user }] = useSession();
69
- const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
70
- const [phoneInputData, setPhoneInputData] = useState({
71
- error: '',
72
- phone: {
73
- country_phone_code: null,
74
- cellphone: null,
75
- },
76
- });
77
-
78
- const showInputPhoneNumber =
79
- validationFields?.fields?.checkout?.cellphone?.enabled ?? false;
80
-
81
- const getInputRules = (field: any) => {
82
- const rules: any = {
83
- required: isRequiredField(field.code)
84
- ? t(
85
- `VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`,
86
- `${field.name} is required`,
87
- ).replace('_attribute_', t(field.name, field.code))
88
- : null,
89
- };
90
- if (field.code && field.code === 'email') {
91
- rules.pattern = {
92
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
93
- message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace(
94
- '_attribute_',
95
- t('EMAIL', 'Email'),
96
- ),
97
- };
98
- }
99
- return rules;
100
- };
101
-
102
- const setUserCellPhone = (isEdit = false) => {
103
- if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
104
- setUserPhoneNumber(userPhoneNumber);
105
- return;
106
- }
107
- if (user?.cellphone) {
108
- let phone = null;
109
- if (user?.country_phone_code) {
110
- phone = `+${user?.country_phone_code} ${user?.cellphone}`;
111
- } else {
112
- phone = user?.cellphone;
113
- }
114
- setUserPhoneNumber(phone);
115
- setPhoneInputData({
116
- ...phoneInputData,
117
- phone: {
118
- country_phone_code: user?.country_phone_code || null,
119
- cellphone: user?.cellphone || null,
120
- },
121
- });
122
- return;
123
- }
124
- setUserPhoneNumber(user?.cellphone || '');
125
- };
126
-
127
- const onSubmit = () => {
128
- if (phoneInputData.error) {
129
- showToast(ToastType.Error, phoneInputData.error);
130
- return;
131
- }
132
- if (Object.keys(formState.changes).length > 0) {
133
- if (
134
- formState.changes?.cellphone === null &&
135
- validationFields?.fields?.checkout?.cellphone?.enabled &&
136
- validationFields?.fields?.checkout?.cellphone?.required
137
- ) {
138
- showToast(
139
- ToastType.Error,
140
- t(
141
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
142
- 'The field Phone Number is required.',
143
- ),
144
- );
145
- return;
146
- }
147
- let changes = null;
148
- if (user?.cellphone && !userPhoneNumber) {
149
- changes = {
150
- country_phone_code: '',
151
- cellphone: '',
152
- };
153
- }
154
- handleButtonUpdateClick(changes);
155
- }
156
- };
157
-
158
- const handleChangePhoneNumber = (number: any) => {
159
- setPhoneInputData(number);
160
- let phoneNumber = {
161
- country_phone_code: {
162
- name: 'country_phone_code',
163
- value: number.phone.country_phone_code,
164
- },
165
- cellphone: {
166
- name: 'cellphone',
167
- value: number.phone.cellphone,
168
- },
169
- };
170
- handleChangeInput(phoneNumber, true);
171
- };
172
-
173
- useEffect(() => {
174
- if (Object.keys(errors).length > 0) {
175
- const list = Object.values(errors);
176
- if (phoneInputData.error) {
177
- list.push({ message: phoneInputData.error });
178
- }
179
- let stringError = '';
180
- list.map((item: any, i: number) => {
181
- stringError +=
182
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
183
- });
184
- showToast(ToastType.Error, stringError);
185
- }
186
- }, [errors]);
187
-
188
- useEffect(() => {
189
- if (!formState?.loading && formState?.result?.error) {
190
- formState.result?.result &&
191
- showToast(ToastType.Error, formState.result?.result[0]);
192
- }
193
- }, [formState?.loading]);
194
-
195
- useEffect(() => {
196
- if (!isEdit && onCloseProfile) {
197
- onCloseProfile();
198
- }
199
- if ((user || !isEdit) && !formState?.loading) {
200
- setUserCellPhone();
201
- if (!isEdit && !formState?.loading) {
202
- cleanFormState && cleanFormState({ changes: {} });
203
- setUserCellPhone(true);
204
- }
205
- }
206
- }, [user, isEdit]);
207
- return (
208
- <>
209
- <UDForm>
210
- {!validationFields?.loading &&
211
- sortInputFields({ values: validationFields?.fields?.checkout })
212
- .length > 0 && (
213
- <UDWrapper>
214
- {sortInputFields({
215
- values: validationFields.fields?.checkout,
216
- }).map(
217
- (field: any) =>
218
- showField &&
219
- showField(field.code) && (
220
- <React.Fragment key={field.id}>
221
- <Controller
222
- key={field.id}
223
- control={control}
224
- render={() => (
225
- <>
226
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
227
- {field?.code}
228
- </OText>
229
- <OInput
230
- name={field.code}
231
- placeholder={t(
232
- field.code.toUpperCase(),
233
- field?.name,
234
- )}
235
- inputStyle={styles.inputStyle}
236
- style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
237
- autoCapitalize={
238
- field.code === 'email' ? 'none' : 'sentences'
239
- }
240
- isDisabled={false}
241
- value={
242
- formState?.changes[field.code] ??
243
- (user && user[field.code]) ??
244
- ''
245
- }
246
- onChange={(val: any) => {
247
- field.code !== 'email'
248
- ? setValue(field.code, val.target.value)
249
- : setValue(
250
- field.code,
251
- val.target.value
252
- .toLowerCase()
253
- .replace(
254
- /[&,()%";:ç?<>{}\\[\]\s]/g,
255
- '',
256
- ),
257
- );
258
- field.code !== 'email'
259
- ? handleChangeInput(val)
260
- : handleChangeInput({
261
- target: {
262
- name: 'email',
263
- value: val.target.value
264
- .toLowerCase()
265
- .replace(
266
- /[&,()%";:ç?<>{}\\[\]\s]/g,
267
- '',
268
- ),
269
- },
270
- });
271
- }}
272
- autoCorrect={field.code === 'email' && false}
273
- type={
274
- field.code === 'email'
275
- ? 'email-address'
276
- : 'default'
277
- }
278
- returnKeyType="done"
279
- autoCompleteType={
280
- field.code === 'email' ? 'email' : 'off'
281
- }
282
- />
283
- </>
284
- )}
285
- name={field.code}
286
- rules={getInputRules(field)}
287
- defaultValue={user && user[field.code]}
288
- />
289
- </React.Fragment>
290
- ),
291
- )}
292
-
293
- {!!showInputPhoneNumber && (
294
- <WrapperPhone>
295
- <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
296
- <PhoneInputNumber
297
- data={phoneInputData}
298
- handleData={(val: any) => handleChangePhoneNumber(val)}
299
- defaultValue={phoneUpdate ? '' : user?.cellphone}
300
- defaultCode={user?.country_phone_code || null}
301
- boxStyle={styles.phoneSelect}
302
- inputStyle={styles.phoneInputStyle}
303
- textStyle={{ color: theme.colors.textNormal, fontSize: 12, padding: 0 }}
304
- noDropIcon
305
- />
306
- {phoneUpdate && (
307
- <OText
308
- size={10}
309
- color={theme.colors.error}
310
- style={{ marginHorizontal: 10, textAlign: 'center' }}>
311
- {t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
312
- {user?.cellphone}
313
- </OText>
314
- )}
315
- </WrapperPhone>
316
- )}
317
- </UDWrapper>
318
- )}
319
- {validationFields?.loading && (
320
- <UDLoader>
321
- <OText size={12}>{t('LOADING', 'Loading')}</OText>
322
- </UDLoader>
323
- )}
324
- </UDForm>
325
- {!hideUpdateButton && (
326
- <>
327
- {((formState &&
328
- Object.keys(formState?.changes).length > 0 &&
329
- isEdit) ||
330
- formState?.loading) && (
331
- <OButton
332
- text={
333
- formState.loading
334
- ? t('UPDATING', 'Updating...')
335
- : t('UPDATE', 'Update')
336
- }
337
- bgColor={theme.colors.white}
338
- textStyle={{ color: theme.colors.primary, fontSize: 14 }}
339
- borderColor={theme.colors.primary}
340
- isDisabled={formState.loading}
341
- imgRightSrc={null}
342
- style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20 }}
343
- onClick={handleSubmit(onSubmit)}
344
- />
345
- )}
346
- </>
347
- )}
348
- </>
349
- );
350
- };
351
-
@@ -1,35 +0,0 @@
1
- import styled from 'styled-components/native';
2
-
3
- export const UDForm = styled.View`
4
- display: flex;
5
- align-items: center;
6
- flex-direction: column;
7
- width: 100%;
8
- margin-top: 20px;
9
- `
10
-
11
- export const UDWrapper = styled.View`
12
- display: flex;
13
- align-items: center;
14
- flex-direction: column;
15
- width: 100%;
16
- margin-top: 20px;
17
- padding-bottom: 50px;
18
- `
19
-
20
- export const UDLoader = styled.View`
21
- width: 100%;
22
- justify-content: center;
23
- height: auto;
24
- display: inline-flex;
25
- flex-wrap: wrap;
26
- padding: 0;
27
- margin-top: 0px;
28
- `
29
-
30
- export const WrapperPhone = styled.View`
31
- margin-bottom: 25px;
32
- width: 100%;
33
- border-bottom-width: 1px;
34
- border-bottom-color: ${(props: any) => props.theme.colors.border};
35
- `
@@ -1,179 +0,0 @@
1
- import React, { useEffect } 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 Spinner from 'react-native-loading-spinner-overlay';
12
- import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native';
13
- import { ProfileParams } from '../../types';
14
- import { LogoutButton } from '../LogoutButton'
15
- import { LanguageSelector } from '../LanguageSelector'
16
-
17
- import {
18
- OIcon,
19
- OText,
20
- } from '../shared';
21
- import {
22
- CenterView,
23
- Actions,
24
- ListWrap,
25
- ListItem
26
- } from './styles';
27
- import { useWindowDimensions } from 'react-native';
28
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
29
-
30
- const ProfileListUI = (props: ProfileParams) => {
31
- const {
32
- navigation,
33
- formState
34
- } = props;
35
-
36
- const theme = useTheme();
37
-
38
-
39
- const langPickerStyle = StyleSheet.create({
40
- inputAndroid: {
41
- color: theme.colors.textNormal,
42
- fontSize: 14,
43
- fontWeight: '500',
44
- paddingEnd: 24,
45
- paddingStart: 0,
46
- height: 40,
47
- borderWidth: 1,
48
- borderColor: theme.colors.clear,
49
- backgroundColor: theme.colors.clear
50
- },
51
- inputIOS: {
52
- color: theme.colors.textNormal,
53
- fontSize: 14,
54
- fontWeight: '500',
55
- paddingEnd: 24,
56
- height: 40,
57
- borderWidth: 1,
58
- borderColor: theme.colors.clear,
59
- backgroundColor: theme.colors.clear
60
- },
61
- icon: {
62
- width: 12,
63
- marginTop: 7,
64
- marginEnd: 7
65
- }
66
- })
67
-
68
- const styles = StyleSheet.create({
69
- photo: {
70
- borderRadius: 7.6,
71
- shadowColor: '#000000',
72
- shadowOffset: { width: 0, height: 1 },
73
- shadowRadius: 2,
74
- shadowOpacity: 0.2,
75
- backgroundColor: theme.colors.white,
76
- marginEnd: 14
77
- },
78
- pagePadding: {
79
- paddingLeft: 40,
80
- paddingRight: 40
81
- }
82
- });
83
-
84
-
85
- const [{ user }] = useSession();
86
- const [, t] = useLanguage();
87
- const [, { showToast }] = useToast();
88
- const { errors } = useForm();
89
-
90
- const { height } = useWindowDimensions();
91
- const { top, bottom } = useSafeAreaInsets();
92
-
93
- const onRedirect = (route: string, params?: any) => {
94
- navigation.navigate(route, params)
95
- }
96
-
97
- useEffect(() => {
98
- if (formState.result.result && !formState.loading) {
99
- if (formState.result?.error) {
100
- showToast(ToastType.Error, formState.result.result);
101
- } else {
102
- showToast(ToastType.Success, t('UPDATE_SUCCESSFULLY', 'Update successfully'));
103
- }
104
- }
105
- }, [formState.result])
106
-
107
- useEffect(() => {
108
- if (Object.keys(errors).length > 0) {
109
- // Convert all errors in one string to show in toast provider
110
- const list = Object.values(errors);
111
- let stringError = '';
112
- list.map((item: any, i: number) => {
113
- stringError +=
114
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
115
- });
116
- showToast(ToastType.Error, stringError);
117
- }
118
- }, [errors]);
119
-
120
- const detailProps = {
121
-
122
- goToBack: () => props.navigation?.canGoBack() && props.navigation.goBack(),
123
- onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params)
124
- }
125
-
126
- return (
127
- <View style={{ flex: 1, height: height - top - bottom - 62 }}>
128
- <OText size={24} color={theme.colors.textNormal} lineHeight={36} weight={Platform.OS === 'ios' ? '600' : 'bold'} style={{ marginTop: 14, marginBottom: 24, ...styles.pagePadding }}>{t('PROFILE', 'Profile')}</OText>
129
- <CenterView style={styles.pagePadding}>
130
- <View style={styles.photo}>
131
- <OIcon
132
- url={user?.photo}
133
- src={!user?.photo && theme.images.general.user}
134
- width={60}
135
- height={60}
136
- />
137
- </View>
138
- <View style={{ flexBasis: '70%' }}>
139
- <OText size={20} lineHeight={30} weight={Platform.OS === 'ios' ? '500' : 'bold'} color={theme.colors.textNormal}>{`${user?.name} ${user?.lastname}`}</OText>
140
- <TouchableOpacity onPress={() => navigation.navigate('ProfileForm', { ...detailProps })}>
141
- <OText size={12} lineHeight={18} color={theme.colors.primary} style={{ textDecorationLine: 'underline' }}>{t('VIEW_ACCOUNT', 'View account')}</OText>
142
- </TouchableOpacity>
143
- </View>
144
- </CenterView>
145
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginVertical: 32 }} />
146
- <Spinner visible={formState?.loading} />
147
- <ListWrap style={{ ...styles.pagePadding }}>
148
- <Actions>
149
- <ListItem onPress={() => onRedirect('AddressList', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
150
- <OIcon src={theme.images.general.pin} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
151
- <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MY_SAVED_PLACES', 'My saved places')}</OText>
152
- </ListItem>
153
- <ListItem onPress={() => navigation.navigate('Help', {})} activeOpacity={0.7}>
154
- <OIcon src={theme.images.general.help} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
155
- <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
156
- </ListItem>
157
- <ListItem onPress={() => navigation.navigate('Notifications', {})} activeOpacity={0.7}>
158
- <OIcon src={theme.images.general.bell} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
159
- <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('NOTIFICATIONS', ' Notifications')}</OText>
160
- </ListItem>
161
- </Actions>
162
-
163
- <Actions>
164
- <LanguageSelector iconColor={theme.colors.textNormal} pickerStyle={langPickerStyle} />
165
- <View style={{ height: 17 }} />
166
- <LogoutButton color={theme.colors.textNormal} text={t('LOGOUT', 'Logout')} />
167
- </Actions>
168
- </ListWrap>
169
- </View>
170
- );
171
- };
172
-
173
- export const UserProfile = (props: any) => {
174
- const profileProps = {
175
- ...props,
176
- UIComponent: ProfileListUI,
177
- };
178
- return <UserProfileController {...profileProps} />;
179
- };
@@ -1,42 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const CenterView = styled.View`
4
- flex-direction: row;
5
- justify-content: flex-start;
6
- align-items: center;
7
- `;
8
-
9
- export const UserData = styled.View`
10
- align-items: center;
11
- text-align: center;
12
- `
13
-
14
- export const Names = styled.View`
15
- flex-direction: row;
16
- `
17
-
18
- export const EditButton = styled.View`
19
- align-items: center;
20
- justify-content: center;
21
- flex-direction: row;
22
- flex: 1;
23
- `
24
-
25
- export const Actions = styled.View`
26
- margin-bottom: 20px;
27
- `
28
-
29
- export const WrapperPhone = styled.View`
30
- padding: 8px 0px;
31
- `
32
- export const ListWrap = styled.View`
33
- flex-grow: 1;
34
- justify-content: space-between;
35
- `
36
- export const ListItem = styled.TouchableOpacity`
37
- flex-direction: row;
38
- justify-content: flex-start;
39
- align-items: center;
40
- margin-bottom: 24px;
41
- `
42
-