ordering-ui-react-native 0.23.97 → 0.23.98

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.97",
3
+ "version": "0.23.98",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -201,7 +201,7 @@ const CheckoutUI = (props: any) => {
201
201
  const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
202
202
  const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
203
203
  const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
204
-
204
+ const isGuestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
205
205
  const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
206
206
  const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
207
207
  const methodsPay = ['google_pay', 'apple_pay']
@@ -230,7 +230,8 @@ const CheckoutUI = (props: any) => {
230
230
  validateDriverTipField ||
231
231
  validateCouponField ||
232
232
  validateZipcodeCard ||
233
- (!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway))
233
+ (!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway)) ||
234
+ (!isGuestCheckoutEnabled && !!user?.guest_id)
234
235
 
235
236
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
236
237
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -276,6 +277,10 @@ const CheckoutUI = (props: any) => {
276
277
  if (user) setOpenModal({ ...openModal, login: false })
277
278
  }
278
279
 
280
+ const handleOpenGuestSignup = () => {
281
+ setOpenModal({ ...openModal, signup: true, isGuest: true })
282
+ }
283
+
279
284
  const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
280
285
  if (stripePaymethods.includes(paymethodSelected?.gateway) && user?.guest_id) {
281
286
  setOpenModal({ ...openModal, signup: true, isGuest: true })
@@ -671,14 +676,16 @@ const CheckoutUI = (props: any) => {
671
676
  style={{ borderRadius: 7.6, marginTop: 20 }}
672
677
  onClick={() => setOpenModal({ ...openModal, login: true })}
673
678
  />
674
- <OButton
675
- text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
676
- textStyle={{ color: theme.colors.black }}
677
- bgColor={theme.colors.white}
678
- borderColor={theme.colors.black}
679
- style={{ borderRadius: 7.6, marginTop: 20 }}
680
- onClick={() => setAllowedGuest(true)}
681
- />
679
+ {isGuestCheckoutEnabled && (
680
+ <OButton
681
+ text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
682
+ textStyle={{ color: theme.colors.black }}
683
+ bgColor={theme.colors.white}
684
+ borderColor={theme.colors.black}
685
+ style={{ borderRadius: 7.6, marginTop: 20 }}
686
+ onClick={() => setAllowedGuest(true)}
687
+ />
688
+ )}
682
689
  </View>
683
690
  ) : (
684
691
  <UserDetails
@@ -869,6 +876,8 @@ const CheckoutUI = (props: any) => {
869
876
  paymethodClicked={paymethodClicked}
870
877
  setPaymethodClicked={setPaymethodClicked}
871
878
  setUserHasCards={setUserHasCards}
879
+ handleOpenGuestSignup={handleOpenGuestSignup}
880
+ guestDisabledError={(!isGuestCheckoutEnabled && !!user?.guest_id)}
872
881
  />
873
882
  </ChPaymethods>
874
883
  </ChSection>
@@ -1038,6 +1047,14 @@ const CheckoutUI = (props: any) => {
1038
1047
  {t('WARNING_INVALID_COUPON_FIELD', 'Coupon is required.')}
1039
1048
  </OText>
1040
1049
  )}
1050
+ {(!isGuestCheckoutEnabled && !!user?.guest_id) && (
1051
+ <OText
1052
+ color={theme.colors.error}
1053
+ size={12}
1054
+ >
1055
+ {t('LOGIN_SIGN_UP_COMPLETE_ORDER', 'Login/Sign up to complete your order.')}
1056
+ </OText>
1057
+ )}
1041
1058
  </ChErrors>
1042
1059
  </View>
1043
1060
  )}
