ordering-ui-react-native 0.22.53 → 0.22.55

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.53",
3
+ "version": "0.22.55",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -156,7 +156,7 @@ const NewOrderNotificationUI = (props: any) => {
156
156
  setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
157
157
  }
158
158
  }
159
- if (!orderStatus.includes(value.status) || value?.author_id === user.id) return
159
+ if ((!orderStatus.includes(value.status) && evtType !== 1) || value?.author_id === user.id) return
160
160
  setCurrentEvent({
161
161
  evt: evtType,
162
162
  orderId: value?.driver
@@ -168,6 +168,7 @@ const CheckoutUI = (props: any) => {
168
168
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
169
169
  const [isOpen, setIsOpen] = useState(false)
170
170
  const [requiredFields, setRequiredFields] = useState<any>([])
171
+ const [orderTypeValidationFields, setOrderTypeValidationFields] = useState<any>([])
171
172
  const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
172
173
  const [allowedGuest, setAllowedGuest] = useState(false)
173
174
  const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
@@ -179,7 +180,7 @@ const CheckoutUI = (props: any) => {
179
180
  const containerRef = useRef<any>()
180
181
  const cardsMethods = ['credomatic']
181
182
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
182
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
183
+ const notFields = ['coupon', 'mobile_phone', 'address', 'zipcode', 'address_notes']
183
184
  const placeSpotTypes = [3, 4, 5]
184
185
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
185
186
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -342,22 +343,22 @@ const CheckoutUI = (props: any) => {
342
343
  const checkGuestValidationFields = () => {
343
344
  const userSelected = user
344
345
  const _requiredFields = checkoutFieldsState?.fields
345
- .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required &&
346
+ .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
346
347
  !notFields.includes(field?.validation_field?.code) &&
347
348
  userSelected && !userSelected[field?.validation_field?.code])
348
- .map((item: any) => item?.validation_field?.code)
349
+ const requiredFieldsCode = _requiredFields.map((item: any) => item?.validation_field?.code)
349
350
  const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
350
-
351
351
  if (
352
352
  userSelected &&
353
353
  !userSelected?.cellphone &&
354
354
  ((guestCheckoutCellPhone?.enabled &&
355
- guestCheckoutCellPhone?.required) ||
355
+ guestCheckoutCellPhone?.required_with_guest) ||
356
356
  configs?.verification_phone_required?.value === '1')
357
357
  ) {
358
- _requiredFields.push('cellphone')
358
+ requiredFieldsCode.push('cellphone')
359
359
  }
360
- setRequiredFields(_requiredFields)
360
+ setRequiredFields(requiredFieldsCode)
361
+ setOrderTypeValidationFields(_requiredFields)
361
362
  }
362
363
 
363
364
  const togglePhoneUpdate = (val: boolean) => {
@@ -1045,8 +1046,10 @@ const CheckoutUI = (props: any) => {
1045
1046
  phoneUpdate={phoneUpdate}
1046
1047
  togglePhoneUpdate={togglePhoneUpdate}
1047
1048
  requiredFields={requiredFields}
1049
+ orderTypeValidationFields={orderTypeValidationFields}
1048
1050
  hideUpdateButton
1049
1051
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
1052
+ isGuest={!!user?.guest_id}
1050
1053
  onClose={() => {
1051
1054
  setIsOpen(false)
1052
1055
  if (paymethodClicked) {
@@ -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
  )}
@@ -84,7 +84,7 @@ export const ActionButton = (props: any) => {
84
84
  textStyle={{ fontSize: 10 }}
85
85
  />
86
86
  ) : (
87
- <OButton onClick={navigation.navigate('AddressList')} />
87
+ <OButton onClick={() => navigation.navigate('AddressList')} />
88
88
  ))}
89
89
  {!auth && (
90
90
  <OButton
@@ -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
  }
@@ -36,7 +36,9 @@ export const UserFormDetailsUI = (props: any) => {
36
36
  isCheckout,
37
37
  setIsOpen,
38
38
  handleRemoveAccount,
39
- isProfile
39
+ isProfile,
40
+ isGuest,
41
+ orderTypeValidationFields
40
42
  } = props;
41
43
 
42
44
  const theme = useTheme();
@@ -298,16 +300,16 @@ export const UserFormDetailsUI = (props: any) => {
298
300
  <>
299
301
  <UDForm>
300
302
  {!validationFields?.loading &&
301
- sortInputFields({ values: validationFields?.fields?.checkout })
303
+ sortInputFields({ values: isGuest ? orderTypeValidationFields : validationFields?.fields?.checkout })
302
304
  .length > 0 && (
303
305
  <UDWrapper>
304
306
  {sortInputFields({
305
- values: validationFields.fields?.checkout,
307
+ values: isGuest ? orderTypeValidationFields : validationFields?.fields?.checkout,
306
308
  }).map(
307
309
  (item: any) => {
308
310
  const field = item?.validation_field || item
309
- return (showField &&
310
- showField(field.code) && ((requiredFields && requiredFields?.includes?.(field.code)) || !requiredFields) && (
311
+ return (
312
+ (isGuest ? item?.enabled : showField && showField(field.code)) && ((requiredFields && requiredFields?.includes?.(field.code)) || !requiredFields) && (
311
313
  <React.Fragment key={field.id}>
312
314
  <Controller
313
315
  key={field.id}