ordering-ui-react-native 0.12.54 → 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 (205) 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 +36 -2
  10. package/themes/doordash/src/components/OrderDetails/index.tsx +8 -0
  11. package/themes/doordash/src/components/OrderSummary/index.tsx +36 -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 +92 -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/PhoneInputNumber/index.tsx +103 -112
  27. package/themes/single-business/src/components/UserDetails/index.tsx +107 -111
  28. package/themes/single-business/src/components/UserDetails/styles.tsx +3 -8
  29. package/themes/single-business/src/components/UserFormDetails/index.tsx +279 -326
  30. package/themes/single-business/src/components/UserFormDetails/styles.tsx +7 -5
  31. package/themes/single-business/src/layouts/Container.tsx +1 -1
  32. package/themes/uber-eats/src/components/Cart/index.tsx +37 -3
  33. package/themes/uber-eats/src/components/OrderDetails/index.tsx +8 -0
  34. package/themes/uber-eats/src/components/OrderSummary/index.tsx +40 -6
  35. package/themes/uber-eats/src/layouts/Container.tsx +1 -1
  36. package/themes/franchises/index.tsx +0 -111
  37. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  38. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  39. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  40. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  41. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  42. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  43. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  44. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  45. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  46. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  47. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  48. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  49. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  50. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  51. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  52. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  53. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  54. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  55. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  56. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  57. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  58. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  59. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  60. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  61. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  62. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  63. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  64. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  65. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  66. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  67. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  68. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  69. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  70. package/themes/franchises/src/components/Cart/index.tsx +0 -298
  71. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  72. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  73. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  74. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  75. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  76. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  77. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  78. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  79. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  80. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  81. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  82. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  83. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  84. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  85. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  86. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  87. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  88. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  89. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  90. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  91. package/themes/franchises/src/components/Help/index.tsx +0 -56
  92. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  93. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  94. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  95. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  96. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  97. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  98. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  99. package/themes/franchises/src/components/Home/index.tsx +0 -102
  100. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  101. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  102. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  103. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  104. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  105. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  106. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  107. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  108. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  109. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  110. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  111. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  112. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  113. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  114. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  115. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  116. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  117. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  118. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  119. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -820
  120. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  121. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -232
  122. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  123. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  124. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  125. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  126. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  127. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  128. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  129. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  130. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  131. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  132. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  133. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  134. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  135. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  136. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  137. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  138. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  139. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  140. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  141. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  142. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  143. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  144. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  145. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  146. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  147. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  148. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  149. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  150. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  151. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  152. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  153. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  154. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  155. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  156. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  157. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  158. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  159. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  160. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  161. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  162. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  163. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  164. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  165. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  166. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  167. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  168. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  169. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  170. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  171. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  172. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  173. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  174. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  175. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  176. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  177. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  178. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  179. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  180. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  181. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  182. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  183. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  184. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  185. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  186. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  187. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  188. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  189. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  190. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  191. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  192. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  193. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  194. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  195. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  196. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  197. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  198. package/themes/franchises/src/components/shared/index.tsx +0 -29
  199. package/themes/franchises/src/config/constants.tsx +0 -57
  200. package/themes/franchises/src/layouts/Container.tsx +0 -23
  201. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  202. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  203. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  204. package/themes/franchises/src/types/index.tsx +0 -445
  205. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,26 +0,0 @@