@@ -103,6 +103,7 @@ const MultiCheckoutUI = (props: any) => {
103
103
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
104
104
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
105
105
  const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
106
+ const isGuestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
106
107
  const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
107
108
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
108
109
  const cartsToShow = openCarts?.length > 0 ? openCarts : cartsInvalid
@@ -123,7 +124,7 @@ const MultiCheckoutUI = (props: any) => {
123
124
 
124
125
  const creditPointGeneralPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
125
126
  const loyalBusinessAvailable = creditPointGeneralPlan?.businesses?.filter((b: any) => b.accumulates) ?? []
126
- const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field : any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
127
+ const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
127
128
 
128
129
  const accumulationRateBusiness = (businessId: number) => {
129
130
  const value = loyalBusinessAvailable?.find((loyal: any) => loyal.business_id === businessId)?.accumulation_rate ?? 0
@@ -162,7 +163,8 @@ const MultiCheckoutUI = (props: any) => {
162
163
  const isDisablePlaceOrderButton = cartGroup?.loading || placing || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
163
164
  (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data) ||
164
165
  walletCarts.length > 0
165
- || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0
166
+ || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0 ||
167
+ (!isGuestCheckoutEnabled && !!user?.guest_id)
166
168
 
167
169
  const handleMomentClick = () => {
168
170
  if (isPreOrder) {
@@ -428,14 +430,16 @@ const MultiCheckoutUI = (props: any) => {
428
430
  style={{ borderRadius: 7.6, marginTop: 20 }}
429
431
  onClick={() => setOpenModal({ ...openModal, login: true })}
430
432
  />
431
- <OButton
432
- text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
433
- textStyle={{ color: theme.colors.black }}
434
- bgColor={theme.colors.white}
435
- borderColor={theme.colors.black}
436
- style={{ borderRadius: 7.6, marginTop: 20 }}
437
- onClick={() => setAllowedGuest(true)}
438
- />
433
+ {isGuestCheckoutEnabled && (
434
+ <OButton
435
+ text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
436
+ textStyle={{ color: theme.colors.black }}
437
+ bgColor={theme.colors.white}
438
+ borderColor={theme.colors.black}
439
+ style={{ borderRadius: 7.6, marginTop: 20 }}
440
+ onClick={() => setAllowedGuest(true)}
441
+ />
442
+ )}
439
443
  </View>
440
444
  ) : (
441
445
  <UserDetails
@@ -643,6 +647,14 @@ const MultiCheckoutUI = (props: any) => {
643
647
  {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
644
648
  </OText>
645
649
  )}
650
+ {(!isGuestCheckoutEnabled && !!user?.guest_id) && (
651
+ <OText
652
+ color={theme.colors.error}
653
+ size={12}
654
+ >
655
+ {t('LOGIN_SIGN_UP_COMPLETE_ORDER', 'Login/Sign up to complete your order.')}
656
+ </OText>
657
+ )}
646
658
  </ChContainer>
647
659
  <OModal
648
660
  open={openModal.signup}
@@ -48,6 +48,8 @@ const stripeDirectMethods = ['stripe_direct']
48
48
  const webViewPaymentGateway: any = ['paypal', 'square']
49
49
  const multiCheckoutMethods = ['global_google_pay', 'global_apple_pay']
50
50
  const cardsPaymethods = ['credomatic']
51
+ const guestNotSupportedMethods = ['stripe', 'stripe_connect', 'stripe_redirect']
52
+ const popupMethods = [...guestNotSupportedMethods, 'stripe_direct', 'paypal']
51
53
 
52
54
  const PaymentOptionsUI = (props: any) => {
53
55
  const {
@@ -77,7 +79,9 @@ const PaymentOptionsUI = (props: any) => {
77
79
  paymethodClicked,
78
80
  setPaymethodClicked,
79
81
  androidAppId,
80
- setUserHasCards
82
+ setUserHasCards,
83
+ guestDisabledError,
84
+ handleOpenGuestSignup
81
85
  } = props
82
86
 
83
87
  const theme = useTheme();
@@ -125,6 +129,11 @@ const PaymentOptionsUI = (props: any) => {
125
129
  const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
126
130
 
127
131
  const handlePaymentMethodClick = (paymethod: any) => {
132
+ const _guestNotSupportedMethods = guestDisabledError ? popupMethods : guestNotSupportedMethods
133
+ if (handleOpenGuestSignup && _guestNotSupportedMethods.includes(paymethod?.gateway) && !!user?.guest_id) {
134
+ handleOpenGuestSignup()
135
+ return
136
+ }
128
137
  if (cart?.balance > 0 || !!user?.guest_id) {
129
138
  if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
130
139
  openUserModal && openUserModal(true)