ordering-ui-external 10.5.3 → 10.6.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 (32) hide show
  1. package/_bundles/{0.ordering-ui.f2a935c917370f7de531.js → 0.ordering-ui.8a4a9a1da3d54294518d.js} +1 -1
  2. package/_bundles/{4.ordering-ui.f2a935c917370f7de531.js → 4.ordering-ui.8a4a9a1da3d54294518d.js} +1 -1
  3. package/_bundles/{7.ordering-ui.f2a935c917370f7de531.js → 7.ordering-ui.8a4a9a1da3d54294518d.js} +1 -1
  4. package/_bundles/{ordering-ui.f2a935c917370f7de531.js → ordering-ui.8a4a9a1da3d54294518d.js} +2 -2
  5. package/_modules/components/Header/index.js +3 -3
  6. package/_modules/themes/callcenterOriginal/src/components/UserDetails/index.js +1 -1
  7. package/_modules/themes/five/src/components/AddressList/styles.js +5 -5
  8. package/_modules/themes/five/src/components/Header/index.js +4 -2
  9. package/_modules/themes/five/src/components/MomentControl/index.js +1 -1
  10. package/_modules/themes/five/src/components/PhoneAutocomplete/styles.js +4 -4
  11. package/_modules/themes/five/src/components/QueryLoginSpoonity/index.js +128 -2
  12. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  13. package/_modules/themes/five/src/components/UserDetails/index.js +3 -3
  14. package/package.json +2 -2
  15. package/src/components/Header/index.js +2 -2
  16. package/src/themes/callcenterOriginal/src/components/UserDetails/index.js +1 -1
  17. package/src/themes/five/src/components/AddressList/styles.js +5 -5
  18. package/src/themes/five/src/components/Header/index.js +4 -2
  19. package/src/themes/five/src/components/MomentControl/index.js +6 -6
  20. package/src/themes/five/src/components/PhoneAutocomplete/styles.js +4 -4
  21. package/src/themes/five/src/components/QueryLoginSpoonity/index.js +120 -3
  22. package/src/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  23. package/src/themes/five/src/components/UserDetails/index.js +2 -2
  24. package/template/app.js +51 -37
  25. /package/_bundles/{1.ordering-ui.f2a935c917370f7de531.js → 1.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  26. /package/_bundles/{2.ordering-ui.f2a935c917370f7de531.js → 2.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  27. /package/_bundles/{5.ordering-ui.f2a935c917370f7de531.js → 5.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  28. /package/_bundles/{6.ordering-ui.f2a935c917370f7de531.js → 6.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  29. /package/_bundles/{7.ordering-ui.f2a935c917370f7de531.js.LICENSE.txt → 7.ordering-ui.8a4a9a1da3d54294518d.js.LICENSE.txt} +0 -0
  30. /package/_bundles/{8.ordering-ui.f2a935c917370f7de531.js → 8.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  31. /package/_bundles/{9.ordering-ui.f2a935c917370f7de531.js → 9.ordering-ui.8a4a9a1da3d54294518d.js} +0 -0
  32. /package/_bundles/{ordering-ui.f2a935c917370f7de531.js.LICENSE.txt → ordering-ui.8a4a9a1da3d54294518d.js.LICENSE.txt} +0 -0
@@ -1,19 +1,136 @@
1
1
  import React from 'react'
2
- import { QueryLoginSpoonity as QueryLoginSpoonityController, useLanguage } from 'ordering-components-external'
2
+ import { QueryLoginSpoonity as QueryLoginSpoonityController, useEvent, useLanguage, useSession, useSite } from 'ordering-components-external'
3
3
  import { SpinnerLoader } from '../../../../../components/SpinnerLoader'
4
+ import Modal from '../Modal'
5
+ import { LoginForm } from '../LoginForm'
6
+ import { SignUpForm } from '../SignUpForm'
7
+ import { ForgotPasswordForm } from '../ForgotPasswordForm'
8
+ import { useTheme } from 'styled-components'
4
9
 
5
10
  const QueryLoginSpoonityUI = (props) => {
6
11
  const {
7
- userState
12
+ userState,
13
+ notificationState,
14
+ authModalOpen,
15
+ setAuthModalOpen,
16
+ modalPageToShow,
17
+ setModalPageToShow
8
18
  } = props
9
19
 
10
20
  const [, t] = useLanguage()
21
+ const [{ auth }, { login }] = useSession()
22
+ const theme = useTheme()
23
+ const [events] = useEvent()
24
+ const [{ site }] = useSite()
25
+ const businessUrlTemplate = site?.business_url_template || '/store/:business_slug'
26
+
27
+ const closeAuthModal = () => {
28
+ setAuthModalOpen(false)
29
+ setModalPageToShow(null)
30
+ const store = window.location.pathname.split('/')?.filter(text => text !== '' && text !== 'store')?.[0]
31
+ if (store) {
32
+ if (businessUrlTemplate === '/store/:business_slug' || businessUrlTemplate === '/:business_slug') {
33
+ events.emit('go_to_page', { page: 'business', params: { business_slug: store } })
34
+ } else {
35
+ events.emit('go_to_page', { page: 'business', search: `?${businessUrlTemplate.split('?')[1].replace(':business_slug', '')}${store}` })
36
+ }
37
+ } else {
38
+ events.emit('go_to_page', { page: 'search' })
39
+ }
40
+ }
41
+
42
+ const handleSuccessLogin = (user) => {
43
+ if (user) {
44
+ closeAuthModal()
45
+ }
46
+ }
47
+
48
+ const handleSuccessSignup = (user) => {
49
+ login({
50
+ user,
51
+ token: user?.session?.access_token
52
+ })
53
+ }
54
+
55
+ const handleCustomModalClick = (e, { page }) => {
56
+ e.preventDefault()
57
+ setModalPageToShow(page)
58
+ }
11
59
 
12
60
  return (
13
61
  <>
14
62
  {userState?.loading ? (
15
63
  <SpinnerLoader content={t('LOADING_DELICIOUS_FOOD', 'Loading Ordering Dashboard...')} />
16
- ) : null}
64
+ ) : (
65
+ <>
66
+ {authModalOpen && !auth && (
67
+ <Modal
68
+ open={authModalOpen}
69
+ onRemove={() => closeAuthModal()}
70
+ onClose={() => closeAuthModal()}
71
+ width='50%'
72
+ authModal
73
+ closeOnBackdrop
74
+ >
75
+ {modalPageToShow === 'login' && (
76
+ <LoginForm
77
+ notificationState={notificationState}
78
+ handleSuccessLogin={handleSuccessLogin}
79
+ elementLinkToSignup={
80
+ <a
81
+ onClick={
82
+ (e) => handleCustomModalClick(e, { page: 'signup' })
83
+ } href='#'
84
+ >{t('CREATE_ACCOUNT', theme?.defaultLanguages?.CREATE_ACCOUNT || 'Create account')}
85
+ </a>
86
+ }
87
+ elementLinkToForgotPassword={
88
+ <a
89
+ onClick={
90
+ (e) => handleCustomModalClick(e, { page: 'forgotpassword' })
91
+ } href='#'
92
+ >{t('RESET_PASSWORD', theme?.defaultLanguages?.RESET_PASSWORD || 'Reset password')}
93
+ </a>
94
+ }
95
+ useLoginByCellphone
96
+ isPopup
97
+ />
98
+ )}
99
+ {modalPageToShow === 'signup' && (
100
+ <SignUpForm
101
+ notificationState={notificationState}
102
+ elementLinkToLogin={
103
+ <a
104
+ onClick={
105
+ (e) => handleCustomModalClick(e, { page: 'login' })
106
+ } href='#'
107
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
108
+ </a>
109
+ }
110
+ useLoginByCellphone
111
+ useChekoutFileds
112
+ handleSuccessSignup={handleSuccessSignup}
113
+ isPopup
114
+ closeModal={() => closeAuthModal()}
115
+ />
116
+ )}
117
+ {modalPageToShow === 'forgotpassword' && (
118
+ <ForgotPasswordForm
119
+ elementLinkToLogin={
120
+ <a
121
+ onClick={
122
+ (e) => handleCustomModalClick(e, { page: 'login' })
123
+ } href='#'
124
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
125
+ </a>
126
+ }
127
+ isPopup
128
+ />
129
+ )}
130
+ </Modal>
131
+ )}
132
+ </>
133
+ )}
17
134
  </>
18
135
  )
19
136
  }
@@ -161,7 +161,7 @@ export const RenderProductsLayout = (props) => {
161
161
  <>
162
162
  {!isLoading && business?.id && (
163
163
  <WrappLayout isCartOnProductsList={isCartOnProductsList}>
164
- {((!hideBusinessNearCity && !useKioskApp) || props.forceShowNearBusiness) && !isCustomLayout && (
164
+ {((!hideBusinessNearCity && !useKioskApp) || props.forceShowNearBusiness) && !isCustomerMode && !isCustomLayout && (
165
165
  <NearBusiness>
166
166
  <BusinessesListing
167
167
  logosLayout
@@ -190,8 +190,8 @@ const UserDetailsUI = (props) => {
190
190
  <PhoneContainer>
191
191
  <CountryFlag>
192
192
  {
193
- userData?.country_phone_code && (
194
- <PhoneInput onChange={() => { }} defaultCountry={parsePhoneNumber(`+${(userData?.country_phone_code?.replace('+', ''))} ${userData?.cellphone.replace(`+${userData?.country_phone_code}`, '')}`)?.country} />
193
+ userData?.country_phone_code && userData?.cellphone && (
194
+ <PhoneInput onChange={() => { }} defaultCountry={parsePhoneNumber(`+${(userData?.country_phone_code?.replace('+', ''))} ${userData?.cellphone?.replace(`+${userData?.country_phone_code}`, '')}`)?.country} />
195
195
  )
196
196
  }
197
197
  </CountryFlag>
package/template/app.js CHANGED
@@ -569,7 +569,7 @@ export const App = () => {
569
569
  isKioskApp
570
570
  ? <HomePage notificationState={oneSignalState} />
571
571
  : queryIntegrationToken && queryIntegrationCode === 'spoonity'
572
- ? <QueryLoginSpoonity token={queryIntegrationToken} />
572
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
573
573
  : (orderStatus.options?.address?.location || isAllowUnaddressOrderType)
574
574
  ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/search'} />
575
575
  : singleBusinessConfig.isActive
@@ -672,7 +672,7 @@ export const App = () => {
672
672
  isKioskApp
673
673
  ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
674
674
  : queryIntegrationToken && queryIntegrationCode === 'spoonity'
675
- ? <QueryLoginSpoonity token={queryIntegrationToken} />
675
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
676
676
  : (
677
677
  orderStatus.loading && !orderStatus.options?.address?.location ? (
678
678
  <SpinnerLoader />
@@ -831,53 +831,67 @@ export const App = () => {
831
831
  )}
832
832
  </Route>
833
833
  <Route exact path='/store'>
834
- {isUserVerifyRequired ? (
835
- <Redirect to='/verify' />
836
- ) : (
837
- <BusinessProductsList />
838
- )}
834
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
835
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
836
+ : isUserVerifyRequired ? (
837
+ <Redirect to='/verify' />
838
+ ) : (
839
+ <BusinessProductsList />
840
+ )}
839
841
  </Route>
840
842
  <Route exact path='/store/:business_slug'>
841
- {isUserVerifyRequired ? (
842
- <Redirect to='/verify' />
843
- ) : (
844
- <BusinessProductsList />
845
- )}
843
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
844
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
845
+ : isUserVerifyRequired ? (
846
+ <Redirect to='/verify' />
847
+ ) : (
848
+ <BusinessProductsList />
849
+ )}
846
850
  </Route>
847
851
  <Route exact path='/store/:business_slug/:category_slug/:product_slug'>
848
- {isUserVerifyRequired ? (
849
- <Redirect to='/verify' />
850
- ) : (
851
- <BusinessProductsList />
852
- )}
852
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
853
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
854
+ : isUserVerifyRequired ? (
855
+ <Redirect to='/verify' />
856
+ ) : (
857
+ <BusinessProductsList />
858
+ )}
853
859
  </Route>
854
860
  <Route exact path='/store/:category_slug/:product_slug'>
855
- {isUserVerifyRequired ? (
856
- <Redirect to='/verify' />
857
- ) : (
858
- <BusinessProductsList />
859
- )}
861
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
862
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
863
+ : isUserVerifyRequired ? (
864
+ <Redirect to='/verify' />
865
+ ) : (
866
+ <BusinessProductsList />
867
+ )}
860
868
  </Route>
861
869
  <Route exact path='/:business_slug'>
862
- {isUserVerifyRequired ? (
863
- <Redirect to='/verify' />
864
- ) : (
865
- <BusinessProductsList />
866
- )}
870
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
871
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
872
+ : isUserVerifyRequired ? (
873
+ <Redirect to='/verify' />
874
+ ) : (
875
+ <BusinessProductsList />
876
+ )}
867
877
  </Route>
868
878
  <Route exact path='/:business_slug/:category_slug/:product_slug'>
869
- {isUserVerifyRequired ? (
870
- <Redirect to='/verify' />
871
- ) : (
872
- <BusinessProductsList />
873
- )}
879
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
880
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
881
+ : isUserVerifyRequired ? (
882
+ <Redirect to='/verify' />
883
+ ) : (
884
+ <BusinessProductsList />
885
+ )}
874
886
  </Route>
875
887
  <Route exact path='/:business_slug/:category_slug'>
876
- {isUserVerifyRequired ? (
877
- <Redirect to='/verify' />
878
- ) : (
879
- <BusinessProductsList />
880
- )}
888
+ {queryIntegrationToken && queryIntegrationCode === 'spoonity'
889
+ ? <QueryLoginSpoonity token={queryIntegrationToken} notificationState={oneSignalState} />
890
+ : isUserVerifyRequired ? (
891
+ <Redirect to='/verify' />
892
+ ) : (
893
+ <BusinessProductsList />
894
+ )}
881
895
  </Route>
882
896
  <Route path='*'>
883
897
  <PageNotFound />