ordering-ui-react-native 0.23.56 → 0.23.58

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.23.56",
3
+ "version": "0.23.58",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -175,9 +175,12 @@ const CheckoutUI = (props: any) => {
175
175
  const [showTitle, setShowTitle] = useState(false)
176
176
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
177
177
  const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
178
+ const [userHasCards, setUserHasCards] = useState(false)
178
179
  const containerRef = useRef<any>()
179
180
  const cardsMethods = ['credomatic']
180
181
  const stripePaymethods: any = ['stripe', 'stripe_connect', 'stripe_redirect']
182
+ const cardsPaymethods: any = ['stripe', 'stripe_connect']
183
+
181
184
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
182
185
 
183
186
  const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
@@ -226,8 +229,8 @@ const CheckoutUI = (props: any) => {
226
229
  validateCommentsCartField ||
227
230
  validateDriverTipField ||
228
231
  validateCouponField ||
229
- validateZipcodeCard
230
-
232
+ validateZipcodeCard ||
233
+ (!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway))
231
234
 
232
235
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
233
236
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -266,7 +269,9 @@ const CheckoutUI = (props: any) => {
266
269
  user,
267
270
  token: user?.session?.access_token
268
271
  })
269
- openModal?.isGuest && handlePlaceOrderAsGuest()
272
+ if (openModal?.isGuest && requiredFields?.length === 0) {
273
+ openModal?.isGuest && handlePlaceOrderAsGuest()
274
+ }
270
275
  setOpenModal({ ...openModal, signup: false, isGuest: false })
271
276
  }
272
277
 
@@ -409,12 +414,14 @@ const CheckoutUI = (props: any) => {
409
414
  }, [errors])
410
415
 
411
416
  useEffect(() => {
412
- if (cart?.products?.length === 0) {
413
- if (cart?.business_id !== null) {
414
- onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
415
- } else if (isGiftCardCart) {
416
- onNavigationRedirect('Wallets')
417
- }
417
+ if (cart?.products?.length === 0 || !userLoading) return
418
+ if (cart?.business_id !== null) {
419
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
420
+ return
421
+ }
422
+ if (isGiftCardCart) {
423
+ onNavigationRedirect('Wallets')
424
+ return
418
425
  }
419
426
  }, [cart?.products?.length])
420
427
 
@@ -864,6 +871,7 @@ const CheckoutUI = (props: any) => {
864
871
  openUserModal={setIsOpen}
865
872
  paymethodClicked={paymethodClicked}
866
873
  setPaymethodClicked={setPaymethodClicked}
874
+ setUserHasCards={setUserHasCards}
867
875
  />
868
876
  </ChPaymethods>
869
877
  </ChSection>
@@ -377,7 +377,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
377
377
  titleWrapStyle={{ paddingHorizontal: 0 }}
378
378
  />
379
379
  )}
380
- {(preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder && (
380
+ {((preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder) && (
381
381
  <WrapSelectOption
382
382
  onPress={() => _handleAsap()}
383
383
  disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
@@ -510,4 +510,4 @@ export const MomentOption = (props: any) => {
510
510
  UIComponent: MomentOptionUI,
511
511
  };
512
512
  return <MomentOptionController {...momentOptionProps} />;
513
- };
513
+ };
@@ -76,7 +76,8 @@ const PaymentOptionsUI = (props: any) => {
76
76
  openUserModal,
77
77
  paymethodClicked,
78
78
  setPaymethodClicked,
79
- androidAppId
79
+ androidAppId,
80
+ setUserHasCards
80
81
  } = props
81
82
 
82
83
  const theme = useTheme();
@@ -348,6 +349,7 @@ const PaymentOptionsUI = (props: any) => {
348
349
  businessId={props.businessId}
349
350
  onPaymentChange={onPaymentChange}
350
351
  paySelected={props.paySelected}
352
+ setUserHasCards={setUserHasCards}
351
353
  />
352
354
  </View>
353
355
  )}
@@ -440,6 +442,7 @@ const PaymentOptionsUI = (props: any) => {
440
442
  publicKey={isOpenMethod?.paymethod?.credentials.publishable}
441
443
  publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
442
444
  paySelected={props.paySelected}
445
+ setUserHasCards={setUserHasCards}
443
446
  />
444
447
  </View>
445
448
  )}
@@ -87,7 +87,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
87
87
  error: '',
88
88
  phone: {
89
89
  country_phone_code: callingCode,
90
- cellphone: !isDisableNumberValidation ? userphoneNumber : formattedNumber?.number
90
+ cellphone: !isDisableNumberValidation ? cellphone.slice(callingCode?.length) : formattedNumber?.number
91
91
  }
92
92
  })
93
93
  } else {
@@ -32,7 +32,8 @@ export const StripeCardsListUI = (props: any) => {
32
32
  gateway,
33
33
  paySelected,
34
34
  newCardAdded,
35
- addNewCardAsDefault
35
+ addNewCardAsDefault,
36
+ setUserHasCards
36
37
  } = props;
37
38
 
38
39
  const theme = useTheme();
@@ -62,6 +63,11 @@ export const StripeCardsListUI = (props: any) => {
62
63
  }
63
64
  }, [JSON.stringify(newCardAdded)])
64
65
 
66
+ useEffect(() => {
67
+ const hasCardSelected = cardsList?.cards?.some?.((card : any) => card?.id === paySelected?.data?.id)
68
+ setUserHasCards && setUserHasCards(cardsList?.cards?.length > 0 && hasCardSelected)
69
+ }, [cardsList?.cards?.length])
70
+
65
71
  return (
66
72
  <>
67
73
  {token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (