ordering-ui-react-native 0.18.18 → 0.18.19

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.18.18",
3
+ "version": "0.18.19",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -8,6 +8,7 @@ import { SignupForm } from '../SignupForm'
8
8
  import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
9
9
 
10
10
  import { OText, OButton, OInput, OModal } from '../shared';
11
+ import Alert from '../../providers/AlertProvider'
11
12
 
12
13
  import { PhoneInputNumber } from '../PhoneInputNumber';
13
14
  import { sortInputFields } from '../../utils';
@@ -83,16 +84,17 @@ export const UserFormDetailsUI = (props: any) => {
83
84
  cellphone: null,
84
85
  },
85
86
  });
87
+ const [alertState, setAlertState] = useState({ open: false, content: '' })
86
88
 
87
89
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
88
90
 
89
91
  const handleSuccessSignup = (user: any) => {
90
- login({
91
- user,
92
- token: user?.session?.access_token
93
- })
94
- handlePlaceOrderAsGuest && handlePlaceOrderAsGuest()
95
- }
92
+ login({
93
+ user,
94
+ token: user?.session?.access_token
95
+ })
96
+ handlePlaceOrderAsGuest && handlePlaceOrderAsGuest()
97
+ }
96
98
 
97
99
  const getInputRules = (field: any) => {
98
100
  const rules: any = {
@@ -199,11 +201,6 @@ export const UserFormDetailsUI = (props: any) => {
199
201
  handleChangeInput(countryCode, true);
200
202
  }
201
203
 
202
- const handleClickBtn = () => {
203
- if (!user?.guest_id) handleSubmit(onSubmit)
204
- else setIsModalOpen(true)
205
- }
206
-
207
204
  useEffect(() => {
208
205
  if (Object.keys(errors).length > 0) {
209
206
  const list = Object.values(errors);
@@ -223,6 +220,12 @@ export const UserFormDetailsUI = (props: any) => {
223
220
  if (!formState?.loading && formState?.result?.error) {
224
221
  formState.result?.result &&
225
222
  showToast(ToastType.Error, formState.result?.result[0]);
223
+ if (isCheckout) {
224
+ setAlertState({
225
+ open: true,
226
+ content: formState.result?.result[0]
227
+ })
228
+ }
226
229
  }
227
230
  }, [formState?.loading]);
228
231
 
@@ -441,8 +444,8 @@ export const UserFormDetailsUI = (props: any) => {
441
444
  formState.loading
442
445
  ? t('UPDATING', 'Updating...')
443
446
  : ((isCheckout && !!user?.guest_id)
444
- ? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
445
- : t('CONTINUE', 'Continue'))
447
+ ? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
448
+ : t('CONTINUE', 'Continue'))
446
449
  }
447
450
  bgColor={theme.colors.white}
448
451
  textStyle={{ color: theme.colors.primary, fontSize: 14 }}
@@ -450,7 +453,7 @@ export const UserFormDetailsUI = (props: any) => {
450
453
  isDisabled={!user?.guest_id && (formState.loading || !isValid)}
451
454
  imgRightSrc={null}
452
455
  style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
453
- onClick={handleClickBtn}
456
+ onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
454
457
  />
455
458
  )}
456
459
  {isCheckout && !!user?.guest_id && (
@@ -462,7 +465,7 @@ export const UserFormDetailsUI = (props: any) => {
462
465
  open={isModalOpen}
463
466
  onClose={() => setIsModalOpen(false)}
464
467
  >
465
- <ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
468
+ <ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
466
469
  <SignupForm
467
470
  handleSuccessSignup={handleSuccessSignup}
468
471
  isGuest
@@ -472,6 +475,13 @@ export const UserFormDetailsUI = (props: any) => {
472
475
  />
473
476
  </ScrollView>
474
477
  </OModal>
478
+ <Alert
479
+ open={alertState.open}
480
+ title=''
481
+ content={[alertState.content]}
482
+ onAccept={() => setAlertState({ open: false, content: '' })}
483
+ onClose={() => setAlertState({ open: false, content: '' })}
484
+ />
475
485
  </>
476
486
  );
477
487
  };