ordering-ui-react-native 0.15.21 → 0.15.23-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 +5 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessTypeFilter/index.tsx +12 -2
- package/src/components/BusinessTypeFilter/styles.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +0 -1
- package/src/components/LanguageSelector/index.tsx +1 -0
- package/src/components/OrderDetails/index.tsx +26 -5
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/config.json +0 -2
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/Checkout.tsx +1 -1
- package/src/pages/Sessions.tsx +22 -0
- package/src/types/index.tsx +3 -9
- package/src/utils/index.tsx +68 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
- package/themes/business/src/components/Chat/index.tsx +38 -86
- 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/Business.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +22 -13
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
- package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
- package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
- package/themes/business/src/components/OrdersOption/index.tsx +53 -49
- package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
- package/themes/business/src/types/index.tsx +2 -1
- 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/BusinessController/index.tsx +27 -6
- package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +48 -21
- package/themes/kiosk/src/components/Cart/index.tsx +98 -24
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
- package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
- package/themes/kiosk/src/components/Intro/index.tsx +13 -13
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
- 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/OrderDetails/index.tsx +136 -41
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
- package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
- package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +178 -1
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +56 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- 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 +52 -22
- 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 +127 -20
- package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +48 -57
- package/themes/original/src/components/Cart/index.tsx +18 -14
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +42 -27
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/GoogleMap/index.tsx +1 -0
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -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/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +34 -25
- 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 +34 -27
- package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- 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/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/index.tsx +25 -33
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -4
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
- package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
- package/themes/original/src/components/ProductForm/index.tsx +40 -33
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
- package/themes/original/src/components/Promotions/index.tsx +250 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +10 -4
- package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
- package/themes/original/src/components/UserProfile/index.tsx +62 -14
- package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +75 -8
- 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 +46 -4
- package/themes/original/src/utils/index.tsx +12 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/StripeMethodForm/index.tsx +0 -168
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
UpsellingPage as UpsellingPageController,
|
|
5
5
|
useUtils,
|
|
6
6
|
useLanguage,
|
|
7
|
-
|
|
7
|
+
useOrder
|
|
8
8
|
} from 'ordering-components/native'
|
|
9
9
|
import { useTheme } from 'styled-components/native';
|
|
10
10
|
import { OText, OIcon, OBottomPopup, OButton } from '../shared'
|
|
@@ -62,7 +62,19 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
62
62
|
borderRadius: 7.6,
|
|
63
63
|
borderColor: theme.colors.textSecondary,
|
|
64
64
|
height: 38
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
headerItem: {
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
marginVertical: 2,
|
|
70
|
+
marginHorizontal: 20,
|
|
71
|
+
},
|
|
72
|
+
btnBackArrow: {
|
|
73
|
+
borderWidth: 0,
|
|
74
|
+
backgroundColor: theme.colors.clear,
|
|
75
|
+
shadowColor: theme.colors.clear,
|
|
76
|
+
padding: 40,
|
|
77
|
+
},
|
|
66
78
|
})
|
|
67
79
|
|
|
68
80
|
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
@@ -77,11 +89,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
77
89
|
? cart?.products.map((product: any) => product.id)
|
|
78
90
|
: []
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
const productsList = !upsellingProducts.loading && !upsellingProducts.error
|
|
93
|
+
? upsellingProducts?.products?.length
|
|
94
|
+
? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
|
|
95
|
+
: (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
|
|
96
|
+
: []
|
|
85
97
|
|
|
86
98
|
useEffect(() => {
|
|
87
99
|
if (!isCustomMode && !props.products) {
|
|
@@ -100,10 +112,10 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
100
112
|
}, [cart, isCheckout])
|
|
101
113
|
|
|
102
114
|
const handleFormProduct = (product: any) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
116
|
+
product: product,
|
|
117
|
+
businessId: product?.api?.businessId,
|
|
118
|
+
businessSlug: business.slug,
|
|
107
119
|
})
|
|
108
120
|
}
|
|
109
121
|
|
|
@@ -119,8 +131,8 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
119
131
|
!upsellingProducts.loading && (
|
|
120
132
|
<>
|
|
121
133
|
{
|
|
122
|
-
!upsellingProducts.error ? productsList.map((product: any) => (
|
|
123
|
-
<Item key={product.id}>
|
|
134
|
+
!upsellingProducts.error ? productsList.map((product: any, i: number) => (
|
|
135
|
+
<Item key={`${product.id}_${i}`}>
|
|
124
136
|
<View style={{ flexBasis: '57%' }}>
|
|
125
137
|
<Details>
|
|
126
138
|
<OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
|
|
@@ -148,50 +160,54 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
148
160
|
)
|
|
149
161
|
}
|
|
150
162
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
163
|
+
const UpsellingContent = () => {
|
|
164
|
+
return (
|
|
165
|
+
<>
|
|
166
|
+
<View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 70 }}>
|
|
167
|
+
<OButton
|
|
168
|
+
imgLeftSrc={theme.images.general.arrow_left}
|
|
169
|
+
imgRightSrc={null}
|
|
170
|
+
style={styles.btnBackArrow}
|
|
171
|
+
onClick={() => onGoBack()}
|
|
172
|
+
imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
|
|
173
|
+
/>
|
|
174
|
+
</View>
|
|
175
|
+
<ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
176
|
+
{productsList.length > 0 &&
|
|
177
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
178
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
179
|
+
<UpsellingLayout />
|
|
180
|
+
</View>
|
|
181
|
+
}
|
|
182
|
+
<View style={{ paddingHorizontal: 40 }}>
|
|
183
|
+
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
184
|
+
<OrderSummary
|
|
185
|
+
cart={cart}
|
|
186
|
+
isCartPending={cart?.status === 2}
|
|
187
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
188
|
+
/>
|
|
189
|
+
</View>
|
|
190
|
+
</ScrollView>
|
|
191
|
+
<View
|
|
192
|
+
style={{
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<OButton
|
|
198
|
+
imgRightSrc=''
|
|
199
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
200
|
+
style={{ ...styles.closeUpsellingButton }}
|
|
201
|
+
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
202
|
+
onClick={() => {
|
|
203
|
+
handleUpsellingPage()
|
|
204
|
+
setIsCheckout(true)
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
208
|
+
</>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
195
211
|
|
|
196
212
|
return (
|
|
197
213
|
<>
|
|
@@ -199,20 +215,20 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
199
215
|
<UpsellingLayout />
|
|
200
216
|
) : (
|
|
201
217
|
<>
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
{props.isPage ? (
|
|
219
|
+
<UpsellingContent />
|
|
220
|
+
) : (
|
|
221
|
+
canOpenUpselling && !modalIsOpen && (
|
|
222
|
+
<OBottomPopup
|
|
223
|
+
title={''}
|
|
224
|
+
open={openUpselling}
|
|
225
|
+
onClose={() => handleUpsellingPage()}
|
|
226
|
+
isStatusBar
|
|
227
|
+
>
|
|
228
|
+
<UpsellingContent />
|
|
229
|
+
</OBottomPopup>
|
|
230
|
+
)
|
|
231
|
+
)}
|
|
216
232
|
</>
|
|
217
233
|
)}
|
|
218
234
|
</>
|
|
@@ -3,17 +3,14 @@ import { TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
4
4
|
|
|
5
5
|
import { UDContainer, UDHeader, UDForm, UDInfo, EditBtn } from './styles';
|
|
6
|
+
|
|
6
7
|
import {
|
|
7
8
|
UserFormDetails as UserFormController,
|
|
8
9
|
useLanguage,
|
|
9
10
|
useSession,
|
|
10
|
-
ToastType,
|
|
11
|
-
useToast
|
|
12
11
|
} from 'ordering-components/native';
|
|
13
12
|
import { useTheme } from 'styled-components/native';
|
|
14
|
-
import { OIcon, OText
|
|
15
|
-
import { VerifyPhone } from '../VerifyPhone';
|
|
16
|
-
import Spinner from 'react-native-loading-spinner-overlay';
|
|
13
|
+
import { OIcon, OText } from '../shared';
|
|
17
14
|
|
|
18
15
|
import { UserFormDetailsUI } from '../UserFormDetails';
|
|
19
16
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
@@ -29,33 +26,15 @@ const UserDetailsUI = (props: any) => {
|
|
|
29
26
|
isUserDetailsEdit,
|
|
30
27
|
phoneUpdate,
|
|
31
28
|
togglePhoneUpdate,
|
|
32
|
-
isCheckout
|
|
33
|
-
checkPhoneCodeState,
|
|
34
|
-
handleSendVerifyCode,
|
|
35
|
-
handleCheckPhoneCode,
|
|
36
|
-
verifyPhoneState,
|
|
37
|
-
isVerifiedPhone,
|
|
38
|
-
setCheckPhoneCodeState
|
|
29
|
+
isCheckout
|
|
39
30
|
} = props
|
|
40
31
|
|
|
41
32
|
const theme = useTheme();
|
|
42
33
|
|
|
43
34
|
const [, t] = useLanguage()
|
|
44
35
|
const [{ user }] = useSession()
|
|
45
|
-
const [, { showToast }] = useToast();
|
|
46
|
-
|
|
47
36
|
const userData = props.userData || (!formState.result.error && formState.result?.result) || user
|
|
48
37
|
|
|
49
|
-
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
50
|
-
const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
|
|
51
|
-
const [phoneInputData, setPhoneInputData] = useState({
|
|
52
|
-
error: '',
|
|
53
|
-
phone: {
|
|
54
|
-
country_phone_code: null,
|
|
55
|
-
cellphone: null,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
38
|
|
|
60
39
|
useEffect(() => {
|
|
61
40
|
if (isUserDetailsEdit) {
|
|
@@ -76,54 +55,6 @@ const UserDetailsUI = (props: any) => {
|
|
|
76
55
|
}
|
|
77
56
|
}, [user?.country_phone_code])
|
|
78
57
|
|
|
79
|
-
const handleVerifyCodeClick = () => {
|
|
80
|
-
if (formState?.changes?.cellphone && formState?.changes?.country_phone_code) {
|
|
81
|
-
const { cellphone, country_phone_code: countryPhoneCode } = formState?.changes
|
|
82
|
-
|
|
83
|
-
setPhoneInputData({
|
|
84
|
-
error: '',
|
|
85
|
-
phone: {
|
|
86
|
-
country_phone_code: countryPhoneCode,
|
|
87
|
-
cellphone: cellphone,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
handleSendVerifyCode({
|
|
91
|
-
cellphone: cellphone,
|
|
92
|
-
country_phone_code: countryPhoneCode
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (willVerifyOtpState) handleVerifyCodeClick()
|
|
99
|
-
}, [willVerifyOtpState])
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (verifyPhoneState && !verifyPhoneState?.loading) {
|
|
103
|
-
if (verifyPhoneState.result?.error) {
|
|
104
|
-
const message = typeof verifyPhoneState?.result?.result === 'string'
|
|
105
|
-
? verifyPhoneState?.result?.result
|
|
106
|
-
: verifyPhoneState?.result?.result[0]
|
|
107
|
-
verifyPhoneState.result?.result && showToast(
|
|
108
|
-
ToastType.Error,
|
|
109
|
-
message
|
|
110
|
-
)
|
|
111
|
-
setWillVerifyOtpState(false)
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const okResult = verifyPhoneState.result?.result === 'OK'
|
|
116
|
-
if (okResult) {
|
|
117
|
-
!isModalVisible && setIsModalVisible(true)
|
|
118
|
-
setWillVerifyOtpState(false)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, [verifyPhoneState])
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (isVerifiedPhone) setIsModalVisible(false)
|
|
125
|
-
}, [isVerifiedPhone])
|
|
126
|
-
|
|
127
58
|
return (
|
|
128
59
|
<>
|
|
129
60
|
{(validationFields.loading || formState.loading) && (
|
|
@@ -186,32 +117,10 @@ const UserDetailsUI = (props: any) => {
|
|
|
186
117
|
)}
|
|
187
118
|
</UDInfo>
|
|
188
119
|
) : (
|
|
189
|
-
<UserFormDetailsUI
|
|
190
|
-
{...props}
|
|
191
|
-
phoneUpdate={phoneUpdate}
|
|
192
|
-
togglePhoneUpdate={togglePhoneUpdate}
|
|
193
|
-
isCheckout={isCheckout}
|
|
194
|
-
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
195
|
-
/>
|
|
120
|
+
<UserFormDetailsUI {...props} phoneUpdate={phoneUpdate} togglePhoneUpdate={togglePhoneUpdate} isCheckout={isCheckout} />
|
|
196
121
|
)}
|
|
197
122
|
</UDContainer>
|
|
198
123
|
)}
|
|
199
|
-
<OModal
|
|
200
|
-
open={isModalVisible}
|
|
201
|
-
onClose={() => setIsModalVisible(false)}
|
|
202
|
-
entireModal
|
|
203
|
-
>
|
|
204
|
-
<VerifyPhone
|
|
205
|
-
phone={phoneInputData.phone}
|
|
206
|
-
verifyPhoneState={verifyPhoneState}
|
|
207
|
-
checkPhoneCodeState={checkPhoneCodeState}
|
|
208
|
-
handleCheckPhoneCode={handleCheckPhoneCode}
|
|
209
|
-
setCheckPhoneCodeState={setCheckPhoneCodeState}
|
|
210
|
-
handleVerifyCodeClick={handleVerifyCodeClick}
|
|
211
|
-
onClose={() => setIsModalVisible(false)}
|
|
212
|
-
/>
|
|
213
|
-
</OModal>
|
|
214
|
-
<Spinner visible={verifyPhoneState?.loading} />
|
|
215
124
|
</>
|
|
216
125
|
)
|
|
217
126
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Platform, StyleSheet,
|
|
2
|
+
import { Platform, StyleSheet, TouchableOpacity } 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';
|
|
@@ -25,8 +25,6 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
25
25
|
handleButtonUpdateClick,
|
|
26
26
|
phoneUpdate,
|
|
27
27
|
hideUpdateButton,
|
|
28
|
-
setWillVerifyOtpState,
|
|
29
|
-
isVerifiedPhone,
|
|
30
28
|
handleChangePromotions
|
|
31
29
|
} = props;
|
|
32
30
|
|
|
@@ -141,8 +139,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
141
139
|
if (
|
|
142
140
|
formState.changes?.cellphone === null &&
|
|
143
141
|
((validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
143
|
+
configs?.verification_phone_required?.value === '1')
|
|
146
144
|
) {
|
|
147
145
|
showToast(
|
|
148
146
|
ToastType.Error,
|
|
@@ -153,9 +151,6 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
153
151
|
);
|
|
154
152
|
return;
|
|
155
153
|
}
|
|
156
|
-
if (formState?.changes?.cellphone && !isVerifiedPhone) {
|
|
157
|
-
showToast(ToastType.Error, t('VERIFY_ERROR_PHONE_NUMBER', 'The Phone Number field is not verified'))
|
|
158
|
-
}
|
|
159
154
|
let changes = null;
|
|
160
155
|
if (user?.cellphone && !userPhoneNumber) {
|
|
161
156
|
changes = {
|
|
@@ -182,6 +177,16 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
182
177
|
handleChangeInput(phoneNumber, true);
|
|
183
178
|
};
|
|
184
179
|
|
|
180
|
+
const changeCountry = (country: any) => {
|
|
181
|
+
let countryCode = {
|
|
182
|
+
country_code: {
|
|
183
|
+
name: 'country_code',
|
|
184
|
+
value: country.cca2
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
handleChangeInput(countryCode, true);
|
|
188
|
+
}
|
|
189
|
+
|
|
185
190
|
useEffect(() => {
|
|
186
191
|
if (Object.keys(errors).length > 0) {
|
|
187
192
|
const list = Object.values(errors);
|
|
@@ -216,13 +221,6 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
}, [user, isEdit]);
|
|
219
|
-
|
|
220
|
-
useEffect(() => {
|
|
221
|
-
if (!phoneInputData.error && phoneInputData?.phone?.country_phone_code && phoneInputData?.phone?.cellphone) {
|
|
222
|
-
setWillVerifyOtpState(true)
|
|
223
|
-
}
|
|
224
|
-
}, [phoneInputData])
|
|
225
|
-
|
|
226
224
|
return (
|
|
227
225
|
<>
|
|
228
226
|
<UDForm>
|
|
@@ -315,6 +313,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
315
313
|
<PhoneInputNumber
|
|
316
314
|
data={phoneInputData}
|
|
317
315
|
handleData={(val: any) => handleChangePhoneNumber(val)}
|
|
316
|
+
changeCountry={(val: any) => changeCountry(val)}
|
|
318
317
|
defaultValue={phoneUpdate ? '' : user?.cellphone}
|
|
319
318
|
defaultCode={user?.country_phone_code || null}
|
|
320
319
|
boxStyle={styles.phoneSelect}
|
|
@@ -368,16 +367,18 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
368
367
|
rules={getInputRules({ name: 'password', code: 'password' })}
|
|
369
368
|
defaultValue=''
|
|
370
369
|
/>
|
|
371
|
-
<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
<Controller
|
|
371
|
+
control={control}
|
|
372
|
+
render={({ onChange, value }: any) => (
|
|
373
|
+
<TouchableOpacity
|
|
374
|
+
style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}
|
|
375
|
+
onPress={() => {
|
|
376
|
+
onChange(!value)
|
|
377
|
+
handleChangePromotions(!value)
|
|
378
|
+
}}
|
|
379
|
+
>
|
|
375
380
|
<CheckBox
|
|
376
381
|
value={value}
|
|
377
|
-
onValueChange={newValue => {
|
|
378
|
-
onChange(newValue)
|
|
379
|
-
handleChangePromotions(newValue)
|
|
380
|
-
}}
|
|
381
382
|
boxType={'square'}
|
|
382
383
|
tintColors={{
|
|
383
384
|
true: theme.colors.primary,
|
|
@@ -388,14 +389,14 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
388
389
|
onTintColor={theme.colors.primary}
|
|
389
390
|
style={Platform.OS === 'ios' && styles.checkBoxStyle}
|
|
390
391
|
/>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
392
|
+
<OText style={{ fontSize: 14, paddingHorizontal: 5, paddingLeft: 10 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
|
|
393
|
+
</TouchableOpacity>
|
|
394
|
+
)}
|
|
395
|
+
name='promotions'
|
|
396
|
+
defaultValue={formState?.result?.result
|
|
397
|
+
? !!formState?.result?.result?.settings?.notification?.newsletter
|
|
398
|
+
: !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
|
|
399
|
+
/>
|
|
399
400
|
</UDWrapper>
|
|
400
401
|
)}
|
|
401
402
|
{validationFields?.loading && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
UserFormDetails as UserProfileController,
|
|
4
4
|
useSession,
|
|
@@ -16,7 +16,10 @@ import { LogoutButton } from '../LogoutButton'
|
|
|
16
16
|
import { LanguageSelector } from '../LanguageSelector'
|
|
17
17
|
import MessageCircle from 'react-native-vector-icons/AntDesign'
|
|
18
18
|
import Ionicons from 'react-native-vector-icons/Ionicons'
|
|
19
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
20
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
19
21
|
import FastImage from 'react-native-fast-image'
|
|
22
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
20
23
|
|
|
21
24
|
import {
|
|
22
25
|
OIcon,
|
|
@@ -34,7 +37,9 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
|
34
37
|
const ProfileListUI = (props: ProfileParams) => {
|
|
35
38
|
const {
|
|
36
39
|
navigation,
|
|
37
|
-
formState
|
|
40
|
+
formState,
|
|
41
|
+
handleRemoveAccount,
|
|
42
|
+
removeAccountState
|
|
38
43
|
} = props;
|
|
39
44
|
|
|
40
45
|
const theme = useTheme();
|
|
@@ -91,17 +96,21 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
|
|
94
|
-
const [{ user }] = useSession();
|
|
99
|
+
const [{ user }, { logout }] = useSession();
|
|
95
100
|
const [, t] = useLanguage();
|
|
96
101
|
const [{ configs }] = useConfig();
|
|
97
102
|
const [, { showToast }] = useToast();
|
|
98
103
|
const { errors } = useForm();
|
|
99
104
|
|
|
105
|
+
const isAdmin = user?.level === 0
|
|
106
|
+
|
|
100
107
|
const { height } = useWindowDimensions();
|
|
101
108
|
const { top, bottom } = useSafeAreaInsets();
|
|
102
109
|
|
|
103
|
-
const
|
|
110
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
104
111
|
|
|
112
|
+
const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
|
|
113
|
+
const IsPromotionsEnabled = configs?.advanced_offers_module?.value === '1' || configs?.advanced_offers_module?.value === true
|
|
105
114
|
const onRedirect = (route: string, params?: any) => {
|
|
106
115
|
navigation.navigate(route, params)
|
|
107
116
|
}
|
|
@@ -135,14 +144,32 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
135
144
|
onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params)
|
|
136
145
|
}
|
|
137
146
|
|
|
147
|
+
const onRemoveAccount = () => {
|
|
148
|
+
setConfirm({
|
|
149
|
+
open: true,
|
|
150
|
+
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
151
|
+
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
152
|
+
handleOnAccept: () => {
|
|
153
|
+
setConfirm({ ...confirm, open: false })
|
|
154
|
+
handleRemoveAccount && handleRemoveAccount(user?.id)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (removeAccountState?.result === 'OK') {
|
|
161
|
+
logout()
|
|
162
|
+
}
|
|
163
|
+
}, [removeAccountState])
|
|
164
|
+
|
|
138
165
|
return (
|
|
139
|
-
<View style={{ flex: 1, height: height - top - bottom - 62 }}>
|
|
140
|
-
<OText size={24} style={{ marginTop: 15, paddingHorizontal: 40 }}>
|
|
166
|
+
<View style={{ flex: 1, height: height - top - bottom - 62, paddingTop: 20 }}>
|
|
167
|
+
{/* <OText size={24} style={{ marginTop: 15, paddingHorizontal: 40 }}>
|
|
141
168
|
{t('PROFILE', 'Profile')}
|
|
142
|
-
</OText>
|
|
169
|
+
</OText> */}
|
|
143
170
|
<CenterView style={styles.pagePadding}>
|
|
144
|
-
|
|
145
|
-
{
|
|
171
|
+
{user?.photo && (
|
|
172
|
+
<View style={styles.photo}>
|
|
146
173
|
<FastImage
|
|
147
174
|
style={{ height: 60, width: 60, borderRadius: 8 }}
|
|
148
175
|
source={{
|
|
@@ -151,10 +178,8 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
151
178
|
}}
|
|
152
179
|
resizeMode={FastImage.resizeMode.cover}
|
|
153
180
|
/>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
)}
|
|
157
|
-
</View>
|
|
181
|
+
</View>
|
|
182
|
+
)}
|
|
158
183
|
<View style={{ flexBasis: '70%' }}>
|
|
159
184
|
<OText size={20} lineHeight={30} weight={Platform.OS === 'ios' ? '500' : 'bold'} color={theme.colors.textNormal}>{user?.name} {user?.lastname}</OText>
|
|
160
185
|
<TouchableOpacity onPress={() => navigation.navigate('ProfileForm', { ...detailProps })}>
|
|
@@ -168,7 +193,7 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
168
193
|
<Actions>
|
|
169
194
|
<ListItem onPress={() => onRedirect('AddressList', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
|
|
170
195
|
<OIcon src={theme.images.general.pin} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
171
|
-
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('
|
|
196
|
+
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('SAVED_PLACES', 'My saved places')}</OText>
|
|
172
197
|
</ListItem>
|
|
173
198
|
<ListItem onPress={() => onRedirect('Messages', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
|
|
174
199
|
<MessageCircle name='message1' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
@@ -180,18 +205,41 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
180
205
|
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('WALLETS', 'Wallets')}</OText>
|
|
181
206
|
</ListItem>
|
|
182
207
|
)}
|
|
208
|
+
{IsPromotionsEnabled && (
|
|
209
|
+
<ListItem onPress={() => onRedirect('Promotions', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
|
|
210
|
+
<MaterialIcons name='local-offer' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
211
|
+
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('PROMOTIONS', 'Promotions')}</OText>
|
|
212
|
+
</ListItem>
|
|
213
|
+
)}
|
|
183
214
|
<ListItem onPress={() => navigation.navigate('Help', {})} activeOpacity={0.7}>
|
|
184
215
|
<OIcon src={theme.images.general.ic_help} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
185
216
|
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
|
|
186
217
|
</ListItem>
|
|
218
|
+
<ListItem onPress={() => navigation.navigate('Sessions')} activeOpacity={0.7}>
|
|
219
|
+
<Ionicons name='md-list-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
220
|
+
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('SESSIONS', 'Sessions')}</OText>
|
|
221
|
+
</ListItem>
|
|
187
222
|
</Actions>
|
|
188
223
|
|
|
189
224
|
<Actions>
|
|
190
225
|
<LanguageSelector iconColor={theme.colors.textNormal} pickerStyle={langPickerStyle} />
|
|
191
226
|
<View style={{ height: 17 }} />
|
|
192
227
|
<LogoutButton color={theme.colors.textNormal} text={t('LOGOUT', 'Logout')} />
|
|
228
|
+
<View style={{ height: 17 }} />
|
|
229
|
+
<ListItem disabled={isAdmin} onPress={() => onRemoveAccount()} activeOpacity={0.7}>
|
|
230
|
+
<OIcon src={theme.images.general.user} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
231
|
+
<OText size={14} lineHeight={24} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1 }} color={theme.colors.danger5}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
|
|
232
|
+
</ListItem>
|
|
193
233
|
</Actions>
|
|
194
234
|
</ListWrap>
|
|
235
|
+
<OAlert
|
|
236
|
+
open={confirm.open}
|
|
237
|
+
title={confirm.title}
|
|
238
|
+
content={confirm.content}
|
|
239
|
+
onAccept={confirm.handleOnAccept}
|
|
240
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
241
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
242
|
+
/>
|
|
195
243
|
</View>
|
|
196
244
|
);
|
|
197
245
|
};
|