ordering-ui-react-native 0.18.18 → 0.18.20
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
|
@@ -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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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,13 @@ 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
|
+
cleanFormState && cleanFormState({ changes: {} })
|
|
229
|
+
}
|
|
226
230
|
}
|
|
227
231
|
}, [formState?.loading]);
|
|
228
232
|
|
|
@@ -441,8 +445,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
441
445
|
formState.loading
|
|
442
446
|
? t('UPDATING', 'Updating...')
|
|
443
447
|
: ((isCheckout && !!user?.guest_id)
|
|
444
|
-
|
|
445
|
-
|
|
448
|
+
? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
|
|
449
|
+
: t('CONTINUE', 'Continue'))
|
|
446
450
|
}
|
|
447
451
|
bgColor={theme.colors.white}
|
|
448
452
|
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
@@ -450,7 +454,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
450
454
|
isDisabled={!user?.guest_id && (formState.loading || !isValid)}
|
|
451
455
|
imgRightSrc={null}
|
|
452
456
|
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
|
|
453
|
-
onClick={
|
|
457
|
+
onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
|
|
454
458
|
/>
|
|
455
459
|
)}
|
|
456
460
|
{isCheckout && !!user?.guest_id && (
|
|
@@ -462,7 +466,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
462
466
|
open={isModalOpen}
|
|
463
467
|
onClose={() => setIsModalOpen(false)}
|
|
464
468
|
>
|
|
465
|
-
<ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
|
|
469
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
466
470
|
<SignupForm
|
|
467
471
|
handleSuccessSignup={handleSuccessSignup}
|
|
468
472
|
isGuest
|
|
@@ -472,6 +476,13 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
472
476
|
/>
|
|
473
477
|
</ScrollView>
|
|
474
478
|
</OModal>
|
|
479
|
+
<Alert
|
|
480
|
+
open={alertState.open}
|
|
481
|
+
title=''
|
|
482
|
+
content={[alertState.content]}
|
|
483
|
+
onAccept={() => setAlertState({ open: false, content: '' })}
|
|
484
|
+
onClose={() => setAlertState({ open: false, content: '' })}
|
|
485
|
+
/>
|
|
475
486
|
</>
|
|
476
487
|
);
|
|
477
488
|
};
|