ordering-ui-react-native 0.17.78 → 0.17.79

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.78",
3
+ "version": "0.17.79",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -184,6 +184,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
184
184
  }
185
185
 
186
186
  const handleUpsellingPage = () => {
187
+ setOpenUpselling(false)
188
+ setCanOpenUpselling(false)
189
+ const cartSelectedHasGroup = currentCart?.group?.uuid
190
+ const cartFilterValidation = (cart: any) => cart?.valid && cart?.status !== 2
191
+ const cartsGroupLength = cartSelectedHasGroup ? Object.values(orderState.carts).filter((_cart: any) => _cart?.group?.uuid === cartSelectedHasGroup && cartFilterValidation(_cart))?.length : 0
192
+ if (cartsGroupLength > 1 && isCheckoutMultiBusinessEnabled) {
193
+ props.onNavigationRedirect('CheckoutNavigator', {
194
+ screen: 'MultiCheckout',
195
+ cartUuid: currentCart?.group?.uuid
196
+ })
197
+ return
198
+ }
199
+ const cartGroupsCount: any = {}
200
+ Object.values(orderState.carts).filter(_cart => cartFilterValidation(_cart))?.forEach((_cart: any) => {
201
+ if (cartGroupsCount[_cart?.group?.uuid]) {
202
+ cartGroupsCount[_cart?.group?.uuid] += 1
203
+ } else {
204
+ cartGroupsCount[_cart?.group?.uuid] = 1
205
+ }
206
+ })
207
+ let groupForTheCart
208
+ const groupForAddCartArray = Object.keys(cartGroupsCount).filter(cartGroupUuid => cartGroupsCount[cartGroupUuid] > 0 && cartGroupsCount[cartGroupUuid] < 5)
209
+ const max = Math.max(...groupForAddCartArray.map(uuid => cartGroupsCount[uuid]))
210
+ const indexes = groupForAddCartArray.filter(uuid => cartGroupsCount[uuid] === max)
211
+ if (indexes?.length > 1) {
212
+ groupForTheCart = indexes.find(uuid => uuid !== 'undefined')
213
+ } else {
214
+ groupForTheCart = indexes[0]
215
+ }
187
216
  if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
188
217
  onRedirect('CheckoutNavigator', {
189
218
  screen: 'MultiCheckout'
@@ -531,7 +560,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
531
560
  btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
532
561
  btnRightValue={parsePrice(currentCart?.total)}
533
562
  disabled={subtotalWithTaxes < currentCart?.minimum || openUpselling}
534
- hideButton={isCheckoutMultiBusinessEnabled}
535
563
  handleClick={() => setOpenUpselling(true)}
536
564
  />
537
565
  </View>
@@ -22,8 +22,7 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
22
22
  disabled,
23
23
  isSecondaryBtn,
24
24
  handleEmpty,
25
- iosBottom,
26
- hideButton
25
+ iosBottom
27
26
  } = props;
28
27
 
29
28
  const [, t] = useLanguage();
@@ -78,17 +77,15 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
78
77
  </View>
79
78
  )}
80
79
  </View>
81
- {!hideButton && (
82
- <Button
83
- style={[isSecondaryBtn ? styles.secondaryBtn : styles.primaryBtn]}
84
- onPress={handleButtonClick}
85
- disabled={disabled}
86
- >
87
- <OText color={isSecondaryBtn ? theme.colors.textSecondary : theme.colors.white} lineHeight={24} size={14} weight={'400'}>
88
- {btnText}
89
- </OText>
90
- </Button>
91
- )}
80
+ <Button
81
+ style={[isSecondaryBtn ? styles.secondaryBtn : styles.primaryBtn]}
82
+ onPress={handleButtonClick}
83
+ disabled={disabled}
84
+ >
85
+ <OText color={isSecondaryBtn ? theme.colors.textSecondary : theme.colors.white} lineHeight={24} size={14} weight={'400'}>
86
+ {btnText}
87
+ </OText>
88
+ </Button>
92
89
  </Container>
93
90
  );
94
91
  };
@@ -23,7 +23,7 @@ export const MyOrders = (props: any) => {
23
23
  const [isEmptyBusinesses, setIsEmptyBusinesses] = useState(false)
24
24
  const [businessOrderIds, setBusinessOrderIds] = useState([])
25
25
  const [ordersLength, setOrdersLength] = useState({
26
- activeOrdersLength: 0,
26
+ activeOrdersLength: null,
27
27
  previousOrdersLength: 0,
28
28
  });
29
29
  const [selectedOption, setSelectedOption] = useState(!hideOrders ? 'orders' : 'business')
@@ -143,7 +143,7 @@ export const MyOrders = (props: any) => {
143
143
  )}
144
144
  {selectedOption === 'orders' && (
145
145
  <>
146
- {ordersLength?.activeOrdersLength > 0 && (
146
+ {ordersLength?.activeOrdersLength !== 0 && (
147
147
  <View style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
148
148
  <OrdersOption
149
149
  {...props}
@@ -192,14 +192,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
192
192
  useEffect(() => {
193
193
  if (loading) return
194
194
 
195
- const updateOrders = orders.filter((order: any) => orderStatus.includes(order.status))
195
+ const updateOrders = _orders.filter((order: any) => orderStatus.includes(order.status))
196
196
 
197
197
  if (activeOrders) {
198
198
  setOrdersLength && setOrdersLength({ ...ordersLength, activeOrdersLength: updateOrders?.length })
199
199
  } else if (!preOrders) {
200
200
  setOrdersLength && setOrdersLength({ ...ordersLength, previousOrdersLength: updateOrders?.length })
201
201
  }
202
- }, [orders, activeOrders, preOrders])
202
+ }, [_orders, activeOrders, preOrders])
203
203
 
204
204
  useEffect(() => {
205
205
  if (refreshOrders) {
@@ -251,6 +251,7 @@ export interface BusinessProductsListingParams {
251
251
  handleChangeProfessionalSelected?: any;
252
252
  handleUpdateProfessionals?: any;
253
253
  onBusinessClick?: any;
254
+ onNavigationRedirect?: any;
254
255
  }
255
256
  export interface BusinessBasicInformationParams {
256
257
  navigation?: any;
@@ -533,7 +534,6 @@ export interface FloatingButtonParams {
533
534
  handleClick?: any;
534
535
  handleEmpty?: any;
535
536
  iosBottom?: number
536
- hideButton?: boolean
537
537
  }
538
538
  export interface MomentOptionParams {
539
539
  navigation: any;