ordering-ui-react-native 0.18.16 → 0.18.18

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.18.16",
3
+ "version": "0.18.18",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -62,6 +62,7 @@ const AddressFormUI = (props: AddressFormParams) => {
62
62
  isFromProductsList,
63
63
  hasAddressDefault,
64
64
  afterSignup,
65
+ businessSlug
65
66
  } = props;
66
67
 
67
68
  const theme = useTheme();
@@ -162,7 +163,7 @@ const AddressFormUI = (props: AddressFormParams) => {
162
163
  const countryCode = configState?.configs?.country_autocomplete?.value
163
164
  const isHideMap = theme?.address?.components?.map?.hidden
164
165
  const isHideIcons = theme?.address?.components?.icons?.hidden
165
- const continueAsGuest = () => navigation.navigate('BusinessList', { isGuestUser: true });
166
+ const continueAsGuest = () => navigation.navigate(!!businessSlug ? 'Business' : 'BusinessList', { isGuestUser: true });
166
167
  const goToBack = () => navigation?.canGoBack() && navigation.goBack();
167
168
 
168
169
  const getAddressFormatted = (address: any) => {
@@ -39,7 +39,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
39
39
  handleUpdateProducts,
40
40
  previouslyProducts,
41
41
  isFiltMode,
42
- navigation
42
+ navigation,
43
+ businessSingleId
43
44
  } = props;
44
45
 
45
46
  const [, t] = useLanguage();
@@ -92,6 +93,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
92
93
  handleUpdateProducts={handleUpdateProducts}
93
94
  currentCart={currentCart}
94
95
  searchValue={searchValue}
96
+ businessSingleId={businessSingleId}
95
97
  />
96
98
  )}
97
99
  {category.id &&
@@ -112,6 +114,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
112
114
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
113
115
  handleUpdateProducts={handleUpdateProducts}
114
116
  navigation={navigation}
117
+ businessSingleId={businessSingleId}
115
118
  />
116
119
  ))
117
120
  }
@@ -139,6 +142,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
139
142
  handleUpdateProducts={handleUpdateProducts}
140
143
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
141
144
  navigation={navigation}
145
+ businessSingleId={businessSingleId}
142
146
  />
143
147
  ),
144
148
  )}
@@ -240,6 +244,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
240
244
  handleUpdateProducts={handleUpdateProducts}
241
245
  navigation={navigation}
242
246
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
247
+ businessSingleId={businessSingleId}
243
248
  />
244
249
  ))}
245
250
  </>
@@ -68,7 +68,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
68
68
  professionalSelected,
69
69
  handleUpdateProfessionals,
70
70
  handleChangeProfessionalSelected,
71
- onBusinessClick
71
+ onBusinessClick,
72
+ businessSingleId
72
73
  } = props
73
74
 
74
75
  const insets = useSafeAreaInsets()
@@ -314,12 +315,15 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
314
315
  marginTop: Platform.OS === 'ios' ? insets.top : 0
315
316
  }}
316
317
  onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height)}
318
+ hideArrow={(businessSingleId && auth)}
317
319
  >
