ordering-ui-react-native 0.23.36 → 0.23.38

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.36",
3
+ "version": "0.23.38",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -180,11 +180,11 @@ const CheckoutUI = (props: any) => {
180
180
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
181
181
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
182
182
 
183
- const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field : any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
184
- const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
185
- const guestCheckoutComment = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
186
- const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
187
- const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
183
+ const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
184
+ const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
185
+ const guestCheckoutComment = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
186
+ const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
187
+ const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
188
188
 
189
189
  const placeSpotTypes = [3, 4, 5]
190
190
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
@@ -212,7 +212,7 @@ const CheckoutUI = (props: any) => {
212
212
 
213
213
  const validateCommentsCartField = (guestCheckoutComment?.enabled && (user?.guest_id ? guestCheckoutComment?.required_with_guest : guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
214
214
  const validateDriverTipField = options.type === 1 && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
215
- const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer : any) => offer?.type === 2)
215
+ const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer: any) => offer?.type === 2)
216
216
  const validateZipcodeCard = (guestCheckoutZipcode?.enabled && (user?.guest_id ? guestCheckoutZipcode?.required_with_guest : guestCheckoutZipcode?.required)) && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
217
217
 
218
218
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
@@ -350,20 +350,30 @@ const CheckoutUI = (props: any) => {
350
350
  const checkGuestValidationFields = () => {
351
351
  const userSelected = user
352
352
  const _requiredFields = checkoutFieldsState?.fields
353
- .filter((field) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
353
+ .filter((field : any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
354
354
  !notFields.includes(field?.validation_field?.code) &&
355
+ field?.validation_field?.code !== 'email' &&
355
356
  userSelected && !userSelected[field?.validation_field?.code])
356
- const requiredFieldsCode = _requiredFields.map((item) => item?.validation_field?.code)
357
- const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
357
+ const requiredFieldsCode = _requiredFields.map((item : any) => item?.validation_field?.code)
358
+ const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
359
+ const guestCheckoutEmail = checkoutFieldsState?.fields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'email')
358
360
  if (
359
361
  userSelected &&
360
- !userSelected?.cellphone &&
362
+ !userSelected?.guest_cellphone &&
361
363
  ((guestCheckoutCellPhone?.enabled &&
362
364
  guestCheckoutCellPhone?.required_with_guest) ||
363
365
  configs?.verification_phone_required?.value === '1')
364
366
  ) {
365
367
  requiredFieldsCode.push('cellphone')
366
368
  }
369
+ if (
370
+ userSelected &&
371
+ !userSelected?.guest_email &&
372
+ guestCheckoutEmail?.enabled &&
373
+ guestCheckoutEmail?.required_with_guest
374
+ ) {
375
+ requiredFieldsCode.push('email')
376
+ }
367
377
  setRequiredFields(requiredFieldsCode)
368
378
  }
369
379
 
@@ -713,13 +713,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
713
713
  {order?.customer?.address}
714
714
  </OText>
715
715
  )}
