ordering-ui-react-native 0.22.48 → 0.22.49-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 -8
  2. package/src/DeliveryApp.tsx +1 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/src/providers/AlertProvider.tsx +3 -1
  8. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  9. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  10. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  11. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  12. package/themes/business/src/components/Chat/index.tsx +15 -3
  13. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  14. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  15. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  16. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  17. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  18. package/themes/business/src/components/MapView/index.tsx +42 -25
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
  20. package/themes/business/src/components/OrderDetails/Business.tsx +88 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  24. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  27. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  28. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +332 -231
  30. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  31. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +30 -18
  33. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  34. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  35. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  36. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  37. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  38. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  46. package/themes/business/src/config/currency.tsx +1010 -0
  47. package/themes/business/src/hooks/useLocation.tsx +16 -12
  48. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  49. package/themes/business/src/types/index.tsx +22 -7
  50. package/themes/business/src/utils/index.tsx +28 -3
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  55. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/original/index.tsx +9 -1
  62. package/themes/original/src/components/AddressForm/index.tsx +19 -19
  63. package/themes/original/src/components/AddressList/index.tsx +0 -13
  64. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  65. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  70. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
  71. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  72. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  73. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  74. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  75. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  76. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  77. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  78. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  79. package/themes/original/src/components/Cart/index.tsx +49 -15
  80. package/themes/original/src/components/CartContent/index.tsx +2 -4
  81. package/themes/original/src/components/Checkout/index.tsx +109 -88
  82. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  83. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  84. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  85. package/themes/original/src/components/Favorite/index.tsx +1 -10
  86. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  87. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -12
  88. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  89. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  90. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  91. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  92. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  93. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  94. package/themes/original/src/components/Help/index.tsx +0 -5
  95. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -5
  96. package/themes/original/src/components/HelpGuide/index.tsx +0 -5
  97. package/themes/original/src/components/HelpOrder/index.tsx +0 -5
  98. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  99. package/themes/original/src/components/Home/index.tsx +35 -19
  100. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  101. package/themes/original/src/components/LoginForm/index.tsx +12 -14
  102. package/themes/original/src/components/MessageListing/index.tsx +1 -6
  103. package/themes/original/src/components/Messages/index.tsx +20 -13
  104. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  105. package/themes/original/src/components/MomentOption/index.tsx +73 -59
  106. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  107. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -4
  108. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  109. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  110. package/themes/original/src/components/MyOrders/index.tsx +2 -7
  111. package/themes/original/src/components/NavBar/index.tsx +7 -6
  112. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  113. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  114. package/themes/original/src/components/Notifications/index.tsx +0 -5
  115. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  116. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
  117. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  118. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  119. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  120. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  121. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -11
  122. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  123. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  124. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  125. package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
  126. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  127. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  128. package/themes/original/src/components/PreviousOrders/index.tsx +1 -4
  129. package/themes/original/src/components/ProductForm/ActionButton.tsx +7 -12
  130. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  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 +2 -7
  134. package/themes/original/src/components/ReviewDriver/index.tsx +1 -6
  135. package/themes/original/src/components/ReviewOrder/index.tsx +2 -7
  136. package/themes/original/src/components/ReviewProducts/index.tsx +1 -6
  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 -8
  140. package/themes/original/src/components/SignupForm/index.tsx +44 -37
  141. package/themes/original/src/components/SingleOrderCard/index.tsx +7 -5
  142. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  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 +16 -3
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +8 -4
  147. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -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 +8 -5
  151. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  152. package/themes/original/src/components/UserFormDetails/index.tsx +113 -73
  153. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  154. package/themes/original/src/components/UserProfileForm/index.tsx +0 -5
  155. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  156. package/themes/original/src/components/Wallets/index.tsx +1 -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 +12 -4
  163. package/themes/original/src/utils/index.tsx +29 -0
  164. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,12 +1,13 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import PhoneInput from "react-native-phone-number-input";
3
- import { StyleSheet, View } from 'react-native';
3
+ import { Pressable, StyleSheet, View } from 'react-native';
4
4
  import { useLanguage, useConfig } from 'ordering-components/native';
5
5
  import { useTheme } from 'styled-components/native';
6
6
  import { Wrapper } from './styles'
7
7
 
8
8
  import { PhoneInputParams } from '../../types';
9
9
  import { OIcon, OText } from '../shared';
