ordering-ui-react-native 0.18.77 → 0.18.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.18.77",
3
+ "version": "0.18.79",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -13,7 +13,8 @@ import {
13
13
  useToast,
14
14
  useSession,
15
15
  ToastType,
16
- useUtils
16
+ useUtils,
17
+ useConfig
17
18
  } from 'ordering-components/native';
18
19
 
19
20
  //Components
@@ -59,7 +60,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
59
60
  } = props;
60
61
  const [, { showToast }] = useToast();
61
62
  const [{ parsePrice, parseNumber }] = useUtils();
63
+ const [{ configs }] = useConfig();
62
64
  const { order } = props.order
65
+
66
+ const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
63
67
  const theme = useTheme();
64
68
  const [, t] = useLanguage();
65
69
  const [session] = useSession();
@@ -295,6 +299,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
295
299
  };
296
300
 
297
301
  const handleViewActionOrder = (action: string) => {
302
+ if (action === 'reject' && !isAllowedDriverRejectOrder) {
303
+ setAlertState({
304
+ open: true,
305
+ content: [
306
+ t('DRIVER_NOT_ALLOWED_TO_REJECT_ORDER', 'The driver is not allowed to reject an order.'),
307
+ ],
308
+ key: null,
309
+ })
310
+ return
311
+ }
298
312
  if (!isGrantedPermissions) {
299
313
  navigation.navigate('RequestPermissions')
300
314
  return
@@ -311,6 +325,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
311
325
  };
312
326
 
313
327
  const handleArrowBack: any = () => {
328
+ if (alertState?.open && !isAllowedDriverRejectOrder) {
329
+ setAlertState({
330
+ ...alertState,
331
+ open: false
332
+ })
333
+ return
334
+ }
314
335
  navigation?.canGoBack() && navigation.goBack();
315
336
  };
316
337
 
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { View, StyleSheet, useWindowDimensions, Keyboard, Platform } from 'react-native';
3
- import { useLanguage, useSession, useConfig } from 'ordering-components/native';
3
+ import { useLanguage, useSession, useConfig, useValidationFields } from 'ordering-components/native';
4
4
  import {
5
5
  StripeProvider,
6
6
  CardField,
@@ -41,6 +41,7 @@ const StripeElementsFormUI = (props: any) => {
41
41
  const [, t] = useLanguage();
42
42
  const [{ user }] = useSession();
43
43
  const [{ configs }] = useConfig();
44
+ const [validationFields] = useValidationFields()
44
45
  const [card, setCard] = useState<any>(null);
45
46
  const [isCompleted, setIsCompleted] = useState(false);
46
47
  const [errors, setErrors] = useState('')
@@ -49,7 +50,8 @@ const StripeElementsFormUI = (props: any) => {
49
50
  const { height } = useWindowDimensions();
50
51
  const { top, bottom } = useSafeAreaInsets();
51
52
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
52
-
53
+ const zipCodeEnabled = validationFields?.checkout?.zipcode?.enabled
54
+ const zipCodeRequired = validationFields?.checkout?.zipcode?.required
53
55
  const styles = StyleSheet.create({
54
56
  container: {
55
57
  width: '100%',
@@ -166,7 +168,8 @@ const StripeElementsFormUI = (props: any) => {
166
168
  !!card?.last4 &&
167
169
  !!card?.expiryMonth &&
168
170
  !!card?.expiryYear &&
169
- !!card?.brand
171
+ !!card?.brand &&
172
+ ((!zipCodeEnabled || !zipCodeRequired || !!card?.postalCode))
170
173
  )
171
174
  }
172
175
  }, [card])
@@ -217,7 +220,7 @@ const StripeElementsFormUI = (props: any) => {
217
220
  />
218
221
  ) : (
219
222
  <CardField
220
- postalCodeEnabled={true}
223
+ postalCodeEnabled={zipCodeEnabled}
221
224
  cardStyle={{
222
225
  backgroundColor: '#FFFFFF',
223
226
  textColor: '#000000',