ordering-ui-external 1.2.3 → 1.3.0

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.
Files changed (97) hide show
  1. package/_bundles/{0.ordering-ui.fc62fe574704c7c4d033.js → 0.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  2. package/_bundles/{1.ordering-ui.fc62fe574704c7c4d033.js → 1.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  3. package/_bundles/{3.ordering-ui.fc62fe574704c7c4d033.js → 3.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  4. package/_bundles/{4.ordering-ui.fc62fe574704c7c4d033.js → 4.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  5. package/_bundles/5.ordering-ui.aee3f88f00476e436e39.js +1 -0
  6. package/_bundles/{6.ordering-ui.fc62fe574704c7c4d033.js → 6.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  7. package/_bundles/7.ordering-ui.aee3f88f00476e436e39.js +2 -0
  8. package/_bundles/{7.ordering-ui.fc62fe574704c7c4d033.js.LICENSE.txt → 7.ordering-ui.aee3f88f00476e436e39.js.LICENSE.txt} +0 -0
  9. package/_bundles/{8.ordering-ui.fc62fe574704c7c4d033.js → 8.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  10. package/_bundles/{9.ordering-ui.fc62fe574704c7c4d033.js → 9.ordering-ui.aee3f88f00476e436e39.js} +1 -1
  11. package/_bundles/ordering-ui.aee3f88f00476e436e39.js +2 -0
  12. package/_bundles/{ordering-ui.fc62fe574704c7c4d033.js.LICENSE.txt → ordering-ui.aee3f88f00476e436e39.js.LICENSE.txt} +0 -0
  13. package/_modules/components/AutoScroll/styles.js +3 -3
  14. package/_modules/hooks/useIsMounted.js +24 -0
  15. package/_modules/index.js +8 -0
  16. package/_modules/themes/five/index.js +33 -1
  17. package/_modules/themes/five/src/components/BusinessBasicInformation/index.js +2 -2
  18. package/_modules/themes/five/src/components/BusinessController/styles.js +42 -42
  19. package/_modules/themes/five/src/components/BusinessProductsCategories/index.js +12 -2
  20. package/_modules/themes/five/src/components/BusinessProductsCategories/styles.js +5 -2
  21. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +10 -3
  22. package/_modules/themes/five/src/components/BusinessProductsListing/styles.js +7 -3
  23. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +1 -0
  24. package/_modules/themes/five/src/components/MultiCheckout/styles.js +1 -1
  25. package/_modules/themes/five/src/components/MyOrders/index.js +9 -3
  26. package/_modules/themes/five/src/components/NavigationBar/index.js +159 -0
  27. package/_modules/themes/five/src/components/NavigationBar/styles.js +33 -0
  28. package/_modules/themes/five/src/components/OrderDetails/index.js +71 -41
  29. package/_modules/themes/five/src/components/ProfessionalBusinessFilter/index.js +96 -0
  30. package/_modules/themes/five/src/components/ProfessionalBusinessFilter/styles.js +48 -0
  31. package/_modules/themes/five/src/components/ProfessionalFilter/index.js +35 -7
  32. package/_modules/themes/five/src/components/ProfessionalFilter/styles.js +10 -4
  33. package/_modules/themes/five/src/components/ProfessionalInfo/index.js +120 -0
  34. package/_modules/themes/five/src/components/ProfessionalInfo/styles.js +100 -0
  35. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +36 -13
  36. package/_modules/themes/five/src/components/RenderProductsLayout/styles.js +21 -18
  37. package/_modules/themes/five/src/components/ReviewProfessional/index.js +314 -0
  38. package/_modules/themes/five/src/components/ReviewProfessional/styles.js +137 -0
  39. package/_modules/themes/five/src/components/SignUpApproval/index.js +106 -0
  40. package/_modules/themes/five/src/components/SignUpApproval/styles.js +71 -0
  41. package/_modules/themes/five/src/components/SignUpBusiness/index.js +7 -383
  42. package/_modules/themes/five/src/components/SignUpBusiness/layouts/NewSignUpBusiness/index.js +405 -0
  43. package/_modules/themes/five/src/components/SignUpBusiness/layouts/NewSignUpBusiness/styles.js +110 -0
  44. package/_modules/themes/five/src/components/SignUpBusiness/layouts/OldSignUpBusiness/index.js +400 -0
  45. package/_modules/themes/five/src/components/SignUpBusiness/{styles.js → layouts/OldSignUpBusiness/styles.js} +0 -0
  46. package/_modules/themes/five/src/components/SignUpDriver/index.js +7 -383
  47. package/_modules/themes/five/src/components/SignUpDriver/layouts/NewSignUpDriver/index.js +405 -0
  48. package/_modules/themes/five/src/components/SignUpDriver/layouts/NewSignUpDriver/styles.js +106 -0
  49. package/_modules/themes/five/src/components/SignUpDriver/layouts/OldSignUpDriver/index.js +400 -0
  50. package/_modules/themes/five/src/components/SignUpDriver/{styles.js → layouts/OldSignUpDriver/styles.js} +0 -0
  51. package/_modules/themes/five/src/components/SingleProductCard/styles.js +1 -1
  52. package/_modules/utils/index.js +103 -0
  53. package/package.json +2 -2
  54. package/src/components/AutoScroll/styles.js +11 -12
  55. package/src/hooks/useIsMounted.js +18 -0
  56. package/src/index.js +2 -0
  57. package/src/themes/five/index.js +9 -1
  58. package/src/themes/five/src/components/BusinessBasicInformation/index.js +1 -1
  59. package/src/themes/five/src/components/BusinessController/styles.js +3 -6
  60. package/src/themes/five/src/components/BusinessProductsCategories/index.js +10 -2
  61. package/src/themes/five/src/components/BusinessProductsCategories/styles.js +5 -0
  62. package/src/themes/five/src/components/BusinessProductsListing/index.js +8 -2
  63. package/src/themes/five/src/components/BusinessProductsListing/styles.js +1 -1
  64. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +2 -0
  65. package/src/themes/five/src/components/MultiCheckout/index.js +1 -0
  66. package/src/themes/five/src/components/MultiCheckout/styles.js +1 -0
  67. package/src/themes/five/src/components/MyOrders/index.js +6 -3
  68. package/src/themes/five/src/components/NavigationBar/index.js +104 -0
  69. package/src/themes/five/src/components/NavigationBar/styles.js +44 -0
  70. package/src/themes/five/src/components/OrderDetails/index.js +19 -11
  71. package/src/themes/five/src/components/ProfessionalBusinessFilter/index.js +82 -0
  72. package/src/themes/five/src/components/ProfessionalBusinessFilter/styles.js +71 -0
  73. package/src/themes/five/src/components/ProfessionalFilter/index.js +30 -7
  74. package/src/themes/five/src/components/ProfessionalFilter/styles.js +15 -2
  75. package/src/themes/five/src/components/ProfessionalInfo/index.js +133 -0
  76. package/src/themes/five/src/components/ProfessionalInfo/styles.js +140 -0
  77. package/src/themes/five/src/components/RenderProductsLayout/index.js +37 -16
  78. package/src/themes/five/src/components/RenderProductsLayout/styles.js +6 -1
  79. package/src/themes/five/src/components/ReviewProfessional/index.js +239 -0
  80. package/src/themes/five/src/components/ReviewProfessional/styles.js +233 -0
  81. package/src/themes/five/src/components/SignUpApproval/index.js +108 -0
  82. package/src/themes/five/src/components/SignUpApproval/styles.js +98 -0
  83. package/src/themes/five/src/components/SignUpBusiness/index.js +10 -374
  84. package/src/themes/five/src/components/SignUpBusiness/layouts/NewSignUpBusiness/index.js +382 -0
  85. package/src/themes/five/src/components/SignUpBusiness/layouts/NewSignUpBusiness/styles.js +256 -0
  86. package/src/themes/five/src/components/SignUpBusiness/layouts/OldSignUpBusiness/index.js +378 -0
  87. package/src/themes/five/src/components/SignUpBusiness/{styles.js → layouts/OldSignUpBusiness/styles.js} +0 -0
  88. package/src/themes/five/src/components/SignUpDriver/index.js +10 -374
  89. package/src/themes/five/src/components/SignUpDriver/layouts/NewSignUpDriver/index.js +382 -0
  90. package/src/themes/five/src/components/SignUpDriver/layouts/NewSignUpDriver/styles.js +262 -0
  91. package/src/themes/five/src/components/SignUpDriver/layouts/OldSignUpDriver/index.js +378 -0
  92. package/src/themes/five/src/components/SignUpDriver/{styles.js → layouts/OldSignUpDriver/styles.js} +0 -0
  93. package/src/themes/five/src/components/SingleProductCard/styles.js +3 -1
  94. package/src/utils/index.js +54 -0
  95. package/_bundles/5.ordering-ui.fc62fe574704c7c4d033.js +0 -1
  96. package/_bundles/7.ordering-ui.fc62fe574704c7c4d033.js +0 -2
  97. package/_bundles/ordering-ui.fc62fe574704c7c4d033.js +0 -2
@@ -1,378 +1,14 @@
1
- import React, { useState, useEffect, useRef } from 'react'
2
- import { useForm } from 'react-hook-form'
3
- import Skeleton from 'react-loading-skeleton'
4
- import { Alert } from '../Confirm'
5
- import { InputPhoneNumber } from '../../../../../components/InputPhoneNumber'
6
- import parsePhoneNumber from 'libphonenumber-js'
7
- import { useTheme } from 'styled-components'
8
- import { Input } from '../../styles/Inputs'
9
- import { Button } from '../../styles/Buttons'
10
- import { Checkbox } from '../../../../../styles/Checkbox'
11
- import { sortInputFields } from '../../../../../utils'
12
-
13
- import AiOutlineEye from '@meronex/icons/ai/AiOutlineEye'
14
- import AiOutlineEyeInvisible from '@meronex/icons/ai/AiOutlineEyeInvisible'
15
-
16
- import {
17
- SignupForm as SignUpController,
18
- useLanguage,
19
- useConfig,
20
- ReCaptcha
21
- } from 'ordering-components-external'
22
-
23
- import {
24
- SignUpDriverContainer,
25
- SignUpHeroWrapper,
26
- SignUpHero,
27
- FormInput,
28
- WrapperPassword,
29
- TogglePassword,
30
- ReCaptchaWrapper,
31
- TermsConditionWrapper,
32
- SkeletonWrapper,
33
- FormSide,
34
- PhoneNumberWrapper
35
- } from './styles'
36
-
37
- const notValidationFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'address_notes']
38
-
39
- const SignUpDriverUI = (props) => {
40
- const {
41
- handleChangeInput,
42
- handleButtonSignupClick,
43
- handleReCaptcha,
44
- useChekoutFileds,
45
- validationFields,
46
- showField,
47
- isRequiredField,
48
- formState,
49
- handleSuccessSignup,
50
- isPopup,
51
- externalPhoneNumber,
52
- saveCustomerUser,
53
- fieldsNotValid,
54
- signupData,
55
- enableReCaptcha
56
- } = props
57
-
58
- const theme = useTheme()
59
- const [, t] = useLanguage()
60
- const [{ configs }] = useConfig()
61
- const formMethods = useForm()
62
- const [alertState, setAlertState] = useState({ open: false, content: [] })
63
- const emailInput = useRef(null)
64
-
65
- const [userPhoneNumber, setUserPhoneNumber] = useState('')
66
- const [isValidPhoneNumber, setIsValidPhoneNumber] = useState(null)
67
- const [passwordSee, setPasswordSee] = useState(false)
68
-
69
- const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
70
-
71
- const togglePasswordView = () => {
72
- setPasswordSee(!passwordSee)
73
- }
74
-
75
- const closeAlert = () => {
76
- setAlertState({
77
- open: false,
78
- content: []
79
- })
80
- }
81
-
82
- const onSubmit = () => {
83
- const isPhoneNumberValid = userPhoneNumber ? isValidPhoneNumber : true
84
- if (!userPhoneNumber &&
85
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
86
- validationFields?.fields?.checkout?.cellphone?.required) ||
87
- configs?.verification_phone_required?.value === '1')
88
- ) {
89
- setAlertState({
90
- open: true,
91
- content: [t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required.')]
92
- })
93
- return
94
- }
95
- if (!isPhoneNumberValid) {
96
- setAlertState({
97
- open: true,
98
- content: [t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid')]
99
- })
100
- return
101
- }
102
- handleButtonSignupClick && handleButtonSignupClick()
103
- if (!formState.loading && formState.result.result && !formState.result.error) {
104
- handleSuccessSignup(formState.result.result)
105
- }
106
- }
107
-
108
- const handleChangePhoneNumber = (number, isValid) => {
109
- setUserPhoneNumber(number)
110
-
111
- let phoneNumberParser = null
112
- let phoneNumber = {
113
- country_phone_code: {
114
- name: 'country_phone_code',
115
- value: ''
116
- },
117
- cellphone: {
118
- name: 'cellphone',
119
- value: ''
120
- }
121
- }
122
- if (isValid) {
123
- phoneNumberParser = parsePhoneNumber(number)
124
- }
125
- if (phoneNumberParser) {
126
- phoneNumber = {
127
- country_phone_code: {
128
- name: 'country_phone_code',
129
- value: phoneNumberParser.countryCallingCode
130
- },
131
- cellphone: {
132
- name: 'cellphone',
133
- value: phoneNumberParser.nationalNumber
134
- }
135
- }
136
- }
137
- handleChangeInput(phoneNumber, true)
138
- }
139
-
140
- const handleChangeInputEmail = (e) => {
141
- handleChangeInput({ target: { name: 'email', value: e.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, '') } })
142
- formMethods.setValue('email', e.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''))
143
- if (emailInput?.current) {
144
- emailInput.current.value = e.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, '')
145
- }
146
- }
147
-
148
- useEffect(() => {
149
- if (!formState.loading && formState.result?.error) {
150
- setAlertState({
151
- open: true,
152
- content: formState.result?.result || [t('ERROR', 'Error')]
153
- })
154
- } else if (!formState.loading && !formState.result?.error && formState.result?.result) {
155
- saveCustomerUser && saveCustomerUser(formState.result?.result)
156
- }
157
- }, [formState])
158
-
159
- useEffect(() => {
160
- if (Object.keys(formMethods.errors).length > 0) {
161
- setAlertState({
162
- open: true,
163
- content: Object.values(formMethods.errors).map(error => error.message)
164
- })
165
- }
166
- }, [formMethods.errors])
167
-
168
- useEffect(() => {
169
- if (!validationFields.loading) {
170
- Object.values(validationFields?.fields?.checkout).map(field => !notValidationFields.includes(field.code) && (
171
- field.code === 'email' ? (
172
- formMethods.register('email', {
173
- required: isRequiredField(field.code)
174
- ? t('VALIDATION_ERROR_EMAIL_REQUIRED', 'The field Email is required').replace('_attribute_', t('EMAIL', 'Email'))
175
- : null,
176
- pattern: {
177
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
178
- message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace('_attribute_', t('EMAIL', 'Email'))
179
- }
180
- })
181
- ) : (
182
- formMethods.register(field.code, {
183
- required: isRequiredField(field.code)
184
- ? t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `${field.name} is required`).replace('_attribute_', t(field.name, field.code))
185
- : null
186
- })
187
- )
188
- ))
189
- }
190
- }, [formMethods])
191
-
192
- useEffect(() => {
193
- Object.keys(signupData).map(fieldName => {
194
- formMethods.setValue(fieldName, signupData[fieldName])
195
- })
196
- }, [signupData])
197
-
198
- useEffect(() => {
199
- if (externalPhoneNumber) {
200
- setUserPhoneNumber(externalPhoneNumber)
201
- handleChangePhoneNumber(externalPhoneNumber, true)
202
- }
203
- }, [externalPhoneNumber])
204
-
205
- useEffect(() => {
206
- handleChangeInput({
207
- target: {
208
- name: 'level',
209
- value: 4
210
- }
211
- })
212
- }, [])
1
+ import React from 'react'
2
+ import { SignUpDriver as OldSignUpDriver } from './layouts/OldSignUpDriver'
3
+ import { SignUpDriver as NewSignUpDriver } from './layouts/NewSignUpDriver'
213
4
 
5
+ export const SignUpDriver = (props) => {
6
+ const { layout } = props
7
+ const _layout = layout ?? 'old'
214
8
  return (
215
- <SignUpDriverContainer>
216
- <SignUpHeroWrapper>
217
- <SignUpHero bgimage={theme.images?.general?.driverSignUpHero} />
218
- </SignUpHeroWrapper>
219
- <FormSide>
220
- <h1>{t('TITLE_DRIVER_SIGNUP', 'Get Started')}</h1>
221
- <FormInput
222
- noValidate
223
- isPopup={isPopup}
224
- onSubmit={formMethods.handleSubmit(onSubmit)}
225
- isSkeleton={useChekoutFileds && validationFields?.loading}
226
- >
227
- {props.beforeMidElements?.map((BeforeMidElements, i) => (
228
- <React.Fragment key={i}>
229
- {BeforeMidElements}
230
- </React.Fragment>))}
231
- {props.beforeMidComponents?.map((BeforeMidComponents, i) => (
232
- <BeforeMidComponents key={i} {...props} />))}
233
- {
234
- !(useChekoutFileds && validationFields?.loading) ? (
235
- <>
236
- {validationFields?.fields?.checkout &&
237
- sortInputFields({ values: validationFields?.fields?.checkout }).map(field =>
238
- showField && showField(field.code) && (
239
- <React.Fragment key={field.id}>
240
- {field.code === 'email' ? (
241
- <Input
242
- type={field.type}
243
- name={field.code}
244
- aria-label={field.code}
245
- className='form'
246
- placeholder={t(field.code.toUpperCase(), field.name)}
247
- onChange={handleChangeInputEmail}
248
- ref={(e) => {
249
- emailInput.current = e
250
- }}
251
- required={!!field.required}
252
- autoComplete='off'
253
- />
254
- ) : (
255
- <Input
256
- type={field.type}
257
- name={field.code}
258
- aria-label={field.code}
259
- className='form'
260
- placeholder={t(field.code.toUpperCase(), field.name)}
261
- onChange={handleChangeInput}
262
- required={field.required}
263
- autoComplete='off'
264
- />
265
- )}
266
- </React.Fragment>
267
- )
268
- )}
269
- {!!showInputPhoneNumber && (
270
- <PhoneNumberWrapper>
271
- <InputPhoneNumber
272
- value={userPhoneNumber}
273
- setValue={handleChangePhoneNumber}
274
- handleIsValid={setIsValidPhoneNumber}
275
- />
276
- </PhoneNumberWrapper>
277
- )}
278
-
279
- {(!fieldsNotValid || (fieldsNotValid && !fieldsNotValid.includes('password'))) && (
280
- <WrapperPassword>
281
- <Input
282
- type={!passwordSee ? 'password' : 'text'}
283
- name='password'
284
- aria-label='password'
285
- className='form'
286
- placeholder={t('PASSWORD', 'Password')}
287
- onChange={handleChangeInput}
288
- required
289
- ref={formMethods.register({
290
- required: isRequiredField('password') ? t('VALIDATION_ERROR_PASSWORD_REQUIRED', 'The field Password is required').replace('_attribute_', t('PASSWORD', 'password')) : null,
291
- minLength: {
292
- value: 8,
293
- message: t('VALIDATION_ERROR_PASSWORD_MIN_STRING', 'The Password must be at least 8 characters.').replace('_attribute_', t('PASSWORD', 'Password')).replace('_min_', 8)
294
- }
295
- })}
296
- />
297
- <TogglePassword onClick={togglePasswordView}>
298
- {!passwordSee ? <AiOutlineEye /> : <AiOutlineEyeInvisible />}
299
- </TogglePassword>
300
- </WrapperPassword>
301
- )}
302
-
303
- {props.afterMidElements?.map((MidElement, i) => (
304
- <React.Fragment key={i}>
305
- {MidElement}
306
- </React.Fragment>))}
307
- {props.afterMidComponents?.map((MidComponent, i) => (
308
- <MidComponent key={i} {...props} />))}
309
- </>
310
- ) : (
311
- <>
312
- {[...Array(5)].map((_, i) => (
313
- <SkeletonWrapper key={i}>
314
- <Skeleton height={43} />
315
- </SkeletonWrapper>
316
- ))}
317
- </>
318
- )
319
- }
320
- {props.isRecaptchaEnable && enableReCaptcha && (
321
- <ReCaptchaWrapper>
322
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
323
- </ReCaptchaWrapper>
324
- )}
325
-
326
- {configs?.terms_and_conditions?.value === 'true' && (
327
- <TermsConditionWrapper>
328
- <Checkbox
329
- name='acceptTerms'
330
- ref={formMethods.register({
331
- required: t('ERROR_ACCEPT_TERMS', 'You must accept the Terms & Conditions.')
332
- })}
333
- id='acceptTerms'
334
- />
335
- <label
336
- htmlFor='acceptTerms'
337
- >
338
- <span>{t('TERMS_AND_CONDITIONS_TEXT', 'I’m agree with')}</span>
339
- <a
340
- href={configs?.terms_and_conditions_url?.value}
341
- target='_blank'
342
- rel='noopener noreferrer'
343
- >
344
- {t('TERMS_AND_CONDITIONS', 'Terms & Conditions')}
345
- </a>
346
- </label>
347
- </TermsConditionWrapper>
348
- )}
349
-
350
- <Button
351
- color='primary'
352
- type='submit'
353
- disabled={formState.loading || validationFields?.loading}
354
- >
355
- {formState.loading ? `${t('LOADING', 'Loading')}...` : t('SUBMIT', 'Submit')}
356
- </Button>
357
- </FormInput>
358
- </FormSide>
359
- <Alert
360
- title={t('SIGN_UP_FOR_BUSINESS', 'Sign up for business')}
361
- content={alertState.content}
362
- acceptText={t('ACCEPT', 'Accept')}
363
- open={alertState.open}
364
- onClose={() => closeAlert()}
365
- onAccept={() => closeAlert()}
366
- closeOnBackdrop={false}
367
- />
368
- </SignUpDriverContainer>
9
+ <>
10
+ {(_layout === 'old') && <OldSignUpDriver {...props} />}
11
+ {(_layout === 'new') && <NewSignUpDriver {...props} />}
12
+ </>
369
13
  )
370
14
  }
371
-
372
- export const SignUpDriver = (props) => {
373
- const signUpDriverProps = {
374
- ...props,
375
- UIComponent: SignUpDriverUI
376
- }
377
- return <SignUpController {...signUpDriverProps} />
378
- }