ordering-ui-react-native 0.22.54 → 0.22.56

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.22.54",
3
+ "version": "0.22.56",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -224,6 +224,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
224
224
  clientSecret={props.clientSecret}
225
225
  onPaymentChange={handlePaymethodDataChange}
226
226
  newCardAdded={newCardAdded}
227
+ addNewCardAsDefault
227
228
  />
228
229
  </View>
229
230
  )}
@@ -35,7 +35,8 @@ export const ProductOptionSubOptionUI = (props: any) => {
35
35
  disabled,
36
36
  setIsScrollAvailable,
37
37
  image,
38
- enableIntersection
38
+ enableIntersection,
39
+ onChange
39
40
  } = props
40
41
 
41
42
  const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max || state.quantity === suboption?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
@@ -88,6 +89,12 @@ export const ProductOptionSubOptionUI = (props: any) => {
88
89
  }
89
90
  }, [balance])
90
91
 
92
+ useEffect(() => {
93
+ if (!suboption?.preselected || !option?.respect_to) return
94
+ const newState = { ...state, selected: suboption?.preselected, quantity: state.selected ? 0 : 1 }
95
+ onChange(newState, suboption, option)
96
+ }, [suboption, option])
97
+
91
98
  return (
92
99
  <InView onChange={(inView: boolean) => handleChangeInterSection(inView)} triggerOnce={true}>
93
100
  {isIntersectionObserver ? (
@@ -31,7 +31,9 @@ export const StripeCardsListUI = (props: any) => {
31
31
  handleCardClick,
32
32
  onOpen,
33
33
  gateway,
34
- paySelected
34
+ paySelected,
35
+ newCardAdded,
36
+ addNewCardAsDefault
35
37
  } = props;
36
38
 
37
39
  const theme = useTheme();
@@ -55,6 +57,12 @@ export const StripeCardsListUI = (props: any) => {
55
57
  }
56
58
  }, [cardsList?.loading])
57
59
 
60
+ useEffect(() => {
61
+ if (newCardAdded && addNewCardAsDefault){
62
+ handleCardSelected(newCardAdded)
63
+ }
64
+ }, [JSON.stringify(newCardAdded)])
65
+
58
66
  return (
59
67
  <>
60
68
  {token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
@@ -151,7 +151,10 @@ const StripeElementsFormUI = (props: any) => {
151
151
  const _isNewCard = index === 0
152
152
  stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
153
153
  })
154
- setNewCardAdded(card)
154
+ setNewCardAdded?.({
155
+ ...card,
156
+ id: setupIntent?.paymentMethodId
157
+ })
155
158
  } else {
156
159
  stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
157
160
  }