ordering-ui-react-native 0.22.76 → 0.22.77-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 -7
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/src/providers/AlertProvider.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +13 -4
- package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
- package/themes/business/src/components/MapView/index.tsx +68 -142
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
- package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
- package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -42
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +271 -176
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +207 -144
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +20 -8
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
- package/themes/business/src/components/ProductItemAccordion/index.tsx +15 -16
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +26 -4
- package/themes/business/src/utils/index.tsx +26 -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 +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- 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/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +223 -219
- package/themes/original/src/components/AddressForm/index.tsx +76 -17
- package/themes/original/src/components/AppleLogin/index.tsx +3 -4
- package/themes/original/src/components/BusinessController/index.tsx +4 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +1 -1
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +102 -90
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
- package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
- package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +72 -69
- package/themes/original/src/components/BusinessProductsList/index.tsx +4 -5
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +1 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -1
- package/themes/original/src/components/Cart/index.tsx +42 -12
- package/themes/original/src/components/Checkout/index.tsx +126 -98
- package/themes/original/src/components/FloatingButton/index.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +2 -1
- package/themes/original/src/components/GoogleMap/index.tsx +3 -2
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +53 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +36 -11
- package/themes/original/src/components/LastOrder/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +883 -852
- package/themes/original/src/components/MessageListing/index.tsx +1 -1
- package/themes/original/src/components/Messages/index.tsx +562 -555
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +141 -61
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +78 -33
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +6 -2
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
- package/themes/original/src/components/OrderDetails/index.tsx +44 -20
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +5 -4
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
- package/themes/original/src/components/OrdersOption/index.tsx +325 -325
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
- package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
- package/themes/original/src/components/ServiceForm/index.tsx +2 -2
- package/themes/original/src/components/SignupForm/index.tsx +1010 -971
- package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
- package/themes/original/src/components/SingleProductCard/index.tsx +2 -1
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
- package/themes/original/src/components/UserVerification/index.tsx +70 -23
- package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +97 -97
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/providers/AlertProvider.tsx +1 -1
- package/themes/original/src/types/index.tsx +700 -695
- package/themes/original/src/utils/index.tsx +50 -34
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
SingleOrderCard as SingleOrderCardController,
|
|
4
4
|
useUtils,
|
|
5
5
|
useOrder,
|
|
6
|
-
useLanguage
|
|
6
|
+
useLanguage,
|
|
7
|
+
useConfig
|
|
7
8
|
} from 'ordering-components/native';
|
|
8
9
|
import FastImage from 'react-native-fast-image'
|
|
9
10
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
@@ -45,6 +46,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
45
46
|
const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
|
|
46
47
|
const [, t] = useLanguage();
|
|
47
48
|
const [{ carts }] = useOrder()
|
|
49
|
+
const [{ configs }] = useConfig()
|
|
48
50
|
const theme = useTheme();
|
|
49
51
|
const isFocused = useIsFocused();
|
|
50
52
|
|
|
@@ -54,6 +56,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
54
56
|
|
|
55
57
|
const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12, 15];
|
|
56
58
|
const isGiftCardOrder = !order?.business_id
|
|
59
|
+
const changeIdToExternalId = configs?.change_order_id?.value === '1'
|
|
57
60
|
|
|
58
61
|
const styles = StyleSheet.create({
|
|
59
62
|
container: {
|
|
@@ -284,7 +287,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
284
287
|
) : (
|
|
285
288
|
<Price>
|
|
286
289
|
<OText size={12} lineHeight={18}>
|
|
287
|
-
{parsePrice(order?.total)}
|
|
290
|
+
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
288
291
|
</OText>
|
|
289
292
|
</Price>
|
|
290
293
|
)}
|
|
@@ -333,7 +336,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
333
336
|
lineHeight={15}
|
|
334
337
|
numberOfLines={1}
|
|
335
338
|
>
|
|
336
|
-
{order?.business?.length > 1 ? order?.business?.length : (t('ORDER_NO', 'Order No') + '.')}
|
|
339
|
+
{order?.business?.length > 1 ? order?.business?.length : !(changeIdToExternalId && order?.external_id) && (t('ORDER_NO', 'Order No') + '.')}
|
|
337
340
|
</OText>
|
|
338
341
|
<OText
|
|
339
342
|
size={10}
|
|
@@ -342,7 +345,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
342
345
|
lineHeight={15}
|
|
343
346
|
numberOfLines={1}
|
|
344
347
|
>
|
|
345
|
-
{order?.business?.length > 1 ? t('ORDERS', 'orders') + ' \u2022 ' : order.id + ` \u2022 `}
|
|
348
|
+
{order?.business?.length > 1 ? t('ORDERS', 'orders') + ' \u2022 ' : ((changeIdToExternalId && order?.external_id) || order.id) + ` \u2022 `}
|
|
346
349
|
</OText>
|
|
347
350
|
</>
|
|
348
351
|
)}
|
|
@@ -367,7 +370,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
367
370
|
size={10}
|
|
368
371
|
lineHeight={15}
|
|
369
372
|
numberOfLines={1}>
|
|
370
|
-
{getOrderStatus(order.status)?.value}
|
|
373
|
+
{getOrderStatus(order.status, t)?.value}
|
|
371
374
|
</OText>
|
|
372
375
|
)}
|
|
373
376
|
</View>
|
|
@@ -54,6 +54,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
54
54
|
: theme?.business_view?.components?.products?.components?.product?.components?.image?.hidden
|
|
55
55
|
const textSize = isChewLayout ? 12 : 10
|
|
56
56
|
const logoPosition = theme?.business_view?.components?.products?.components?.product?.components?.image?.position
|
|
57
|
+
const hideFavoriteIcon = theme?.business_view?.components?.products?.components?.product?.components?.favorite?.hidden
|
|
57
58
|
|
|
58
59
|
const styles = StyleSheet.create({
|
|
59
60
|
container: {
|
|
@@ -198,7 +199,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
198
199
|
style={{ ...styles.line18, flex: 1 }}>
|
|
199
200
|
{product?.name}
|
|
200
201
|
</OText>
|
|
201
|
-
{!isPreviously && (
|
|
202
|
+
{!isPreviously && !hideFavoriteIcon && (
|
|
202
203
|
<LottieAnimation
|
|
203
204
|
type='favorite'
|
|
204
205
|
onClick={handleChangeFavorite}
|
|
@@ -49,15 +49,12 @@ export const RibbonBox = styled.View`
|
|
|
49
49
|
background-color: ${(props: any) => props.theme.colors.primary};
|
|
50
50
|
padding: 1px 8px;
|
|
51
51
|
max-width: 60px;
|
|
52
|
-
|
|
53
52
|
${(props: any) => props.bgColor && css`
|
|
54
53
|
background-color: ${props.bgColor};
|
|
55
54
|
`}
|
|
56
|
-
|
|
57
55
|
${(props: any) => props.isRoundRect && css`
|
|
58
56
|
border-radius: 7.6px;
|
|
59
57
|
`}
|
|
60
|
-
|
|
61
58
|
${(props: any) => props.isCapsule && css`
|
|
62
59
|
border-radius: 50px;
|
|
63
60
|
`}
|
|
@@ -32,7 +32,8 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
32
32
|
gateway,
|
|
33
33
|
paySelected,
|
|
34
34
|
newCardAdded,
|
|
35
|
-
addNewCardAsDefault
|
|
35
|
+
addNewCardAsDefault,
|
|
36
|
+
setUserHasCards
|
|
36
37
|
} = props;
|
|
37
38
|
|
|
38
39
|
const theme = useTheme();
|
|
@@ -62,6 +63,11 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
62
63
|
}
|
|
63
64
|
}, [JSON.stringify(newCardAdded)])
|
|
64
65
|
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const hasCardSelected = cardsList?.cards?.some?.((card : any) => card?.id === paySelected?.data?.id)
|
|
68
|
+
setUserHasCards && setUserHasCards(cardsList?.cards?.length > 0 && hasCardSelected)
|
|
69
|
+
}, [cardsList?.cards?.length, paySelected])
|
|
70
|
+
|
|
65
71
|
return (
|
|
66
72
|
<>
|
|
67
73
|
{token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
|
|
@@ -35,7 +35,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
35
35
|
setPlaceByMethodPay,
|
|
36
36
|
cartTotal,
|
|
37
37
|
publicKeyAddCard,
|
|
38
|
-
|
|
38
|
+
urlscheme,
|
|
39
39
|
androidAppId,
|
|
40
40
|
businessNames,
|
|
41
41
|
setNewCardAdded
|
|
@@ -218,7 +218,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
218
218
|
<StripeProvider
|
|
219
219
|
publishableKey={isToSave}
|
|
220
220
|
merchantIdentifier={merchantId}
|
|
221
|
-
|
|
221
|
+
urlscheme={`${urlscheme}://checkout/${cart?.uuid}`}
|
|
222
222
|
>
|
|
223
223
|
{methodsPay?.includes(paymethod) ? (
|
|
224
224
|
<StripeMethodForm
|
|
@@ -14,7 +14,8 @@ interface taxInformationParams {
|
|
|
14
14
|
percentage?: number,
|
|
15
15
|
id: number,
|
|
16
16
|
discounts?: any,
|
|
17
|
-
rate_type?: number
|
|
17
|
+
rate_type?: number,
|
|
18
|
+
target?: string
|
|
18
19
|
},
|
|
19
20
|
products: Array<any>,
|
|
20
21
|
type: string
|
|
@@ -34,7 +35,7 @@ export const TaxInformation = (props: taxInformationParams) => {
|
|
|
34
35
|
const offersHideArray = ['offer_target_2', 'offer_target_3']
|
|
35
36
|
const hideProductsSectionOffers = offersHideArray.includes(type)
|
|
36
37
|
const dataHideArray : Array<string | number> = ['platform', 'business']
|
|
37
|
-
const hideProductsSectionData = dataHideArray.includes(data.type)
|
|
38
|
+
const hideProductsSectionData = dataHideArray.includes(data.type) || data?.target === 'delivery_fee'
|
|
38
39
|
|
|
39
40
|
const getFilterValidation = (product: any) => {
|
|
40
41
|
return (
|
|
@@ -35,7 +35,8 @@ const UserDetailsUI = (props: any) => {
|
|
|
35
35
|
handleSendVerifyCode,
|
|
36
36
|
verifyPhoneState,
|
|
37
37
|
setFormState,
|
|
38
|
-
setIsOpen
|
|
38
|
+
setIsOpen,
|
|
39
|
+
isCheckoutPlace
|
|
39
40
|
} = props
|
|
40
41
|
|
|
41
42
|
const theme = useTheme();
|
|
@@ -95,23 +96,23 @@ const UserDetailsUI = (props: any) => {
|
|
|
95
96
|
},
|
|
96
97
|
});
|
|
97
98
|
handleSendVerifyCode({
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
cellphone: cellphone,
|
|
100
|
+
country_phone_code: countryPhoneCode
|
|
100
101
|
})
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
const handleSendPhoneCode = (values: any) => {
|
|
105
|
-
|
|
106
|
+
setWillVerifyOtpState(false)
|
|
106
107
|
setIsModalVisible(false)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
setFormState({
|
|
109
|
+
...formState,
|
|
110
|
+
changes: {
|
|
111
|
+
...formState?.changes,
|
|
112
|
+
verification_code: values?.code
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
115
116
|
|
|
116
117
|
useEffect(() => {
|
|
117
118
|
if (willVerifyOtpState) handleVerifyCodeClick()
|
|
@@ -158,7 +159,7 @@ const UserDetailsUI = (props: any) => {
|
|
|
158
159
|
{t('CUSTOMER_DETAILS', 'Customer Details')}
|
|
159
160
|
</OText>
|
|
160
161
|
)}
|
|
161
|
-
{cartStatus !== 2 && !
|
|
162
|
+
{cartStatus !== 2 && !isCheckoutPlace && (
|
|
162
163
|
!isEdit ? (
|
|
163
164
|
<EditBtn onPress={() => toggleIsEdit()} activeOpacity={0.7}>
|
|
164
165
|
<OIcon
|
|
@@ -189,12 +190,12 @@ const UserDetailsUI = (props: any) => {
|
|
|
189
190
|
{userData?.name} {userData?.middle_name} {userData?.lastname} {userData?.second_lastname}
|
|
190
191
|
</OText>
|
|
191
192
|
<OText size={12} lineHeight={18} weight={'400'}>
|
|
192
|
-
{userData?.email}
|
|
193
|
+
{userData?.guest_id ? userData?.guest_email : userData?.email}
|
|
193
194
|
</OText>
|
|
194
|
-
{!!(userData?.cellphone || user?.cellphone) && (
|
|
195
|
+
{!!((userData?.cellphone ?? userData?.guest_cellphone) || (user?.cellphone ?? user?.guest_cellphone)) && (
|
|
195
196
|
<>
|
|
196
197
|
<OText size={12} lineHeight={18} weight={'400'}>
|
|
197
|
-
{(userData?.country_phone_code) && `+${(userData?.country_phone_code)} `}{(userData?.cellphone)}
|
|
198
|
+
{(userData?.country_phone_code) && `+${(userData?.country_phone_code)} `}{(userData?.guest_id ? user?.guest_cellphone : userData?.cellphone)}
|
|
198
199
|
</OText>
|
|
199
200
|
{!!phoneUpdate && (
|
|
200
201
|
<OText color={theme.colors.error} style={{ textAlign: 'center' }}>{t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number')}</OText>
|
|
@@ -16,6 +16,8 @@ import { ListItem } from '../UserProfile/styles';
|
|
|
16
16
|
import moment from 'moment';
|
|
17
17
|
import { DatePickerUI } from '../DatePicker';
|
|
18
18
|
|
|
19
|
+
const CONDITIONAL_CODES = ['PR']
|
|
20
|
+
|
|
19
21
|
export const UserFormDetailsUI = (props: any) => {
|
|
20
22
|
const {
|
|
21
23
|
isEdit,
|
|
@@ -38,7 +40,13 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
38
40
|
handleRemoveAccount,
|
|
39
41
|
isProfile,
|
|
40
42
|
isGuest,
|
|
41
|
-
|
|
43
|
+
isOrderTypeValidationField,
|
|
44
|
+
checkoutFields,
|
|
45
|
+
isCheckoutPlace,
|
|
46
|
+
setCellphoneStartZero,
|
|
47
|
+
setPhoneState,
|
|
48
|
+
isPhoneVerifyRequired,
|
|
49
|
+
cellphoneOtpSent
|
|
42
50
|
} = props;
|
|
43
51
|
|
|
44
52
|
const theme = useTheme();
|
|
@@ -80,7 +88,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
80
88
|
const [, { showToast }] = useToast();
|
|
81
89
|
const { handleSubmit, control, errors, setValue } = useForm();
|
|
82
90
|
|
|
83
|
-
const [{ user }, { login }] = useSession();
|
|
91
|
+
const [{ user }, { login, logout }] = useSession();
|
|
84
92
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
85
93
|
const [isValid, setIsValid] = useState(false)
|
|
86
94
|
const [isChanged, setIsChanged] = useState(false)
|
|
@@ -97,8 +105,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
97
105
|
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
98
106
|
|
|
99
107
|
const isAdmin = user?.level === 0
|
|
100
|
-
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false)
|
|
101
|
-
const showInputBirthday = validationFields?.fields?.checkout?.birthdate?.enabled ?? false
|
|
108
|
+
const showInputPhoneNumber = isOrderTypeValidationField ? checkoutFields?.find(field => field?.validation_field?.code === 'mobile_phone')?.enabled : (validationFields?.fields?.checkout?.cellphone?.enabled ?? false)
|
|
109
|
+
const showInputBirthday = isOrderTypeValidationField ? checkoutFields?.find(field => field?.validation_field?.code === 'birthdate')?.enabled : (validationFields?.fields?.checkout?.birthdate?.enabled ?? false)
|
|
102
110
|
|
|
103
111
|
const handleSuccessSignup = (user: any) => {
|
|
104
112
|
login({
|
|
@@ -129,15 +137,27 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
129
137
|
return rules;
|
|
130
138
|
};
|
|
131
139
|
|
|
140
|
+
const cellphoneValue = () => {
|
|
141
|
+
let cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
|
|
142
|
+
if (cellphone && CONDITIONAL_CODES.includes(user?.country_code)) {
|
|
143
|
+
if (user?.country_code === 'PR') {
|
|
144
|
+
cellphone = user?.cellphone?.slice(3)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return cellphone
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
const setUserCellPhone = (isEdit = false) => {
|
|
133
151
|
if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
|
|
134
152
|
setUserPhoneNumber(userPhoneNumber);
|
|
135
153
|
return;
|
|
136
154
|
}
|
|
137
|
-
|
|
155
|
+
const cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
|
|
156
|
+
|
|
157
|
+
if (cellphone) {
|
|
138
158
|
let phone = null;
|
|
139
159
|
if (user?.country_phone_code) {
|
|
140
|
-
phone = `+${user?.country_phone_code} ${
|
|
160
|
+
phone = `+${user?.country_phone_code} ${cellphone}`;
|
|
141
161
|
} else {
|
|
142
162
|
phone = user?.cellphone;
|
|
143
163
|
}
|
|
@@ -146,17 +166,22 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
146
166
|
...phoneInputData,
|
|
147
167
|
phone: {
|
|
148
168
|
country_phone_code: user?.country_phone_code || null,
|
|
149
|
-
cellphone:
|
|
169
|
+
cellphone: cellphoneValue()
|
|
150
170
|
},
|
|
151
171
|
});
|
|
152
172
|
return;
|
|
153
173
|
}
|
|
154
|
-
setUserPhoneNumber(
|
|
174
|
+
setUserPhoneNumber(cellphone || '');
|
|
155
175
|
};
|
|
156
176
|
|
|
157
177
|
const onSubmit = () => {
|
|
178
|
+
let content = ''
|
|
179
|
+
if (requiredFields?.includes?.('birthdate') && !birthdate) {
|
|
180
|
+
content = content + `${t('VALIDATION_ERROR_BIRTHDATE_REQUIRED', 'Birthdate is required')}\n`
|
|
181
|
+
}
|
|
158
182
|
if (phoneInputData.error) {
|
|
159
|
-
|
|
183
|
+
content = content + `${phoneInputData.error}\n`
|
|
184
|
+
showToast(ToastType.Error, content);
|
|
160
185
|
return;
|
|
161
186
|
}
|
|
162
187
|
if (Object.keys(formState.changes).length > 0) {
|
|
@@ -164,17 +189,16 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
164
189
|
formState.changes?.cellphone === null &&
|
|
165
190
|
((validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
166
191
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
167
|
-
configs?.verification_phone_required?.value === '1')
|
|
192
|
+
(configs?.verification_phone_required?.value === '1' && !user?.guest_id))
|
|
168
193
|
) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
t(
|
|
172
|
-
'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
|
|
173
|
-
'The field Phone Number is required.',
|
|
174
|
-
),
|
|
175
|
-
);
|
|
194
|
+
content = content + `${t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone Number is required.',)}\n`
|
|
195
|
+
showToast(ToastType.Error, content);
|
|
176
196
|
return;
|
|
177
197
|
}
|
|
198
|
+
if (content.length > 0) {
|
|
199
|
+
showToast(ToastType.Error, content);
|
|
200
|
+
return
|
|
201
|
+
}
|
|
178
202
|
let changes = null;
|
|
179
203
|
if (user?.cellphone && !userPhoneNumber) {
|
|
180
204
|
changes = {
|
|
@@ -187,7 +211,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
187
211
|
}
|
|
188
212
|
};
|
|
189
213
|
|
|
190
|
-
const handleChangePhoneNumber = (number: any) => {
|
|
214
|
+
const handleChangePhoneNumber = (number: any, rawNumber : any) => {
|
|
191
215
|
setPhoneInputData(number);
|
|
192
216
|
setIsChanged(true)
|
|
193
217
|
let phoneNumber = {
|
|
@@ -200,6 +224,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
200
224
|
value: number.phone.cellphone,
|
|
201
225
|
},
|
|
202
226
|
};
|
|
227
|
+
setCellphoneStartZero && setCellphoneStartZero(rawNumber?.number && rawNumber?.countryCallingCode ? rawNumber?.number : null)
|
|
203
228
|
handleChangeInput(phoneNumber, true);
|
|
204
229
|
};
|
|
205
230
|
|
|
@@ -225,9 +250,12 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
225
250
|
open: true,
|
|
226
251
|
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
227
252
|
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
228
|
-
handleOnAccept: () => {
|
|
253
|
+
handleOnAccept: async () => {
|
|
229
254
|
setConfirm({ ...confirm, open: false })
|
|
230
|
-
|
|
255
|
+
const response = await handleRemoveAccount?.(user?.id)
|
|
256
|
+
if (response === 'OK'){
|
|
257
|
+
logout()
|
|
258
|
+
}
|
|
231
259
|
}
|
|
232
260
|
})
|
|
233
261
|
}
|
|
@@ -296,20 +324,29 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
296
324
|
setIsValid(_isValid)
|
|
297
325
|
}, [formState?.changes, requiredFields])
|
|
298
326
|
|
|
327
|
+
useEffect(() => {
|
|
328
|
+
if (!isPhoneVerifyRequired || cellphoneOtpSent || formState?.changes?.length === 0) return
|
|
329
|
+
setPhoneState?.({
|
|
330
|
+
cellphone: formState?.changes?.country_code === "PR" ? formState?.changes?.cellphone.replace('787', '') : formState?.changes?.cellphone,
|
|
331
|
+
country_phone_code: formState?.changes?.country_code === "PR" ? '1787' : formState?.changes?.country_phone_code,
|
|
332
|
+
formatted: `+${formState?.changes?.country_phone_code} ${formState?.changes?.cellphone}`
|
|
333
|
+
})
|
|
334
|
+
}, [formState?.changes, cellphoneOtpSent])
|
|
335
|
+
|
|
299
336
|
return (
|
|
300
337
|
<>
|
|
301
338
|
<UDForm>
|
|
302
339
|
{!validationFields?.loading &&
|
|
303
|
-
sortInputFields({ values:
|
|
340
|
+
sortInputFields({ values: isOrderTypeValidationField ? checkoutFields : validationFields?.fields?.checkout })
|
|
304
341
|
.length > 0 && (
|
|
305
342
|
<UDWrapper>
|
|
306
343
|
{sortInputFields({
|
|
307
|
-
values:
|
|
344
|
+
values: isOrderTypeValidationField ? checkoutFields : validationFields?.fields?.checkout,
|
|
308
345
|
}).map(
|
|
309
346
|
(item: any) => {
|
|
310
347
|
const field = item?.validation_field || item
|
|
311
348
|
return (
|
|
312
|
-
(
|
|
349
|
+
((isOrderTypeValidationField ? item?.enabled : (showField && showField(field.code))) && ((requiredFields && requiredFields?.includes?.(field.code)) || !requiredFields || !isCheckoutPlace)) && (
|
|
313
350
|
<React.Fragment key={field.id}>
|
|
314
351
|
<Controller
|
|
315
352
|
key={field.id}
|
|
@@ -333,7 +370,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
333
370
|
isDisabled={false}
|
|
334
371
|
value={
|
|
335
372
|
formState?.changes[field.code] ??
|
|
336
|
-
(user && user[field.code]) ??
|
|
373
|
+
(user && user?.guest_id && field.code === 'email' ? user?.guest_email : user?.[field.code]) ??
|
|
337
374
|
''
|
|
338
375
|
}
|
|
339
376
|
onChange={(val: any) => {
|
|
@@ -377,52 +414,58 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
377
414
|
)}
|
|
378
415
|
name={field.code}
|
|
379
416
|
rules={getInputRules(field)}
|
|
380
|
-
defaultValue={user && user[field.code]}
|
|
417
|
+
defaultValue={user && (field.code === 'email' && user?.guest_id ? user?.guest_email : user?.[field.code])}
|
|
381
418
|
/>
|
|
382
419
|
</React.Fragment>
|
|
383
420
|
))
|
|
384
421
|
},
|
|
385
422
|
)}
|
|
386
|
-
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
{birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
|
|
423
|
+
{((!user?.guest_id && showInputBirthday) || (isOrderTypeValidationField || user?.guest_id)) &&
|
|
424
|
+
showInputBirthday &&
|
|
425
|
+
((requiredFields && requiredFields?.includes?.('birthdate')) || !requiredFields || !isCheckoutPlace) &&
|
|
426
|
+
(
|
|
427
|
+
<>
|
|
428
|
+
<WrapperBirthdate>
|
|
429
|
+
<OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
|
|
430
|
+
{t('BIRTHDATE', 'Birthdate')}
|
|
395
431
|
</OText>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
432
|
+
<TouchableOpacity onPress={() => setShowDatePicker(!showDatePicker)}>
|
|
433
|
+
<OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ marginTop: 6 }}>
|
|
434
|
+
{birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
|
|
435
|
+
</OText>
|
|
436
|
+
</TouchableOpacity>
|
|
437
|
+
</WrapperBirthdate>
|
|
438
|
+
<DatePickerUI open={showDatePicker} birthdate={birthdate} onConfirm={_handleChangeDate} onCancel={() => setShowDatePicker(false)} />
|
|
439
|
+
</>
|
|
440
|
+
)}
|
|
441
|
+
{((!user?.guest_id && !!showInputPhoneNumber) || (isOrderTypeValidationField || user?.guest_id)) &&
|
|
442
|
+
((requiredFields && requiredFields?.includes?.('cellphone')) || !requiredFields || !isCheckoutPlace) &&
|
|
443
|
+
(
|
|
444
|
+
<WrapperPhone>
|
|
445
|
+
<OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
|
|
446
|
+
<PhoneInputNumber
|
|
447
|
+
data={phoneInputData}
|
|
448
|
+
handleData={handleChangePhoneNumber}
|
|
449
|
+
changeCountry={(val: any) => changeCountry(val)}
|
|
450
|
+
defaultValue={phoneUpdate ? '' : cellphoneValue()}
|
|
451
|
+
defaultCode={user?.country_code ?? user?.country_phone_code ?? null}
|
|
452
|
+
defaultCodeFallback={user?.country_phone_code}
|
|
453
|
+
boxStyle={styles.phoneSelect}
|
|
454
|
+
inputStyle={styles.phoneInputStyle}
|
|
455
|
+
textStyle={{ color: theme.colors.textNormal, fontSize: 12, padding: 0 }}
|
|
456
|
+
noDropIcon
|
|
457
|
+
/>
|
|
458
|
+
{phoneUpdate && (
|
|
459
|
+
<OText
|
|
460
|
+
size={10}
|
|
461
|
+
color={theme.colors.error}
|
|
462
|
+
style={{ marginHorizontal: 10, textAlign: 'center' }}>
|
|
463
|
+
{t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
|
|
464
|
+
{cellphoneValue()}
|
|
465
|
+
</OText>
|
|
466
|
+
)}
|
|
467
|
+
</WrapperPhone>
|
|
468
|
+
)}
|
|
426
469
|
{!requiredFields && (
|
|
427
470
|
<Controller
|
|
428
471
|
control={control}
|
|
@@ -474,7 +517,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
474
517
|
</UDLoader>
|
|
475
518
|
)}
|
|
476
519
|
</UDForm>
|
|
477
|
-
{!hideUpdateButton && (
|
|
520
|
+
{!hideUpdateButton && !isPhoneVerifyRequired && (
|
|
478
521
|
<>
|
|
479
522
|
{((formState &&
|
|
480
523
|
Object.keys(formState?.changes).length > 0 &&
|
|
@@ -495,7 +538,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
495
538
|
)}
|
|
496
539
|
</>
|
|
497
540
|
)}
|
|
498
|
-
{
|
|
541
|
+
{isCheckoutPlace && (
|
|
499
542
|
<OButton
|
|
500
543
|
text={
|
|
501
544
|
formState.loading
|
|
@@ -554,4 +597,3 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
554
597
|
</>
|
|
555
598
|
);
|
|
556
599
|
};
|
|
557
|
-
|