318
320
  {!isOpenSearchBar && (
319
321
  <>
320
- <TopActions onPress={() => handleBackNavigation()}>
321
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
322
- </TopActions>
322
+ {!(businessSingleId && auth) && (
323
+ <TopActions onPress={() => handleBackNavigation()}>
324
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
325
+ </TopActions>
326
+ )}
323
327
  {!errorQuantityProducts && (
324
328
  <View style={{ ...styles.headerItem }}>
325
329
  <TouchableOpacity
@@ -409,6 +413,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
409
413
  previouslyProducts={business?.previously_products}
410
414
  navigation={navigation}
411
415
  isFiltMode
416
+ businessSingleId={businessSingleId}
412
417
  />
413
418
  </View>
414
419
  </FiltProductsContainer>
@@ -511,6 +516,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
511
516
  handleUpdateProducts={handleUpdateProducts}
512
517
  navigation={navigation}
513
518
  previouslyProducts={business?.previously_products}
519
+ businessSingleId={businessSingleId}
514
520
  />
515
521
  </WrapContent>
516
522
  </>
@@ -7,7 +7,7 @@ export const TopHeader = styled.View`
7
7
  width: 100%;
8
8
  flex-direction: row;
9
9
  align-items: center;
10
- justify-content: space-between;
10
+ justify-content: ${({ hideArrow }: any) => hideArrow ? 'flex-end' : 'space-between'};
11
11
  z-index: 1;
12
12
  height: 60px;
13
13
  min-height: 60px;
@@ -80,6 +80,7 @@ const CheckoutUI = (props: any) => {
80
80
  placing,
81
81
  cartState,
82
82
  cartUuid,
83
+ loyaltyPlansState,
83
84
  businessDetails,
84
85
  paymethodSelected,
85
86
  handlePaymethodChange,
@@ -656,6 +657,7 @@ const CheckoutUI = (props: any) => {
656
657
  <WalletPaymentOptionContainer>
657
658
  <PaymentOptionWallet
658
659
  cart={cart}
660
+ loyaltyPlansState={loyaltyPlansState}
659
661
  businessId={cart?.business_id}
660
662
  businessConfigs={businessDetails?.business?.configs}
661
663
  />
@@ -727,6 +729,7 @@ const CheckoutUI = (props: any) => {
727
729
  placeSpotTypes={placeSpotTypes}
728
730
  businessConfigs={businessConfigs}
729
731
  maxDate={maxDate}
732
+ loyaltyRewardRate={loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')?.accumulation_rate ?? 0}
730
733
  />
731
734
  </>
732
735
  )}
@@ -8,7 +8,7 @@ import { TouchableOpacity } from 'react-native-gesture-handler';
8
8
  import { useWindowDimensions, Platform } from 'react-native';
9
9
 
10
10
  export const Home = (props: any) => {
11
- const { onNavigationRedirect } = props;
11
+ const { onNavigationRedirect, businessSlug } = props;
12
12
  const { width, height } = useWindowDimensions();
13
13
  const [, t] = useLanguage();
14
14
  const [orderState] = useOrder();
@@ -20,7 +20,7 @@ export const Home = (props: any) => {
20
20
 
21
21
  useEffect(() => {
22
22
  if (isAllowUnaddressOrderType) {
23
- onNavigationRedirect('BusinessList')
23
+ onNavigationRedirect(!!businessSlug ? 'Business' : 'BusinessList')
24
24
  }
25
25
  }, [isAllowUnaddressOrderType])
26
26
 
@@ -69,7 +69,7 @@ export const Home = (props: any) => {
69
69
  style={{ ...styles.textLink, marginTop: 12 }}
70
70
  onPress={() =>
71
71
  orderState?.options?.address?.address
72
- ? onNavigationRedirect('BusinessList', { isGuestUser: true })
72
+ ? onNavigationRedirect(!!businessSlug ? 'Business' : 'BusinessList', { isGuestUser: true })
73
73
  : onNavigationRedirect('AddressForm', { isGuestUser: true })
74
74
  }>
75
75
  <OText weight="normal" size={18} color={theme.colors.white}>
@@ -60,6 +60,7 @@ const MultiCheckoutUI = (props: any) => {
60
60
  handleSelectWallet,
61
61
  handlePaymethodDataChange,
62
62
  cartUuid,
63
+ rewardRate,
63
64
  totalCartsFee,
64
65
  cartGroup
65
66
  } = props
@@ -90,6 +91,8 @@ const MultiCheckoutUI = (props: any) => {
90
91
  ? JSON.parse(configs?.driver_tip_options?.value) || []
91
92
  : configs?.driver_tip_options?.value || []
92
93
 
94
+ const loyaltyRewardValue = Math.round(openCarts.reduce((sum: any, cart: any) => sum + cart?.subtotal, 0) / rewardRate)
95
+
93
96
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
94
97
  const [phoneUpdate, setPhoneUpdate] = useState(false);
95
98
  const [userErrors, setUserErrors] = useState<any>([]);
@@ -351,6 +354,13 @@ const MultiCheckoutUI = (props: any) => {
351
354
  </OText>
352
355
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
353
356
  </View>
357
+ {!!loyaltyRewardValue && isFinite(loyaltyRewardValue) && (
358
+ <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'flex-end' }}>
359
+ <OText size={12} color={theme.colors.textNormal}>
360
+ {t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
361
+ </OText>
362
+ </View>
363
+ )}
354
364
  <OText size={12} color={theme.colors.mediumGray} mRight={70} style={{ marginTop: 10 }}>
355
365
  {t('MULTI_CHECKOUT_DESCRIPTION', 'You will receive a receipt for each business. The payment is not combined between multiple stores. Each payment is processed by the store')}
356
366
  </OText>
@@ -20,7 +20,8 @@ export const OrderItAgain = (props: OrderItAgainParams) => {
20
20
  currentCart,
21
21
  handleUpdateProducts,
22
22
  navigation,
23
- searchValue
23
+ searchValue,
24
+ businessSingleId
24
25
  } = props
25
26
 
26
27
  const [, t] = useLanguage()
@@ -65,6 +66,7 @@ export const OrderItAgain = (props: OrderItAgainParams) => {
65
66
  handleUpdateProducts={handleUpdateProducts}
66
67
  navigation={navigation}
67
68
  isPreviously
69
+ businessSingleId={businessSingleId}
68
70
  />
69
71
  </ProductWrapper>
70
72
  ))}
@@ -46,6 +46,7 @@ const OrderSummaryUI = (props: any) => {
46
46
  preorderMaximumDays,
47
47
  preorderMinimumDays,
48
48
  cateringTypes,
49
+ loyaltyRewardRate,
49
50
  maxDate
50
51
  } = props;
51
52
 
@@ -59,6 +60,18 @@ const OrderSummaryUI = (props: any) => {
59
60
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
60
61
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
61
62
 
63
+ const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
64
+ const loyaltyRewardValue = Math.round(cart?.subtotal / loyaltyRewardRate)
65
+
66
+ const walletName: any = {
67
+ cash: {
68
+ name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
69
+ },
70
+ credit_point: {
71
+ name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
72
+ }
73
+ }
74
+
62
75
  const handleDeleteClick = (product: any) => {
63
76
  removeProduct(product, cart)
64
77
  }
@@ -101,17 +114,6 @@ const OrderSummaryUI = (props: any) => {
101
114
  })
102
115
  }
103
116
 
104
- const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
105
-
106
- const walletName: any = {
107
- cash: {
108
- name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
109
- },
110
- credit_point: {
111
- name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
112
- }
113
- }
114
-
115
117
  return (
116
118
  <OSContainer>
117
119
  {cart?.products?.length > 0 && (
@@ -310,6 +312,13 @@ const OrderSummaryUI = (props: any) => {
310
312
  {parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
311
313
  </OText>
312
314
  </OSTable>
315
+ {!!loyaltyRewardValue && isFinite(loyaltyRewardValue) && (
316
+ <OSTable style={{ justifyContent: 'flex-end' }}>
317
+ <OText size={12} color={theme.colors.textNormal}>
318
+ {t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
319
+ </OText>
320
+ </OSTable>
321
+ )}
313
322
  </View>
314
323
  )}
315
324
  {cart?.business_id && cart?.status !== 2 && (
@@ -591,7 +591,7 @@ const SignupFormUI = (props: SignupParams) => {
591
591
  control={control}
592
592
  render={({ onChange, value }: any) => (
593
593
  <OInput
594
- placeholder={t(field.name)}
594
+ placeholder={t(field.name?.replace(/\s/g, '_')?.toUpperCase(), field.name)}
595
595
  style={style.inputStyle}
596
596
  icon={
597
597
  field.code === 'email'
@@ -40,7 +40,8 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
40
40
  navigation,
41
41
  businessId,
42
42
  isPreviously,
43
- viewString
43
+ viewString,
44
+ businessSingleId
44
45
  } = props;
45
46
 
46
47
  const theme = useTheme();
@@ -180,7 +181,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
180
181
  >
181
182
  <View style={{ flexDirection: logoPosition === 'left' ? 'row-reverse' : 'row' }}>
182
183
  {productAddedToCartLength > 0 && (
183
- <QuantityContainer style={[styles.quantityContainer, {
184
+ <QuantityContainer businessSingleId={businessSingleId} style={[styles.quantityContainer, {
184
185
  transform: [{ translateX: 25 }, { translateY: -25 }],
185
186
  }]}>
186
187
  <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
@@ -283,8 +284,8 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
283
284
  {!hideProductLogo && (
284
285
  <FastImage
285
286
  style={styles.productStyle}
286
- source={product?.images || typeof theme?.images?.dummies?.product === 'string' ? {
287
- uri: optimizeImage(product?.images || theme?.images?.dummies?.products, 'h_250,c_limit'),
287
+ source={product?.images ? {
288
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
288
289
  priority: FastImage.priority.normal,
289
290
  } : theme?.images?.dummies?.product}
290
291
  resizeMode={FastImage.resizeMode.cover}
@@ -18,6 +18,11 @@ export const QuantityContainer = styled.View`
18
18
  background: ${({ theme }: any) => theme.colors.primary};
19
19
  align-items: center;
20
20
  justify-content: center;
21
+ ${({businessSingleId} : any) => businessSingleId ? css`
22
+ left: 0;
23
+ ` : css`
24
+ right: 0;
25
+ `}
21
26
  `
22
27
  export const PricesContainer = styled.View`
23
28
  flex-direction: row;
@@ -92,7 +92,8 @@ export interface AddressFormParams {
92
92
  hasAddressDefault?: any,
93
93
  isFromCheckout?: boolean
94
94
  afterSignup?: boolean
95
- isGuestFromStore?: boolean
95
+ isGuestFromStore?: boolean,
96
+ businessSlug?: number | string
96
97
  }
97
98
  export interface SignupParams {
98
99
  navigation?: any;
@@ -254,6 +255,7 @@ export interface BusinessProductsListingParams {
254
255
  handleUpdateProfessionals?: any;
255
256
  onBusinessClick?: any;
256
257
  onNavigationRedirect?: any;
258
+ businessSingleId?: number | string
257
259
  }
258
260
  export interface BusinessBasicInformationParams {
259
261
  navigation?: any;
@@ -305,6 +307,7 @@ export interface BusinessProductsListParams {
305
307
  handleUpdateProducts?: any,
306
308
  navigation?: any;
307
309
  previouslyProducts?: any;
310
+ businessSingleId?: number | string
308
311
  }
309
312
  export interface SingleProductCardParams {
310
313
  businessId: any;
@@ -321,6 +324,7 @@ export interface SingleProductCardParams {
321
324
  isPreviously?: any;
322
325
  isProductId?: any;
323
326
  viewString?: string;
327
+ businessSingleId?: number
324
328
  }
325
329
  export interface BusinessInformationParams {
326
330
  navigation?: any,
@@ -800,7 +804,8 @@ export interface OrderItAgainParams {
800
804
  currentCart: any,
801
805
  handleUpdateProducts: any,
802
806
  navigation: any,
803
- searchValue?: string
807
+ searchValue?: string,
808
+ businessSingleId?: number | string
804
809
  }
805
810
 
806
811
  export interface PreviousProductsOrderedParams {