ordering-ui-react-native 0.16.35 → 0.16.36
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
|
@@ -114,6 +114,10 @@ const CheckoutUI = (props: any) => {
|
|
|
114
114
|
position: 'absolute',
|
|
115
115
|
fontSize: 20
|
|
116
116
|
},
|
|
117
|
+
detailWrapper: {
|
|
118
|
+
paddingHorizontal: 40,
|
|
119
|
+
width: '100%'
|
|
120
|
+
},
|
|
117
121
|
wrapperNavbar: Platform.OS === 'ios'
|
|
118
122
|
? { paddingVertical: 0, paddingHorizontal: 40 }
|
|
119
123
|
: { paddingVertical: 20, paddingHorizontal: 40 }
|
|
@@ -136,6 +140,8 @@ const CheckoutUI = (props: any) => {
|
|
|
136
140
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
137
141
|
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
138
142
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
143
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
144
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
139
145
|
|
|
140
146
|
const placeSpotTypes = [3, 4]
|
|
141
147
|
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
@@ -173,10 +179,14 @@ const CheckoutUI = (props: any) => {
|
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
const handlePlaceOrder = (confirmPayment) => {
|
|
176
|
-
if (!userErrors.length) {
|
|
182
|
+
if (!userErrors.length && !requiredFields?.length) {
|
|
177
183
|
handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
|
|
178
184
|
return
|
|
179
185
|
}
|
|
186
|
+
if (requiredFields?.length) {
|
|
187
|
+
setIsOpen(true)
|
|
188
|
+
return
|
|
189
|
+
}
|
|
180
190
|
let stringError = ''
|
|
181
191
|
Object.values(userErrors).map((item: any, i: number) => {
|
|
182
192
|
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
@@ -204,11 +214,12 @@ const CheckoutUI = (props: any) => {
|
|
|
204
214
|
setUserErrors([])
|
|
205
215
|
const errors = []
|
|
206
216
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
217
|
+
const _requiredFields: any = []
|
|
207
218
|
|
|
208
219
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
209
220
|
if (field?.required && !notFields.includes(field.code)) {
|
|
210
221
|
if (!user[field?.code]) {
|
|
211
|
-
|
|
222
|
+
_requiredFields.push(field?.code)
|
|
212
223
|
}
|
|
213
224
|
}
|
|
214
225
|
})
|
|
@@ -219,8 +230,9 @@ const CheckoutUI = (props: any) => {
|
|
|
219
230
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
220
231
|
configs?.verification_phone_required?.value === '1')
|
|
221
232
|
) {
|
|
222
|
-
|
|
233
|
+
_requiredFields.push('cellphone')
|
|
223
234
|
}
|
|
235
|
+
setRequiredFields(_requiredFields)
|
|
224
236
|
|
|
225
237
|
if (phoneUpdate) {
|
|
226
238
|
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
@@ -703,6 +715,28 @@ const CheckoutUI = (props: any) => {
|
|
|
703
715
|
onClose={() => setOpenChangeStore(false)}
|
|
704
716
|
/>
|
|
705
717
|
</OModal>
|
|
718
|
+
<OModal
|
|
719
|
+
open={isOpen}
|
|
720
|
+
onClose={() => setIsOpen(false)}
|
|
721
|
+
>
|
|
722
|
+
<View style={styles.detailWrapper}>
|
|
723
|
+
<UserDetails
|
|
724
|
+
isUserDetailsEdit
|
|
725
|
+
cartStatus={cart?.status}
|
|
726
|
+
businessId={cart?.business_id}
|
|
727
|
+
useValidationFields
|
|
728
|
+
useDefualtSessionManager
|
|
729
|
+
useSessionUser
|
|
730
|
+
isCheckout
|
|
731
|
+
isEdit
|
|
732
|
+
phoneUpdate={phoneUpdate}
|
|
733
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
734
|
+
requiredFields={requiredFields}
|
|
735
|
+
hideUpdateButton
|
|
736
|
+
onClose={() => setIsOpen(false)}
|
|
737
|
+
/>
|
|
738
|
+
</View>
|
|
739
|
+
</OModal>
|
|
706
740
|
</ChContainer>
|
|
707
741
|
</Container>
|
|
708
742
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
@@ -23,6 +23,8 @@ const UserDetailsUI = (props: any) => {
|
|
|
23
23
|
isEdit,
|
|
24
24
|
formState,
|
|
25
25
|
cleanFormState,
|
|
26
|
+
requiredFields,
|
|
27
|
+
onClose,
|
|
26
28
|
cartStatus,
|
|
27
29
|
toggleIsEdit,
|
|
28
30
|
validationFields,
|
|
@@ -44,6 +46,7 @@ const UserDetailsUI = (props: any) => {
|
|
|
44
46
|
const userData = props.userData || (!formState.result.error && formState.result?.result) || user
|
|
45
47
|
|
|
46
48
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
49
|
+
const [isSubmit, setIsSubmit] = useState(false)
|
|
47
50
|
const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
|
|
48
51
|
const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
|
|
49
52
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
@@ -54,7 +57,6 @@ const UserDetailsUI = (props: any) => {
|
|
|
54
57
|
},
|
|
55
58
|
});
|
|
56
59
|
|
|
57
|
-
|
|
58
60
|
useEffect(() => {
|
|
59
61
|
if (isUserDetailsEdit) {
|
|
60
62
|
!isEdit && toggleIsEdit()
|
|
@@ -66,6 +68,12 @@ const UserDetailsUI = (props: any) => {
|
|
|
66
68
|
cleanFormState({ changes: {} })
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (isSubmit && !isEdit && requiredFields) {
|
|
73
|
+
onClose && onClose()
|
|
74
|
+
}
|
|
75
|
+
}, [isSubmit, requiredFields, isEdit])
|
|
76
|
+
|
|
69
77
|
useEffect(() => {
|
|
70
78
|
if (user?.cellphone && !user?.country_phone_code) {
|
|
71
79
|
togglePhoneUpdate(true)
|
|
@@ -147,7 +155,7 @@ const UserDetailsUI = (props: any) => {
|
|
|
147
155
|
<OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal}>
|
|
148
156
|
{t('CUSTOMER_DETAILS', 'Customer Details')}
|
|
149
157
|
</OText>
|
|
150
|
-
{cartStatus !== 2 && (
|
|
158
|
+
{cartStatus !== 2 && !requiredFields && (
|
|
151
159
|
!isEdit ? (
|
|
152
160
|
<EditBtn onPress={() => toggleIsEdit()} activeOpacity={0.7}>
|
|
153
161
|
<OIcon
|
|
@@ -198,6 +206,7 @@ const UserDetailsUI = (props: any) => {
|
|
|
198
206
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
199
207
|
isCheckout={isCheckout}
|
|
200
208
|
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
209
|
+
setIsSubmit={setIsSubmit}
|
|
201
210
|
/>
|
|
202
211
|
)}
|
|
203
212
|
</UDContainer>
|
|
@@ -17,6 +17,9 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
17
17
|
isEdit,
|
|
18
18
|
formState,
|
|
19
19
|
showField,
|
|
20
|
+
requiredFields,
|
|
21
|
+
onClose,
|
|
22
|
+
setIsSubmit,
|
|
20
23
|
cleanFormState,
|
|
21
24
|
onCloseProfile,
|
|
22
25
|
isRequiredField,
|
|
@@ -75,6 +78,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
75
78
|
|
|
76
79
|
const [{ user }] = useSession();
|
|
77
80
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
81
|
+
const [isValid, setIsValid] = useState(false)
|
|
78
82
|
const [isChanged, setIsChanged] = useState(false)
|
|
79
83
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
80
84
|
error: '',
|
|
@@ -160,6 +164,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
160
164
|
cellphone: '',
|
|
161
165
|
};
|
|
162
166
|
}
|
|
167
|
+
setIsSubmit && setIsSubmit(true)
|
|
163
168
|
handleButtonUpdateClick(changes);
|
|
164
169
|
}
|
|
165
170
|
};
|
|
@@ -235,6 +240,12 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
235
240
|
setWillVerifyOtpState?.(true)
|
|
236
241
|
}
|
|
237
242
|
}, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
|
|
243
|
+
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (!requiredFields || formState?.changes?.length === 0) return
|
|
246
|
+
const _isValid = requiredFields.every((key: any) => formState?.changes[key])
|
|
247
|
+
setIsValid(_isValid)
|
|
248
|
+
}, [formState?.changes, requiredFields])
|
|
238
249
|
|
|
239
250
|
return (
|
|
240
251
|
<>
|
|
@@ -248,7 +259,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
248
259
|
}).map(
|
|
249
260
|
(field: any) =>
|
|
250
261
|
showField &&
|
|
251
|
-
showField(field.code) && (
|
|
262
|
+
showField(field.code) && ((requiredFields && requiredFields.includes(field.code)) || !requiredFields) && (
|
|
252
263
|
<React.Fragment key={field.id}>
|
|
253
264
|
<Controller
|
|
254
265
|
key={field.id}
|
|
@@ -322,7 +333,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
322
333
|
),
|
|
323
334
|
)}
|
|
324
335
|
|
|
325
|
-
{!!showInputPhoneNumber && (
|
|
336
|
+
{!!showInputPhoneNumber &&((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
|
|
326
337
|
<WrapperPhone>
|
|
327
338
|
<OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
|
|
328
339
|
<PhoneInputNumber
|
|
@@ -347,71 +358,76 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
347
358
|
)}
|
|
348
359
|
</WrapperPhone>
|
|
349
360
|
)}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
value={value}
|
|
397
|
-
boxType={'square'}
|
|
398
|
-
tintColors={{
|
|
399
|
-
true: theme.colors.primary,
|
|
400
|
-
false: theme.colors.disabled
|
|
361
|
+
{!requiredFields && (
|
|
362
|
+
<Controller
|
|
363
|
+
control={control}
|
|
364
|
+
render={() => (
|
|
365
|
+
<>
|
|
366
|
+
<OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
|
|
367
|
+
{t('PASSWORD', 'Password')}
|
|
368
|
+
</OText>
|
|
369
|
+
<OInput
|
|
370
|
+
name='password'
|
|
371
|
+
placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
|
|
372
|
+
inputStyle={styles.inputStyle}
|
|
373
|
+
style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
|
|
374
|
+
autoCapitalize='none'
|
|
375
|
+
isDisabled={false}
|
|
376
|
+
value={
|
|
377
|
+
formState?.changes['password'] ??
|
|
378
|
+
(user && user['password']) ??
|
|
379
|
+
''
|
|
380
|
+
}
|
|
381
|
+
onChange={(val: any) => {
|
|
382
|
+
setValue('password', val.target.value)
|
|
383
|
+
handleChangeInput(val)
|
|
384
|
+
}}
|
|
385
|
+
autoCorrect
|
|
386
|
+
type='default'
|
|
387
|
+
returnKeyType="done"
|
|
388
|
+
autoCompleteType='off'
|
|
389
|
+
isSecured
|
|
390
|
+
/>
|
|
391
|
+
</>
|
|
392
|
+
)}
|
|
393
|
+
name='password'
|
|
394
|
+
rules={getInputRules({ name: 'password', code: 'password' })}
|
|
395
|
+
defaultValue=''
|
|
396
|
+
/>
|
|
397
|
+
)}
|
|
398
|
+
{!requiredFields && (
|
|
399
|
+
<Controller
|
|
400
|
+
control={control}
|
|
401
|
+
render={({ onChange, value }: any) => (
|
|
402
|
+
<TouchableOpacity
|
|
403
|
+
style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}
|
|
404
|
+
onPress={() => {
|
|
405
|
+
onChange(!value)
|
|
406
|
+
handleChangePromotions(!value)
|
|
401
407
|
}}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
408
|
+
>
|
|
409
|
+
<CheckBox
|
|
410
|
+
value={value}
|
|
411
|
+
boxType={'square'}
|
|
412
|
+
tintColors={{
|
|
413
|
+
true: theme.colors.primary,
|
|
414
|
+
false: theme.colors.disabled
|
|
415
|
+
}}
|
|
416
|
+
tintColor={theme.colors.disabled}
|
|
417
|
+
onCheckColor={theme.colors.primary}
|
|
418
|
+
onTintColor={theme.colors.primary}
|
|
419
|
+
style={Platform.OS === 'ios' && styles.checkBoxStyle}
|
|
420
|
+
/>
|
|
421
|
+
<OText style={{ fontSize: 14, paddingHorizontal: 5, paddingLeft: 10 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
|
|
422
|
+
</TouchableOpacity>
|
|
423
|
+
)}
|
|
424
|
+
name='promotions'
|
|
425
|
+
defaultValue={formState?.result?.result
|
|
426
|
+
? !!formState?.result?.result?.settings?.notification?.newsletter
|
|
427
|
+
: !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
|
|
428
|
+
/>
|
|
429
|
+
)}
|
|
430
|
+
|
|
415
431
|
</UDWrapper>
|
|
416
432
|
)}
|
|
417
433
|
{validationFields?.loading && (
|
|
@@ -443,6 +459,22 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
443
459
|
)}
|
|
444
460
|
</>
|
|
445
461
|
)}
|
|
462
|
+
{requiredFields && (
|
|
463
|
+
<OButton
|
|
464
|
+
text={
|
|
465
|
+
formState.loading
|
|
466
|
+
? t('UPDATING', 'Updating...')
|
|
467
|
+
: t('CONTINUE', 'Continue')
|
|
468
|
+
}
|
|
469
|
+
bgColor={theme.colors.white}
|
|
470
|
+
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
471
|
+
borderColor={theme.colors.primary}
|
|
472
|
+
isDisabled={formState.loading || !isValid}
|
|
473
|
+
imgRightSrc={null}
|
|
474
|
+
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
|
|
475
|
+
onClick={handleSubmit(onSubmit)}
|
|
476
|
+
/>
|
|
477
|
+
)}
|
|
446
478
|
</>
|
|
447
479
|
);
|
|
448
480
|
};
|