1
- import styled, { css } from 'styled-components/native'
2
-
3
- export const Container = styled.View`
4
- position: absolute;
5
- bottom: 0px;
6
- left: 0;
7
- right: 0;
8
- padding: 12px 40px;
9
- flex-direction: row;
10
- border-top-width: 1px;
11
- border-color: ${(props: any) => props.theme.colors.border};
12
- width: 100%;
13
- justify-content: space-between;
14
- background-color: #FFF;
15
- z-index: 1000;
16
- justify-content: space-between;
17
- `
18
-
19
- export const Button = styled.TouchableOpacity`
20
- justify-content: center;
21
- align-items: center;
22
- border-radius: 7.6px;
23
- height: 44px;
24
- max-height; 44px;
25
- padding-horizontal: 20px;
26
- `
@@ -1,156 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { StyleSheet } from 'react-native';
3
- import { useForm, Controller } from 'react-hook-form';
4
-
5
- import {
6
- ForgotPasswordForm as ForgotPasswordController,
7
- useLanguage,
8
- useToast,
9
- ToastType,
10
- } from 'ordering-components/native';
11
- import { useTheme } from 'styled-components/native';
12
- import NavBar from '../NavBar';
13
- import { FormInput, FormSide } from '../LoginForm/styles'
14
- import { Container } from './styles'
15
-
16
- import { OButton, OInput, OText } from '../shared';
17
-
18
- const ForgotPasswordUI = (props: any) => {
19
- const {
20
- navigation,
21
- formState,
22
- handleButtonForgotPasswordClick,
23
- } = props;
24
- const [, t] = useLanguage();
25
- const [, { showToast }] = useToast();
26
- const { control, handleSubmit, errors } = useForm();
27
-
28
- const theme = useTheme();
29
-
30
- const styles = StyleSheet.create({
31
- inputStyle: {
32
- marginBottom: 25,
33
- borderWidth: 1,
34
- borderColor: theme.theme.colors.border,
35
- minHeight: 40,
36
- borderRadius: 7.6,
37
- }
38
- });
39
-
40
- const [emailSent, setEmailSent] = useState(null);
41
-
42
- const onSubmit = (values: any) => {
43
- setEmailSent(values.email)
44
- handleButtonForgotPasswordClick && handleButtonForgotPasswordClick(values)
45
- }
46
-
47
- const handleChangeInputEmail = (value: string, onChange: any) => {
48
- onChange(value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''))
49
- }
50
-
51
- useEffect(() => {
52
- if (!formState.loading && emailSent) {
53
- if (formState.result?.error) {
54
- setEmailSent(null)
55
- formState.result?.result && showToast(
56
- ToastType.Error,
57
- formState.result?.result[0]
58
- )
59
- return
60
- }
61
- showToast(
62
- ToastType.Success,
63
- `${t('SUCCESS_SEND_FORGOT_PASSWORD', 'Your link has been sent to the email')}: ${emailSent}`
64
- )
65
- }
66
- }, [formState])
67
-
68
- useEffect(() => {
69
- if (Object.keys(errors).length > 0) {
70
- // Convert all errors in one string to show in toast provider
71
- const list = Object.values(errors)
72
- let stringError = ''
73
- list.map((item: any, i: number) => {
74
- stringError += (i + 1) === list.length ? `- ${item.message}` : `- ${item.message}\n`
75
- })
76
- showToast(ToastType.Error, stringError)
77
- }
78
- }, [errors])
79
-
80
- return (
81
- <Container>
82
- <NavBar
83
- title={t('FORGOT_YOUR_PASSWORD', 'Forgot your password?')}
84
- titleAlign={'auto'}
85
- btnStyle={{ paddingLeft: 0 }}
86
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
87
- showCall={false}
88
- paddingTop={0}
89
- style={{ flexDirection: 'column', alignItems: 'flex-start' }}
90
- titleStyle={{ width: '100%', marginLeft: 0, paddingLeft: 0 }}
91
- titleWrapStyle={{ paddingHorizontal: 0, paddingStart: 0, flex: 1 }}
92
- />
93
- <FormSide>
94
- <OText
95
- color={'gray'}
96
- size={16}
97
- weight={'300'}
98
- style={{ marginBottom: 30 }}
99
- >
100
- {t('FORGOT_PASSWORD_TEXT_MESSAGE', "Enter your email address and we'll sent a link to reset your password.")}
101
- </OText>
102
- <FormInput>
103
- <Controller
104
- control={control}
105
- render={({ onChange, value }: any) => (
106
- <OInput
107
- placeholder={t('EMAIL', 'Email')}
108
- style={styles.inputStyle}
109
- icon={theme.images.general.email}
110
- onChange={(e: any) => {
111
- handleChangeInputEmail(e, onChange)
112
- }}
113
- value={value}
114
- autoCapitalize='none'
115
- autoCorrect={false}
116
- type='email-address'
117
- autoCompleteType='email'
118
- returnKeyType='done'
119
- blurOnSubmit
120
- onSubmitEditing={handleSubmit(onSubmit)}
121
- />
122
- )}
123
- name="email"
124
- rules={{
125
- required: t('VALIDATION_ERROR_EMAIL_REQUIRED', 'The field Email is required').replace('_attribute_', t('EMAIL', 'Email')),
126
- pattern: {
127
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
128
- message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace('_attribute_', t('EMAIL', 'Email'))
129
- }
130
- }}
131
- defaultValue=""
132
- />
133
-
134
- <OButton
135
- text={emailSent && !formState.result?.error ? t('LINK_SEND_FORGOT_PASSWORD', 'Link Sent') : t('FRONT_RECOVER_PASSWORD', 'Recover Password')}
136
- textStyle={{ color: 'white' }}
137
- bgColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
138
- borderColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
139
- isLoading={formState.loading}
140
- imgRightSrc={null}
141
- onClick={emailSent && !formState.result?.error ? () => { } : handleSubmit(onSubmit)}
142
- style={{ borderRadius: 7.6, shadowOpacity: 0 }}
143
- />
144
- </FormInput>
145
- </FormSide>
146
- </Container>
147
- );
148
- };
149
-
150
- export const ForgotPasswordForm = (props: any) => {
151
- const ForgotPasswordProps = {
152
- ...props,
153
- UIComponent: ForgotPasswordUI
154
- }
155
- return <ForgotPasswordController {...ForgotPasswordProps} />
156
- }
@@ -1,11 +0,0 @@
1
- import styled from 'styled-components/native';
2
-
3
- export const Wrapper = styled.View`
4
- background-color: white;
5
- min-height: 200px;
6
- padding: 0px 25px;
7
- `;
8
-
9
- export const Container = styled.View`
10
- padding-bottom: 40px;
11
- `
@@ -1,84 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import Geolocation from '@react-native-community/geolocation'
3
- import Geocoder from 'react-native-geocoding'
4
- import { GpsButtonStyle } from './styles'
5
- import { View } from 'react-native'
6
- import { OText } from '../shared'
7
- import { ActivityIndicator } from 'react-native-paper'
8
-
9
- export const GPSButton = (props: any) => {
10
- const {
11
- handleGPS,
12
- apiKey,
13
- googleReady,
14
- IconButton,
15
- IconLoadingButton
16
- } = props
17
-
18
- const [isLoading, setLoading] = useState(false);
19
-
20
- const geoCodePosition = (pos: { latitude: number, longitude: number }) => {
21
- Geocoder.from({
22
- latitude: pos.latitude,
23
- longitude: pos.longitude
24
- }).then(({ results }: any) => {
25
- let zipcode = null
26
- if (results && results.length > 0) {
27
- for (const component of results[0].address_components) {
28
- const addressType = component.types[0]
29
- if (addressType === 'postal_code') {
30
- zipcode = component.short_name
31
- break
32
- }
33
- }
34
- let data = null
35
- const details = {
36
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
37
- }
38
- // if (isSetInputs) {
39
- data = {
40
- address: results[0]?.formatted_address,
41
- location: results[0]?.geometry?.location,
42
- zipcode,
43
- place_id: results[0]?.place_id,
44
- }
45
- console.log(JSON.stringify(data));
46
- // }
47
- handleGPS && handleGPS(data, details)
48
- } else {
49
- // setMapErrors && setMapErrors('ERROR_NOT_FOUND_ADDRESS')
50
- }
51
- setLoading(false);
52
- }).catch((err: any) => {
53
- console.log(err);
54
- setLoading(false);
55
- })
56
- }
57
-
58
- const getCurrentPosition = () => {
59
- setLoading(true);
60
- Geolocation.getCurrentPosition((pos) => {
61
- geoCodePosition(pos.coords);
62
- }, (err) => {
63
- setLoading(false);
64
- console.log(err);
65
- });
66
- }
67
-
68
- useEffect(() => {
69
- Geocoder.init(apiKey);
70
- }, [])
71
-
72
- return (
73
- <GpsButtonStyle
74
- disabled={isLoading}
75
- onPress={getCurrentPosition}
76
- >
77
- {isLoading ? (
78
- IconLoadingButton ? IconLoadingButton : <ActivityIndicator size={'small'} />
79
- ) : (
80
- IconButton ? IconButton : <OText>{'GPS'}</OText>
81
- )}
82
- </GpsButtonStyle>
83
- )
84
- }
@@ -1,6 +0,0 @@
1
- import styled, { css } from 'styled-components/native'
2
-
3
- export const GpsButtonStyle = styled.TouchableOpacity`
4
- width: 30px;
5
- height: 30px;
6
- `
@@ -1,122 +0,0 @@
1
- import React from 'react';
2
- import { StyleSheet, Text, View } from 'react-native';
3
- import { useLanguage, useApi, useSession } from 'ordering-components/native';
4
- import { GoogleSignin, statusCodes } from '@react-native-google-signin/google-signin';
5
- import { Container, GoogleButton } from './styles';
6
- import { useTheme } from 'styled-components/native';
7
- import { OIcon } from '../shared';
8
-
9
- export const GoogleLogin = (props: any) => {
10
- const {
11
- handleErrors,
12
- handleLoading,
13
- handleSuccessGoogleLogin,
14
- notificationState,
15
- } = props
16
-
17
- const [, t] = useLanguage()
18
- const [ordering] = useApi()
19
- const theme = useTheme()
20
- const [{ auth }] = useSession();
21
-
22
- const buttonText = auth
23
- ? t('LOGOUT_WITH_FACEBOOK', 'Logout with Google')
24
- : t('CONTINUE_WITH_GOOGLE', 'Continue with Google');
25
-
26
- const performGoogleLogin = async (accessToken: string) => {
27
- try {
28
- const body: any = {
29
- access_token: accessToken
30
- }
31
- if (notificationState?.notification_token) {
32
- body.notification_token = notificationState.notification_token
33
- body.notification_app = notificationState.notification_app
34
- }
35
- const response: any = await fetch(`${ordering.root}/auth/google`, {
36
- method: 'POST',
37
- headers: { 'Content-Type': 'application/json' },
38
- body: JSON.stringify(body)
39
- })
40
- if (!response.content.error) {
41
- if (handleSuccessGoogleLogin) {
42
- handleSuccessGoogleLogin(response.content.result)
43
- handleLoading && handleLoading(false)
44
- }
45
- } else {
46
- handleLoading && handleLoading(false)
47
- onSignoutFromGoogle()
48
- }
49
- } catch (err: any) {
50
- handleLoading && handleLoading(false)
51
- handleErrors && handleErrors(err.message)
52
- }
53
- }
54
-
55
- const onLoginWithGoogle = async () => {
56
- try {
57
-
58
- await GoogleSignin.configure({
59
- iosClientId: '733099999972-s1s5amppj9qlfi5t16oemqbfvetap2t5.apps.googleusercontent.com',
60
- offlineAccess: false
61
- })
62
-
63
- await GoogleSignin.hasPlayServices();
64
- const userInfo = await GoogleSignin.signIn();
65
- if (userInfo.idToken) {
66
- performGoogleLogin(userInfo.idToken);
67
- }
68
- // this.setState({ userInfo });
69
- } catch (error: any) {
70
- if (error.code === statusCodes.SIGN_IN_CANCELLED) {
71
- // user cancelled the login flow
72
- } else if (error.code === statusCodes.IN_PROGRESS) {
73
- // operation (e.g. sign in) is in progress already
74
- } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
75
- // play services not available or outdated
76
- } else {
77
- // some other error happened
78
- }
79
- }
80
- };
81
-
82
- const onSignoutFromGoogle = async () => {
83
- try {
84
- await GoogleSignin.signOut();
85
- // this.setState({ user: null }); // Remember to remove the user from your app's state as well
86
- } catch (error) {
87
- console.error(error);
88
- }
89
- }
90
-
91
- return (
92
- <Container>
93
- <GoogleButton
94
- onPress={onLoginWithGoogle}
95
- >
96
- <View style={style.fbBtn}>
97
- <OIcon
98
- src={theme.images.general.google}
99
- width={16}
100
- />
101
- </View>
102
- <Text style={style.textBtn}>
103
- {buttonText}
104
- </Text>
105
- </GoogleButton>
106
- </Container>
107
-
108
- );
109
- }
110
-
111
- const style = StyleSheet.create({
112
- fbBtn: {
113
- position: 'absolute',
114
- left: 0,
115
- marginHorizontal: 10
116
- },
117
- textBtn: {
118
- fontSize: 16,
119
- color: '#000000',
120
- marginLeft: 20
121
- }
122
- })
@@ -1,23 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const Container = styled.View`
4
- margin-vertical: 20px;
5
- `
6
-
7
- export const GoogleButton = styled.TouchableOpacity`
8
- background-color: #FFFFFF;
9
- border-radius: 7.6px;
10
- padding: 15px 30px;
11
- font-size: 14px;
12
- font-weight: 400;
13
- text-align: center;
14
- width: 100%;
15
- display: flex;
16
- flex-direction: row;
17
- align-items: center;
18
- justify-content: center;
19
- position: relative;
20
- height: 52px;
21
- border-color: black;
22
- border-width: 1px;
23
- `
@@ -1,229 +0,0 @@
1
- import React, { useState, useEffect, useRef } from 'react'
2
- import { Dimensions, StyleSheet, View, Platform } from 'react-native';
3
- import MapView, { PROVIDER_DEFAULT, PROVIDER_GOOGLE, Marker, Region, } from 'react-native-maps'
4
- import Geocoder from 'react-native-geocoding';
5
- import { useLanguage, useConfig } from 'ordering-components/native'
6
- import { GoogleMapsParams } from '../../types';
7
- import Alert from '../../../../../src/providers/AlertProvider'
8
- import { OIcon } from '../shared';
9
-
10
- export const GoogleMap = (props: GoogleMapsParams) => {
11
-
12
- const {
13
- location,
14
- handleChangeAddressMap,
15
- maxLimitLocation,
16
- readOnly,
17
- markerTitle,
18
- saveLocation,
19
- setSaveLocation,
20
- handleToggleMap,
21
- locations
22
- } = props
23
-
24
- const [, t] = useLanguage()
25
- const [configState] = useConfig()
26
- const { width, height } = Dimensions.get('window');
27
- const ASPECT_RATIO = width / height;
28
- const [markerPosition, setMarkerPosition] = useState({ latitude: locations ? locations[2].lat : location.lat, longitude: locations ? locations[2].lng : location.lng })
29
- const [region, setRegion] = useState({
30
- latitude: location.lat,
31
- longitude: location.lng,
32
- latitudeDelta: 0.0010,
33
- longitudeDelta: 0.0010 * ASPECT_RATIO
34
- })
35
- let mapRef = useRef<any>(null)
36
- const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value
37
-
38
- const center = { lat: location?.lat, lng: location?.lng }
39
- const [alertState, setAlertState] = useState<{ open: boolean, content: Array<string>, key?: string | null }>({ open: false, content: [], key: null })
40
- const mapErrors: any = {
41
- ERROR_NOT_FOUND_ADDRESS: 'Sorry, we couldn\'t find an address',
42
- ERROR_MAX_LIMIT_LOCATION: `Sorry, You can only set the position to ${maxLimitLocation}m`
43
- }
44
- const MARKERS = locations && locations.map((location: { lat: number, lng: number }) => {
45
- return {
46
- latitude: location.lat,
47
- longitude: location.lng
48
- }
49
- })
50
- const geocodePosition = (pos: { latitude: number, longitude: number }) => {
51
- Geocoder.from({
52
- latitude: pos.latitude,
53
- longitude: pos.longitude
54
- }).then(({ results }) => {
55
- let zipcode = null
56
- if (results && results.length > 0) {
57
- for (const component of results[0].address_components) {
58
- const addressType = component.types[0]
59
- if (addressType === 'postal_code') {
60
- zipcode = component.short_name
61
- break
62
- }
63
- }
64
- const address = {
65
- address: results[0]?.formatted_address,
66
- location: results[0]?.geometry?.location,
67
- zipcode,
68
- place_id: results[0]?.place_id,
69
- }
70
- const details = {
71
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
72
- }
73
- handleChangeAddressMap && handleChangeAddressMap(address, details)
74
- setSaveLocation && setSaveLocation(false)
75
- handleToggleMap && handleToggleMap()
76
- } else {
77
- setMapErrors && setMapErrors('ERROR_NOT_FOUND_ADDRESS')
78
- }
79
- }).catch(err => {
80
- setMapErrors && setMapErrors(err.message)
81
- })
82
- }
83
-
84
- const validateResult = (curPos: { latitude: number, longitude: number }) => {
85
- const loc1 = center
86
- const loc2 = curPos
87
- const distance = calculateDistance(loc1, loc2)
88
-
89
- if (!maxLimitLocation) {
90
- geocodePosition(curPos)
91
- setMarkerPosition(curPos)
92
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
93
- return
94
- }
95
-
96
- if (distance <= maxLimitLocation) {
97
- setMarkerPosition(curPos)
98
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
99
- } else {
100
- setMapErrors && setMapErrors('ERROR_MAX_LIMIT_LOCATION')
101
- setMarkerPosition({ latitude: center.lat, longitude: center.lng })
102
- }
103
- }
104
-
105
- const calculateDistance = (pointA: { lat: number, lng: number }, pointB: { latitude: number, longitude: number }) => {
106
-
107
- const lat1 = pointA.lat;
108
- const lon1 = pointA.lng;
109
-
110
- const lat2 = pointB.latitude;
111
- const lon2 = pointB.longitude;
112
-
113
- const R = 6371e3;
114
- const φ1 = lat1 * (Math.PI / 180);
115
- const φ2 = lat2 * (Math.PI / 180);
116
- const Δφ = (lat2 - lat1) * (Math.PI / 180);
117
- const Δλ = (lon2 - lon1) * (Math.PI / 180);
118
-
119
- const a = (Math.sin(Δφ / 2) * Math.sin(Δφ / 2)) +
120
- ((Math.cos(φ1) * Math.cos(φ2)) * (Math.sin(Δλ / 2) * Math.sin(Δλ / 2)));
121
-
122
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
123
-
124
- const distance = R * c;
125
- return distance;
126
- }
127
-
128
- const handleChangeRegion = (coordinates: Region) => {
129
- validateResult(coordinates)
130
- }
131
-
132
- const closeAlert = () => {
133
- setAlertState({
134
- open: false,
135
- content: []
136
- })
137
- }
138
-
139
- const setMapErrors = (errKey: string) => {
140
- setAlertState({
141
- open: true,
142
- content: !(errKey === 'ERROR_MAX_LIMIT_LOCATION')
143
- ? [t(errKey, mapErrors[errKey])]
144
- : [`${t(errKey, mapErrors[errKey])} ${maxLimitLocation} ${t('METTERS', 'meters')}`],
145
- key: errKey
146
- })
147
- }
148
-
149
- const fitAllMarkers = () => {
150
- mapRef.current.fitToCoordinates(MARKERS, {
151
- edgePadding: { top: 80, right: 80, bottom: 80, left: 80 },
152
- animated: true,
153
- });
154
- }
155
-
156
- useEffect(() => {
157
- Geocoder.init(googleMapsApiKey)
158
- }, [])
159
-
160
-
161
- useEffect(() => {
162
- if (saveLocation) {
163
- geocodePosition(markerPosition)
164
- }
165
- }, [saveLocation])
166
-
167
- useEffect(() => {
168
- const interval = setInterval(() => {
169
- if (mapRef.current && locations) {
170
- fitAllMarkers()
171
- }
172
- }, 1000)
173
- return () => clearInterval(interval)
174
- }, [locations])
175
-
176
- return (
177
- <>
178
- <MapView
179
- provider={Platform.OS === "android" ? PROVIDER_GOOGLE : PROVIDER_DEFAULT}
180
- initialRegion={region}
181
- style={styles.map}
182
- onRegionChangeComplete={!readOnly ? (coordinates) => handleChangeRegion(coordinates) : () => { }}
183
- zoomTapEnabled
184
- zoomEnabled
185
- zoomControlEnabled
186
- cacheEnabled
187
- moveOnMarkerPress
188
- ref={mapRef}
189
- >
190
- {locations ? (
191
- <>
192
- {MARKERS && MARKERS.map((location: { latitude: number, longitude: number }, i: number) => (
193
- <React.Fragment key={i}>
194
- {
195
- <Marker
196
- coordinate={location}
197
- title={locations[i]?.title}
198
- >
199
- <View>
200
- <OIcon url={locations[i].icon} width={50} height={50} />
201
- </View>
202
- </Marker>
203
- }
204
- </React.Fragment>
205
- ))}
206
- </>
207
- ) : (
208
- <Marker
209
- coordinate={markerPosition}
210
- title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
211
- />
212
- )}
213
- </MapView>
214
- <Alert
215
- open={alertState.open}
216
- onAccept={closeAlert}
217
- onClose={closeAlert}
218
- content={alertState.content}
219
- title={t('ERROR', 'Error')}
220
- />
221
- </>
222
- )
223
- }
224
-
225
- const styles = StyleSheet.create({
226
- map: {
227
- ...StyleSheet.absoluteFillObject,
228
- }
229
- })