ordering-ui-react-native 0.15.35 → 0.15.38-test
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.
- package/package.json +3 -2
- package/src/components/BusinessTypeFilter/index.tsx +4 -1
- package/src/components/LanguageSelector/index.tsx +1 -0
- package/src/components/OrderDetails/index.tsx +2 -2
- package/src/components/PaymentOptions/index.tsx +2 -2
- package/src/components/StripeMethodForm/index.tsx +22 -21
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
- package/themes/business/src/components/OrderDetails/Delivery.tsx +9 -9
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +152 -91
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +51 -48
- package/themes/business/src/components/OrdersOption/index.tsx +52 -48
- package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
- package/themes/kiosk/src/components/Cart/index.tsx +99 -25
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/OrderDetails/index.tsx +134 -39
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +176 -1
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +28 -2
- package/themes/original/src/components/AppleLogin/index.tsx +118 -77
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +28 -6
- package/themes/original/src/components/BusinessController/styles.tsx +22 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
- package/themes/original/src/components/BusinessProductsList/index.tsx +126 -21
- package/themes/original/src/components/BusinessProductsList/styles.tsx +32 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +27 -6
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessesListing/index.tsx +23 -22
- package/themes/original/src/components/Cart/index.tsx +1 -3
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +2 -1
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +73 -2
- package/themes/original/src/components/LoginForm/styles.tsx +6 -1
- package/themes/original/src/components/LogoutButton/index.tsx +7 -1
- package/themes/original/src/components/Messages/index.tsx +5 -0
- package/themes/original/src/components/Messages/styles.tsx +1 -3
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +11 -5
- package/themes/original/src/components/OrderProgress/index.tsx +3 -3
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/PhoneInputNumber/index.tsx +10 -4
- package/themes/original/src/components/PreviousOrders/index.tsx +14 -12
- package/themes/original/src/components/ProductForm/index.tsx +20 -13
- package/themes/original/src/components/Promotions/index.tsx +232 -0
- package/themes/original/src/components/Promotions/styles.tsx +80 -0
- package/themes/original/src/components/SignupForm/index.tsx +109 -13
- package/themes/original/src/components/SingleProductCard/index.tsx +39 -18
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/TaxInformation/index.tsx +10 -4
- package/themes/original/src/components/UserFormDetails/index.tsx +13 -2
- package/themes/original/src/components/UserProfile/index.tsx +53 -8
- package/themes/original/src/components/Wallets/index.tsx +57 -3
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
- package/themes/original/src/components/shared/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +21 -1
- package/themes/original/src/utils/index.tsx +9 -0
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
|
@@ -7,11 +7,15 @@ import { SignupForm } from './src/components/SignupForm';
|
|
|
7
7
|
import { ActiveOrders } from './src/components/ActiveOrders';
|
|
8
8
|
import { AddressList } from './src/components/AddressList';
|
|
9
9
|
import { AppleLogin } from './src/components/AppleLogin';
|
|
10
|
+
import { BusinessBasicInformation } from './src/components/BusinessBasicInformation';
|
|
11
|
+
import { BusinessProductsCategories } from './src/components/BusinessProductsCategories';
|
|
12
|
+
import { BusinessProductsList } from './src/components/BusinessProductsList';
|
|
10
13
|
import { BusinessesListing } from './src/components/BusinessesListing';
|
|
11
14
|
import { BusinessProductsListing } from './src/components/BusinessProductsListing';
|
|
12
15
|
import { CartContent } from './src/components/CartContent';
|
|
13
16
|
import { BusinessCart } from './src/components/BusinessCart';
|
|
14
17
|
import { Checkout } from './src/components/Checkout';
|
|
18
|
+
import { FloatingButton } from './src/components/FloatingButton';
|
|
15
19
|
import { ForgotPasswordForm } from './src/components/ForgotPasswordForm';
|
|
16
20
|
import { MomentOption } from './src/components/MomentOption';
|
|
17
21
|
import { OrdersOption } from './src/components/OrdersOption';
|
|
@@ -33,12 +37,87 @@ import { HelpOrder } from './src/components/HelpOrder';
|
|
|
33
37
|
import { NetworkError } from './src/components/NetworkError';
|
|
34
38
|
import { NotFoundSource } from './src/components/NotFoundSource';
|
|
35
39
|
import { OrderTypeSelector } from './src/components/OrderTypeSelector';
|
|
40
|
+
import { SearchBar } from './src/components/SearchBar';
|
|
36
41
|
import { Wallets } from './src/components/Wallets';
|
|
37
42
|
import { PaymentOptionWallet } from './src/components/PaymentOptionWallet';
|
|
38
43
|
import { ProductForm } from './src/components/ProductForm';
|
|
39
44
|
import { UpsellingProducts } from './src/components/UpsellingProducts';
|
|
40
45
|
import { UserVerification } from './src/components/UserVerification';
|
|
41
46
|
import { BusinessListingSearch } from './src/components/BusinessListingSearch';
|
|
47
|
+
import { LastOrders } from './src/components/LastOrders';
|
|
48
|
+
import NavBar from './src/components/NavBar';
|
|
49
|
+
import { BusinessTypeFilter } from './src/components/BusinessTypeFilter';
|
|
50
|
+
import { BusinessController } from './src/components/BusinessController';
|
|
51
|
+
import { BusinessFeaturedController } from './src/components/BusinessFeaturedController';
|
|
52
|
+
import { HighestRatedBusinesses } from './src/components/HighestRatedBusinesses';
|
|
53
|
+
import { PaymentOptions } from './src/components/PaymentOptions';
|
|
54
|
+
import { DriverTips } from './src/components/DriverTips';
|
|
55
|
+
import { UserDetails } from './src/components/UserDetails';
|
|
56
|
+
import { OrderSummary } from './src/components/OrderSummary';
|
|
57
|
+
import { CartStoresListing } from './src/components/CartStoresListing';
|
|
58
|
+
import { PaymentOptionsWebView } from '../../src/components/PaymentOptionsWebView';
|
|
59
|
+
import { GoogleMap } from './src/components/GoogleMap';
|
|
60
|
+
import { SingleProductCard } from './src/components/SingleProductCard';
|
|
61
|
+
import { UpsellingRedirect } from './src/components/BusinessProductsListing/UpsellingRedirect';
|
|
62
|
+
import { ProductItemAccordion } from './src/components/ProductItemAccordion';
|
|
63
|
+
import { BusinessItemAccordion } from './src/components/BusinessItemAccordion';
|
|
64
|
+
import { CouponControl } from './src/components/CouponControl';
|
|
65
|
+
import { TaxInformation } from './src/components/TaxInformation';
|
|
66
|
+
import { PlaceSpot } from './src/components/PlaceSpot';
|
|
67
|
+
import { Cart } from './src/components/Cart';
|
|
68
|
+
import { LanguageSelector } from './src/components/LanguageSelector';
|
|
69
|
+
import { PhoneInputNumber } from './src/components/PhoneInputNumber'
|
|
70
|
+
import { FacebookLogin } from './src/components/FacebookLogin';
|
|
71
|
+
import { VerifyPhone } from './src/components/VerifyPhone';
|
|
72
|
+
import { GoogleLogin } from './src/components/GoogleLogin';
|
|
73
|
+
import { PreviousOrders } from './src/components/PreviousOrders';
|
|
74
|
+
import { PaymentOptionCash } from './src/components/PaymentOptionCash';
|
|
75
|
+
import { StripeElementsForm } from './src/components/StripeElementsForm';
|
|
76
|
+
import { StripeCardsList } from './src/components/StripeCardsList';
|
|
77
|
+
import { ProductIngredient } from './src/components/ProductIngredient';
|
|
78
|
+
import { ProductOption } from './src/components/ProductOption';
|
|
79
|
+
import { ProductOptionSubOption } from './src/components/ProductOptionSubOption';
|
|
80
|
+
import { SingleProductReview } from './src/components/SingleProductReview';
|
|
81
|
+
import { LogoutButton } from './src/components/LogoutButton';
|
|
82
|
+
import { UserFormDetailsUI } from './src/components/UserFormDetails';
|
|
83
|
+
import { WalletTransactionItem } from './src/components/WalletTransactionItem';
|
|
84
|
+
|
|
85
|
+
import { USER_TYPE, ORDER_TYPES } from './src/config/constants'
|
|
86
|
+
|
|
87
|
+
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from './src/components/OrderSummary/styles';
|
|
88
|
+
|
|
89
|
+
import { FormInput, FormSide, ButtonsWrapper, LoginWith, OTab, OTabs } from './src/components/LoginForm/styles';
|
|
90
|
+
import { OSItem, OSItemContent, OSItemActions} from './src/components/PaymentOptionStripe/styles';
|
|
91
|
+
|
|
92
|
+
import Alert from './src/providers/AlertProvider'
|
|
93
|
+
|
|
94
|
+
import {
|
|
95
|
+
LoginParams,
|
|
96
|
+
ProfileParams,
|
|
97
|
+
AddressListParams,
|
|
98
|
+
AddressFormParams,
|
|
99
|
+
SignupParams,
|
|
100
|
+
PhoneInputParams,
|
|
101
|
+
LanguageSelectorParams,
|
|
102
|
+
BusinessesListingParams,
|
|
103
|
+
HighestRatedBusinessesParams,
|
|
104
|
+
BusinessTypeFilterParams,
|
|
105
|
+
BusinessControllerParams,
|
|
106
|
+
BusinessProductsListingParams,
|
|
107
|
+
BusinessBasicInformationParams,
|
|
108
|
+
BusinessProductsCategoriesParams,
|
|
109
|
+
BusinessProductsListParams,
|
|
110
|
+
SingleProductCardParams,
|
|
111
|
+
BusinessInformationParams,
|
|
112
|
+
BusinessReviewsParams,
|
|
113
|
+
SearchBarParams,
|
|
114
|
+
NotFoundSourceParams,
|
|
115
|
+
OrdersOptionParams,
|
|
116
|
+
ActiveOrdersParams,
|
|
117
|
+
PreviousOrdersParams,
|
|
118
|
+
OrderDetailsParams,
|
|
119
|
+
ReviewDriverParams
|
|
120
|
+
} from './src/types';
|
|
42
121
|
|
|
43
122
|
import { Toast } from './src/components/shared/OToast';
|
|
44
123
|
import {
|
|
@@ -55,10 +134,13 @@ import {
|
|
|
55
134
|
OAlert,
|
|
56
135
|
OModal,
|
|
57
136
|
OBottomPopup,
|
|
137
|
+
HeaderTitle
|
|
58
138
|
} from './src/components/shared';
|
|
59
139
|
|
|
60
140
|
import { Container } from './src/layouts/Container';
|
|
61
141
|
import { SafeAreaContainer } from './src/layouts/SafeAreaContainer';
|
|
142
|
+
import { FloatingBottomContainer } from './src/layouts/FloatingBottomContainer';
|
|
143
|
+
|
|
62
144
|
import {
|
|
63
145
|
_retrieveStoreData,
|
|
64
146
|
_setStoreData,
|
|
@@ -94,7 +176,7 @@ export {
|
|
|
94
176
|
BusinessMenuList,
|
|
95
177
|
UserProfile,
|
|
96
178
|
MessageListing,
|
|
97
|
-
|
|
179
|
+
Messages,
|
|
98
180
|
Help,
|
|
99
181
|
HelpAccountAndPayment,
|
|
100
182
|
HelpGuide,
|
|
@@ -108,6 +190,96 @@ export {
|
|
|
108
190
|
UpsellingProducts,
|
|
109
191
|
UserVerification,
|
|
110
192
|
BusinessListingSearch,
|
|
193
|
+
BusinessBasicInformation,
|
|
194
|
+
BusinessProductsCategories,
|
|
195
|
+
BusinessProductsList,
|
|
196
|
+
FloatingButton,
|
|
197
|
+
SearchBar,
|
|
198
|
+
LastOrders,
|
|
199
|
+
BusinessTypeFilter,
|
|
200
|
+
BusinessController,
|
|
201
|
+
BusinessFeaturedController,
|
|
202
|
+
HighestRatedBusinesses,
|
|
203
|
+
PaymentOptions,
|
|
204
|
+
DriverTips,
|
|
205
|
+
UserDetails,
|
|
206
|
+
OrderSummary,
|
|
207
|
+
CartStoresListing,
|
|
208
|
+
PaymentOptionsWebView,
|
|
209
|
+
GoogleMap,
|
|
210
|
+
SingleProductCard,
|
|
211
|
+
UpsellingRedirect,
|
|
212
|
+
ProductItemAccordion,
|
|
213
|
+
BusinessItemAccordion,
|
|
214
|
+
CouponControl,
|
|
215
|
+
TaxInformation,
|
|
216
|
+
PlaceSpot,
|
|
217
|
+
Cart,
|
|
218
|
+
LanguageSelector,
|
|
219
|
+
PhoneInputNumber,
|
|
220
|
+
FacebookLogin,
|
|
221
|
+
VerifyPhone,
|
|
222
|
+
GoogleLogin,
|
|
223
|
+
PreviousOrders,
|
|
224
|
+
PaymentOptionCash,
|
|
225
|
+
StripeElementsForm,
|
|
226
|
+
StripeCardsList,
|
|
227
|
+
ProductIngredient,
|
|
228
|
+
ProductOption,
|
|
229
|
+
ProductOptionSubOption,
|
|
230
|
+
SingleProductReview,
|
|
231
|
+
LogoutButton,
|
|
232
|
+
UserFormDetailsUI,
|
|
233
|
+
WalletTransactionItem,
|
|
234
|
+
|
|
235
|
+
ORDER_TYPES,
|
|
236
|
+
USER_TYPE,
|
|
237
|
+
|
|
238
|
+
OSBill,
|
|
239
|
+
OSTable,
|
|
240
|
+
OSCoupon,
|
|
241
|
+
OSTotal,
|
|
242
|
+
OSRow,
|
|
243
|
+
|
|
244
|
+
FormInput,
|
|
245
|
+
FormSide,
|
|
246
|
+
ButtonsWrapper,
|
|
247
|
+
LoginWith,
|
|
248
|
+
OTab,
|
|
249
|
+
OTabs,
|
|
250
|
+
|
|
251
|
+
OSItem,
|
|
252
|
+
OSItemContent,
|
|
253
|
+
OSItemActions,
|
|
254
|
+
|
|
255
|
+
Alert,
|
|
256
|
+
|
|
257
|
+
//Types
|
|
258
|
+
LoginParams,
|
|
259
|
+
ProfileParams,
|
|
260
|
+
AddressListParams,
|
|
261
|
+
AddressFormParams,
|
|
262
|
+
SignupParams,
|
|
263
|
+
PhoneInputParams,
|
|
264
|
+
LanguageSelectorParams,
|
|
265
|
+
BusinessesListingParams,
|
|
266
|
+
HighestRatedBusinessesParams,
|
|
267
|
+
BusinessTypeFilterParams,
|
|
268
|
+
BusinessControllerParams,
|
|
269
|
+
BusinessProductsListingParams,
|
|
270
|
+
BusinessBasicInformationParams,
|
|
271
|
+
BusinessProductsCategoriesParams,
|
|
272
|
+
BusinessProductsListParams,
|
|
273
|
+
SingleProductCardParams,
|
|
274
|
+
BusinessInformationParams,
|
|
275
|
+
BusinessReviewsParams,
|
|
276
|
+
SearchBarParams,
|
|
277
|
+
NotFoundSourceParams,
|
|
278
|
+
OrdersOptionParams,
|
|
279
|
+
ActiveOrdersParams,
|
|
280
|
+
PreviousOrdersParams,
|
|
281
|
+
OrderDetailsParams,
|
|
282
|
+
ReviewDriverParams,
|
|
111
283
|
|
|
112
284
|
// OComponents
|
|
113
285
|
Toast,
|
|
@@ -124,10 +296,13 @@ export {
|
|
|
124
296
|
OAlert,
|
|
125
297
|
OModal,
|
|
126
298
|
OBottomPopup,
|
|
299
|
+
HeaderTitle,
|
|
127
300
|
|
|
128
301
|
// layout
|
|
129
302
|
Container,
|
|
130
303
|
SafeAreaContainer,
|
|
304
|
+
FloatingBottomContainer,
|
|
305
|
+
NavBar,
|
|
131
306
|
|
|
132
307
|
// utils
|
|
133
308
|
_retrieveStoreData,
|
|
@@ -108,6 +108,9 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
108
108
|
top: 12,
|
|
109
109
|
zIndex: 1002,
|
|
110
110
|
},
|
|
111
|
+
wrapperNavbar: Platform.OS === 'ios'
|
|
112
|
+
? { paddingVertical: 0, paddingHorizontal: 40 }
|
|
113
|
+
: { paddingVertical: 20, paddingHorizontal: 40 }
|
|
111
114
|
});
|
|
112
115
|
|
|
113
116
|
const [, t] = useLanguage();
|
|
@@ -500,16 +503,18 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
500
503
|
keyboardShouldPersistTaps='always'
|
|
501
504
|
listViewDisplayed={false}
|
|
502
505
|
>
|
|
503
|
-
<
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
506
|
+
<View style={styles.wrapperNavbar}>
|
|
507
|
+
<NavBar
|
|
508
|
+
title={t('WHERE_DO_WE_DELIVERY', 'Where do we delivery?')}
|
|
509
|
+
titleAlign={'center'}
|
|
510
|
+
onActionLeft={goToBack}
|
|
511
|
+
showCall={false}
|
|
512
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
513
|
+
style={{ flexDirection: 'column', alignItems: 'flex-start' }}
|
|
514
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
515
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
516
|
+
/>
|
|
517
|
+
</View>
|
|
513
518
|
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
|
514
519
|
<AddressFormContainer style={{ height: 600, overflow: 'scroll' }}>
|
|
515
520
|
<View>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react'
|
|
2
2
|
import { AddressList as AddressListController, useLanguage, useOrder, useSession } from 'ordering-components/native'
|
|
3
3
|
import { AddressListContainer, AddressItem } from './styles'
|
|
4
|
-
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { Platform, StyleSheet, View } from 'react-native'
|
|
5
5
|
import { OButton, OText, OAlert, OModal, OIcon } from '../shared'
|
|
6
6
|
import { Container } from '../../layouts/Container'
|
|
7
7
|
import { AddressListParams } from '../../types'
|
|
@@ -140,7 +140,7 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
140
140
|
<AddressListContainer>
|
|
141
141
|
{isProfile && (
|
|
142
142
|
<NavBar
|
|
143
|
-
title={t('
|
|
143
|
+
title={t('SAVED_PLACES', 'My saved places')}
|
|
144
144
|
titleAlign={'center'}
|
|
145
145
|
onActionLeft={() => goToBack()}
|
|
146
146
|
showCall={false}
|
|
@@ -261,6 +261,32 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
261
261
|
)}
|
|
262
262
|
{!addressList.loading && !addressList.error && (
|
|
263
263
|
<>
|
|
264
|
+
{addressList?.addresses?.length === 0 && (
|
|
265
|
+
<View
|
|
266
|
+
style={{
|
|
267
|
+
flexDirection: 'column',
|
|
268
|
+
paddingHorizontal: 10,
|
|
269
|
+
paddingTop: 20
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
<OText
|
|
273
|
+
size={24}
|
|
274
|
+
lineHeight={36}
|
|
275
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
276
|
+
style={{
|
|
277
|
+
textAlign: 'center',
|
|
278
|
+
marginRight: 40,
|
|
279
|
+
color: theme.colors.textNormal,
|
|
280
|
+
paddingHorizontal: 0,
|
|
281
|
+
width: '100%',
|
|
282
|
+
marginLeft: 0
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{t('ADDRESS_LIST', 'Address List')}
|
|
286
|
+
</OText>
|
|
287
|
+
</View>
|
|
288
|
+
)}
|
|
289
|
+
|
|
264
290
|
<OButton
|
|
265
291
|
text={t('ADD_NEW_ADDRESS', 'Add new Address')}
|
|
266
292
|
imgRightSrc=''
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Platform, Text, StyleSheet } from 'react-native';
|
|
3
|
-
import { useApi, useSession, useLanguage } from 'ordering-components/native';
|
|
3
|
+
import { useApi, useSession, useLanguage, useConfig, useToast, ToastType } from 'ordering-components/native';
|
|
4
4
|
import { appleAuthAndroid, appleAuth } from '@invertase/react-native-apple-authentication';
|
|
5
5
|
import uuid from 'react-native-uuid';
|
|
6
6
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
@@ -16,12 +16,17 @@ export const AppleLogin = (props: any) => {
|
|
|
16
16
|
} = props
|
|
17
17
|
|
|
18
18
|
const [ordering] = useApi();
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const [{ auth }] = useSession();
|
|
20
|
+
const [, t] = useLanguage();
|
|
21
|
+
const [{ configs }] = useConfig();
|
|
22
|
+
const [, {showToast}] = useToast()
|
|
23
|
+
const [credentialStateForUser, updateCredentialStateForUser] = useState<any>(-1);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
let user : any= null
|
|
26
|
+
|
|
27
|
+
const buttonText = auth
|
|
28
|
+
? t('CONTINUE_WITH_APPLE', 'Logout with Apple')
|
|
29
|
+
: t('CONTINUE_WITH_FACEBOOK', 'Continue with Apple');
|
|
25
30
|
|
|
26
31
|
const performAppleLogin = async (code: string) => {
|
|
27
32
|
try {
|
|
@@ -29,17 +34,19 @@ export const AppleLogin = (props: any) => {
|
|
|
29
34
|
method: 'POST',
|
|
30
35
|
headers: { 'Content-Type': 'application/json' },
|
|
31
36
|
body: JSON.stringify({
|
|
32
|
-
code: code
|
|
37
|
+
code: code,
|
|
38
|
+
platform: Platform.OS === 'ios' ? 'ios' : 'other'
|
|
33
39
|
})
|
|
34
40
|
})
|
|
35
|
-
|
|
41
|
+
const { result, error } = await response.json()
|
|
42
|
+
if (!error) {
|
|
36
43
|
if (handleSuccessAppleLogin) {
|
|
37
|
-
handleSuccessAppleLogin(
|
|
44
|
+
handleSuccessAppleLogin(result)
|
|
38
45
|
handleLoading && handleLoading(false)
|
|
39
46
|
}
|
|
40
47
|
} else {
|
|
48
|
+
handleErrors && handleErrors(result)
|
|
41
49
|
handleLoading && handleLoading(false)
|
|
42
|
-
logoutFromApple()
|
|
43
50
|
}
|
|
44
51
|
} catch (err: any) {
|
|
45
52
|
handleLoading && handleLoading(false)
|
|
@@ -47,66 +54,99 @@ export const AppleLogin = (props: any) => {
|
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
const
|
|
51
|
-
|
|
57
|
+
const fetchAndUpdateCredentialState = async (updateCredentialStateForUser : any) => {
|
|
58
|
+
if (user === null) {
|
|
59
|
+
updateCredentialStateForUser('N/A');
|
|
60
|
+
} else {
|
|
61
|
+
const credentialState = await appleAuth.getCredentialStateForUser(user);
|
|
62
|
+
if (credentialState === appleAuth.State.AUTHORIZED) {
|
|
63
|
+
updateCredentialStateForUser('AUTHORIZED');
|
|
64
|
+
} else {
|
|
65
|
+
updateCredentialStateForUser(credentialState);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
|
-
const onIOSButtonPress = async () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
const onIOSButtonPress = async (updateCredentialStateForUser : any) => {
|
|
71
|
+
try {
|
|
72
|
+
const appleAuthRequestResponse = await appleAuth.performRequest({
|
|
73
|
+
requestedOperation: appleAuth.Operation.LOGIN,
|
|
74
|
+
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
user: newUser,
|
|
79
|
+
email,
|
|
80
|
+
identityToken,
|
|
81
|
+
authorizationCode
|
|
82
|
+
} = appleAuthRequestResponse;
|
|
64
83
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
user = newUser;
|
|
85
|
+
|
|
86
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
87
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (identityToken && authorizationCode) {
|
|
91
|
+
showToast(ToastType.Success, `Apple Authentication Completed, ${email}`)
|
|
92
|
+
performAppleLogin(authorizationCode)
|
|
93
|
+
} else {
|
|
94
|
+
handleErrors && handleErrors('UNABLE_LOGIN_TOKEN', 'Unable to login, no token found')
|
|
70
95
|
}
|
|
71
|
-
}
|
|
72
96
|
|
|
97
|
+
} catch (err: any) {
|
|
98
|
+
handleLoading && handleLoading(false)
|
|
99
|
+
handleErrors && handleErrors(err.message)
|
|
100
|
+
}
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
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
104
|
try {
|
|
105
|
+
// Generate secure, random values for state and nonce
|
|
106
|
+
const rawNonce: any = uuid.v4();
|
|
107
|
+
const state: any = uuid.v4();
|
|
108
|
+
|
|
109
|
+
// Configure the request
|
|
110
|
+
appleAuthAndroid.configure({
|
|
111
|
+
// The Service ID you registered with Apple
|
|
112
|
+
clientId: configs?.apple_login_client_id?.value,
|
|
113
|
+
// Return URL added to your Apple dev console. We intercept this redirect, but it must still match
|
|
114
|
+
// the URL you provided to Apple. It can be an empty route on your backend as it's never called.
|
|
115
|
+
redirectUri: 'https://example.com/auth/callback',
|
|
116
|
+
responseType: appleAuthAndroid.ResponseType.ALL,
|
|
117
|
+
scope: appleAuthAndroid.Scope.ALL,
|
|
118
|
+
// Random nonce value that will be SHA256 hashed before sending to Apple.
|
|
119
|
+
nonce: rawNonce,
|
|
120
|
+
state,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Open the browser window for user sign in
|
|
124
|
+
const response = await appleAuthAndroid.signIn();
|
|
97
125
|
if (response.code) {
|
|
98
126
|
performAppleLogin(response.code)
|
|
99
127
|
}
|
|
100
128
|
} catch (err: any) {
|
|
101
|
-
|
|
129
|
+
handleLoading && handleLoading(false)
|
|
130
|
+
handleErrors && handleErrors(err.message)
|
|
102
131
|
}
|
|
132
|
+
|
|
103
133
|
}
|
|
104
134
|
|
|
105
135
|
useEffect(() => {
|
|
106
|
-
if (Platform.OS
|
|
107
|
-
|
|
136
|
+
if (!appleAuth.isSupported || Platform.OS === 'android') return;
|
|
137
|
+
|
|
138
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
139
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
140
|
+
);
|
|
141
|
+
}, []);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!appleAuth.isSupported || Platform.OS === 'android') return;
|
|
145
|
+
|
|
108
146
|
return appleAuth.onCredentialRevoked(async () => {
|
|
109
|
-
|
|
147
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
148
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
149
|
+
);
|
|
110
150
|
});
|
|
111
151
|
}, []);
|
|
112
152
|
|
|
@@ -115,35 +155,36 @@ export const AppleLogin = (props: any) => {
|
|
|
115
155
|
if (Platform.OS === 'android') return appleAuthAndroid.isSupported;
|
|
116
156
|
return false;
|
|
117
157
|
}
|
|
158
|
+
|
|
118
159
|
return (
|
|
119
160
|
<Container>
|
|
120
|
-
{canShowButton() &&
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
161
|
+
{canShowButton() &&
|
|
162
|
+
<AppleButton
|
|
163
|
+
onPress={() => Platform.OS == 'android' ? onAndroidButtonPress() : onIOSButtonPress(updateCredentialStateForUser)}
|
|
164
|
+
>
|
|
165
|
+
<Icon
|
|
166
|
+
name="apple"
|
|
167
|
+
size={20}
|
|
168
|
+
color={'black'}
|
|
169
|
+
style={style.fbBtn}
|
|
170
|
+
/>
|
|
171
|
+
<Text style={style.textBtn}>
|
|
172
|
+
{buttonText}
|
|
173
|
+
</Text>
|
|
174
|
+
</AppleButton>
|
|
134
175
|
}
|
|
135
176
|
</Container>
|
|
136
177
|
);
|
|
137
178
|
}
|
|
138
179
|
|
|
139
180
|
const style = StyleSheet.create({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
181
|
+
fbBtn: {
|
|
182
|
+
position: 'absolute',
|
|
183
|
+
left: 0,
|
|
184
|
+
marginHorizontal: 16
|
|
185
|
+
},
|
|
186
|
+
textBtn: {
|
|
187
|
+
fontSize: 14,
|
|
188
|
+
color: '#000000'
|
|
189
|
+
}
|
|
190
|
+
})
|