ordering-ui-react-native 0.21.29 → 0.21.31-test

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.21.29",
3
+ "version": "0.21.31-test",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -126,46 +126,46 @@ const NewOrderNotificationUI = (props: any) => {
126
126
  }, [])
127
127
 
128
128
  useEffect(() => {
129
- return () => {
130
- handleCloseEvents()
131
- }
129
+ return () => handleCloseEvents()
132
130
  }, [])
133
131
 
134
132
  return (
135
- <Modal
136
- animationType='slide'
137
- transparent={true}
138
- visible={!!currentEvent?.orderId}
139
- >
140
- <NotificationContainer>
141
- <View style={styles.modalView}>
142
- <TouchableOpacity
143
- style={styles.wrapperIcon}
144
- onPress={() => handleCloseEvents()}
145
- >
146
- <Icon name="x" size={30} />
147
- </TouchableOpacity>
148
- <OText
149
- size={18}
150
- color={theme.colors.textGray}
151
- weight={600}
152
- >
153
- {evtList[currentEvent?.evt]?.message}
154
- </OText>
155
- <OIcon
156
- src={theme.images.general.newOrder}
157
- width={250}
158
- height={200}
159
- />
160
- <OText
161
- color={theme.colors.textGray}
162
- mBottom={15}
163
- >
164
- {evtList[currentEvent?.evt]?.message2}
165
- </OText>
166
- </View>
167
- </NotificationContainer>
168
- </Modal>
133
+ <>
134
+ <Modal
135
+ animationType='slide'
136
+ transparent={true}
137
+ visible={!!currentEvent?.orderId}
138
+ >
139
+ <NotificationContainer>
140
+ <View style={styles.modalView}>
141
+ <TouchableOpacity
142
+ style={styles.wrapperIcon}
143
+ onPress={() => handleCloseEvents()}
144
+ >
145
+ <Icon name="x" size={30} />
146
+ </TouchableOpacity>
147
+ <OText
148
+ size={18}
149
+ color={theme.colors.textGray}
150
+ weight={600}
151
+ >
152
+ {evtList[currentEvent?.evt]?.message}
153
+ </OText>
154
+ <OIcon
155
+ src={theme.images.general.newOrder}
156
+ width={250}
157
+ height={200}
158
+ />
159
+ <OText
160
+ color={theme.colors.textGray}
161
+ mBottom={15}
162
+ >
163
+ {evtList[currentEvent?.evt]?.message2}
164
+ </OText>
165
+ </View>
166
+ </NotificationContainer>
167
+ </Modal>
168
+ </>
169
169
  )
170
170
  }
171
171
 
@@ -162,6 +162,7 @@ const CheckoutUI = (props: any) => {
162
162
  const [allowedGuest, setAllowedGuest] = useState(false)
163
163
  const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
164
164
  const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
165
+ const [paymethodClicked, setPaymethodClicked] = useState<any>(null)
165
166
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
166
167
  const cardsMethods = ['credomatic']
167
168
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
@@ -742,6 +743,10 @@ const CheckoutUI = (props: any) => {
742
743
  setPlaceByMethodPay={setPlaceByMethodPay}
743
744
  cardList={cardList}
744
745
  setCardList={setCardList}
746
+ requiredFields={requiredFields}
747
+ openUserModal={setIsOpen}
748
+ paymethodClicked={paymethodClicked}
749
+ setPaymethodClicked={setPaymethodClicked}
745
750
  />
746
751
  </ChPaymethods>
747
752
  </ChSection>
@@ -926,7 +931,14 @@ const CheckoutUI = (props: any) => {
926
931
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
927
932
  onClose={() => {
928
933
  setIsOpen(false)
929
- handlePlaceOrder(null, true)
934
+ if (paymethodClicked) {
935
+ setPaymethodClicked({
936
+ ...paymethodClicked,
937
+ confirmed: true
938
+ })
939
+ } else {
940
+ handlePlaceOrder(null, true)
941
+ }
930
942
  }}
931
943
  setIsOpen={setIsOpen}
932
944
  />
@@ -69,7 +69,11 @@ const PaymentOptionsUI = (props: any) => {
69
69
  methodPaySupported,
70
70
  setPlaceByMethodPay,
71
71
  setCardList,
72
- onPaymentChange
72
+ onPaymentChange,
73
+ requiredFields,
74
+ openUserModal,
75
+ paymethodClicked,
76
+ setPaymethodClicked
73
77
  } = props
74
78
 
75
79
  const theme = useTheme();
@@ -115,6 +119,14 @@ const PaymentOptionsUI = (props: any) => {
115
119
 
116
120
  const handlePaymentMethodClick = (paymethod: any) => {
117
121
  if (cart?.balance > 0) {
122
+ if (paymethod?.gateway === 'paypal' && requiredFields.length > 0) {
123
+ openUserModal && openUserModal(true)
124
+ setPaymethodClicked({
125
+ confirmed: false,
126
+ paymethod
127
+ })
128
+ return
129
+ }
118
130
  const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
119
131
  if (webViewPaymentGateway.includes(paymethod?.gateway)) {
120
132
  handlePaymentMethodClickCustom(paymethod)
@@ -159,7 +171,14 @@ const PaymentOptionsUI = (props: any) => {
159
171
  handlePlaceOrder(confirmApplePayPayment)
160
172
  }
161
173
  }, [paymethodData, paymethodSelected])
162
-
174
+
175
+ useEffect(() => {
176
+ if (paymethodClicked?.confirmed) {
177
+ handlePaymentMethodClickCustom(paymethodClicked?.paymethod)
178
+ }
179
+ }, [paymethodClicked?.confirmed])
180
+
181
+
163
182
  const renderPaymethods = ({ item }: any) => {
164
183
  return (
165
184
  <>