10
+ import { OModal } from '../../../../../src/components/shared'
10
11
  import { findExitingCode, transformCountryCode } from '../../utils'
11
12
 
12
13
  export const PhoneInputNumber = (props: PhoneInputParams) => {
@@ -25,7 +26,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
25
26
  isDisabled,
26
27
  isStartValidation,
27
28
  changeCountry,
28
- updateStateWithSubmit
29
+ updateStateWithSubmit,
30
+ defaultCodeFallback
29
31
  } = props
30
32
 
31
33
  const theme = useTheme();
@@ -34,6 +36,13 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
34
36
  const [{ configs }] = useConfig()
35
37
  const phoneInput = useRef<PhoneInput>(null);
36
38
  const [userphoneNumber, setUserphoneNumber] = useState('');
39
+ const [countryPhoneSuboptions, setCountryPhoneSuboptions] = useState({
40
+ open: false,
41
+ options: []
42
+ })
43
+ const isDisableNumberValidation = parseInt(configs?.validation_phone_number_lib?.value ?? 1, 10)
44
+ const countriesWithSubOptions = ['PR']
45
+ const codesStartsWithZero: any = ['44']
37
46
 
38
47
  const style = StyleSheet.create({
39
48
  input: {
@@ -62,13 +71,22 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
62
71
  useEffect(() => {
63
72
  if ((defaultValue && userphoneNumber) || !defaultValue) {
64
73
  if (userphoneNumber) {
65
- const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
74
+ const validationsForUK = ['01', '02', '07', '0800', '0808', '0845', '0870', '0871']
75
+
76
+ let isPossibly = false
77
+ let numberWithoutCountryCode = ''
66
78
  const callingCode = phoneInput.current?.getCallingCode();
79
+ const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
80
+ if (codesStartsWithZero.includes(callingCode)) {
81
+ numberWithoutCountryCode = cellphone.replace(callingCode || '', '')
82
+ const result = validationsForUK.some(areaCode => numberWithoutCountryCode?.startsWith(areaCode))
83
+ isPossibly = result && numberWithoutCountryCode?.length >= 10 && numberWithoutCountryCode?.length < 12
84
+ }
85
+ const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
67
86
  const formattedNumber = phoneInput.current?.getNumberAfterPossiblyEliminatingZero();
68
87
  const regex = /^[0-9]*$/
69
- const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
70
88
  const validNumber = regex.test(cellphone)
71
- if ((!checkValid && formattedNumber?.number) || !validNumber) {
89
+ if (((!checkValid && formattedNumber?.number && !isPossibly) || !validNumber) && !!isDisableNumberValidation) {
72
90
  handleData && handleData({
73
91
  ...data,
74
92
  error: t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid')
@@ -80,8 +98,11 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
80
98
  error: '',
81
99
  phone: {
82
100
  country_phone_code: callingCode,
83
- cellphone: formattedNumber?.number
101
+ cellphone: !isDisableNumberValidation ? cellphone.slice(callingCode?.length) : formattedNumber?.number
84
102
  }
103
+ }, {
104
+ countryCallingCode: callingCode,
105
+ number: numberWithoutCountryCode,
85
106
  })
86
107
  } else {
87
108
  handleData && handleData({
@@ -109,6 +130,37 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
109
130
  }
110
131
  }, [defaultValue])
111
132
 
133
+ useEffect(() => {
134
+ if (defaultCodeFallback && countriesWithSubOptions.includes(defaultCode) && phoneInput.current) {
135
+ phoneInput.current?.setState({
136
+ ...phoneInput.current.state,
137
+ code: `${defaultCodeFallback}`
138
+ })
139
+ }
140
+ }, [phoneInput.current])
141
+
142
+ const _changeCountry = (c) => {
143
+ changeCountry?.(c)
144
+ if (c.callingCode?.length > 1) {
145
+ setCountryPhoneSuboptions({
146
+ open: true,
147
+ options: c.callingCode
148
+ })
149
+ }
150
+ }
151
+
152
+ const handleSelectCallingCode = (option: any) => {
153
+ setCountryPhoneSuboptions({
154
+ open: false,
155
+ options: []
156
+ })
157
+ handleChangeNumber(`+${option}`)
158
+ phoneInput.current?.setState({
159
+ ...phoneInput.current.state,
160
+ code: `${option}`
161
+ })
162
+ }
163
+
112
164
  return (
113
165
  <Wrapper onPress={() => forwardRef?.current?.focus?.()}>
114
166
  {(isStartValidation && userphoneNumber === '') && (
@@ -130,7 +182,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
130
182
  : findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
131
183
  onChangeFormattedText={(text: string) => handleChangeNumber(text)}
132
184
  withDarkTheme
133
- onChangeCountry={(country) => changeCountry?.(country)}
185
+ onChangeCountry={(country: any) => _changeCountry?.(country)}
134
186
  countryPickerProps={{ withAlphaFilter: true }}
135
187
  textContainerStyle={{ ...style.input, ...inputStyle ? inputStyle : {} }}
136
188
  textInputStyle={textStyle}
@@ -151,6 +203,39 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
151
203
  {data.error}
152
204
  </OText>
153
205
  )}
206
+ <OModal
207
+ open={countryPhoneSuboptions.open}
208
+ onClose={() => setCountryPhoneSuboptions({
209
+ open: false,
210
+ options: []
211
+ })}
212
+ title={t('SELECT_THE_PHONE_CODE', 'Select the phone code')}
213
+ entireModal
214
+ >
215
+ <View
216
+ style={{
217
+ alignItems: 'center'
218
+ }}
219
+ >
220
+ {countryPhoneSuboptions.options.map((option: any) => (
221
+ <Pressable
222
+ style={{
223
+ margin: 10,
224
+ padding: 10,
225
+ borderBottomColor: '#ccc',
226
+ borderBottomWidth: 1,
227
+ width: '100%'
228
+ }}
229
+ key={option}
230
+ onPress={() => handleSelectCallingCode(option)}
231
+ >
232
+ <OText>
233
+ {`+${option}`}
234
+ </OText>
235
+ </Pressable>
236
+ ))}
237
+ </View>
238
+ </OModal>
154
239
  </Wrapper>
155
240
  )
156
241
  }
@@ -236,9 +236,7 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
236
236
  <View style={{ alignItems: 'flex-start' }}>
237
237
  <OButton
238
238
  onClick={() => onChangeSpot()}
239
- bgColor={theme.colors.primary}
240
- borderColor={theme.colors.primary}
241
- textStyle={{ color: 'white', fontSize: 12 }}
239
+ textStyle={{ fontSize: 12 }}
242
240
  imgRightSrc={null}
243
241
  text={t('UPDATE_SPOT_NUMBER', 'Update')}
244
242
  isDisabled={(!spotNumber && !Object.values(vehicle).every(e => e))}
@@ -27,7 +27,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
27
27
 
28
28
  const [, t] = useLanguage();
29
29
 
30
- const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
30
+ const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
31
31
 
32
32
  return (
33
33
  <View style={{ marginBottom: 30 }}>
@@ -49,9 +49,6 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
49
49
  onClick={loadMoreOrders}
50
50
  text={t('LOAD_MORE_ORDERS', 'Load more orders')}
51
51
  imgRightSrc={null}
52
- bgColor={theme.colors.primary}
53
- borderColor={theme.colors.primary}
54
- textStyle={{ color: theme.colors.white }}
55
52
  style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
56
53
  />
57
54
  </WrappButton>
@@ -43,9 +43,9 @@ export const ActionButton = (props: any) => {
43
43
  style={{
44
44
  width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
45
45
  }}>
46
- {((productCart &&
46
+ {(productCart &&
47
47
  auth &&
48
- (orderState.options?.address_id || isAllowUnaddressOrderType)) || (isSoldOut || maxProductQuantity <= 0)) && (
48
+ ((orderState.options?.address_id || isAllowUnaddressOrderType) || (isSoldOut || maxProductQuantity <= 0))) && (
49
49
  <OButton
50
50
  onClick={() => handleSaveProduct()}
51
51
  imgRightSrc=""
@@ -57,15 +57,11 @@ export const ActionButton = (props: any) => {
57
57
  ? t('UPDATE', 'Update')
58
58
  : t('ADD', 'Add')
59
59
  }`}
60
- isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order))}
60
+ isDisabled={buttonColor}
61
61
  textStyle={{
62
- color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
63
62
  fontSize: orderState.loading || editMode ? 10 : 14
64
63
  }}
65
- bgColor={buttonColor ? theme.colors.lightGray : theme.colors.primary}
66
- borderColor={!buttonColor ? theme.colors.white : theme.colors.primary}
67
64
  style={{
68
- opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
69
65
  borderRadius: 7.6,
70
66
  height: 44,
71
67
  shadowOpacity: 0,
@@ -84,7 +80,7 @@ export const ActionButton = (props: any) => {
84
80
  textStyle={{ fontSize: 10 }}
85
81
  />
86
82
  ) : (
87
- <OButton onClick={navigation.navigate('AddressList')} />
83
+ <OButton onClick={() => navigation.navigate('AddressList')} />
88
84
  ))}
89
85
  {!auth && (
90
86
  <OButton
@@ -96,13 +92,12 @@ export const ActionButton = (props: any) => {
96
92
  : t('LOGIN_SIGNUP', 'Login / Sign Up')
97
93
  }
98
94
  imgRightSrc=""
99
- textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
95
+ textStyle={{ fontSize: 13, textAlign: 'center' }}
100
96
  style={{
101
97
  height: 42,
102
- borderColor: theme.colors.primary,
103
- backgroundColor: theme.colors.white,
104
98
  paddingLeft: 0,
105
- paddingRight: 0
99
+ paddingRight: 0,
100
+ borderRadius: 7.6
106
101
  }}
107
102
  />
108
103
  )}
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { View, Animated, StyleSheet, TouchableOpacity } from 'react-native'
3
- import { useUtils, useLanguage, useOrder } from 'ordering-components/native'
3
+ import { useUtils, useLanguage, useOrder, ProductItemAccordion as ProductItemAccordionController } from 'ordering-components/native'
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
6
6
  import RNPickerSelect from 'react-native-picker-select'
@@ -24,7 +24,7 @@ import { OIcon, OText, OAlert, OModal } from '../shared'
24
24
 
25
25
  import { ProductItemAccordionParams } from '../../types'
26
26
 
27
- export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
27
+ export const ProductItemAccordionUI = (props: ProductItemAccordionParams) => {
28
28
 
29
29
  const {
30
30
  isDisabledEdit,
@@ -36,6 +36,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
36
36
  onDeleteProduct,
37
37
  onEditProduct,
38
38
  isFromCheckout,
39
+ productInfo
39
40
  } = props
40
41
 
41
42
  const theme = useTheme();
@@ -46,6 +47,14 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
46
47
  const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
47
48
  const hideProductCommentHide = isFromCheckout && theme?.checkout?.components?.cart?.components?.product?.components?.comments?.hidden
48
49
 
50
+ const styles = StyleSheet.create({
51
+ productImage: {
52
+ borderRadius: 7.6,
53
+ width: 48,
54
+ height: 48
55
+ }
56
+ })
57
+
49
58
  const pickerStyle = StyleSheet.create({
50
59
  inputAndroid: {
51
60
  width: 45,
@@ -91,24 +100,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
91
100
  const [isServiceOpen, setIsServiceOpen] = useState(false)
92
101
  const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
93
102
 
94
- const productInfo = () => {
95
- if (isCartProduct) {
96
- const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
97
- let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
98
-
99
- options = options.map((option: any) => {
100
- option.suboptions = Object.values(option.suboptions ?? {})
101
- return option
102
- })
103
- return {
104
- ...productInfo,
105
- ingredients,
106
- options
107
- }
108
- }
109
- return product
110
- }
111
-
112
103
  const handleEditProduct = (curProduct: any) => {
113
104
  if (!curProduct?.calendar_event) {
114
105
  onEditProduct && onEditProduct(curProduct)
@@ -154,8 +145,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
154
145
  isValid={product?.valid ?? true}
155
146
  onPress={
156
147
  (!product?.valid_menu && isCartProduct) ||
157
- !(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || !!product.comment)
158
- ? null : () => setActiveState(!isActive)
148
+ !(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment)
149
+ ? null : () => setActiveState(!isActive)
159
150
  }
160
151
  >
161
152
  <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
@@ -246,7 +237,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
246
237
  <View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
247
238
  <View style={{ flexDirection: 'row' }}>
248
239
  <OText size={12} lineHeight={18} weight={'400'}>{parsePrice(product.total || product.price)}</OText>
249
- {(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || !!product.comment) && (
240
+ {(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment) && (
250
241
  <MaterialCommunityIcon name='chevron-down' size={18} />
251
242
  )}
252
243
  </View>
@@ -290,20 +281,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
290
281
  <View style={{ display: isActive ? 'flex' : 'none', paddingStart: isFromCheckout ? 100 : 40, marginTop: isFromCheckout ? -80 : -30 }}>
291
282
  <Animated.View>
292
283
  <AccordionContent>
293
- {productInfo().ingredients.length > 0 && productInfo().ingredients.some((ingredient: any) => !ingredient.selected) && (
284
+ {productInfo.ingredients.length > 0 && productInfo.ingredients.some((ingredient: any) => !ingredient.selected) && (
294
285
  <ProductOptionsList>
295
286
  <OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
296
- {productInfo().ingredients.map((ingredient: any, i) => !ingredient.selected && (
287
+ {productInfo.ingredients.map((ingredient: any, i) => !ingredient.selected && (
297
288
  <OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
298
289
  ))}
299
290
  </ProductOptionsList>
300
291
  )}
301
- {productInfo().options.length > 0 && (
292
+ {productInfo.options.length > 0 && (
302
293
  <ProductOptionsList>
303
- {productInfo().options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => (
294
+ {productInfo.options.map((option: any) => (
304
295
  <ProductOption key={option.id}>
305
296
  <OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
306
- {option.suboptions.map((suboption: any) => (
297
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map((suboption: any) => (
307
298
  <ProductSubOption key={suboption.id}>
308
299
  <OText size={10} color={theme.colors.textThird}>
309
300
  {getFormattedSubOptionName({
@@ -350,13 +341,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
350
341
  )
351
342
  }
352
343
 
353
- const styles = StyleSheet.create({
354
- productImage: {
355
- borderRadius: 7.6,
356
- width: 48,
357
- height: 48
358
- },
359
- test: {
360
- overflow: 'hidden',
344
+ export const ProductItemAccordion = (props: any) => {
345
+ const productItemAccordionProps = {
346
+ ...props,
347
+ UIComponent: ProductItemAccordionUI
361
348
  }
362
- })
349
+
350
+ return (
351
+ <ProductItemAccordionController {...productItemAccordionProps} />
352
+ )
353
+ }
@@ -35,10 +35,17 @@ export const ProductOptionSubOptionUI = (props: any) => {
35
35
  disabled,
36
36
  setIsScrollAvailable,
37
37
  image,
38
- enableIntersection
38
+ enableIntersection,
39
+ usePizzaValidation,
40
+ pizzaState
39
41
  } = props
40
42
 
41
- const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max || state.quantity === suboption?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
43
+ const disableIncrement =
44
+ option?.with_half_option
45
+ ? pizzaState?.[`option:${option?.id}`]?.value === option?.max
46
+ : option?.limit_suboptions_by_max
47
+ ? (balance === option?.max || state.quantity === suboption.max)
48
+ : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
42
49
  const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
43
50
 
44
51
  const theme = useTheme();
@@ -65,8 +72,9 @@ export const ProductOptionSubOptionUI = (props: any) => {
65
72
  const handleSuboptionClick = () => {
66
73
  toggleSelect()
67
74
  setIsDirty(true)
75
+ const minMaxValidation = option?.with_half_option ? usePizzaValidation : (balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))
68
76
 
69
- if (balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1)) {
77
+ if (!state.selected && minMaxValidation) {
70
78
  setShowMessage(true)
71
79
  }
72
80
  }
@@ -86,7 +94,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
86
94
  if (!(balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))) {
87
95
  setShowMessage(false)
88
96
  }
89
- }, [balance])
97
+ }, [balance, pizzaState?.[`option:${option?.id}`]?.value])
90
98
 
91
99
  return (
92
100
  <InView onChange={(inView: boolean) => handleChangeInterSection(inView)} triggerOnce={true}>
@@ -122,7 +130,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
122
130
  {suboption?.name}
123
131
  </OText>
124
132
  </IconControl>
125
- {option?.allow_suboption_quantity && state?.selected && (
133
+ {!(option?.max === 1 && option?.min === 1) && option?.allow_suboption_quantity && state?.selected && (
126
134
  <QuantityControl>
127
135
  <>
128
136
  <Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
@@ -135,11 +143,11 @@ export const ProductOptionSubOptionUI = (props: any) => {
135
143
  <OText size={12}>
136
144
  {state.quantity}
137
145
  </OText>
138
- <Checkbox disabled={disabled || disableIncrement} onPress={increment}>
146
+ <Checkbox disabled={disabled || disableIncrement || usePizzaValidation} onPress={increment}>
139
147
  <IconAntDesign
140
148
  name='pluscircleo'
141
149
  size={iconsSize}
142
- color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
150
+ color={disableIncrement || disabled || usePizzaValidation ? theme.colors.disabled : theme.colors.primary}
143
151
  />
144
152
  </Checkbox>
145
153
  </>
@@ -157,7 +165,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
157
165
  style={styles.inverse}
158
166
  />
159
167
  </Circle>
160
- <Circle disabled={disabled} onPress={() => changePosition('whole')}>
168
+ <Circle disabled={disabled || (pizzaState?.[`option:${option?.id}`]?.value === option?.max)} onPress={() => changePosition('whole')}>
161
169
  <OIcon
162
170
  src={theme.images.general.half_f}
163
171
  color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
@@ -233,7 +233,7 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
233
233
  <CalendarWrapper>
234
234
  {(timeList?.length > 0 && isEnabled) ? (
235
235
  <SelectDropdown
236
- ref={dropdownRef}
236
+ ref={dropdownRef}
237
237
  data={timeList}
238
238
  onSelect={(selectedItem, index) => {
239
239
  console.log(selectedItem.value)
@@ -244,7 +244,7 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
244
244
  rowTextForSelection={(item, index) => {
245
245
  return item.text
246
246
  }}
247
- buttonStyle={{borderRadius: 7.6, ...styles.selectOption}}
247
+ buttonStyle={{ borderRadius: 7.6, ...styles.selectOption }}
248
248
  buttonTextStyle={{
249
249
  color: theme.colors.disabled,
250
250
  fontSize: 14,
@@ -267,7 +267,7 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
267
267
  }}
268
268
  renderCustomizedRowChild={(item, index) => {
269
269
  return (
270
- <Text style={[styles.dropDownRow, { color: isBusyTime(professional, getMomentTime(item.value)) ? theme.colors.lightGray : theme.colors.primary } ]}>
270
+ <Text style={[styles.dropDownRow, { color: isBusyTime(professional, getMomentTime(item.value)) ? theme.colors.lightGray : theme.colors.primary }]}>
271
271
  {item.text}
272
272
  </Text>
273
273
  )
@@ -326,11 +326,10 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
326
326
  </ScheduleWrapper>
327
327
  <ButtonWrapper>
328
328
  <OButton
329
- bgColor={theme.colors.primary}
330
329
  onClick={() => handleSelectProfessional()}
331
330
  text={t('BOOK', 'Book')}
332
331
  style={styles.buttonStyle}
333
- textStyle={{ fontSize: 14, color: theme.colors.white }}
332
+ textStyle={{ fontSize: 14 }}
334
333
  />
335
334
  </ButtonWrapper>
336
335
  </Container>
@@ -113,11 +113,6 @@ const PromotionsUI = (props: PromotionParams) => {
113
113
  paddingTop={Platform.OS === 'ios' ? 20 : 10}
114
114
  style={{ paddingVertical: 0 }}
115
115
  btnStyle={{ paddingLeft: 0 }}
116
- buttonProps={{
117
- bgColor: theme.colors.white,
118
- borderColor: theme.colors.white,
119
- textStyle: { color: theme.colors.btnFont }
120
- }}
121
116
  />
122
117
  <PromotionsContainer>
123
118
  <SearchBarContainer>
@@ -176,7 +171,7 @@ const PromotionsUI = (props: PromotionParams) => {
176
171
  onClick={() => handleClickOffer(offer)}
177
172
  text={t('VIEW', 'View')}
178
173
  style={styles.buttonStyle}
179
- textStyle={{ fontSize: 14, color: '#fff', flexWrap: 'nowrap' }}
174
+ textStyle={{ fontSize: 14, flexWrap: 'nowrap' }}
180
175
  />
181
176
  </WrapperSingleOffer>
182
177
  ))}
@@ -240,7 +235,7 @@ const PromotionsUI = (props: PromotionParams) => {
240
235
  onClick={() => handleBusinessClick(business)}
241
236
  text={t('GO_TO_BUSINESSS', 'Go to business')}
242
237
  style={styles.modalButtonStyle}
243
- textStyle={{ fontSize: 10, color: '#fff' }}
238
+ textStyle={{ fontSize: 10 }}
244
239
  />
245
240
  </BusinessInfo>
246
241
  </SingleBusinessOffer>
@@ -192,11 +192,6 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
192
192
  style={{ flexDirection: 'column', alignItems: 'flex-start' }}
193
193
  titleWrapStyle={{ paddingHorizontal: 0 }}
194
194
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
195
- buttonProps={{
196
- bgColor: theme.colors.white,
197
- borderColor: theme.colors.white,
198
- textStyle: { color: theme.colors.btnFont }
199
- }}
200
195
  />
201
196
  <DriverPhotoContainer>
202
197
  <View
@@ -298,7 +293,7 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
298
293
  <FloatingBottomContainer>
299
294
  <ActionContainer>
300
295
  <OButton
301
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
296
+ textStyle={{ paddingRight: 10 }}
302
297
  text={t('SEND_REVIEW', 'Send Review')}
303
298
  style={{ borderRadius: 8 }}
304
299
  imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
@@ -215,11 +215,6 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
215
215
  style={{ flexDirection: 'column', alignItems: 'flex-start' }}
216
216
  titleWrapStyle={{ paddingHorizontal: 0 }}
217
217
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
218
- buttonProps={{
219
- bgColor: theme.colors.white,
220
- borderColor: theme.colors.white,
221
- textStyle: { color: theme.colors.btnFont }
222
- }}
223
218
  />
224
219
  <BusinessLogo isMulti={order?.business?.length > 1}>
225
220
  {typeof order?.logo === 'string' || !order?.logo ? (
@@ -232,7 +227,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
232
227
  </View>
233
228
  ) : (
234
229
  <MultiLogosContainer>
235
- {order?.logo?.map((logo : string, i : number) => (
230
+ {order?.logo?.map((logo: string, i: number) => (
236
231
  <React.Fragment key={logo}>
237
232
  <View style={styles.logoWrapper}>
238
233
  <OIcon
@@ -338,7 +333,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
338
333
  <OText weight={700} size={18} color={theme.colors.textNormal}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
339
334
  </SkipButton>
340
335
  <OButton
341
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
336
+ textStyle={{ paddingRight: 10 }}
342
337
  text={t('CONTINUE', 'Continue')}
343
338
  style={{ borderRadius: 8 }}
344
339
  imgRightSrc={theme.images.general.arrow_right}
@@ -73,11 +73,6 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
73
73
  style={{ flexDirection: 'column', alignItems: 'flex-start' }}
74
74
  titleWrapStyle={{ paddingHorizontal: 0 }}
75
75
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
76
- buttonProps={{
77
- bgColor: theme.colors.white,
78
- borderColor: theme.colors.white,
79
- textStyle: { color: theme.colors.btnFont }
80
- }}
81
76
  />
82
77
  {order?.products && order.products.length > 0 && order?.products.map(productsOrder => (
83
78
  productsOrder?.length ? productsOrder?.map((product: any, i: any) => !product?.deleted ?
@@ -109,7 +104,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
109
104
  <OText weight={700} size={18} color={theme.colors.textNormal}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
110
105
  </SkipButton>
111
106
  <OButton
112
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
107
+ textStyle={{ paddingRight: 10 }}
113
108
  text={order?.driver && !order?.user_review ? t('CONTINUE', 'Continue') : t('SEND_REVIEW', 'Send Review')}
114
109
  style={{ borderRadius: 8 }}
115
110
  imgRightSrc={theme.images.general.arrow_right}
@@ -90,7 +90,7 @@ export const ReviewTrigger = (props: any) => {
90
90
  </View>
91
91
  ) : (
92
92
  <MultiLogosContainer>
93
- {order?.logo?.map((logo : string, i : number) => (
93
+ {order?.logo?.map((logo: string, i: number) => (
94
94
  <React.Fragment key={logo}>
95
95
  <View style={styles.logoWrapper}>
96
96
  <OIcon
@@ -122,7 +122,7 @@ export const ReviewTrigger = (props: any) => {
122
122
  <FloatingBottomContainer borderTopWidth={0} borderRadius={10}>
123
123
  <ActionContainer>
124
124
  <OButton
125
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
125
+ textStyle={{ paddingRight: 10 }}
126
126
  text={t('GOTO_REVIEW', 'Go to review')}
127
127
  style={{ borderRadius: 8 }}
128
128
  imgRightSrc={theme.images.general.arrow_right}