ordering-ui-react-native 0.22.13 → 0.22.14-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.
Files changed (164) hide show
  1. package/package.json +6 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/StripeMethodForm/index.tsx +4 -2
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/context/OfflineActions/index.tsx +236 -0
  8. package/src/types/index.tsx +2 -1
  9. package/themes/business/index.tsx +2 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  11. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  12. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  13. package/themes/business/src/components/BusinessProductList/index.tsx +2 -1
  14. package/themes/business/src/components/Chat/index.tsx +15 -3
  15. package/themes/business/src/components/DriverMap/index.tsx +49 -26
  16. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  17. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  18. package/themes/business/src/components/LanguageSelector/index.tsx +2 -3
  19. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  20. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  21. package/themes/business/src/components/MapView/index.tsx +36 -17
  22. package/themes/business/src/components/NewOrderNotification/index.tsx +40 -27
  23. package/themes/business/src/components/OrderDetails/Business.tsx +47 -27
  24. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  25. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +128 -41
  26. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +46 -19
  27. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  28. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +46 -21
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  30. package/themes/business/src/components/OrderSummary/index.tsx +7 -5
  31. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  32. package/themes/business/src/components/OrdersOption/index.tsx +217 -156
  33. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  34. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  35. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +39 -16
  36. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  37. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  38. package/themes/business/src/components/PrinterEdition/index.tsx +431 -0
  39. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  40. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  41. package/themes/business/src/components/PrinterSettings/index.tsx +162 -174
  42. package/themes/business/src/components/PrinterSettings/styles.tsx +14 -1
  43. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  44. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  45. package/themes/business/src/components/StoresList/index.tsx +2 -2
  46. package/themes/business/src/components/UserProfileForm/index.tsx +16 -17
  47. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  48. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  49. package/themes/business/src/config/currency.tsx +1010 -0
  50. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  51. package/themes/business/src/types/index.tsx +13 -4
  52. package/themes/business/src/utils/index.tsx +33 -3
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  57. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  58. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  59. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/original/index.tsx +11 -0
  62. package/themes/original/src/components/AddressForm/index.tsx +32 -17
  63. package/themes/original/src/components/AddressList/index.tsx +8 -7
  64. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  65. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  66. package/themes/original/src/components/BusinessBasicInformation/index.tsx +5 -8
  67. package/themes/original/src/components/BusinessController/index.tsx +3 -3
  68. package/themes/original/src/components/BusinessItemAccordion/index.tsx +13 -5
  69. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  70. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  71. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  72. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
  73. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  74. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  75. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  76. package/themes/original/src/components/BusinessProductsListing/index.tsx +18 -6
  77. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  78. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  79. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  80. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  81. package/themes/original/src/components/Cart/index.tsx +46 -14
  82. package/themes/original/src/components/CartContent/index.tsx +2 -4
  83. package/themes/original/src/components/Checkout/index.tsx +113 -59
  84. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  85. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  86. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  87. package/themes/original/src/components/Favorite/index.tsx +1 -5
  88. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  89. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  90. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  91. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  92. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  93. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  94. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  95. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  96. package/themes/original/src/components/Help/index.tsx +2 -0
  97. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  98. package/themes/original/src/components/Home/index.tsx +3 -11
  99. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  100. package/themes/original/src/components/LoginForm/index.tsx +4 -7
  101. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  102. package/themes/original/src/components/Messages/index.tsx +27 -19
  103. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  104. package/themes/original/src/components/MomentOption/index.tsx +80 -51
  105. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  106. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  107. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  108. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  109. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  110. package/themes/original/src/components/NavBar/index.tsx +7 -4
  111. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  112. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  113. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  114. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +13 -10
  115. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  116. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  117. package/themes/original/src/components/OrderProgress/index.tsx +5 -4
  118. package/themes/original/src/components/OrderSummary/index.tsx +29 -10
  119. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  120. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  121. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  122. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  123. package/themes/original/src/components/PaymentOptions/index.tsx +0 -2
  124. package/themes/original/src/components/PhoneInputNumber/index.tsx +74 -4
  125. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  126. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  127. package/themes/original/src/components/ProductForm/ActionButton.tsx +17 -20
  128. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  129. package/themes/original/src/components/ProductItemAccordion/index.tsx +50 -43
  130. package/themes/original/src/components/ProductItemAccordion/styles.tsx +0 -3
  131. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  132. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  133. package/themes/original/src/components/Promotions/index.tsx +6 -9
  134. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  135. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  136. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  137. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  138. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  139. package/themes/original/src/components/Sessions/index.tsx +3 -3
  140. package/themes/original/src/components/SignupForm/index.tsx +86 -78
  141. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  142. package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
  143. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  144. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  145. package/themes/original/src/components/StripeCardsList/index.tsx +10 -3
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +76 -62
  147. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  148. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  149. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  150. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  151. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  152. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  153. package/themes/original/src/components/UserFormDetails/index.tsx +161 -134
  154. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  155. package/themes/original/src/components/UserVerification/index.tsx +15 -4
  156. package/themes/original/src/components/Wallets/index.tsx +6 -3
  157. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  158. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  159. package/themes/original/src/components/shared/OButton.tsx +5 -4
  160. package/themes/original/src/components/shared/OInput.tsx +4 -8
  161. package/themes/original/src/components/shared/OModal.tsx +7 -2
  162. package/themes/original/src/types/index.tsx +7 -2
  163. package/themes/original/src/utils/index.tsx +30 -1
  164. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -13,6 +13,7 @@ export const StripeElementsForm = (props: any) => {
13
13
  const [ordering] = useApi();
14
14
  const [{ token }] = useSession();
15
15
  const [state, setState] = useState({ loading: false, loadingAdd: false, error: null, requirements: null });
16
+ const [publicKeyState, setPublicKeyState] = useState({ key: props.publicKey, loading: true, error: null })
16
17
 
17
18
  const getRequirements = async () => {
18
19
  try {
@@ -52,7 +53,7 @@ export const StripeElementsForm = (props: any) => {
52
53
  const result = await fetch(`${ordering.root}/payments/stripe/cards`, {
53
54
  method: 'POST',
54
55
  headers: {
55
- Authorization: `Bearer ${user?.session?.access_token}`,
56
+ Authorization: `Bearer ${token}`,
56
57
  'Content-Type': 'application/json'
57
58
  },
58
59
  body: JSON.stringify({
@@ -85,6 +86,51 @@ export const StripeElementsForm = (props: any) => {
85
86
  }
86
87
  }
87
88
 
89
+ /**
90
+ * Method to get stripe credentials from API
91
+ */
92
+ const getCredentials = async () => {
93
+ try {
94
+ setPublicKeyState({
95
+ ...publicKeyState,
96
+ loading: true
97
+ })
98
+ const { content: { result, error } } = await ordering.setAccessToken(token).paymentCards().getCredentials()
99
+ if (!error) {
100
+ setPublicKeyState({
101
+ loading: false,
102
+ key: result.publishable,
103
+ error: null
104
+ })
105
+ } else {
106
+ setPublicKeyState({
107
+ ...publicKeyState,
108
+ loading: false,
109
+ error: result
110
+ })
111
+ }
112
+ } catch (error) {
113
+ setPublicKeyState({
114
+ ...publicKeyState,
115
+ loading: false,
116
+ error: error.message
117
+ })
118
+ }
119
+ }
120
+
121
+ useEffect(() => {
122
+ if (!token) return
123
+ if (props.publicKey) {
124
+ setPublicKeyState({
125
+ loading: false,
126
+ key: props.publicKey,
127
+ error: null
128
+ })
129
+ } else {
130
+ getCredentials()
131
+ }
132
+ }, [token, props.publicKey])
133
+
88
134
  useEffect(() => {
89
135
  if (!token || state.requirements) return
90
136
  toSave && getRequirements()
@@ -96,6 +142,7 @@ export const StripeElementsForm = (props: any) => {
96
142
  values={state}
97
143
  requirements={state.requirements}
98
144
  stripeTokenHandler={stripeTokenHandler}
145
+ publicKeyState={publicKeyState}
99
146
  />
100
147
  )
101
148
  }
@@ -138,9 +138,6 @@ const StripeRedirectFormUI = (props: any) => {
138
138
  <OButton
139
139
  // text={formState.isSubmitting ? t('LOADING', 'Loading...') : t('OK', 'OK')}
140
140
  text={t('OK', 'OK')}
141
- bgColor={theme.colors.primary}
142
- borderColor={theme.colors.primary}
143
- textStyle={{ color: 'white' }}
144
141
  imgRightSrc={null}
145
142
  // isDisabled={formState.isSubmitting}
146
143
  // onClick={() => handleSubmit(onSubmit)}
@@ -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 (
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react'
2
- import { Platform, StyleSheet, View } from 'react-native'
2
+ import { Platform, StyleSheet, View, Vibration } from 'react-native'
3
3
  import {
4
4
  useLanguage,
5
5
  useOrder,
@@ -20,7 +20,7 @@ import IconAntDesign from 'react-native-vector-icons/AntDesign';
20
20
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
21
21
  import { UpsellingLayout } from './UpsellingLayout';
22
22
 
23
- export const UpsellingContent = (props : any) => {
23
+ export const UpsellingContent = (props: any) => {
24
24
  const {
25
25
  onGoBack,
26
26
  handleUpsellingPage,
@@ -44,12 +44,10 @@ export const UpsellingContent = (props : any) => {
44
44
  const commentDelayTime = isChewLayout ? 500 : null
45
45
 
46
46
  const cartList = (carts && Object.values(carts).filter((_cart: any) => _cart?.products?.length > 0 && _cart.uuid !== cart?.uuid)) || []
47
-
47
+
48
48
  const styles = StyleSheet.create({
49
49
  closeUpsellingButton: {
50
50
  borderRadius: 7.6,
51
- borderColor: theme.colors.primary,
52
- backgroundColor: theme.colors.primary,
53
51
  borderWidth: 1,
54
52
  alignSelf: 'center',
55
53
  height: 44,
@@ -92,6 +90,11 @@ export const UpsellingContent = (props : any) => {
92
90
  setShowTitle(contentOffset.y > 30)
93
91
  }
94
92
 
93
+ const handleClickCheckout = () => {
94
+ Vibration.vibrate(100)
95
+ handleUpsellingPage(cart)
96
+ }
97
+
95
98
  return (
96
99
  <>
97
100
  <View style={styles.wrapperNavbar}>
@@ -160,9 +163,9 @@ export const UpsellingContent = (props : any) => {
160
163
  <OButton
161
164
  imgRightSrc=''
162
165
  text={t('CHECKOUT', 'Checkout')}
166
+ textStyle={{ fontSize: 14 }}
163
167
  style={{ ...styles.closeUpsellingButton }}
164
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
165
- onClick={() => handleUpsellingPage(cart)}
168
+ onClick={() => handleClickCheckout()}
166
169
  />
167
170
  </View>
168
171
  </>
@@ -25,6 +25,9 @@ export const UpsellingLayout = (props : any) => {
25
25
  const [{ parsePrice }] = useUtils()
26
26
  const [, t] = useLanguage()
27
27
 
28
+ const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
29
+
30
+
28
31
  const styles = StyleSheet.create({
29
32
  imageStyle: {
30
33
  width: 73,
@@ -66,9 +69,11 @@ export const UpsellingLayout = (props : any) => {
66
69
  <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
67
70
  </AddButton>
68
71
  </View>
69
- <View>
70
- <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
71
- </View>
72
+ {(product?.images || !hideProductDummyLogo) && (
73
+ <View>
74
+ <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
75
+ </View>
76
+ )}
72
77
  </Item>
73
78
  )) : (
74
79
  <OText>
@@ -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
- cellphone: cellphone,
99
- country_phone_code: countryPhoneCode
99
+ cellphone: cellphone,
100
+ country_phone_code: countryPhoneCode
100
101
  })
101
102
  }
102
103
  }
103
104
 
104
105
  const handleSendPhoneCode = (values: any) => {
105
- setWillVerifyOtpState(false)
106
+ setWillVerifyOtpState(false)
106
107
  setIsModalVisible(false)
107
- setFormState({
108
- ...formState,
109
- changes: {
110
- ...formState?.changes,
111
- verification_code: values?.code
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 && !requiredFields && (
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,
@@ -36,7 +38,11 @@ export const UserFormDetailsUI = (props: any) => {
36
38
  isCheckout,
37
39
  setIsOpen,
38
40
  handleRemoveAccount,
39
- isProfile
41
+ isProfile,
42
+ isGuest,
43
+ isOrderTypeValidationField,
44
+ checkoutFields,
45
+ isCheckoutPlace
40
46
  } = props;
41
47
 
42
48
  const theme = useTheme();
@@ -95,8 +101,8 @@ export const UserFormDetailsUI = (props: any) => {
95
101
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
96
102
 
97
103
  const isAdmin = user?.level === 0
98
- const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
99
- const showInputBirthday = validationFields?.fields?.checkout?.birthdate?.enabled ?? false
104
+ const showInputPhoneNumber = isOrderTypeValidationField ? checkoutFields?.find(field => field?.validation_field?.code === 'mobile_phone')?.enabled : (validationFields?.fields?.checkout?.cellphone?.enabled ?? false)
105
+ const showInputBirthday = isOrderTypeValidationField ? checkoutFields?.find(field => field?.validation_field?.code === 'birthdate')?.enabled : (validationFields?.fields?.checkout?.birthdate?.enabled ?? false)
100
106
 
101
107
  const handleSuccessSignup = (user: any) => {
102
108
  login({
@@ -127,15 +133,27 @@ export const UserFormDetailsUI = (props: any) => {
127
133
  return rules;
128
134
  };
129
135
 
136
+ const cellphoneValue = () => {
137
+ let cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
138
+ if (cellphone && CONDITIONAL_CODES.includes(user?.country_code)) {
139
+ if (user?.country_code === 'PR') {
140
+ cellphone = user?.cellphone?.slice(3)
141
+ }
142
+ }
143
+ return cellphone
144
+ }
145
+
130
146
  const setUserCellPhone = (isEdit = false) => {
131
147
  if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
132
148
  setUserPhoneNumber(userPhoneNumber);
133
149
  return;
134
150
  }
135
- if (user?.cellphone) {
151
+ const cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
152
+
153
+ if (cellphone) {
136
154
  let phone = null;
137
155
  if (user?.country_phone_code) {
138
- phone = `+${user?.country_phone_code} ${user?.cellphone}`;
156
+ phone = `+${user?.country_phone_code} ${cellphone}`;
139
157
  } else {
140
158
  phone = user?.cellphone;
141
159
  }
@@ -144,17 +162,22 @@ export const UserFormDetailsUI = (props: any) => {
144
162
  ...phoneInputData,
145
163
  phone: {
146
164
  country_phone_code: user?.country_phone_code || null,
147
- cellphone: user?.cellphone || null,
165
+ cellphone: cellphoneValue()
148
166
  },
149
167
  });
150
168
  return;
151
169
  }
152
- setUserPhoneNumber(user?.cellphone || '');
170
+ setUserPhoneNumber(cellphone || '');
153
171
  };
154
172
 
155
173
  const onSubmit = () => {
174
+ let content = ''
175
+ if (requiredFields?.includes?.('birthdate') && !birthdate) {
176
+ content = content + `${t('VALIDATION_ERROR_BIRTHDATE_REQUIRED', 'Birthdate is required')}\n`
177
+ }
156
178
  if (phoneInputData.error) {
157
- showToast(ToastType.Error, phoneInputData.error);
179
+ content = content + `${phoneInputData.error}\n`
180
+ showToast(ToastType.Error, content);
158
181
  return;
159
182
  }
160
183
  if (Object.keys(formState.changes).length > 0) {
@@ -162,17 +185,16 @@ export const UserFormDetailsUI = (props: any) => {
162
185
  formState.changes?.cellphone === null &&
163
186
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
164
187
  validationFields?.fields?.checkout?.cellphone?.required) ||
165
- configs?.verification_phone_required?.value === '1')
188
+ (configs?.verification_phone_required?.value === '1' && !user?.guest_id))
166
189
  ) {
167
- showToast(
168
- ToastType.Error,
169
- t(
170
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
171
- 'The field Phone Number is required.',
172
- ),
173
- );
190
+ content = content + `${t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone Number is required.',)}\n`
191
+ showToast(ToastType.Error, content);
174
192
  return;
175
193
  }
194
+ if (content.length > 0) {
195
+ showToast(ToastType.Error, content);
196
+ return
197
+ }
176
198
  let changes = null;
177
199
  if (user?.cellphone && !userPhoneNumber) {
178
200
  changes = {
@@ -298,125 +320,135 @@ export const UserFormDetailsUI = (props: any) => {
298
320
  <>
299
321
  <UDForm>
300
322
  {!validationFields?.loading &&
301
- sortInputFields({ values: validationFields?.fields?.checkout })
323
+ sortInputFields({ values: isOrderTypeValidationField ? checkoutFields : validationFields?.fields?.checkout })
302
324
  .length > 0 && (
303
325
  <UDWrapper>
304
326
  {sortInputFields({
305
- values: validationFields.fields?.checkout,
327
+ values: isOrderTypeValidationField ? checkoutFields : validationFields?.fields?.checkout,
306
328
  }).map(
307
- (field: any) =>
308
- showField &&
309
- showField(field.code) && ((requiredFields && requiredFields.includes(field.code)) || !requiredFields) && (
310
- <React.Fragment key={field.id}>
311
- <Controller
312
- key={field.id}
313
- control={control}
314
- render={() => (
315
- <>
316
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
317
- {t(field?.code?.toUpperCase(), field?.name)}
318
- </OText>
319
- <OInput
320
- name={field.code}
321
- placeholder={t(
322
- field.code.toUpperCase(),
323
- field?.name,
324
- )}
325
- inputStyle={styles.inputStyle}
326
- style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
327
- autoCapitalize={
328
- field.code === 'email' ? 'none' : 'sentences'
329
- }
330
- isDisabled={false}
331
- value={
332
- formState?.changes[field.code] ??
333
- (user && user[field.code]) ??
334
- ''
335
- }
336
- onChange={(val: any) => {
337
- field.code !== 'email'
338
- ? setValue(field.code, val.target.value)
339
- : setValue(
340
- field.code,
341
- val.target.value
342
- .toLowerCase()
343
- .replace(
344
- /[&,()%";:ç?<>{}\\[\]\s]/g,
345
- '',
346
- ),
347
- );
348
- field.code !== 'email'
349
- ? handleChangeInput(val)
350
- : handleChangeInput({
351
- target: {
352
- name: 'email',
353
- value: val.target.value
329
+ (item: any) => {
330
+ const field = item?.validation_field || item
331
+ return (
332
+ ((isOrderTypeValidationField ? item?.enabled : (showField && showField(field.code))) && ((requiredFields && requiredFields?.includes?.(field.code)) || !requiredFields || !isCheckoutPlace)) && (
333
+ <React.Fragment key={field.id}>
334
+ <Controller
335
+ key={field.id}
336
+ control={control}
337
+ render={() => (
338
+ <>
339
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
340
+ {t(field?.code?.toUpperCase(), field?.name)}
341
+ </OText>
342
+ <OInput
343
+ name={field.code}
344
+ placeholder={t(
345
+ field.code.toUpperCase(),
346
+ field?.name,
347
+ )}
348
+ inputStyle={styles.inputStyle}
349
+ style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
350
+ autoCapitalize={
351
+ field.code === 'email' ? 'none' : 'sentences'
352
+ }
353
+ isDisabled={false}
354
+ value={
355
+ formState?.changes[field.code] ??
356
+ (user && user?.guest_id ? user?.guest_email : user[field.code]) ??
357
+ ''
358
+ }
359
+ onChange={(val: any) => {
360
+ field.code !== 'email'
361
+ ? setValue(field.code, val.target.value)
362
+ : setValue(
363
+ field.code,
364
+ val.target.value
354
365
  .toLowerCase()
355
366
  .replace(
356
367
  /[&,()%";:ç?<>{}\\[\]\s]/g,
357
368
  '',
358
369
  ),
359
- },
360
- });
361
- }}
362
- autoCorrect={field.code === 'email' && false}
363
- type={
364
- field.code === 'email'
365
- ? 'email-address'
366
- : 'default'
367
- }
368
- returnKeyType="done"
369
- autoCompleteType={
370
- field.code === 'email' ? 'email' : 'off'
371
- }
372
- />
373
- </>
374
- )}
375
- name={field.code}
376
- rules={getInputRules(field)}
377
- defaultValue={user && user[field.code]}
378
- />
379
- </React.Fragment>
380
- ),
381
- )}
382
- {showInputBirthday && (
383
- <WrapperBirthdate>
384
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
385
- {t('BIRTHDATE', 'Birthdate')}
386
- </OText>
387
- <TouchableOpacity onPress={() => setShowDatePicker(!showDatePicker)}>
388
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ marginTop: 6, marginBottom: -15 }}>
389
- {birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
390
- </OText>
391
- </TouchableOpacity>
392
- <DatePickerUI open={showDatePicker} birthdate={birthdate} onConfirm={_handleChangeDate} onCancel={() => setShowDatePicker(false)} />
393
- </WrapperBirthdate>
394
- )}
395
- {!!showInputPhoneNumber && ((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
396
- <WrapperPhone>
397
- <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
398
- <PhoneInputNumber
399
- data={phoneInputData}
400
- handleData={(val: any) => handleChangePhoneNumber(val)}
401
- changeCountry={(val: any) => changeCountry(val)}
402
- defaultValue={phoneUpdate ? '' : user?.cellphone}
403
- defaultCode={user?.country_code ?? user?.country_phone_code ?? null}
404
- boxStyle={styles.phoneSelect}
405
- inputStyle={styles.phoneInputStyle}
406
- textStyle={{ color: theme.colors.textNormal, fontSize: 12, padding: 0 }}
407
- noDropIcon
408
- />
409
- {phoneUpdate && (
410
- <OText
411
- size={10}
412
- color={theme.colors.error}
413
- style={{ marginHorizontal: 10, textAlign: 'center' }}>
414
- {t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
415
- {user?.cellphone}
416
- </OText>
417
- )}
418
- </WrapperPhone>
370
+ );
371
+ field.code !== 'email'
372
+ ? handleChangeInput(val)
373
+ : handleChangeInput({
374
+ target: {
375
+ name: 'email',
376
+ value: val.target.value
377
+ .toLowerCase()
378
+ .replace(
379
+ /[&,()%";:ç?<>{}\\[\]\s]/g,
380
+ '',
381
+ ),
382
+ },
383
+ });
384
+ }}
385
+ autoCorrect={field.code === 'email' && false}
386
+ type={
387
+ field.code === 'email'
388
+ ? 'email-address'
389
+ : 'default'
390
+ }
391
+ returnKeyType="done"
392
+ autoCompleteType={
393
+ field.code === 'email' ? 'email' : 'off'
394
+ }
395
+ />
396
+ </>
397
+ )}
398
+ name={field.code}
399
+ rules={getInputRules(field)}
400
+ defaultValue={user && (field.code === 'email' && user?.guest_id ? user?.guest_email : user[field.code])}
401
+ />
402
+ </React.Fragment>
403
+ ))
404
+ },
419
405
  )}
406
+ {((!user?.guest_id && showInputBirthday) || (isOrderTypeValidationField || user?.guest_id)) &&
407
+ showInputBirthday &&
408
+ ((requiredFields && requiredFields?.includes?.('birthdate')) || !requiredFields || !isCheckoutPlace) &&
409
+ (
410
+ <>
411
+ <WrapperBirthdate>
412
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
413
+ {t('BIRTHDATE', 'Birthdate')}
414
+ </OText>
415
+ <TouchableOpacity onPress={() => setShowDatePicker(!showDatePicker)}>
416
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ marginTop: 6 }}>
417
+ {birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
418
+ </OText>
419
+ </TouchableOpacity>
420
+ </WrapperBirthdate>
421
+ <DatePickerUI open={showDatePicker} birthdate={birthdate} onConfirm={_handleChangeDate} onCancel={() => setShowDatePicker(false)} />
422
+ </>
423
+ )}
424
+ {((!user?.guest_id && !!showInputPhoneNumber) || (isOrderTypeValidationField || user?.guest_id)) &&
425
+ ((requiredFields && requiredFields?.includes?.('cellphone')) || !requiredFields || !isCheckoutPlace) &&
426
+ (
427
+ <WrapperPhone>
428
+ <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
429
+ <PhoneInputNumber
430
+ data={phoneInputData}
431
+ handleData={(val: any) => handleChangePhoneNumber(val)}
432
+ changeCountry={(val: any) => changeCountry(val)}
433
+ defaultValue={phoneUpdate ? '' : cellphoneValue()}
434
+ defaultCode={user?.country_code ?? user?.country_phone_code ?? null}
435
+ defaultCodeFallback={user?.country_phone_code}
436
+ boxStyle={styles.phoneSelect}
437
+ inputStyle={styles.phoneInputStyle}
438
+ textStyle={{ color: theme.colors.textNormal, fontSize: 12, padding: 0 }}
439
+ noDropIcon
440
+ />
441
+ {phoneUpdate && (
442
+ <OText
443
+ size={10}
444
+ color={theme.colors.error}
445
+ style={{ marginHorizontal: 10, textAlign: 'center' }}>
446
+ {t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
447
+ {cellphoneValue()}
448
+ </OText>
449
+ )}
450
+ </WrapperPhone>
451
+ )}
420
452
  {!requiredFields && (
421
453
  <Controller
422
454
  control={control}
@@ -480,9 +512,7 @@ export const UserFormDetailsUI = (props: any) => {
480
512
  ? t('UPDATING', 'Updating...')
481
513
  : t('UPDATE', 'Update')
482
514
  }
483
- bgColor={theme.colors.primary}
484
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
485
- borderColor={theme.colors.primary}
515
+ textStyle={{ fontSize: 14 }}
486
516
  isDisabled={formState.loading}
487
517
  imgRightSrc={null}
488
518
  style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
@@ -491,7 +521,7 @@ export const UserFormDetailsUI = (props: any) => {
491
521
  )}
492
522
  </>
493
523
  )}
494
- {requiredFields && (
524
+ {isCheckoutPlace && (
495
525
  <OButton
496
526
  text={
497
527
  formState.loading
@@ -500,12 +530,10 @@ export const UserFormDetailsUI = (props: any) => {
500
530
  ? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
501
531
  : t('CONTINUE', 'Continue'))
502
532
  }
503
- bgColor={theme.colors.primary}
504
533
  textStyle={{
505
534
  color: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.primary : theme.colors.white,
506
535
  fontSize: 14
507
536
  }}
508
- borderColor={theme.colors.primary}
509
537
  isDisabled={!user?.guest_id && (formState.loading || !isValid)}
510
538
  imgRightSrc={null}
511
539
  style={{
@@ -519,10 +547,10 @@ export const UserFormDetailsUI = (props: any) => {
519
547
  borderColor: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.white : theme.colors.primary,
520
548
  opacity: !user?.guest_id && (formState.loading || !isValid) ? 0.3 : 1,
521
549
  }}
522
- onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
550
+ onClick={handleSubmit(onSubmit)}
523
551
  />
524
552
  )}
525
- {isCheckout && !!user?.guest_id && (
553
+ {isCheckout && !!user?.guest_id && !requiredFields && (
526
554
  <TouchableOpacity style={{ marginTop: 10 }} onPress={() => handlePlaceOrderAsGuest()}>
527
555
  <OText color={theme.colors.primary} style={{ textAlign: 'center' }}>{t('PLACE_ORDER_AS_GUEST', 'Place order as guest')}</OText>
528
556
  </TouchableOpacity>
@@ -552,4 +580,3 @@ export const UserFormDetailsUI = (props: any) => {
552
580
  </>
553
581
  );
554
582
  };
555
-