ordering-ui-react-native 0.14.60 → 0.14.61

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.14.60",
3
+ "version": "0.14.61",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -95,7 +95,7 @@ interface Props {
95
95
  style?: ViewStyle;
96
96
  bgImage: ImageSourcePropType;
97
97
  innerStyle?: ViewStyle;
98
- icon: ImageSourcePropType;
98
+ icon?: ImageSourcePropType;
99
99
  iconStyle?: ImageStyle;
100
100
  callToActionText: string;
101
101
  callToActionTextStyle?: TextStyle;
@@ -15,6 +15,8 @@ import { Container } from '../../layouts/Container'
15
15
  import NavBar from '../NavBar'
16
16
  import { LANDSCAPE, PORTRAIT, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation'
17
17
  import GridContainer from '../../layouts/GridContainer'
18
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
19
+ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
18
20
 
19
21
  const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
20
22
  const {
@@ -27,7 +29,7 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
27
29
  callback
28
30
  } = props
29
31
 
30
- const theme = useTheme();
32
+ const theme = useTheme();
31
33
  const [, t] = useLanguage();
32
34
  const [orientationState] = useDeviceOrientation();
33
35
  const [orderState] = useOrder()
@@ -45,7 +47,7 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
45
47
  }
46
48
 
47
49
  useEffect(() => {
48
- if(isCardCliked){
50
+ if (isCardCliked) {
49
51
  callback?.()
50
52
  setIsCardClicked(false)
51
53
  setIsLoadingCard(null)
@@ -57,8 +59,8 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
57
59
  <Container>
58
60
  <NavBar
59
61
  title={t('ORDER_TYPE_X_ID', 'Order type')}
60
- {...(goBack && { onActionLeft: goBack } )}
61
- btnStyle={{paddingLeft: 0}}
62
+ {...(goBack && { onActionLeft: goBack })}
63
+ btnStyle={{ paddingLeft: 0 }}
62
64
  />
63
65
 
64
66
  <View style={{ marginVertical: orientationState?.dimensions?.height * 0.03 }}>
@@ -83,13 +85,13 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
83
85
  style={cardStyle}
84
86
  isDisabled={isCardCliked}
85
87
  isLoading={isLoadingCard === 'Eat In'}
86
- title={t('EAT_IN','Eat In')}
88
+ title={t('EAT_IN', 'Eat In')}
87
89
  description={t('EAT_IN_DESCRIPTION', 'We are very glad to have you here. Bon appetit!')}
88
90
  bgImage={theme.images.general.eatIn}
89
- icon={theme.images.general.pushPin}
91
+ VectorIcon={() => <MaterialIcon name='pin-outline' size={28} color='white' style={{ marginBottom: 10 }} />}
90
92
  callToActionText={t('START_MY_ORDER', 'Start my order')}
91
93
  onClick={() => {
92
- if(_eatIn?.value !== orderState?.options?.type){
94
+ if (_eatIn?.value !== orderState?.options?.type) {
93
95
  handleChangeOrderType(_eatIn?.value);
94
96
  setIsCardClicked(true)
95
97
  setIsLoadingCard('Eat In')
@@ -106,15 +108,15 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
106
108
 
107
109
  <OptionCard
108
110
  style={cardStyle}
109
- title={t('TAKE_OUT','Take out')}
111
+ title={t('TAKE_OUT', 'Take out')}
110
112
  isDisabled={isCardCliked}
111
113
  isLoading={isLoadingCard === 'Take out'}
112
114
  description={t('TAKE_OUT_DESCRIPTION', 'You are very welcome anytime you visit us!')}
113
115
  bgImage={theme.images.general.takeOut}
114
- icon={theme.images.general.shoppingCart}
116
+ VectorIcon={() => <AntDesignIcon name='shoppingcart' size={28} color='white' style={{ marginBottom: 10 }} />}
115
117
  callToActionText={t('START_MY_ORDER', 'Start my order')}
116
118
  onClick={() => {
117
- if(_takeOut?.value !== orderState?.options?.type){
119
+ if (_takeOut?.value !== orderState?.options?.type) {
118
120
  handleChangeOrderType(_takeOut?.value);
119
121
  setIsCardClicked(true)
120
122
  setIsLoadingCard('Take out')
@@ -246,8 +246,9 @@ export const ProductOptionsUI = (props: any) => {
246
246
  {...navBarProps}
247
247
  titleColor={theme.colors.white}
248
248
  btnStyle={{
249
- width: 66,
250
- height: 66,
249
+ width: 55,
250
+ height: 55,
251
+ overflow: 'scroll',
251
252
  backgroundColor: 'black',
252
253
  borderRadius: 100,
253
254
  color: 'white',
@@ -125,7 +125,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
125
125
  {product.name}
126
126
  </OText>
127
127
 
128
- {product?.price && (
128
+ {!!product?.price && (
129
129
  <OText>
130
130
  <OText
131
131
  color={theme.colors.primary}
@@ -200,7 +200,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
200
200
  {product.name}
201
201
  </OText>
202
202
 
203
- {product?.price && (
203
+ {!!product?.price && (
204
204
  <OText>
205
205
  <OText
206
206
  color={theme.colors.primary}
@@ -127,7 +127,7 @@ const CheckoutUI = (props: any) => {
127
127
  const [openChangeStore, setOpenChangeStore] = useState(false)
128
128
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
129
129
 
130
- const isWalletEnabled = configs?.wallet_enabled?.value === '1'
130
+ const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
131
131
 
132
132
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
133
133
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -569,7 +569,7 @@ const CheckoutUI = (props: any) => {
569
569
  </OText>
570
570
  )}
571
571
 
572
- {!paymethodSelected && cart?.status !== 2 && cart?.valid && (
572
+ {(!paymethodSelected && cart?.balance > 0) && cart?.status !== 2 && cart?.valid && (
573
573
  <OText
574
574
  color={theme.colors.error}
575
575
  size={12}
@@ -605,8 +605,8 @@ const CheckoutUI = (props: any) => {
605
605
  {!cartState.loading && cart && cart?.status !== 2 && (
606
606
  <FloatingButton
607
607
  handleClick={() => handlePlaceOrder()}
608
- isSecondaryBtn={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal < cart?.minimum}
609
- disabled={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal < cart?.minimum}
608
+ isSecondaryBtn={loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash || cart?.subtotal < cart?.minimum}
609
+ disabled={loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash || cart?.subtotal < cart?.minimum}
610
610
  btnText={cart?.subtotal >= cart?.minimum
611
611
  ? (
612
612
  placing
@@ -7,7 +7,8 @@ import {
7
7
  PaymentOptionWallet as PaymentOptionWalletController,
8
8
  useLanguage,
9
9
  useUtils,
10
- useOrder
10
+ useOrder,
11
+ useConfig
11
12
  } from 'ordering-components/native'
12
13
 
13
14
  import {
@@ -27,11 +28,15 @@ const PaymentOptionWalletUI = (props: any) => {
27
28
 
28
29
  const theme = useTheme()
29
30
  const [, t] = useLanguage()
31
+ const [{ configs }] = useConfig()
30
32
  const [{ carts }] = useOrder()
31
33
  const [{ parsePrice }] = useUtils()
32
34
 
33
35
  const cart = carts?.[`businessId:${businessId}`] ?? {}
34
36
 
37
+ const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
38
+ const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
39
+
35
40
  const styles = StyleSheet.create({
36
41
  checkBoxStyle: {
37
42
  width: 25,
@@ -48,9 +53,11 @@ const PaymentOptionWalletUI = (props: any) => {
48
53
  const walletName: any = {
49
54
  cash: {
50
55
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
56
+ isActive: isWalletCashEnabled
51
57
  },
52
58
  credit_point: {
53
59
  name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
60
+ isActive: isWalletPointsEnabled
54
61
  }
55
62
  }
56
63
 
@@ -85,7 +92,7 @@ const PaymentOptionWalletUI = (props: any) => {
85
92
  walletsState.result?.length > 0 &&
86
93
  (
87
94
  <>
88
- {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && (
95
+ {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
89
96
  <Container
90
97
  key={wallet.id}
91
98
  isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
@@ -99,7 +99,7 @@ const ProfileListUI = (props: ProfileParams) => {
99
99
  const { height } = useWindowDimensions();
100
100
  const { top, bottom } = useSafeAreaInsets();
101
101
 
102
- const isWalletEnabled = configs?.wallet_enabled?.value === '1'
102
+ const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
103
103
 
104
104
  const onRedirect = (route: string, params?: any) => {
105
105
  navigation.navigate(route, params)
@@ -35,19 +35,25 @@ const WalletsUI = (props: any) => {
35
35
  const theme = useTheme()
36
36
  const [{ parsePrice, parseDate }] = useUtils()
37
37
  const [{ configs }] = useConfig()
38
+ const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
39
+ const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
38
40
 
39
- const [tabSelected, setTabSelected] = useState('cash')
41
+ const [tabSelected, setTabSelected] = useState(isWalletCashEnabled ? 'cash' : 'credit_point')
42
+
43
+ const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletPointsEnabled)
40
44
 
41
45
  const currentWalletSelected = (walletList.wallets?.length > 0 && walletList.wallets?.find((w: any) => w.type === tabSelected)) ?? null
42
46
 
43
47
  const walletName: any = {
44
48
  cash: {
45
49
  name: t('CASH_WALLET', 'Cash Wallet'),
46
- value: 0
50
+ value: 0,
51
+ isActive: isWalletCashEnabled
47
52
  },
48
53
  credit_point: {
49
54
  name: t('CREDITS_POINTS_WALLET', 'Credit Points Wallet'),
50
- value: 1
55
+ value: 1,
56
+ isActive: isWalletPointsEnabled
51
57
  }
52
58
  }
53
59
 
@@ -61,7 +67,7 @@ const WalletsUI = (props: any) => {
61
67
  }
62
68
 
63
69
  useEffect(() => {
64
- if (configs?.wallet_enabled?.value === '0') {
70
+ if (!isWalletEnabled) {
65
71
  navigation.navigate('BottomTab', {
66
72
  screen: 'Profile'
67
73
  })
@@ -85,7 +91,7 @@ const WalletsUI = (props: any) => {
85
91
  (
86
92
  <>
87
93
  <OTabs>
88
- {walletList.wallets?.map((wallet: any) =>(
94
+ {walletList.wallets?.map((wallet: any) => walletName[wallet.type]?.isActive && (
89
95
  <Pressable
90
96
  key={wallet.id}
91
97
  onPress={() => handleChangeTab(wallet)}