ordering-ui-react-native 0.17.42-release → 0.17.43-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.42-release",
3
+ "version": "0.17.43-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { View, StyleSheet, useWindowDimensions, Keyboard } from 'react-native';
3
- import { useLanguage, useSession, useConfig } from 'ordering-components/native';
2
+ import { View, StyleSheet, useWindowDimensions, Keyboard, Platform } from 'react-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,6 +50,23 @@ const StripeElementsFormUI = (props: any) => {
49
50
  const { height } = useWindowDimensions();
50
51
  const { top, bottom } = useSafeAreaInsets();
51
52
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
53
+ const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
54
+ const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
55
+ const styles = StyleSheet.create({
56
+ container: {
57
+ width: '100%',
58
+ paddingHorizontal: 40,
59
+ justifyContent: 'space-between',
60
+ paddingBottom: 12
61
+ },
62
+ btnAddStyle: {
63
+ marginTop: 20,
64
+ borderRadius: 7.6,
65
+ shadowOpacity: 0,
66
+ height: 44,
67
+ marginBottom: isKeyboardShow && Platform.OS === 'ios' ? 40 : 0
68
+ },
69
+ })
52
70
 
53
71
  let billingDetails: any = {}
54
72
 
@@ -150,7 +168,8 @@ const StripeElementsFormUI = (props: any) => {
150
168
  !!card?.last4 &&
151
169
  !!card?.expiryMonth &&
152
170
  !!card?.expiryYear &&
153
- !!card?.brand
171
+ !!card?.brand &&
172
+ ((!zipCodeEnabled || !zipCodeRequired || !!card?.postalCode))
154
173
  )
155
174
  }
156
175
  }, [card])
@@ -201,7 +220,7 @@ const StripeElementsFormUI = (props: any) => {
201
220
  />
202
221
  ) : (
203
222
  <CardField
204
- postalCodeEnabled={true}
223
+ postalCodeEnabled={zipCodeEnabled}
205
224
  cardStyle={{
206
225
  backgroundColor: '#FFFFFF',
207
226
  textColor: '#000000',
@@ -259,21 +278,6 @@ const StripeElementsFormUI = (props: any) => {
259
278
  )
260
279
  }
261
280
 
262
- const styles = StyleSheet.create({
263
- container: {
264
- width: '100%',
265
- paddingHorizontal: 40,
266
- justifyContent: 'space-between',
267
- paddingBottom: 12
268
- },
269
- btnAddStyle: {
270
- marginTop: 20,
271
- borderRadius: 7.6,
272
- shadowOpacity: 0,
273
- height: 44
274
- },
275
- })
276
-
277
281
  export const StripeElementsForm = (props: any) => {
278
282
  const stripeProps = {
279
283
  ...props,