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,27 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const AddressFormContainer = styled.View`
4
- flex: 1;
5
- padding: 0px 40px 20px;
6
- background-color: ${(props: any) => props.theme.colors.backgroundPage};
7
- justify-content: space-between;
8
- `
9
-
10
- export const IconsContainer = styled.View`
11
- flex-direction: row;
12
- justify-content: space-between;
13
- margin-bottom: 20px;
14
- `
15
-
16
- export const AutocompleteInput = styled.View`
17
- z-index: 1000;
18
- `
19
-
20
- export const GoogleMapContainer = styled.View`
21
- flex: 1;
22
- `
23
-
24
- export const FormInput = styled.View`
25
- display: flex;
26
- flex-direction: column;
27
- `
@@ -1,338 +0,0 @@
1
- import React, { useEffect } from 'react'
2
- import { AddressList as AddressListController, useLanguage, useOrder, useSession } from 'ordering-components/native'
3
- import { AddressListContainer, AddressItem } from './styles'
4
- import { StyleSheet, View } from 'react-native'
5
- import { OButton, OText, OAlert, OModal, OIcon } from '../shared'
6
- import { Container } from '../../layouts/Container'
7
- import { AddressListParams } from '../../types'
8
- import { NotFoundSource } from '../NotFoundSource'
9
- import NavBar from '../NavBar'
10
- import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
11
- import { TouchableRipple } from 'react-native-paper'
12
- import { useState } from 'react'
13
- import { useTheme } from 'styled-components/native';
14
-
15
- const AddressListUI = (props: AddressListParams) => {
16
-
17
- const {
18
- navigation,
19
- route,
20
- addressList,
21
- isFromProfile,
22
- nopadding,
23
- handleSetDefault,
24
- handleDelete,
25
- setAddressList,
26
- isGoBack,
27
- actionStatus,
28
- isFromBusinesses,
29
- isFromProductsList,
30
- afterSignup
31
- } = props
32
-
33
- const theme = useTheme();
34
-
35
- const [orderState] = useOrder()
36
- const [, t] = useLanguage()
37
- const [{ auth }] = useSession()
38
-
39
- const [isProfile, setIsProfile] = useState(isFromProfile || route?.params?.isFromProfile);
40
-
41
- const onNavigatorRedirect = () => {
42
- if (route && (isFromBusinesses || isGoBack)) {
43
- isGoBack ? goToBack() : onNavigationRedirect('BottomTab')
44
- return
45
- }
46
- if (route && route?.params?.isFromCheckout) {
47
- onNavigationRedirect('CheckoutPage')
48
- return
49
- }
50
- if (route && !route?.params?.isFromCheckout) {
51
- onNavigationRedirect('BottomTab')
52
- }
53
-
54
- }
55
-
56
- const uniqueAddressesList = (addressList.addresses && addressList.addresses.filter(
57
- (address: any, i: number, self: any) =>
58
- i === self.findIndex((obj: any) => (
59
- address.address === obj.address &&
60
- address.address_notes === obj.address_notes &&
61
- address.zipcode === obj.zipcode &&
62
- address.internal_number === obj.internal_number
63
- )))) || []
64
-
65
- const checkAddress = (address: any) => {
66
- if (!orderState?.options?.address) return true
67
- const props = ['address', 'address_notes', 'zipcode', 'location', 'internal_number']
68
- const values: any = []
69
- props.forEach(prop => {
70
- if (address[prop]) {
71
- if (prop === 'location') {
72
- values.push(address[prop].lat === orderState?.options?.address[prop]?.lat &&
73
- address[prop].lng === orderState?.options?.address[prop]?.lng)
74
- } else {
75
- values.push(address[prop] === orderState?.options?.address[prop])
76
- }
77
- } else {
78
- values.push(orderState?.options?.address[prop] === null || orderState?.options?.address[prop] === '')
79
- }
80
- })
81
- return values.every((value: any) => value)
82
- }
83
-
84
- const addressIcon = (tag: string) => {
85
- switch (tag) {
86
- case 'other':
87
- return theme.images.general.tag_plus
88
- case 'office':
89
- return theme.images.general.tag_building
90
- case 'home':
91
- return theme.images.general.tag_home
92
- case 'favorite':
93
- return theme.images.general.tag_heart
94
- default:
95
- return theme.images.general.tag_plus
96
- }
97
- }
98
-
99
- const handleSetAddress = (address: any) => {
100
- if (address.id === orderState?.options?.address_id) return
101
- handleSetDefault(address)
102
- }
103
-
104
- const handleSaveAddress = (address: any) => {
105
- let found = false
106
- const addresses = addressList.addresses.map((_address: any) => {
107
- if (_address?.id === address?.id) {
108
- Object.assign(_address, address)
109
- found = true
110
- } else if (address.default) {
111
- _address.default = false
112
- }
113
- return _address
114
- })
115
- if (!found) {
116
- addresses.push(address)
117
- }
118
- setAddressList({
119
- ...addressList,
120
- addresses
121
- })
122
- }
123
-
124
- const goToBack = () => navigation?.canGoBack() && navigation.goBack()
125
- const onNavigationRedirect = (route: string, params?: any) => navigation.navigate(route, params)
126
-
127
- useEffect(() => {
128
- if (orderState.loading && auth && orderState.options.address?.location) {
129
- onNavigatorRedirect()
130
- }
131
- }, [orderState.options.address])
132
-
133
- useEffect(() => {
134
- console.log('From profile : ' + isProfile)
135
- }, [])
136
-
137
- return (
138
- <Container noPadding>
139
- {(!addressList.loading || (isFromProductsList || isFromBusinesses || isFromProfile || isProfile)) && (
140
- <AddressListContainer>
141
- {isProfile && (
142
- <NavBar
143
- title={t('MY_SAVED_PLACES', 'My saved places')}
144
- titleAlign={'center'}
145
- onActionLeft={() => goToBack()}
146
- showCall={false}
147
- btnStyle={{ paddingLeft: 0 }}
148
- paddingTop={0}
149
- isVertical
150
- titleWrapStyle={{ paddingHorizontal: 0 }}
151
- />
152
- )}
153
- {
154
- route &&
155
- (
156
- route?.params?.isFromBusinesses ||
157
- route?.params?.isFromCheckout ||
158
- route?.params?.isFromProductsList
159
- ) &&
160
- !isFromProfile &&
161
- (
162
- <NavBar
163
- title={t('ADDRESS_LIST', 'Address List')}
164
- titleAlign={'center'}
165
- onActionLeft={() => goToBack()}
166
- showCall={false}
167
- btnStyle={{ paddingLeft: 0 }}
168
- paddingTop={0}
169
- style={{ flexDirection: 'column', alignItems: 'flex-start' }}
170
- titleWrapStyle={{ paddingHorizontal: 0 }}
171
- />
172
- )}
173
- {addressList.loading && (
174
- <>
175
- {[...Array(5)].map((item, i) => (
176
- <Placeholder key={i} style={{ paddingVertical: 20 }} Animation={Fade}>
177
- <View style={{ flexDirection: 'row' }}>
178
- <PlaceholderLine width={20} height={60} style={{ marginBottom: 0, marginRight: 15 }} />
179
- <Placeholder>
180
- <PlaceholderLine width={70} />
181
- <PlaceholderLine width={40} />
182
- <PlaceholderLine width={70} />
183
- </Placeholder>
184
- </View>
185
- </Placeholder>
186
- ))}
187
- </>
188
- )}
189
- {
190
- !addressList.error &&
191
- addressList?.addresses?.length > 0 && (
192
- <>
193
- {uniqueAddressesList.map((address: any) => (
194
- <AddressItem
195
- key={address.id}
196
- isSelected={checkAddress(address)}
197
- onPress={() => handleSetAddress(address)}
198
- style={{ borderColor: checkAddress(address) ? theme.colors.primary : theme.colors.border }}
199
- >
200
- <OIcon src={addressIcon(address?.tag)} width={24} color={checkAddress(address) ? theme.colors.primary : theme.colors.disabled} style={{ marginEnd: 16 }} />
201
- <OText style={styles.address} size={12}>{address.address}</OText>
202
- <TouchableRipple
203
- onPress={() => !afterSignup ? onNavigationRedirect(
204
- 'AddressForm',
205
- {
206
- address: address,
207
- isEditing: true,
208
- addressesList: addressList,
209
- onSaveAddress: handleSaveAddress,
210
- isSelectedAfterAdd: true,
211
- isFromProductsList: isFromProductsList,
212
- hasAddressDefault: !!orderState.options?.address?.location
213
- }
214
- ) : onNavigationRedirect(
215
- 'AddressFormInitial',
216
- {
217
- address: address,
218
- isEditing: true,
219
- addressesList: addressList,
220
- onSaveAddress: handleSaveAddress,
221
- isSelectedAfterAdd: true,
222
- isFromProductsList: isFromProductsList,
223
- hasAddressDefault: !!orderState.options?.address?.location
224
- })}
225
- >
226
- <OIcon src={theme.images.general.pencil} width={16} style={{ marginHorizontal: 4 }} />
227
- </TouchableRipple>
228
- <OAlert
229
- title={t('DELETE_ADDRESS', 'Delete Address')}
230
- message={t('QUESTION_DELETE_ADDRESS', 'Are you sure to you wants delete the selected address')}
231
- onAccept={() => handleDelete(address)}
232
- disabled={checkAddress(address)}
233
- >
234
- <OIcon
235
- src={theme.images.general.trash}
236
- width={16}
237
- color={theme.colors.disabled}
238
- />
239
- </OAlert>
240
- </AddressItem>
241
- ))}
242
- </>
243
- )}
244
- {!addressList.loading && addressList.error && (
245
- addressList.error.length > 0 && (
246
- <NotFoundSource
247
- content={
248
- addressList.error[0]?.message ||
249
- addressList.error[0] ||
250
- t('NETWORK_ERROR', 'Network Error, please reload the app')
251
- }
252
- />
253
- )
254
- )}
255
- {!addressList.loading && !addressList.error && (
256
- <>
257
- {!(
258
- route && (route?.params?.isFromBusinesses || route?.params?.isFromCheckout)
259
- ) && !isProfile && (
260
- <OText size={24}>
261
- {t('WHERE_DELIVER_NOW', 'Where do we deliver you?')}
262
- </OText>
263
- )}
264
- <OButton
265
- text={t('ADD_NEW_ADDRESS', 'Add new Address')}
266
- imgRightSrc=''
267
- bgColor={theme.colors.white}
268
- textStyle={{ color: theme.colors.primary }}
269
- style={styles.button}
270
- borderColor={theme.colors.primary}
271
- onClick={() => !afterSignup ? onNavigationRedirect(
272
- 'AddressForm',
273
- {
274
- address: null,
275
- onSaveAddress: handleSaveAddress,
276
- addressesList: addressList?.addresses,
277
- nopadding: true,
278
- isSelectedAfterAdd: true,
279
- hasAddressDefault: !!orderState.options?.address?.location
280
- }) : onNavigationRedirect(
281
- 'AddressFormInitial',
282
- {
283
- address: null,
284
- onSaveAddress: handleSaveAddress,
285
- addressesList: addressList?.addresses,
286
- nopadding: true,
287
- isSelectedAfterAdd: true,
288
- hasAddressDefault: !!orderState.options?.address?.location
289
- })}
290
- />
291
- </>
292
- )}
293
- {!isProfile && addressList?.addresses?.length > 0 && (
294
- <OButton
295
- text={t('CONTINUE', 'Continue')}
296
- style={styles.button}
297
- onClick={() => onNavigatorRedirect()}
298
- textStyle={{ color: theme.colors.white }}
299
- />
300
- )}
301
- </AddressListContainer>
302
- )}
303
- </Container>
304
- )
305
- }
306
-
307
- const styles = StyleSheet.create({
308
- address: {
309
- flex: 1,
310
- marginHorizontal: 5
311
- },
312
- icon: {
313
- flex: 0.2
314
- },
315
- buttonIcon: {
316
- width: 20,
317
- height: 20,
318
- resizeMode: 'contain',
319
- left: 20,
320
- position: 'absolute',
321
- },
322
- button: {
323
- marginTop: 30,
324
- marginBottom: 0,
325
- borderRadius: 7.6,
326
- borderWidth: 1,
327
- shadowOpacity: 0,
328
- height: 44,
329
- }
330
- })
331
-
332
- export const AddressList = (props: AddressListParams) => {
333
- const addressListProps = {
334
- ...props,
335
- UIComponent: AddressListUI
336
- }
337
- return <AddressListController {...addressListProps} />
338
- }
@@ -1,20 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const AddressListContainer = styled.View`
4
- flex: 1;
5
- paddingLeft: 40px;
6
- paddingRight: 40px;
7
- paddingBottom: 20px;
8
- `
9
-
10
- export const AddressItem = styled.TouchableOpacity`
11
- padding-vertical: 20px;
12
- flex-direction: row;
13
- justify-content: center;
14
- align-items: center;
15
- border-bottom-width: 1px;
16
- `
17
-
18
- export const ContainerButtons = styled.View`
19
- margin-vertical: 50px
20
- `
@@ -1,149 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import { Platform, Text, StyleSheet } from 'react-native';
3
- import { useApi, useSession, useLanguage } from 'ordering-components/native';
4
- import { appleAuthAndroid, appleAuth } from '@invertase/react-native-apple-authentication';
5
- import uuid from 'react-native-uuid';
6
- import Icon from 'react-native-vector-icons/FontAwesome5';
7
-
8
- import { Container, AppleButton } from './styles';
9
-
10
- export const AppleLogin = (props: any) => {
11
- const {
12
- handleErrors,
13
- handleLoading,
14
- handleSuccessAppleLogin,
15
- notificationState
16
- } = props
17
-
18
- const [ordering] = useApi();
19
- const [{ auth }] = useSession();
20
- const [, t] = useLanguage();
21
-
22
- const buttonText = auth
23
- ? t('CONTINUE_WITH_APPLE', 'Logout with Apple')
24
- : t('CONTINUE_WITH_FACEBOOK', 'Continue with Apple');
25
-
26
- const performAppleLogin = async (code: string) => {
27
- try {
28
- const response: any = await fetch(`${ordering.root}/auth/apple`, {
29
- method: 'POST',
30
- headers: { 'Content-Type': 'application/json' },
31
- body: JSON.stringify({
32
- code: code
33
- })
34
- })
35
- if (!response.content.error) {
36
- if (handleSuccessAppleLogin) {
37
- handleSuccessAppleLogin(response.content.result)
38
- handleLoading && handleLoading(false)
39
- }
40
- } else {
41
- handleLoading && handleLoading(false)
42
- logoutFromApple()
43
- }
44
- } catch (err: any) {
45
- handleLoading && handleLoading(false)
46
- handleErrors && handleErrors(err.message)
47
- }
48
- }
49
-
50
- const logoutFromApple = () => {
51
-
52
- }
53
-
54
- const onIOSButtonPress = async () => {
55
-
56
- const appleAuthRequestResponse = await appleAuth.performRequest({
57
- requestedOperation: appleAuth.Operation.LOGIN,
58
- requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
59
- });
60
-
61
- // get current authentication state for user
62
- // /!\ This method must be tested on a real device. On the iOS simulator it always throws an error.
63
- const credentialState = await appleAuth.getCredentialStateForUser(appleAuthRequestResponse.user);
64
-
65
- // use credentialState response to ensure the user is authenticated
66
- if (credentialState === appleAuth.State.AUTHORIZED) {
67
- // user is authenticated
68
- if (appleAuthRequestResponse.authorizationCode) {
69
- performAppleLogin(appleAuthRequestResponse.authorizationCode)
70
- }
71
- }
72
-
73
- }
74
-
75
- const onAndroidButtonPress = async () => {
76
- // Generate secure, random values for state and nonce
77
- const rawNonce: any = uuid.v4();
78
- const state: any = uuid.v4();
79
-
80
- // Configure the request
81
- appleAuthAndroid.configure({
82
- clientId: 'com.example.client-android',
83
- // Return URL added to your Apple dev console. We intercept this redirect, but it must still match
84
- // the URL you provided to Apple. It can be an empty route on your backend as it's never called.
85
- redirectUri: 'https://example.com/auth/callback',
86
- responseType: appleAuthAndroid.ResponseType.ALL,
87
- scope: appleAuthAndroid.Scope.ALL,
88
- // Random nonce value that will be SHA256 hashed before sending to Apple.
89
- nonce: rawNonce,
90
- state,
91
- });
92
-
93
- // Open the browser window for user sign in
94
- const response = await appleAuthAndroid.signIn();
95
-
96
- try {
97
- if (response.code) {
98
- performAppleLogin(response.code)
99
- }
100
- } catch (err: any) {
101
-
102
- }
103
- }
104
-
105
- useEffect(() => {
106
- if (Platform.OS == 'android') return;
107
- // onCredentialRevoked returns a function that will remove the event listener. useEffect will call this function when the component unmounts
108
- return appleAuth.onCredentialRevoked(async () => {
109
- console.warn('If this function executes, User Credentials have been Revoked');
110
- });
111
- }, []);
112
-
113
- const canShowButton = () => {
114
- if (Platform.OS === 'ios') return true;
115
- if (Platform.OS === 'android') return appleAuthAndroid.isSupported;
116
- return false;
117
- }
118
- return (
119
- <Container>
120
- {canShowButton() &&
121
- <AppleButton
122
- onPress={() => Platform.OS == 'android' ? onAndroidButtonPress() : onIOSButtonPress()}
123
- >
124
- <Icon
125
- name="apple"
126
- size={20}
127
- color={'black'}
128
- style={style.fbBtn}
129
- />
130
- <Text style={style.textBtn}>
131
- {buttonText}
132
- </Text>
133
- </AppleButton>
134
- }
135
- </Container>
136
- );
137
- }
138
-
139
- const style = StyleSheet.create({
140
- fbBtn: {
141
- position: 'absolute',
142
- left: 0,
143
- marginHorizontal: 16
144
- },
145
- textBtn: {
146
- fontSize: 14,
147
- color: '#000000'
148
- }
149
- })
@@ -1,21 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const Container = styled.View``
4
-
5
- export const AppleButton = styled.TouchableOpacity`
6
- background-color: #FFFFFF;
7
- border-radius: 7.6px;
8
- padding: 15px 30px;
9
- font-size: 14px;
10
- font-weight: 400;
11
- text-align: center;
12
- width: 100%;
13
- display: flex;
14
- flex-direction: row;
15
- align-items: center;
16
- justify-content: center;
17
- position: relative;
18
- height: 52px;
19
- border-color: black;
20
- border-width: 1px;
21
- `
@@ -1,29 +0,0 @@
1
- import * as React from 'react'
2
- import { ViewStyle } from 'react-native'
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
- import styled from 'styled-components/native'
5
-
6
- const Wrapper = styled.View`
7
- box-shadow: 0 -1px 3px #00000010;
8
- background-color: white;
9
- height: 60px;
10
- padding-vertical: 20px;
11
- `
12
-
13
- interface Props {
14
- style?: ViewStyle,
15
- children: any
16
- }
17
-
18
- const BottomWrapper = (props: Props) => {
19
- const safeAreaInset = useSafeAreaInsets();
20
- return (
21
- <Wrapper
22
- style={{ paddingBottom: safeAreaInset.bottom || 16, ...props.style }}
23
- >
24
- { props.children}
25
- </Wrapper>
26
- )
27
- }
28
-
29
- export default BottomWrapper