716
- {(!!order?.customer?.cellphone && !hideCustomerPhone) && (
716
+ {(!!(order?.customer?.cellphone || order?.customer?.guest_cellphone) && !hideCustomerPhone) && (
717
717
  <OText
718
718
  size={12}
719
719
  lineHeight={18}
720
720
  color={theme.colors.textNormal}
721
721
  mBottom={2}>
722
- {`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
722
+ {`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.guest_id ? order?.customer?.guest_cellphone : order?.customer?.cellphone}`}
723
723
  </OText>
724
724
  )}
725
725
  </InfoBlock>
@@ -96,23 +96,23 @@ const UserDetailsUI = (props: any) => {
96
96
  },
97
97
  });
98
98
  handleSendVerifyCode({
99
- cellphone: cellphone,
100
- country_phone_code: countryPhoneCode
99
+ cellphone: cellphone,
100
+ country_phone_code: countryPhoneCode
101
101
  })
102
102
  }
103
103
  }
104
104
 
105
105
  const handleSendPhoneCode = (values: any) => {
106
- setWillVerifyOtpState(false)
106
+ setWillVerifyOtpState(false)
107
107
  setIsModalVisible(false)
108
- setFormState({
109
- ...formState,
110
- changes: {
111
- ...formState?.changes,
112
- verification_code: values?.code
113
- }
114
- })
115
- }
108
+ setFormState({
109
+ ...formState,
110
+ changes: {
111
+ ...formState?.changes,
112
+ verification_code: values?.code
113
+ }
114
+ })
115
+ }
116
116
 
117
117
  useEffect(() => {
118
118
  if (willVerifyOtpState) handleVerifyCodeClick()
@@ -190,12 +190,12 @@ const UserDetailsUI = (props: any) => {
190
190
  {userData?.name} {userData?.middle_name} {userData?.lastname} {userData?.second_lastname}
191
191
  </OText>
192
192
  <OText size={12} lineHeight={18} weight={'400'}>
193
- {userData?.email}
193
+ {userData?.guest_id ? userData?.guest_email : userData?.email}
194
194
  </OText>
195
- {!!(userData?.cellphone || user?.cellphone) && (
195
+ {!!((userData?.cellphone ?? userData?.guest_cellphone) || (user?.cellphone ?? user?.guest_cellphone)) && (
196
196
  <>
197
197
  <OText size={12} lineHeight={18} weight={'400'}>
198
- {(userData?.country_phone_code) && `+${(userData?.country_phone_code)} `}{(userData?.cellphone)}
198
+ {(userData?.country_phone_code) && `+${(userData?.country_phone_code)} `}{(userData?.guest_id ? user?.guest_cellphone : userData?.cellphone)}
199
199
  </OText>
200
200
  {!!phoneUpdate && (
201
201
  <OText color={theme.colors.error} style={{ textAlign: 'center' }}>{t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number')}</OText>
@@ -134,7 +134,7 @@ export const UserFormDetailsUI = (props: any) => {
134
134
  };
135
135
 
136
136
  const cellphoneValue = () => {
137
- let cellphone = user?.cellphone || null
137
+ let cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
138
138
  if (cellphone && CONDITIONAL_CODES.includes(user?.country_code)) {
139
139
  if (user?.country_code === 'PR') {
140
140
  cellphone = user?.cellphone?.slice(3)
@@ -148,10 +148,12 @@ export const UserFormDetailsUI = (props: any) => {
148
148
  setUserPhoneNumber(userPhoneNumber);
149
149
  return;
150
150
  }
151
- if (user?.cellphone) {
151
+ const cellphone = user?.guest_id ? user?.guest_cellphone : user?.cellphone
152
+
153
+ if (cellphone) {
152
154
  let phone = null;
153
155
  if (user?.country_phone_code) {
154
- phone = `+${user?.country_phone_code} ${user?.cellphone}`;
156
+ phone = `+${user?.country_phone_code} ${cellphone}`;
155
157
  } else {
156
158
  phone = user?.cellphone;
157
159
  }
@@ -165,7 +167,7 @@ export const UserFormDetailsUI = (props: any) => {
165
167
  });
166
168
  return;
167
169
  }
168
- setUserPhoneNumber(user?.cellphone || '');
170
+ setUserPhoneNumber(cellphone || '');
169
171
  };
170
172
 
171
173
  const onSubmit = () => {
@@ -351,7 +353,7 @@ export const UserFormDetailsUI = (props: any) => {
351
353
  isDisabled={false}
352
354
  value={
353
355
  formState?.changes[field.code] ??
354
- (user && user[field.code]) ??
356
+ (user && user?.guest_id ? user?.guest_email : user[field.code]) ??
355
357
  ''
356
358
  }
357
359
  onChange={(val: any) => {
@@ -395,7 +397,7 @@ export const UserFormDetailsUI = (props: any) => {
395
397
  )}
396
398
  name={field.code}
397
399
  rules={getInputRules(field)}
398
- defaultValue={user && user[field.code]}
400
+ defaultValue={user && (field.code === 'email' && user?.guest_id ? user?.guest_email : user[field.code])}
399
401
  />
400
402
  </React.Fragment>
401
403
  ))
@@ -37,6 +37,7 @@ import {
37
37
  WrapperActions
38
38
  } from './styles'
39
39
 
40
+ const CONDITIONAL_CODES = [1787]
40
41
  const TIME_COUNTDOWN = 60 * 10 // 10 minutes
41
42
 
42
43
  const UserDetails = (props: any) => {
@@ -176,9 +177,18 @@ const UserVerificationUI = (props: any) => {
176
177
  setTimer(`${TIME_COUNTDOWN / 60}:00`)
177
178
  setIsSendCodeAgain(true)
178
179
  if (opt === 'phone') {
180
+ let cellphone = phoneState?.cellphone
181
+ let country_phone_code = phoneState?.country_phone_code
182
+
183
+ if (CONDITIONAL_CODES.includes(Number(country_phone_code))) {
184
+ if (Number(country_phone_code) === 1787) {
185
+ cellphone = `787${cellphone}`
186
+ country_phone_code = '1'
187
+ }
188
+ }
179
189
  sendVerifyPhoneCode({
180
- cellphone: phoneState?.cellphone,
181
- country_phone_code: phoneState?.country_phone_code
190
+ cellphone,
191
+ country_phone_code
182
192
  })
183
193
  return
184
194
  }