ordering-ui-react-native 0.17.91 → 0.17.92-release
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 +8 -7
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessInformation/index.tsx +10 -9
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/OrderCreating/index.tsx +0 -20
- package/src/components/PaymentOptionsWebView/index.tsx +29 -8
- package/src/components/PhoneInputNumber/index.tsx +6 -2
- package/src/components/StripeMethodForm/index.tsx +136 -102
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +3 -2
- package/src/types/index.tsx +5 -0
- package/src/utils/index.tsx +5 -0
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +36 -26
- package/themes/business/src/components/BusinessController/index.tsx +0 -1
- package/themes/business/src/components/Chat/index.tsx +163 -123
- package/themes/business/src/components/DriverMap/index.tsx +17 -6
- package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/GoogleMap/index.tsx +58 -57
- package/themes/business/src/components/LoginForm/index.tsx +5 -2
- package/themes/business/src/components/MapView/index.tsx +14 -10
- package/themes/business/src/components/MessagesOption/index.tsx +20 -93
- package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
- package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +81 -66
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
- package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
- package/themes/business/src/components/OrderMessage/index.tsx +19 -18
- package/themes/business/src/components/OrderSummary/index.tsx +114 -123
- package/themes/business/src/components/OrdersOption/index.tsx +22 -22
- package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
- package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
- package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
- package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
- package/themes/business/src/components/StoresList/index.tsx +3 -4
- package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
- package/themes/business/src/components/shared/OModal.tsx +16 -9
- package/themes/business/src/types/index.tsx +24 -10
- package/themes/business/src/utils/index.tsx +29 -2
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/Intro/index.tsx +16 -1
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -5
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +1 -1
- package/themes/original/src/components/AddressDetails/index.tsx +19 -3
- package/themes/original/src/components/AddressForm/index.tsx +35 -17
- package/themes/original/src/components/AddressList/index.tsx +5 -8
- package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +73 -37
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
- package/themes/original/src/components/BusinessController/index.tsx +35 -44
- package/themes/original/src/components/BusinessController/styles.tsx +12 -5
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
- package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
- package/themes/original/src/components/BusinessListingSearch/index.tsx +347 -341
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
- package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
- package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +664 -556
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
- package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +38 -405
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +56 -56
- package/themes/original/src/components/CartContent/index.tsx +102 -58
- package/themes/original/src/components/CartContent/styles.tsx +6 -6
- package/themes/original/src/components/Checkout/index.tsx +277 -33
- package/themes/original/src/components/CitiesControl/index.tsx +1 -1
- package/themes/original/src/components/CouponControl/index.tsx +10 -3
- package/themes/original/src/components/DriverTips/index.tsx +14 -6
- package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/GPSButton/index.tsx +6 -4
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +86 -10
- package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
- package/themes/original/src/components/GoogleMap/index.tsx +63 -7
- package/themes/original/src/components/Home/index.tsx +13 -4
- package/themes/original/src/components/LastOrder/index.tsx +2 -1
- package/themes/original/src/components/LastOrders/index.tsx +2 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
- package/themes/original/src/components/LoginForm/index.tsx +64 -34
- package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
- package/themes/original/src/components/MessageListing/index.tsx +9 -2
- package/themes/original/src/components/Messages/index.tsx +15 -4
- package/themes/original/src/components/MomentOption/index.tsx +193 -92
- package/themes/original/src/components/MomentSelector/index.tsx +1 -1
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
- package/themes/original/src/components/MultiCheckout/index.tsx +385 -46
- package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +23 -19
- package/themes/original/src/components/MyOrders/index.tsx +15 -4
- package/themes/original/src/components/NavBar/index.tsx +20 -13
- package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
- package/themes/original/src/components/OrderDetails/index.tsx +50 -38
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
- package/themes/original/src/components/OrderProgress/index.tsx +34 -25
- package/themes/original/src/components/OrderSummary/index.tsx +83 -57
- package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +13 -13
- package/themes/original/src/components/OrdersOption/index.tsx +43 -20
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PageBanner/index.tsx +65 -29
- package/themes/original/src/components/PageBanner/styles.tsx +0 -3
- package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
- package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
- package/themes/original/src/components/ProductForm/index.tsx +87 -31
- package/themes/original/src/components/ProductForm/styles.tsx +3 -3
- package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
- package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
- package/themes/original/src/components/Promotions/index.tsx +2 -2
- package/themes/original/src/components/Promotions/styles.tsx +3 -1
- package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
- package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
- package/themes/original/src/components/ServiceForm/index.tsx +63 -20
- package/themes/original/src/components/SignupForm/index.tsx +43 -27
- package/themes/original/src/components/SingleOrderCard/index.tsx +44 -20
- package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
- package/themes/original/src/components/SingleProductCard/index.tsx +14 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
- package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
- package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
- package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
- package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
- package/themes/original/src/components/UserDetails/index.tsx +3 -1
- package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
- package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
- package/themes/original/src/components/UserProfile/index.tsx +8 -26
- package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
- package/themes/original/src/components/UserVerification/index.tsx +55 -50
- package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
- package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
- package/themes/original/src/components/Wallets/index.tsx +52 -62
- package/themes/original/src/components/Wallets/styles.tsx +2 -4
- package/themes/original/src/components/shared/OButton.tsx +3 -3
- package/themes/original/src/components/shared/OInput.tsx +4 -5
- package/themes/original/src/components/shared/OModal.tsx +3 -3
- package/themes/original/src/types/index.tsx +37 -10
- package/themes/original/src/utils/index.tsx +185 -13
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/navigators/BottomNavigator.tsx +0 -117
- package/src/navigators/CheckoutNavigator.tsx +0 -66
- package/src/navigators/HomeNavigator.tsx +0 -202
- package/src/navigators/NavigationRef.tsx +0 -7
- package/src/navigators/RootNavigator.tsx +0 -269
- package/src/pages/Account.tsx +0 -34
- package/src/pages/AddressForm.tsx +0 -62
- package/src/pages/AddressList.tsx +0 -24
- package/src/pages/BusinessProductsList.tsx +0 -81
- package/src/pages/BusinessesListing.tsx +0 -43
- package/src/pages/CartList.tsx +0 -49
- package/src/pages/Checkout.tsx +0 -101
- package/src/pages/ForgotPassword.tsx +0 -24
- package/src/pages/Help.tsx +0 -23
- package/src/pages/HelpAccountAndPayment.tsx +0 -23
- package/src/pages/HelpGuide.tsx +0 -23
- package/src/pages/HelpOrder.tsx +0 -23
- package/src/pages/Home.tsx +0 -36
- package/src/pages/IntroductoryTutorial.tsx +0 -170
- package/src/pages/Login.tsx +0 -47
- package/src/pages/MomentOption.tsx +0 -30
- package/src/pages/MultiCheckout.tsx +0 -31
- package/src/pages/MultiOrdersDetails.tsx +0 -27
- package/src/pages/MyOrders.tsx +0 -40
- package/src/pages/NetworkError.tsx +0 -24
- package/src/pages/NotFound.tsx +0 -22
- package/src/pages/OrderDetails.tsx +0 -25
- package/src/pages/ProductDetails.tsx +0 -55
- package/src/pages/Profile.tsx +0 -36
- package/src/pages/ReviewDriver.tsx +0 -30
- package/src/pages/ReviewOrder.tsx +0 -32
- package/src/pages/ReviewProducts.tsx +0 -30
- package/src/pages/Sessions.tsx +0 -22
- package/src/pages/Signup.tsx +0 -53
- package/src/pages/SpinnerLoader.tsx +0 -10
- package/src/pages/Splash.tsx +0 -21
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, StyleSheet, ScrollView } from 'react-native';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { View, StyleSheet, ScrollView, Platform } from 'react-native';
|
|
3
3
|
import {
|
|
4
4
|
PaymentOptionStripe,
|
|
5
5
|
useSession,
|
|
6
6
|
useLanguage,
|
|
7
|
+
useValidationFields
|
|
7
8
|
} from 'ordering-components/native';
|
|
8
9
|
import { PlaceholderLine } from 'rn-placeholder';
|
|
9
10
|
import { useTheme } from 'styled-components/native';
|
|
10
11
|
import { getIconCard } from '../../utils';
|
|
11
|
-
import { OAlert, OIcon, OText } from '../shared';
|
|
12
|
+
import { OAlert, OIcon, OText, OModal } from '../shared';
|
|
12
13
|
|
|
13
14
|
import { NotFoundSource } from '../NotFoundSource';
|
|
14
15
|
|
|
@@ -17,26 +18,46 @@ import {
|
|
|
17
18
|
OSItemContent,
|
|
18
19
|
OSItemActions,
|
|
19
20
|
} from '../PaymentOptionStripe/styles';
|
|
21
|
+
import { StripeElementsForm } from '../StripeElementsForm';
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
import { KeyboardAvoidingView } from 'react-native';
|
|
24
|
+
|
|
25
|
+
export const StripeCardsListUI = (props: any) => {
|
|
22
26
|
const {
|
|
23
27
|
onSelectCard,
|
|
24
28
|
deleteCard,
|
|
25
29
|
cardSelected,
|
|
26
30
|
cardsList,
|
|
27
31
|
handleCardClick,
|
|
32
|
+
setAddCardOpen,
|
|
33
|
+
gateway,
|
|
34
|
+
setCardsList,
|
|
35
|
+
addCardOpen,
|
|
36
|
+
isOpenMethod,
|
|
37
|
+
handlePaymethodDataChange
|
|
28
38
|
} = props;
|
|
29
39
|
|
|
30
40
|
const theme = useTheme();
|
|
31
41
|
|
|
32
42
|
const [{ token }] = useSession();
|
|
33
43
|
const [, t] = useLanguage();
|
|
44
|
+
const [validationFields] = useValidationFields()
|
|
45
|
+
const validateZipcodeCard =
|
|
46
|
+
validationFields?.fields?.card?.zipcode?.enabled && validationFields?.fields?.card?.zipcode?.required
|
|
47
|
+
const paymethodsWithoutSaveCards = ['credomatic']
|
|
34
48
|
|
|
35
49
|
const handleCardSelected = (card: any) => {
|
|
50
|
+
if (!card?.zipcode && validateZipcodeCard) return
|
|
36
51
|
handleCardClick(card);
|
|
37
52
|
onSelectCard(card);
|
|
38
53
|
}
|
|
39
54
|
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
|
|
57
|
+
setAddCardOpen({ ...addCardOpen, stripe: true })
|
|
58
|
+
}
|
|
59
|
+
}, [cardsList?.loading])
|
|
60
|
+
|
|
40
61
|
return (
|
|
41
62
|
<>
|
|
42
63
|
{token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
|
|
@@ -75,7 +96,8 @@ const StripeCardsListUI = (props: any) => {
|
|
|
75
96
|
style={styles.cardsList}
|
|
76
97
|
>
|
|
77
98
|
{cardsList.cards.map((card: any) => (
|
|
78
|
-
<OSItem key={card.id} isUnique={cardsList.cards.length}>
|
|
99
|
+
<OSItem key={card.id} isUnique={cardsList.cards.length} isInvalid={!card?.zipcode && validateZipcodeCard}>
|
|
100
|
+
{console.log(card?.zipcode && validateZipcodeCard)}
|
|
79
101
|
<OSItemContent onPress={() => handleCardSelected(card)}>
|
|
80
102
|
<View style={styles.viewStyle}>
|
|
81
103
|
{card.id === cardSelected?.id ? (
|
|
@@ -100,6 +122,13 @@ const StripeCardsListUI = (props: any) => {
|
|
|
100
122
|
XXXX-XXXX-XXXX-{card.last4}
|
|
101
123
|
</OText>
|
|
102
124
|
</View>
|
|
125
|
+
{!card?.zipcode && validateZipcodeCard && (
|
|
126
|
+
<View style={styles.viewStyle}>
|
|
127
|
+
<OText size={10} color={theme?.colors?.danger5}>
|
|
128
|
+
({t('MISSING_ZIPCODE', 'Missing zipcode')})
|
|
129
|
+
</OText>
|
|
130
|
+
</View>
|
|
131
|
+
)}
|
|
103
132
|
</OSItemContent>
|
|
104
133
|
<OSItemActions>
|
|
105
134
|
<OAlert
|
|
@@ -118,6 +147,33 @@ const StripeCardsListUI = (props: any) => {
|
|
|
118
147
|
))}
|
|
119
148
|
</ScrollView>
|
|
120
149
|
)}
|
|
150
|
+
<OModal
|
|
151
|
+
entireModal
|
|
152
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
153
|
+
open={addCardOpen.stripe}
|
|
154
|
+
onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
155
|
+
style={{ backgroundColor: 'red' }}
|
|
156
|
+
>
|
|
157
|
+
<KeyboardAvoidingView
|
|
158
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
159
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
160
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
161
|
+
>
|
|
162
|
+
<StripeElementsForm
|
|
163
|
+
openCarts={props.openCarts}
|
|
164
|
+
toSave
|
|
165
|
+
businessId={props.businessId}
|
|
166
|
+
businessIds={props.businessIds}
|
|
167
|
+
publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
|
|
168
|
+
setCardsList={setCardsList}
|
|
169
|
+
cardsList={cardsList}
|
|
170
|
+
requirements={props.clientSecret}
|
|
171
|
+
handleCardClick={handleCardClick}
|
|
172
|
+
onSelectCard={handlePaymethodDataChange}
|
|
173
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
174
|
+
/>
|
|
175
|
+
</KeyboardAvoidingView>
|
|
176
|
+
</OModal>
|
|
121
177
|
</>
|
|
122
178
|
)
|
|
123
179
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, useWindowDimensions, Keyboard } from 'react-native';
|
|
3
|
-
import { useLanguage, useSession, useConfig } from 'ordering-components/native';
|
|
2
|
+
import { View, StyleSheet, useWindowDimensions, Keyboard, Platform } from 'react-native';
|
|
3
|
+
import { useLanguage, useSession, useConfig, useValidationFields } from 'ordering-components/native';
|
|
4
4
|
import {
|
|
5
5
|
StripeProvider,
|
|
6
6
|
CardField,
|
|
@@ -28,7 +28,12 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
28
28
|
onCancel,
|
|
29
29
|
cart,
|
|
30
30
|
merchantId,
|
|
31
|
-
businessIds
|
|
31
|
+
businessIds,
|
|
32
|
+
setMethodPaySupported,
|
|
33
|
+
placeByMethodPay,
|
|
34
|
+
methodPaySupported,
|
|
35
|
+
setPlaceByMethodPay,
|
|
36
|
+
cartTotal
|
|
32
37
|
} = props;
|
|
33
38
|
|
|
34
39
|
const theme = useTheme();
|
|
@@ -36,6 +41,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
36
41
|
const [, t] = useLanguage();
|
|
37
42
|
const [{ user }] = useSession();
|
|
38
43
|
const [{ configs }] = useConfig();
|
|
44
|
+
const [validationFields] = useValidationFields()
|
|
39
45
|
const [card, setCard] = useState<any>(null);
|
|
40
46
|
const [isCompleted, setIsCompleted] = useState(false);
|
|
41
47
|
const [errors, setErrors] = useState('')
|
|
@@ -44,6 +50,23 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
44
50
|
const { height } = useWindowDimensions();
|
|
45
51
|
const { top, bottom } = useSafeAreaInsets();
|
|
46
52
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
53
|
+
const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
|
|
54
|
+
const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
|
|
55
|
+
const styles = StyleSheet.create({
|
|
56
|
+
container: {
|
|
57
|
+
width: '100%',
|
|
58
|
+
paddingHorizontal: 40,
|
|
59
|
+
justifyContent: 'space-between',
|
|
60
|
+
paddingBottom: 12
|
|
61
|
+
},
|
|
62
|
+
btnAddStyle: {
|
|
63
|
+
marginTop: 20,
|
|
64
|
+
borderRadius: 7.6,
|
|
65
|
+
shadowOpacity: 0,
|
|
66
|
+
height: 44,
|
|
67
|
+
marginBottom: isKeyboardShow && Platform.OS === 'ios' ? 40 : 0
|
|
68
|
+
},
|
|
69
|
+
})
|
|
47
70
|
|
|
48
71
|
let billingDetails: any = {}
|
|
49
72
|
|
|
@@ -62,24 +85,24 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
62
85
|
|
|
63
86
|
if (user?.address) {
|
|
64
87
|
billingDetails.address = {
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
line1: user?.address
|
|
89
|
+
}
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
const createPayMethod = async () => {
|
|
70
93
|
const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
|
|
71
94
|
if (Object.keys(billingDetails).length > 0) {
|
|
72
|
-
params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
|
|
95
|
+
params.paymentMethodData.billingDetails = { ...billingDetails, token: card?.last4 }
|
|
73
96
|
}
|
|
74
97
|
try {
|
|
75
98
|
setCreatePmLoading(true)
|
|
76
99
|
const { paymentMethod, error } = await createPaymentMethod(params);
|
|
77
100
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
101
|
+
if (error) {
|
|
102
|
+
setErrors(error?.message);
|
|
103
|
+
setCreatePmLoading(false)
|
|
104
|
+
return
|
|
105
|
+
}
|
|
83
106
|
|
|
84
107
|
setCreatePmLoading(false)
|
|
85
108
|
handleSource && handleSource({
|
|
@@ -102,7 +125,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
102
125
|
setErrors(error?.message || error?.toString());
|
|
103
126
|
}
|
|
104
127
|
}
|
|
105
|
-
|
|
128
|
+
|
|
106
129
|
const handleSaveCard = async () => {
|
|
107
130
|
setErrors('');
|
|
108
131
|
if (!requirements) {
|
|
@@ -111,7 +134,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
111
134
|
}
|
|
112
135
|
const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
|
|
113
136
|
if (Object.keys(billingDetails).length > 0) {
|
|
114
|
-
params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
|
|
137
|
+
params.paymentMethodData.billingDetails = { ...billingDetails, token: card?.last4 }
|
|
115
138
|
}
|
|
116
139
|
try {
|
|
117
140
|
const { setupIntent, error } = await confirmSetupIntent(requirements, params);
|
|
@@ -119,8 +142,8 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
119
142
|
if (setupIntent?.status === 'Succeeded') {
|
|
120
143
|
if (businessIds) {
|
|
121
144
|
businessIds.forEach((_businessId: any, index: any) => {
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
const _isNewCard = index === 0
|
|
146
|
+
stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
|
|
124
147
|
})
|
|
125
148
|
} else {
|
|
126
149
|
stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
|
|
@@ -145,7 +168,8 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
145
168
|
!!card?.last4 &&
|
|
146
169
|
!!card?.expiryMonth &&
|
|
147
170
|
!!card?.expiryYear &&
|
|
148
|
-
!!card?.brand
|
|
171
|
+
!!card?.brand &&
|
|
172
|
+
((!zipCodeEnabled || !zipCodeRequired || !!card?.postalCode))
|
|
149
173
|
)
|
|
150
174
|
}
|
|
151
175
|
}, [card])
|
|
@@ -172,12 +196,12 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
172
196
|
}, []);
|
|
173
197
|
|
|
174
198
|
return (
|
|
175
|
-
<View style={{ ...styles.container, height: height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
|
|
199
|
+
<View style={{ ...styles.container, height: methodsPay?.includes(paymethod) ? 'auto' : height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
|
|
176
200
|
{publicKey ? (
|
|
177
201
|
<View style={{ flex: 1 }}>
|
|
178
202
|
<StripeProvider
|
|
179
203
|
publishableKey={publicKey}
|
|
180
|
-
merchantIdentifier={
|
|
204
|
+
merchantIdentifier={merchantId}
|
|
181
205
|
urlScheme={merchantId}
|
|
182
206
|
>
|
|
183
207
|
{methodsPay?.includes(paymethod) ? (
|
|
@@ -185,13 +209,18 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
185
209
|
handleSource={handleSource}
|
|
186
210
|
onCancel={onCancel}
|
|
187
211
|
cart={cart}
|
|
212
|
+
cartTotal={cartTotal}
|
|
188
213
|
setErrors={setErrors}
|
|
189
214
|
paymethod={paymethod}
|
|
190
215
|
devMode={publicKey?.includes('test')}
|
|
216
|
+
setMethodPaySupported={setMethodPaySupported}
|
|
217
|
+
placeByMethodPay={placeByMethodPay}
|
|
218
|
+
methodPaySupported={methodPaySupported}
|
|
219
|
+
setPlaceByMethodPay={setPlaceByMethodPay}
|
|
191
220
|
/>
|
|
192
221
|
) : (
|
|
193
222
|
<CardField
|
|
194
|
-
postalCodeEnabled={
|
|
223
|
+
postalCodeEnabled={zipCodeEnabled}
|
|
195
224
|
cardStyle={{
|
|
196
225
|
backgroundColor: '#FFFFFF',
|
|
197
226
|
textColor: '#000000',
|
|
@@ -249,21 +278,6 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
249
278
|
)
|
|
250
279
|
}
|
|
251
280
|
|
|
252
|
-
const styles = StyleSheet.create({
|
|
253
|
-
container: {
|
|
254
|
-
width: '100%',
|
|
255
|
-
paddingHorizontal: 40,
|
|
256
|
-
justifyContent: 'space-between',
|
|
257
|
-
paddingBottom: 12
|
|
258
|
-
},
|
|
259
|
-
btnAddStyle: {
|
|
260
|
-
marginTop: 20,
|
|
261
|
-
borderRadius: 7.6,
|
|
262
|
-
shadowOpacity: 0,
|
|
263
|
-
height: 44
|
|
264
|
-
},
|
|
265
|
-
})
|
|
266
|
-
|
|
267
281
|
export const StripeElementsForm = (props: any) => {
|
|
268
282
|
const stripeProps = {
|
|
269
283
|
...props,
|
|
@@ -4,7 +4,10 @@ import { useApi, useSession } from 'ordering-components/native';
|
|
|
4
4
|
export const StripeElementsForm = (props: any) => {
|
|
5
5
|
const {
|
|
6
6
|
UIComponent,
|
|
7
|
-
toSave
|
|
7
|
+
toSave,
|
|
8
|
+
setCardsList,
|
|
9
|
+
cardsList,
|
|
10
|
+
handleCardClick
|
|
8
11
|
} = props;
|
|
9
12
|
|
|
10
13
|
const [ordering] = useApi();
|
|
@@ -61,6 +64,14 @@ export const StripeElementsForm = (props: any) => {
|
|
|
61
64
|
})
|
|
62
65
|
const response = await result.json();
|
|
63
66
|
isNewCard && props.onSelectCard && props.onSelectCard(response.result);
|
|
67
|
+
setCardsList && setCardsList({
|
|
68
|
+
...cardsList,
|
|
69
|
+
cards: [
|
|
70
|
+
...cardsList.cards,
|
|
71
|
+
response.result
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
handleCardClick(response.result)
|
|
64
75
|
setState({
|
|
65
76
|
...state,
|
|
66
77
|
loadingAdd: false
|
|
@@ -30,7 +30,6 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
30
30
|
upsellingProducts,
|
|
31
31
|
business,
|
|
32
32
|
handleUpsellingPage,
|
|
33
|
-
handleCloseUpsellingPage,
|
|
34
33
|
openUpselling,
|
|
35
34
|
canOpenUpselling,
|
|
36
35
|
setCanOpenUpselling,
|
|
@@ -85,13 +84,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
85
84
|
},
|
|
86
85
|
})
|
|
87
86
|
|
|
88
|
-
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
89
87
|
const [{ carts }] = useOrder()
|
|
90
88
|
const [{ parsePrice }] = useUtils()
|
|
91
89
|
const [{ configs }] = useConfig()
|
|
92
90
|
const [, t] = useLanguage()
|
|
93
91
|
const { bottom } = useSafeAreaInsets()
|
|
94
|
-
const [isCheckout, setIsCheckout] = useState(false)
|
|
95
92
|
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
96
93
|
|
|
97
94
|
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
@@ -117,7 +114,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
117
114
|
if (upsellingProducts?.products?.length && !isFromCart) {
|
|
118
115
|
setCanOpenUpselling && setCanOpenUpselling(true)
|
|
119
116
|
} else {
|
|
120
|
-
handleUpsellingPage && handleUpsellingPage()
|
|
117
|
+
handleUpsellingPage && handleUpsellingPage(cart)
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
}
|
|
@@ -199,6 +196,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
199
196
|
{showCartList && cartList.map((cart: any, i: number) => (
|
|
200
197
|
<CartList key={i}>
|
|
201
198
|
<Cart
|
|
199
|
+
isFromUpselling
|
|
202
200
|
cart={cart}
|
|
203
201
|
cartuuid={cart.uuid}
|
|
204
202
|
hideUpselling
|
|
@@ -224,10 +222,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
224
222
|
text={t('CHECKOUT', 'Checkout')}
|
|
225
223
|
style={{ ...styles.closeUpsellingButton }}
|
|
226
224
|
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
227
|
-
onClick={() =>
|
|
228
|
-
handleUpsellingPage()
|
|
229
|
-
setIsCheckout(true)
|
|
230
|
-
}}
|
|
225
|
+
onClick={() => handleUpsellingPage(cart)}
|
|
231
226
|
/>
|
|
232
227
|
</View>
|
|
233
228
|
</>
|
|
@@ -243,11 +238,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
243
238
|
{props.isPage ? (
|
|
244
239
|
<UpsellingContent />
|
|
245
240
|
) : (
|
|
246
|
-
canOpenUpselling &&
|
|
241
|
+
canOpenUpselling && (
|
|
247
242
|
<OBottomPopup
|
|
248
243
|
title={''}
|
|
249
244
|
open={openUpselling}
|
|
250
|
-
onClose={() => handleUpsellingPage()}
|
|
245
|
+
onClose={() => handleUpsellingPage(cart)}
|
|
251
246
|
isStatusBar
|
|
252
247
|
>
|
|
253
248
|
<UpsellingContent />
|
|
@@ -34,7 +34,8 @@ const UserDetailsUI = (props: any) => {
|
|
|
34
34
|
isCheckout,
|
|
35
35
|
handleSendVerifyCode,
|
|
36
36
|
verifyPhoneState,
|
|
37
|
-
setFormState
|
|
37
|
+
setFormState,
|
|
38
|
+
setIsOpen
|
|
38
39
|
} = props
|
|
39
40
|
|
|
40
41
|
const theme = useTheme();
|
|
@@ -209,6 +210,7 @@ const UserDetailsUI = (props: any) => {
|
|
|
209
210
|
isCheckout={isCheckout}
|
|
210
211
|
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
211
212
|
setIsSubmit={setIsSubmit}
|
|
213
|
+
setIsOpen={setIsOpen}
|
|
212
214
|
/>
|
|
213
215
|
)}
|
|
214
216
|
</UDContainer>
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Platform, StyleSheet, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { Platform, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
3
|
import { useSession, useLanguage, ToastType, useToast, useConfig } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { useForm, Controller } from 'react-hook-form';
|
|
6
|
+
import { SignupForm } from '../SignupForm'
|
|
6
7
|
|
|
7
8
|
import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
|
|
8
9
|
|
|
9
|
-
import { OText, OButton, OInput } from '../shared';
|
|
10
|
+
import { OText, OButton, OInput, OModal, OIcon } from '../shared';
|
|
11
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
10
12
|
|
|
11
13
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
12
14
|
import { sortInputFields } from '../../utils';
|
|
15
|
+
import { ListItem } from '../UserProfile/styles';
|
|
13
16
|
|
|
14
17
|
export const UserFormDetailsUI = (props: any) => {
|
|
15
18
|
const {
|
|
@@ -27,6 +30,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
27
30
|
phoneUpdate,
|
|
28
31
|
hideUpdateButton,
|
|
29
32
|
setWillVerifyOtpState,
|
|
33
|
+
handlePlaceOrderAsGuest,
|
|
34
|
+
isCheckout,
|
|
35
|
+
setIsOpen,
|
|
36
|
+
handleRemoveAccount,
|
|
37
|
+
isProfile
|
|
30
38
|
} = props;
|
|
31
39
|
|
|
32
40
|
const theme = useTheme();
|
|
@@ -68,10 +76,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
68
76
|
const [, { showToast }] = useToast();
|
|
69
77
|
const { handleSubmit, control, errors, setValue } = useForm();
|
|
70
78
|
|
|
71
|
-
const [{ user }] = useSession();
|
|
79
|
+
const [{ user }, { login }] = useSession();
|
|
72
80
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
73
81
|
const [isValid, setIsValid] = useState(false)
|
|
74
82
|
const [isChanged, setIsChanged] = useState(false)
|
|
83
|
+
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
75
84
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
76
85
|
error: '',
|
|
77
86
|
phone: {
|
|
@@ -79,9 +88,19 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
79
88
|
cellphone: null,
|
|
80
89
|
},
|
|
81
90
|
});
|
|
91
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
82
92
|
|
|
93
|
+
const isAdmin = user?.level === 0
|
|
83
94
|
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
84
95
|
|
|
96
|
+
const handleSuccessSignup = (user: any) => {
|
|
97
|
+
login({
|
|
98
|
+
user,
|
|
99
|
+
token: user?.session?.access_token
|
|
100
|
+
})
|
|
101
|
+
handlePlaceOrderAsGuest && handlePlaceOrderAsGuest()
|
|
102
|
+
}
|
|
103
|
+
|
|
85
104
|
const getInputRules = (field: any) => {
|
|
86
105
|
const rules: any = {
|
|
87
106
|
required: isRequiredField(field.code)
|
|
@@ -187,6 +206,18 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
187
206
|
handleChangeInput(countryCode, true);
|
|
188
207
|
}
|
|
189
208
|
|
|
209
|
+
const onRemoveAccount = () => {
|
|
210
|
+
setConfirm({
|
|
211
|
+
open: true,
|
|
212
|
+
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
213
|
+
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
214
|
+
handleOnAccept: () => {
|
|
215
|
+
setConfirm({ ...confirm, open: false })
|
|
216
|
+
handleRemoveAccount && handleRemoveAccount(user?.id)
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
190
221
|
useEffect(() => {
|
|
191
222
|
if (Object.keys(errors).length > 0) {
|
|
192
223
|
const list = Object.values(errors);
|
|
@@ -206,6 +237,10 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
206
237
|
if (!formState?.loading && formState?.result?.error) {
|
|
207
238
|
formState.result?.result &&
|
|
208
239
|
showToast(ToastType.Error, formState.result?.result[0]);
|
|
240
|
+
if (isCheckout) {
|
|
241
|
+
setIsOpen && setIsOpen(false)
|
|
242
|
+
cleanFormState && cleanFormState({ changes: {} })
|
|
243
|
+
}
|
|
209
244
|
}
|
|
210
245
|
}, [formState?.loading]);
|
|
211
246
|
|
|
@@ -389,6 +424,12 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
389
424
|
)}
|
|
390
425
|
</UDWrapper>
|
|
391
426
|
)}
|
|
427
|
+
{isProfile && (
|
|
428
|
+
<ListItem disabled={isAdmin} onPress={() => onRemoveAccount()} activeOpacity={0.7}>
|
|
429
|
+
<OIcon src={theme.images.general.user} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
430
|
+
<OText size={14} lineHeight={24} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1 }} color={theme.colors.danger5}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
|
|
431
|
+
</ListItem>
|
|
432
|
+
)}
|
|
392
433
|
{validationFields?.loading && (
|
|
393
434
|
<UDLoader>
|
|
394
435
|
<OText size={12}>{t('LOADING', 'Loading')}</OText>
|
|
@@ -407,8 +448,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
407
448
|
? t('UPDATING', 'Updating...')
|
|
408
449
|
: t('UPDATE', 'Update')
|
|
409
450
|
}
|
|
410
|
-
bgColor={theme.colors.
|
|
411
|
-
textStyle={{ color: theme.colors.
|
|
451
|
+
bgColor={theme.colors.primary}
|
|
452
|
+
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
412
453
|
borderColor={theme.colors.primary}
|
|
413
454
|
isDisabled={formState.loading}
|
|
414
455
|
imgRightSrc={null}
|
|
@@ -423,18 +464,46 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
423
464
|
text={
|
|
424
465
|
formState.loading
|
|
425
466
|
? t('UPDATING', 'Updating...')
|
|
426
|
-
:
|
|
467
|
+
: ((isCheckout && !!user?.guest_id)
|
|
468
|
+
? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
|
|
469
|
+
: t('CONTINUE', 'Continue'))
|
|
427
470
|
}
|
|
428
471
|
bgColor={theme.colors.white}
|
|
429
472
|
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
430
473
|
borderColor={theme.colors.primary}
|
|
431
|
-
isDisabled={formState.loading || !isValid}
|
|
474
|
+
isDisabled={!user?.guest_id && (formState.loading || !isValid)}
|
|
432
475
|
imgRightSrc={null}
|
|
433
476
|
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
|
|
434
|
-
onClick={handleSubmit(onSubmit)}
|
|
477
|
+
onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
|
|
435
478
|
/>
|
|
436
479
|
)}
|
|
480
|
+
{isCheckout && !!user?.guest_id && (
|
|
481
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={() => handlePlaceOrderAsGuest()}>
|
|
482
|
+
<OText color={theme.colors.primary} style={{ textAlign: 'center' }}>{t('PLACE_ORDER_AS_GUEST', 'Place order as guest')}</OText>
|
|
483
|
+
</TouchableOpacity>
|
|
484
|
+
)}
|
|
485
|
+
<OModal
|
|
486
|
+
open={isModalOpen}
|
|
487
|
+
onClose={() => setIsModalOpen(false)}
|
|
488
|
+
>
|
|
489
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
490
|
+
<SignupForm
|
|
491
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
492
|
+
isGuest
|
|
493
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
494
|
+
useSignupByEmail
|
|
495
|
+
useChekoutFileds
|
|
496
|
+
/>
|
|
497
|
+
</ScrollView>
|
|
498
|
+
</OModal>
|
|
499
|
+
<OAlert
|
|
500
|
+
open={confirm.open}
|
|
501
|
+
title={confirm.title}
|
|
502
|
+
content={confirm.content}
|
|
503
|
+
onAccept={confirm.handleOnAccept}
|
|
504
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
505
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
506
|
+
/>
|
|
437
507
|
</>
|
|
438
508
|
);
|
|
439
509
|
};
|
|
440
|
-
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
} from './styles';
|
|
36
36
|
import { useWindowDimensions } from 'react-native';
|
|
37
37
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
38
|
-
import styled from 'styled-components';
|
|
39
38
|
import ToggleSwitch from 'toggle-switch-react-native';
|
|
40
39
|
|
|
41
40
|
const ProfileListUI = (props: ProfileParams) => {
|
|
@@ -49,7 +48,7 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
49
48
|
|
|
50
49
|
const theme = useTheme();
|
|
51
50
|
|
|
52
|
-
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
51
|
+
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
53
52
|
const hideProfileImage = theme?.profile?.components?.picture?.hidden
|
|
54
53
|
const hideOrders = theme?.profile?.components?.orders?.hidden
|
|
55
54
|
const hideProfile = theme?.profile?.components?.profile?.hidden
|
|
@@ -60,7 +59,7 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
60
59
|
const hideSession = theme?.bar_menu?.components?.sessions?.hidden
|
|
61
60
|
const hidePromotions = theme?.bar_menu?.components?.promotions?.hidden
|
|
62
61
|
const hideAddressList = theme?.profile?.components?.address_list?.hidden
|
|
63
|
-
const showLanguages =
|
|
62
|
+
const showLanguages = theme?.profile?.components?.languages?.hidden
|
|
64
63
|
const showNotifications = !theme?.profile?.components?.notification_settings?.hidden
|
|
65
64
|
const langPickerStyle = StyleSheet.create({
|
|
66
65
|
inputAndroid: {
|
|
@@ -118,8 +117,6 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
118
117
|
const [, { showToast }] = useToast();
|
|
119
118
|
const { errors } = useForm();
|
|
120
119
|
|
|
121
|
-
const isAdmin = user?.level === 0
|
|
122
|
-
|
|
123
120
|
const { height } = useWindowDimensions();
|
|
124
121
|
const { top, bottom } = useSafeAreaInsets();
|
|
125
122
|
|
|
@@ -153,19 +150,8 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
153
150
|
|
|
154
151
|
const detailProps = {
|
|
155
152
|
goToBack: () => props.navigation?.canGoBack() && props.navigation.goBack(),
|
|
156
|
-
onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const onRemoveAccount = () => {
|
|
160
|
-
setConfirm({
|
|
161
|
-
open: true,
|
|
162
|
-
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
163
|
-
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
164
|
-
handleOnAccept: () => {
|
|
165
|
-
setConfirm({ ...confirm, open: false })
|
|
166
|
-
handleRemoveAccount && handleRemoveAccount(user?.id)
|
|
167
|
-
}
|
|
168
|
-
})
|
|
153
|
+
onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params),
|
|
154
|
+
handleRemoveAccount
|
|
169
155
|
}
|
|
170
156
|
|
|
171
157
|
useEffect(() => {
|
|
@@ -175,7 +161,7 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
175
161
|
}, [removeAccountState])
|
|
176
162
|
|
|
177
163
|
return (
|
|
178
|
-
<View style={{ flex: 1, height:
|
|
164
|
+
<View style={{ flex: 1, height: '100%', paddingTop: 20 }}>
|
|
179
165
|
<CenterView style={styles.pagePadding}>
|
|
180
166
|
{user?.photo && !hideProfileImage && (
|
|
181
167
|
<View style={styles.photo}>
|
|
@@ -238,11 +224,11 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
238
224
|
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
|
|
239
225
|
</ListItem>
|
|
240
226
|
)}
|
|
241
|
-
{
|
|
227
|
+
{showNotifications && (
|
|
242
228
|
<ListItem onPress={() => navigation.navigate('Notifications', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
|
|
243
229
|
<NotificationBadge style={{ borderRadius: 100 / 2 }} />
|
|
244
230
|
<Ionicons name='notifications-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
245
|
-
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('
|
|
231
|
+
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MARKETING_NOTIFICATIONS', 'Marketing notifications')}
|
|
246
232
|
</OText>
|
|
247
233
|
<NotificationsWrapper>
|
|
248
234
|
<ToggleSwitch
|
|
@@ -275,17 +261,13 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
275
261
|
)}
|
|
276
262
|
</Actions>
|
|
277
263
|
|
|
278
|
-
<Actions>
|
|
264
|
+
<Actions style={{ paddingTop: height * .02 }}>
|
|
279
265
|
{!showLanguages && (
|
|
280
266
|
<LanguageSelector iconColor={theme.colors.textNormal} pickerStyle={langPickerStyle} />
|
|
281
267
|
)}
|
|
282
268
|
<View style={{ height: 17 }} />
|
|
283
269
|
<LogoutButton color={theme.colors.textNormal} text={t('LOGOUT', 'Logout')} />
|
|
284
270
|
<View style={{ height: 17 }} />
|
|
285
|
-
<ListItem disabled={isAdmin} onPress={() => onRemoveAccount()} activeOpacity={0.7}>
|
|
286
|
-
<OIcon src={theme.images.general.user} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
287
|
-
<OText size={14} lineHeight={24} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1 }} color={theme.colors.danger5}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
|
|
288
|
-
</ListItem>
|
|
289
271
|
</Actions>
|
|
290
272
|
</ListWrap>
|
|
291
273
|
<OAlert
|