ordering-ui-external 1.3.2 → 1.4.1

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 (133) hide show
  1. package/_bundles/0.ordering-ui.eec38d66166bc4458215.js +1 -0
  2. package/_bundles/{0.ordering-ui.8d3ec9f208550df10621.js → 1.ordering-ui.eec38d66166bc4458215.js} +1 -1
  3. package/_bundles/{1.ordering-ui.8d3ec9f208550df10621.js → 2.ordering-ui.eec38d66166bc4458215.js} +1 -1
  4. package/_bundles/{4.ordering-ui.8d3ec9f208550df10621.js → 4.ordering-ui.eec38d66166bc4458215.js} +1 -1
  5. package/_bundles/{5.ordering-ui.8d3ec9f208550df10621.js → 5.ordering-ui.eec38d66166bc4458215.js} +1 -1
  6. package/_bundles/{6.ordering-ui.8d3ec9f208550df10621.js → 6.ordering-ui.eec38d66166bc4458215.js} +1 -1
  7. package/_bundles/7.ordering-ui.eec38d66166bc4458215.js +2 -0
  8. package/_bundles/{7.ordering-ui.8d3ec9f208550df10621.js.LICENSE.txt → 7.ordering-ui.eec38d66166bc4458215.js.LICENSE.txt} +0 -0
  9. package/_bundles/{8.ordering-ui.8d3ec9f208550df10621.js → 8.ordering-ui.eec38d66166bc4458215.js} +1 -1
  10. package/_bundles/{9.ordering-ui.8d3ec9f208550df10621.js → 9.ordering-ui.eec38d66166bc4458215.js} +1 -1
  11. package/_bundles/ordering-ui.eec38d66166bc4458215.js +2 -0
  12. package/_bundles/{ordering-ui.8d3ec9f208550df10621.js.LICENSE.txt → ordering-ui.eec38d66166bc4458215.js.LICENSE.txt} +0 -0
  13. package/_modules/themes/five/index.js +7 -0
  14. package/_modules/themes/five/src/components/BusinessListingSearch/MaxSectionItem/index.js +47 -0
  15. package/_modules/themes/five/src/components/BusinessListingSearch/index.js +14 -29
  16. package/_modules/themes/five/src/components/BusinessProductsList/index.js +10 -6
  17. package/_modules/themes/five/src/components/BusinessProductsList/styles.js +8 -7
  18. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +1 -1
  19. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +3 -3
  20. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +4 -1
  21. package/_modules/themes/five/src/components/Cart/index.js +3 -1
  22. package/_modules/themes/five/src/components/Checkout/index.js +52 -39
  23. package/_modules/themes/five/src/components/Favorite/index.js +16 -2
  24. package/_modules/themes/five/src/components/FavoriteList/index.js +15 -1
  25. package/_modules/themes/five/src/components/Header/index.js +2 -2
  26. package/_modules/themes/five/src/components/Header/styles.js +5 -3
  27. package/_modules/themes/five/src/components/Modal/index.js +2 -2
  28. package/_modules/themes/five/src/components/Modal/styles.js +8 -4
  29. package/_modules/themes/five/src/components/MyOrders/index.js +9 -2
  30. package/_modules/themes/five/src/components/OrderDetails/ActionsSection.js +1 -0
  31. package/_modules/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/index.js +10 -40
  32. package/_modules/themes/five/src/components/OrdersOption/PreviousProfessionalOrdered/index.js +25 -0
  33. package/_modules/themes/five/src/components/OrdersOption/PreviousProfessionalOrdered/styles.js +19 -0
  34. package/_modules/themes/five/src/components/OrdersOption/index.js +16 -13
  35. package/_modules/themes/five/src/components/ProductForm/index.js +5 -5
  36. package/_modules/themes/five/src/components/RenderProductsLayout/styles.js +1 -1
  37. package/_modules/themes/five/src/components/SidebarMenu/index.js +39 -17
  38. package/_modules/themes/five/src/components/SingleProductCard/styles.js +1 -1
  39. package/_modules/themes/five/src/components/SingleProfessionalCard/index.js +95 -0
  40. package/_modules/themes/five/src/components/SingleProfessionalCard/styles.js +47 -0
  41. package/_modules/themes/five/src/styles/Selects/index.js +1 -1
  42. package/index-template.js +28 -5
  43. package/package.json +6 -3
  44. package/src/themes/five/index.js +2 -0
  45. package/src/themes/five/src/components/BusinessListingSearch/MaxSectionItem/index.js +44 -0
  46. package/src/themes/five/src/components/BusinessListingSearch/index.js +8 -30
  47. package/src/themes/five/src/components/BusinessProductsList/index.js +29 -22
  48. package/src/themes/five/src/components/BusinessProductsList/styles.js +25 -2
  49. package/src/themes/five/src/components/BusinessProductsListing/index.js +1 -1
  50. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +4 -3
  51. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +1 -1
  52. package/src/themes/five/src/components/Cart/index.js +2 -0
  53. package/src/themes/five/src/components/Checkout/index.js +22 -14
  54. package/src/themes/five/src/components/Favorite/index.js +19 -1
  55. package/src/themes/five/src/components/FavoriteList/index.js +24 -0
  56. package/src/themes/five/src/components/Header/index.js +11 -8
  57. package/src/themes/five/src/components/Header/styles.js +5 -0
  58. package/src/themes/five/src/components/Modal/index.js +9 -6
  59. package/src/themes/five/src/components/Modal/styles.js +15 -1
  60. package/src/themes/five/src/components/MyOrders/index.js +11 -1
  61. package/src/themes/five/src/components/OrderDetails/ActionsSection.js +1 -0
  62. package/src/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/index.js +8 -29
  63. package/src/themes/five/src/components/OrdersOption/PreviousProfessionalOrdered/index.js +32 -0
  64. package/src/themes/five/src/components/OrdersOption/PreviousProfessionalOrdered/styles.js +38 -0
  65. package/src/themes/five/src/components/OrdersOption/index.js +18 -9
  66. package/src/themes/five/src/components/ProductForm/index.js +5 -5
  67. package/src/themes/five/src/components/RenderProductsLayout/styles.js +1 -1
  68. package/src/themes/five/src/components/SidebarMenu/index.js +98 -42
  69. package/src/themes/five/src/components/SingleProductCard/styles.js +5 -1
  70. package/src/themes/five/src/components/SingleProfessionalCard/index.js +82 -0
  71. package/src/themes/five/src/components/SingleProfessionalCard/styles.js +92 -0
  72. package/src/themes/five/src/styles/Selects/index.js +1 -0
  73. package/template/Utils/index.js +4 -0
  74. package/template/app.js +554 -143
  75. package/template/assets/images/business-hero.jpg +0 -0
  76. package/template/assets/images/business-signup-background.png +0 -0
  77. package/template/assets/images/business_signup.png +0 -0
  78. package/template/assets/images/congratulation_approval.png +0 -0
  79. package/template/assets/images/congratulation_no_approval.png +0 -0
  80. package/template/assets/images/credit.png +0 -0
  81. package/template/assets/images/delivery-types/curbside.jpg +0 -0
  82. package/template/assets/images/delivery-types/delivery.jpg +0 -0
  83. package/template/assets/images/delivery-types/drive_thru.jpg +0 -0
  84. package/template/assets/images/delivery-types/eat_in.jpg +0 -0
  85. package/template/assets/images/delivery-types/pickup.jpg +0 -0
  86. package/template/assets/images/driver-signup-background.png +0 -0
  87. package/template/assets/images/driver-signup-hero.png +0 -0
  88. package/template/assets/images/driver_congratulation_approval.png +0 -0
  89. package/template/assets/images/driver_congratulation_no_approval.png +0 -0
  90. package/template/assets/images/driver_signup.png +0 -0
  91. package/template/assets/images/home-hero.jpg +0 -0
  92. package/template/assets/images/loyalty_level.png +0 -0
  93. package/template/assets/images/mastercard.png +0 -0
  94. package/template/assets/images/not-found.svg +94 -1
  95. package/template/assets/images/not-network.svg +226 -1
  96. package/template/assets/images/visa.png +0 -0
  97. package/template/components/HelmetTags/index.js +5 -4
  98. package/template/components/ListenPageChanges/index.js +25 -12
  99. package/template/components/ScrollToTop/index.js +4 -0
  100. package/template/config.js +14 -0
  101. package/template/config.json +1 -0
  102. package/template/helmetdata.json +91 -28
  103. package/template/pages/AddressList/index.js +34 -0
  104. package/template/pages/AddressList/styles.js +43 -0
  105. package/template/pages/BusinessListingSearch/index.js +106 -0
  106. package/template/pages/BusinessProductsList/index.js +152 -29
  107. package/template/pages/BusinessesList/index.js +17 -6
  108. package/template/pages/Checkout/index.js +14 -4
  109. package/template/pages/Favorite/index.js +12 -0
  110. package/template/pages/Help/index.js +7 -2
  111. package/template/pages/Home/index.js +58 -36
  112. package/template/pages/Home/styles.js +14 -0
  113. package/template/pages/MessagesList/index.js +19 -0
  114. package/template/pages/MultiCheckout/index.js +26 -0
  115. package/template/pages/MultiOrdersDetails/index.js +21 -0
  116. package/template/pages/MyOrders/index.js +87 -3
  117. package/template/pages/OrderDetails/index.js +12 -2
  118. package/template/pages/Profile/index.js +16 -3
  119. package/template/pages/Promotions/index.js +13 -0
  120. package/template/pages/ResetPassword/index.js +15 -9
  121. package/template/pages/SessionsList/index.js +12 -0
  122. package/template/pages/SignUpBusiness/index.js +12 -0
  123. package/template/pages/SignUpDriver/index.js +12 -0
  124. package/template/pages/UserVerification/index.js +12 -0
  125. package/template/pages/Wallets/index.js +12 -0
  126. package/template/service-worker.js +72 -0
  127. package/template/theme.json +27 -51
  128. package/_bundles/3.ordering-ui.8d3ec9f208550df10621.js +0 -1
  129. package/_bundles/7.ordering-ui.8d3ec9f208550df10621.js +0 -2
  130. package/_bundles/ordering-ui.8d3ec9f208550df10621.js +0 -2
  131. package/template/assets/images/exclamation.svg +0 -3
  132. package/template/assets/images/order-creating.png +0 -0
  133. package/template/assets/images/order-sucess.png +0 -0
package/template/app.js CHANGED
@@ -6,47 +6,121 @@ import {
6
6
  Link,
7
7
  useLocation
8
8
  } from 'react-router-dom'
9
- import { useSession, useLanguage, useOrder, Analytics, useConfig, FacebookPixel } from 'ordering-components-external'
9
+ import { useTheme, ThemeProvider } from 'styled-components'
10
+ import PWAPrompt from 'react-ios-pwa-prompt'
11
+
12
+ import { useSession, useApi, useLanguage, useOrder, Analytics, FacebookPixel, useConfig, AnalyticsSegment, useEvent, useOrderingTheme, useSite } from 'ordering-components-external'
13
+ import { Header } from '../src/themes/five/src/components/Header'
14
+ import { Header as HeaderKiosk } from '../src/themes/five/src/components/Header/layouts/Kiosk'
15
+ import { Footer } from '../src/themes/five/src/components/Footer'
16
+ import { NotNetworkConnectivity } from '../src/themes/five/src/components/NotNetworkConnectivity'
10
17
 
11
- import { Header } from '../src/components/Header'
12
- import { Footer } from '../src/components/Footer'
13
18
  import { SpinnerLoader } from '../src/components/SpinnerLoader'
14
- import { NotNetworkConnectivity } from '../src/components/NotNetworkConnectivity'
19
+ import { Header as HeaderOld } from '../src/components/Header'
20
+ import { Header as HeaderRed } from '../src/themes/seven/src/components/Header'
21
+ import { Header as HeaderStarbucks } from '../src/themes/six/src/components/Header'
15
22
  import { useOnlineStatus } from '../src/hooks/useOnlineStatus'
23
+ import { useWindowSize } from '../src/hooks/useWindowSize'
16
24
  import { Alert } from '../src/components/Confirm'
17
25
  import { SmartAppBanner } from '../src/components/SmartAppBanner'
18
26
 
27
+ import { NavigationBar } from '../src/themes/five/src/components/NavigationBar'
28
+ import { Modal } from '../src/themes/five/src/components/Modal'
29
+
30
+ import { ReviewTrigger } from '../src/themes/five/src/components/ReviewTrigger'
31
+ import { ReviewOrder } from '../src/themes/five/src/components/ReviewOrder'
32
+ import { ReviewProduct } from '../src/themes/five/src/components/ReviewProduct'
33
+ import { ReviewDriver } from '../src/themes/five/src/components/ReviewDriver'
34
+ import { SignUpApproval } from '../src/themes/five/src/components/SignUpApproval'
35
+
36
+ import { AddressList } from './pages/AddressList'
19
37
  import { BusinessesList } from './pages/BusinessesList'
20
38
  import { BusinessProductsList } from './pages/BusinessProductsList'
21
39
  import { CheckoutPage } from './pages/Checkout'
22
40
  import { Cms } from './pages/Cms'
23
- import { ForgotPassword } from './pages/ForgotPassword'
24
41
  import { HomePage } from './pages/Home'
25
- import { Login } from './pages/Login'
26
42
  import { MyOrders } from './pages/MyOrders'
27
43
  import { OrderDetailsPage } from './pages/OrderDetails'
28
44
  import { PageNotFound } from './pages/PageNotFound'
29
45
  import { PagesList } from './pages/PagesList'
30
46
  import { Profile } from './pages/Profile'
31
- import { ResetPassword } from './pages/ResetPassword'
32
- import { SignUp } from './pages/SignUp'
47
+ import { Wallets } from './pages/Wallets'
48
+ import { MessagesList } from './pages/MessagesList'
33
49
  import { Help } from './pages/Help'
34
-
50
+ import { Favorite } from './pages/Favorite'
51
+ import { SessionsList } from './pages/SessionsList'
52
+ import { SignUpBusiness } from './pages/SignUpBusiness'
53
+ import { SignUpDriver } from './pages/SignUpDriver'
54
+ import { UserVerification } from './pages/UserVerification'
55
+ import { BusinessListingSearch } from './pages/BusinessListingSearch'
56
+ import { ResetPassword } from './pages/ResetPassword'
35
57
  import { ScrollToTop } from './components/ScrollToTop'
36
58
  import { ListenPageChanges } from './components/ListenPageChanges'
37
59
  import { HelmetTags } from './components/HelmetTags'
38
- import settings from './config.json'
60
+ import settings from './config'
61
+ import { Promotions } from './pages/Promotions'
62
+ import { MultiCheckout } from './pages/MultiCheckout'
63
+ import { MultiOrdersDetails } from './pages/MultiOrdersDetails'
39
64
 
40
65
  export const App = () => {
41
- const [{ auth, user, loading }, { login }] = useSession()
42
- const [orderStatus] = useOrder()
43
- const [{ configs }] = useConfig()
66
+ const [{ auth, user }, { login }] = useSession()
67
+ const [events] = useEvent()
68
+ const [ordering] = useApi()
69
+ const theme = useTheme()
70
+ const [orderStatus, { changeType, getLastOrderHasNoReview }] = useOrder()
71
+ const [{ configs, loading: configLoading }] = useConfig()
72
+ const [{ loading: siteLoading }] = useSite()
44
73
  const [, t] = useLanguage()
74
+ const [orderingTheme] = useOrderingTheme()
45
75
  const [loaded, setLoaded] = useState(false)
46
76
  const onlineStatus = useOnlineStatus()
47
77
  const location = useLocation()
48
78
  const [alertState, setAlertState] = useState({ open: false, content: [] })
79
+ const signUplayout = 'new'
80
+ const windowSize = useWindowSize()
81
+ const [businessSignUpSuccessed, setBusinessSignUpSuccessed] = useState({ open: false, content: {} })
82
+ const [lastOrderReview, setLastOrderReview] = useState({
83
+ isReviewOpen: false,
84
+ order: null,
85
+ defaultStar: 5,
86
+ reviewStatus: { trigger: false, order: false, product: false, driver: false },
87
+ reviewed: { isOrderReviewed: false, isProductReviewed: false, isDriverReviewed: false }
88
+ })
49
89
  const hashKey = new URLSearchParams(useLocation()?.search)?.get('hash') || null
90
+ const isKioskApp = settings?.use_kiosk
91
+
92
+ const themeUpdated = {
93
+ ...theme,
94
+ ...orderingTheme?.theme
95
+ }
96
+
97
+ const businessesSlug = {
98
+ marketplace: 'marketplace',
99
+ kiosk: settings?.businessSlug
100
+ }
101
+
102
+ const singleBusinessConfig = {
103
+ isActive: settings?.use_marketplace || isKioskApp,
104
+ businessSlug: businessesSlug[isKioskApp ? 'kiosk' : 'marketplace']
105
+ }
106
+
107
+ const HeaderComponent =
108
+ isKioskApp ? HeaderKiosk
109
+ : orderingTheme?.theme?.header?.components?.layout?.type === 'old'
110
+ ? HeaderOld
111
+ : orderingTheme?.theme?.header?.components?.layout?.type === 'red'
112
+ ? HeaderRed
113
+ : orderingTheme?.theme?.header?.components?.layout?.type === 'starbucks'
114
+ ? HeaderStarbucks
115
+ : Header
116
+
117
+ const orderTypeSearchParam = parseInt(new URLSearchParams(useLocation()?.search)?.get('order_type') ?? 0, 10)
118
+ const configTypes = configs?.order_types_allowed?.value.split('|').map(value => Number(value)) || []
119
+
120
+ const isWalletEnabled = (configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')) && !isKioskApp
121
+ const isEmailVerifyRequired = auth && configs?.verification_email_required?.value === '1' && !user?.email_verified
122
+ const isPhoneVerifyRequired = auth && configs?.verification_phone_required?.value === '1' && !user?.phone_verified
123
+ const isUserVerifyRequired = (isEmailVerifyRequired || isPhoneVerifyRequired) && !isKioskApp
50
124
 
51
125
  const closeAlert = () => {
52
126
  setAlertState({
@@ -61,26 +135,152 @@ export const App = () => {
61
135
  }
62
136
 
63
137
  const isHome = location.pathname === '/' || location.pathname === '/home'
64
- const isFooterPage = location.pathname === '/pages/footer'
138
+ const isFooterPage = location.pathname === '/pages/footer' || isKioskApp
65
139
 
66
140
  const handleSuccessSignup = (user) => {
67
- login({
68
- user,
69
- token: user?.session?.access_token
141
+ if (!user?.enabled && (configs?.business_signup_enabled_default?.value === '0' || configs?.driver_signup_enabled_default?.value === '0')) {
142
+ signUplayout === 'new' ?
143
+ setBusinessSignUpSuccessed({
144
+ open: true,
145
+ content: {
146
+ approvalType: 'no_automatic',
147
+ businessType: user?.level,
148
+ project: settings.project,
149
+ dashboardUrl: settings.url_dashboard,
150
+ dashboardLoginUrl: `${settings.url_dashboard}/login/?project=${settings.project}&token=${user?.session?.access_token}`
151
+ }
152
+ }) : setAlertState({
153
+ open: true,
154
+ content: [t('BUSINESS_SIGNUP_MESSAGE', 'We will contact you as soon as possible')]
155
+ })
156
+ return
157
+ }
158
+
159
+ if (configs?.business_signup_enabled_default?.value === '1' || configs?.driver_signup_enabled_default?.value === '1') {
160
+ signUplayout === 'new' ? setBusinessSignUpSuccessed({
161
+ open: true,
162
+ content: {
163
+ approvalType: 'automatic',
164
+ businessType: user?.level,
165
+ project: settings.project,
166
+ dashboardUrl: settings.url_dashboard,
167
+ dashboardLoginUrl: `${settings.url_dashboard}/login/?project=${settings.project}&token=${user?.session?.access_token}`
168
+ }
169
+ }) : setAlertState({
170
+ open: true,
171
+ content: [
172
+ `${t('PROJECT', 'Project')}: ${settings.project}`
173
+ ],
174
+ links: [
175
+ <span key='url dashboard'>
176
+ {`${t('DASHBOARD_WEBPAGE_MESSAGE', 'Dashboard webpage')}: `}
177
+ <a
178
+ target='blank'
179
+ href={`${settings.url_dashboard}/login/?project=${settings.project}&token=${user?.session?.access_token}`}
180
+ >
181
+ <span style={{ color: theme.colors.links }}>{settings.url_dashboard}</span>
182
+ </a>
183
+ </span>
184
+ ],
185
+ isOnlyAlert: true
186
+ })
187
+
188
+ login({
189
+ user,
190
+ token: user?.session?.access_token
191
+ })
192
+ }
193
+ }
194
+
195
+ const goToPage = (page, params) => {
196
+ events.emit('go_to_page', { page, params })
197
+ }
198
+
199
+ const _getLastOrderHasNoReview = async () => {
200
+ const lastOrderHasNoReview = await getLastOrderHasNoReview()
201
+ lastOrderHasNoReview && OrderReviewRequired(lastOrderHasNoReview)
202
+ }
203
+
204
+ const reviewModalTitle = () => {
205
+ if (lastOrderReview?.reviewStatus?.trigger) return t('HOW_WAS_YOUR_ORDER', 'How was your order?')
206
+ if (lastOrderReview?.reviewStatus?.order) return t('REVIEW_ORDER', 'Review order')
207
+ if (lastOrderReview?.reviewStatus?.product) return t('REVIEW_PRODUCT', 'Review Product')
208
+ return t('REVIEW_DRIVER', 'Review Driver')
209
+ }
210
+
211
+ const OrderReviewRequired = (order) => {
212
+ setLastOrderReview({
213
+ isReviewOpen: true,
214
+ order: order,
215
+ defaultStar: 5,
216
+ reviewStatus: { trigger: true, order: false, product: false, driver: false },
217
+ reviewed: { isOrderReviewed: false, isProductReviewed: false, isDriverReviewed: false }
218
+ })
219
+ }
220
+
221
+ const handleOpenOrderReview = (star) => {
222
+ setLastOrderReview({
223
+ ...lastOrderReview,
224
+ defaultStar: star,
225
+ reviewStatus: { trigger: false, order: true, product: false, driver: false }
70
226
  })
71
227
  }
72
228
 
229
+ const handleCloseReivew = () => {
230
+ setLastOrderReview({
231
+ ...lastOrderReview,
232
+ isReviewOpen: false,
233
+ reviewStatus: { trigger: false, order: false, product: false, driver: false }
234
+ })
235
+ }
236
+
237
+ const setIsReviewed = (reviewType) => {
238
+ const _reviewStatus = { ...lastOrderReview?.reviewed }
239
+ setLastOrderReview({
240
+ ...lastOrderReview,
241
+ reviewed: { ..._reviewStatus, [reviewType]: true }
242
+ })
243
+ }
244
+
245
+ const closeReviewOrder = () => {
246
+ if (!lastOrderReview?.reviewed?.isProductReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: true, driver: false } })
247
+ else if (lastOrderReview?.order?.driver && !lastOrderReview?.order?.user_review && !lastOrderReview?.reviewed?.isDriverReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: false, driver: true } })
248
+ else handleCloseReivew()
249
+ }
250
+
251
+ const closeReviewProduct = () => {
252
+ if (lastOrderReview?.order?.driver && !lastOrderReview?.order?.user_review && !lastOrderReview?.reviewed?.isDriverReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: false, driver: true } })
253
+ else {
254
+ setIsReviewed('isDriverReviewed')
255
+ handleCloseReivew()
256
+ }
257
+ }
258
+
73
259
  useEffect(() => {
74
- if (!loaded && !orderStatus.loading) {
75
- setLoaded(true)
260
+ const _user = window.localStorage.getItem('user')
261
+ const _token = window.localStorage.getItem('token')
262
+ const _reviewRequired = window.sessionStorage.getItem('review-required')
263
+ if (((_user || _token) && auth) && _reviewRequired !== '1') {
264
+ window.sessionStorage.setItem('review-required', '1')
265
+ _getLastOrderHasNoReview()
76
266
  }
77
- }, [orderStatus])
267
+ if (!(_user || _token)) {
268
+ window.sessionStorage.removeItem('review-required')
269
+ }
270
+ }, [auth])
78
271
 
79
272
  useEffect(() => {
80
- if (!loading) {
81
- setLoaded(!auth)
273
+ if (!loaded && !orderStatus.loading && !configLoading && !siteLoading && !orderingTheme?.loading) {
274
+ if (orderTypeSearchParam && configTypes.includes(orderTypeSearchParam)) {
275
+ changeType(parseInt(orderTypeSearchParam, 10))
276
+ if (orderStatus?.options?.type === parseInt(orderTypeSearchParam, 10)) {
277
+ setLoaded(true)
278
+ }
279
+ return
280
+ }
281
+ setLoaded(true)
82
282
  }
83
- }, [loading])
283
+ }, [orderStatus, configLoading, siteLoading, orderingTheme])
84
284
 
85
285
  useEffect(() => {
86
286
  if (configs?.front_version?.value && loaded) {
@@ -94,185 +294,357 @@ export const App = () => {
94
294
  }
95
295
  }, [configs, loaded])
96
296
 
297
+ useEffect(() => {
298
+ if (isHome && settings?.use_marketplace) {
299
+ goToPage('business', { store: 'marketplace' })
300
+ }
301
+ }, [])
302
+
303
+ useEffect(() => {
304
+ if (!orderStatus.loading) {
305
+ const localCountryCode = orderStatus?.options?.address?.country_code ??
306
+ window.localStorage.getItem('country-code')
307
+
308
+ if (localCountryCode) {
309
+ ordering?.setCountryCode(localCountryCode)
310
+ }
311
+ }
312
+ }, [orderStatus])
313
+
97
314
  return (
98
315
  <>
99
316
  {!!configs?.track_id_google_analytics?.value && (
100
317
  <Analytics trackId={configs?.track_id_google_analytics?.value} />
101
318
  )}
102
- {!!configs?.facebook_id?.value && (
319
+ {!!configs?.segment_track_id?.value && (
320
+ <AnalyticsSegment writeKey={configs?.segment_track_id?.value} />
321
+ )}
322
+ {!!configs?.facebook_id?.value && FacebookPixel && (
103
323
  <FacebookPixel trackId={configs?.facebook_id?.value} />
104
324
  )}
105
- <ListenPageChanges />
106
- {
107
- !loaded && (
108
- <SpinnerLoader />
109
- )
110
- }
325
+ {!loaded && <SpinnerLoader />}
111
326
  <SmartAppBanner
112
- storeAndroidId={settings?.store_android_id}
113
- storeAppleId={settings?.store_apple_id}
114
- storeKindleId={settings?.store_kindle_id}
327
+ storeAndroidId={settings?.store_android_id !== '0' ? settings?.store_android_id : false}
328
+ storeAppleId={settings?.store_apple_id !== '0' ? settings?.store_apple_id : false}
329
+ storeKindleId={settings?.store_kindle_id !== '0' ? settings?.store_kindle_id : false}
115
330
  />
116
331
  {
117
332
  loaded && (
118
- <>
119
- <Header
120
- isHome={isHome}
121
- location={location}
122
- />
123
-
333
+ <ThemeProvider theme={themeUpdated}>
334
+ <ListenPageChanges />
335
+ {!(isKioskApp && isHome) && (
336
+ <HeaderComponent
337
+ isHome={isHome}
338
+ location={location}
339
+ isCustomLayout={singleBusinessConfig.isActive}
340
+ />
341
+ )}
124
342
  <NotNetworkConnectivity />
125
343
  {onlineStatus && (
126
344
  <ScrollToTop>
127
345
  <HelmetTags />
128
346
  <Switch>
129
347
  <Route exact path='/home'>
130
- {
131
- orderStatus.options?.address?.location
132
- ? <Redirect to='/search' />
133
- : <HomePage />
134
- }
348
+ {isUserVerifyRequired ? (
349
+ <Redirect to='/verify' />
350
+ ) : (
351
+ isKioskApp
352
+ ? <HomePage />
353
+ : orderStatus.options?.address?.location
354
+ ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/search'} />
355
+ : singleBusinessConfig.isActive
356
+ ? <Redirect to={singleBusinessConfig.isActive ? '' : '/search'} />
357
+ : <HomePage />
358
+ )}
135
359
  </Route>
136
360
  <Route exact path='/'>
137
- {
138
- orderStatus.options?.address?.location
139
- ? <Redirect to='/search' />
140
- : <HomePage />
141
- }
361
+ {isUserVerifyRequired ? (
362
+ <Redirect to='/verify' />
363
+ ) : (
364
+ isKioskApp
365
+ ? <HomePage />
366
+ : orderStatus.options?.address?.location
367
+ ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/search'} />
368
+ : <HomePage />
369
+ )}
142
370
  </Route>
143
- <Route exact path='/signup'>
144
- {
145
- !auth
146
- ? (
147
- <SignUp
148
- elementLinkToLogin={<Link to='/login'>{t('LOGIN', 'Login')}</Link>}
149
- useLoginByCellphone
150
- useChekoutFileds
151
- handleSuccessSignup={handleSuccessSignup}
152
- isRecaptchaEnable
153
- />
154
- )
155
- : <Redirect to='/' />
156
- }
371
+ <Route exact path='/wallets'>
372
+ {auth
373
+ ? isUserVerifyRequired
374
+ ? <Redirect to='/verify' />
375
+ : isWalletEnabled
376
+ ? <Wallets />
377
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
378
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />}
157
379
  </Route>
158
- <Route exact path='/login'>
159
- {
160
- !auth
161
- ? (
162
- <Login
163
- elementLinkToSignup={<Link to='/signup'>{t('CREATE_ACCOUNT', 'Create account')}</Link>}
164
- elementLinkToForgotPassword={<Link to='/password/forgot'>{t('RESET_PASSWORD', 'Reset password')}</Link>}
165
- useLoginByCellphone
166
- isRecaptchaEnable
167
- />
168
- )
169
- : (
170
- orderStatus?.options?.user_id && !orderStatus?.loading ? (
171
- orderStatus.options?.address?.location
172
- ? <Redirect to='/search' />
173
- : <Redirect to='/' />
174
- ) : (
175
- <SpinnerLoader />
176
- )
177
- )
178
- }
380
+ <Route exact path='/signup_business'>
381
+ {!auth && !isKioskApp ? (
382
+ <SignUpBusiness
383
+ elementLinkToLogin={<Link to='/'>{t('LOGIN', 'Login')}</Link>}
384
+ useLoginByCellphone
385
+ useChekoutFileds
386
+ handleSuccessSignup={handleSuccessSignup}
387
+ layout={signUplayout}
388
+ isRecaptchaEnable
389
+ />
390
+ ) : (
391
+ <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
392
+ )}
179
393
  </Route>
180
- <Route exact path='/signin'>
181
- {
182
- !auth
183
- ? (
184
- <Login
185
- elementLinkToSignup={<Link to='/signup'>{t('CREATE_ACCOUNT', 'Create account')}</Link>}
186
- elementLinkToForgotPassword={<Link to='/password/forgot'>{t('RESET_PASSWORD', 'Reset password')}</Link>}
187
- useLoginByCellphone
188
- isRecaptchaEnable
189
- />
190
- )
191
- : (
192
- orderStatus?.options?.user_id && !orderStatus?.loading ? (
193
- orderStatus.options?.address?.location
194
- ? <Redirect to='/search' />
195
- : <Redirect to='/' />
196
- ) : (
197
- <SpinnerLoader />
198
- )
199
- )
200
- }
394
+ <Route exact path='/signup-driver'>
395
+ {!auth && !isKioskApp ? (
396
+ <SignUpDriver
397
+ layout={signUplayout}
398
+ elementLinkToLogin={<Link to='/'>{t('LOGIN', 'Login')}</Link>}
399
+ useLoginByCellphone
400
+ useChekoutFileds
401
+ handleSuccessSignup={handleSuccessSignup}
402
+ isRecaptchaEnable
403
+ />
404
+ ) : (
405
+ <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
406
+ )}
201
407
  </Route>
202
- <Route exact path='/password/forgot'>
203
- {
204
- !auth ? (
205
- <ForgotPassword
206
- elementLinkToLogin={<Link to='/login'>{t('LOGIN', 'Login')}</Link>}
207
- />
208
- )
209
- : <Redirect to='/' />
210
- }
408
+ <Route exact path='/password/reset'>
409
+ {auth ? (
410
+ <Redirect to='/' />
411
+ ) : (
412
+ isKioskApp
413
+ ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
414
+ : <ResetPassword />
415
+ )}
211
416
  </Route>
212
- <Route exact path='/password/reset' component={ResetPassword} />
213
417
  <Route exact path='/profile'>
214
418
  {auth
215
- ? (<Profile userId={user?.id} accessToken={user?.session?.access_token} useValidationFields />)
216
- : <Redirect to='/login' />}
419
+ ? isUserVerifyRequired
420
+ ? <Redirect to='/verify' />
421
+ : (<Profile userId={user?.id} accessToken={user?.session?.access_token} useValidationFields />)
422
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />}
423
+ </Route>
424
+ <Route exact path='/verify'>
425
+ {isUserVerifyRequired
426
+ ? <UserVerification />
427
+ : <Redirect to={(auth || isKioskApp) ? singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/search' : '/'} />}
217
428
  </Route>
218
429
  <Route exact path='/profile/orders'>
219
430
  {auth
220
- ? (<MyOrders />)
221
- : <Redirect to='/login' />}
431
+ ? isUserVerifyRequired
432
+ ? <Redirect to='/verify' />
433
+ : (<MyOrders />)
434
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />}
435
+ </Route>
436
+ <Route exact path='/profile/addresses'>
437
+ {auth
438
+ ? isUserVerifyRequired
439
+ ? <Redirect to='/verify' />
440
+ : (<AddressList />)
441
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />}
442
+ </Route>
443
+ <Route exact path='/messages'>
444
+ {auth
445
+ ? isUserVerifyRequired
446
+ ? <Redirect to='/verify' />
447
+ : <MessagesList />
448
+ : (
449
+ isKioskApp
450
+ ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
451
+ : <Redirect to={{ pathname: '/search' }} />
452
+ )}
453
+ </Route>
454
+ <Route exact path='/help'>
455
+ {auth
456
+ ? isUserVerifyRequired
457
+ ? <Redirect to='/verify' />
458
+ : (<Help />)
459
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />}
222
460
  </Route>
223
461
  <Route exact path='/search'>
462
+ {
463
+ isKioskApp
464
+ ? <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
465
+ : (
466
+ orderStatus.loading && !orderStatus.options?.address?.location ? (
467
+ <SpinnerLoader />
468
+ ) : (
469
+ isUserVerifyRequired ? (
470
+ <Redirect to='/verify' />
471
+ ) : (
472
+ orderStatus.options?.address?.location
473
+ ? <BusinessesList />
474
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
475
+ )
476
+ )
477
+ )
478
+ }
479
+ </Route>
480
+ <Route exact path='/business_search'>
481
+ {isUserVerifyRequired ? (
482
+ <Redirect to='/verify' />
483
+ ) : (
484
+ orderStatus.options?.address?.location && !isKioskApp ? (
485
+ <BusinessListingSearch />
486
+ ) : (
487
+ <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
488
+ )
489
+ )}
490
+ </Route>
491
+ <Route exact path='/promotions'>
224
492
  {orderStatus.loading && !orderStatus.options?.address?.location ? (
225
493
  <SpinnerLoader />
226
494
  ) : (
227
- orderStatus.options?.address?.location
228
- ? <BusinessesList />
229
- : <Redirect to='/' />
495
+ isUserVerifyRequired ? (
496
+ <Redirect to='/verify' />
497
+ ) : (
498
+ orderStatus.options?.address?.location && !isKioskApp
499
+ ? <Promotions />
500
+ : <Redirect to={singleBusinessConfig.isActive ? `/${singleBusinessConfig.businessSlug}` : '/'} />
501
+ )
230
502
  )}
231
503
  </Route>
232
- <Route exact path='/store/:store'>
233
- <BusinessProductsList />
234
- </Route>
235
504
  <Route path='/checkout/:cartUuid?'>
236
505
  {auth
237
- ? <CheckoutPage />
506
+ ? isUserVerifyRequired
507
+ ? <Redirect to='/verify' />
508
+ : <CheckoutPage />
238
509
  : (
239
510
  <Redirect to={{
240
- pathname: '/login',
511
+ pathname: singleBusinessConfig.isActive
512
+ ? `/${singleBusinessConfig.businessSlug}`
513
+ : '/',
241
514
  state: { from: location.pathname || null }
242
515
  }}
243
516
  />
244
517
  )}
245
518
  </Route>
246
- <Route exact path='/orders/:orderId'>
247
- {(auth || hashKey)
248
- ? <OrderDetailsPage />
519
+ <Route path='/multi-checkout'>
520
+ {auth
521
+ ? isUserVerifyRequired
522
+ ? <Redirect to='/verify' />
523
+ : <MultiCheckout />
249
524
  : (
250
525
  <Redirect to={{
251
- pathname: '/login',
526
+ pathname: singleBusinessConfig.isActive
527
+ ? `/${singleBusinessConfig.businessSlug}`
528
+ : '/',
252
529
  state: { from: location.pathname || null }
253
530
  }}
254
531
  />
255
532
  )}
256
533
  </Route>
257
- <Route exact path='/pages/:pageSlug'>
258
- <Cms />
534
+ <Route path='/multi-orders'>
535
+ {auth
536
+ ? isUserVerifyRequired
537
+ ? <Redirect to='/verify' />
538
+ : <MultiOrdersDetails />
539
+ : (
540
+ <Redirect to={{
541
+ pathname: singleBusinessConfig.isActive
542
+ ? `/${singleBusinessConfig.businessSlug}`
543
+ : '/',
544
+ state: { from: location.pathname || null }
545
+ }}
546
+ />
547
+ )}
259
548
  </Route>
260
- <Route exact path='/pages'>
261
- <PagesList />
549
+ <Route exact path='/orders/:orderId'>
550
+ {(auth || hashKey)
551
+ ? isUserVerifyRequired
552
+ ? <Redirect to='/verify' />
553
+ : <OrderDetailsPage />
554
+ : (
555
+ <Redirect to={{
556
+ pathname: singleBusinessConfig.isActive
557
+ ? `/${singleBusinessConfig.businessSlug}`
558
+ : '/',
559
+ state: { from: location.pathname || null }
560
+ }}
561
+ />
562
+ )}
262
563
  </Route>
263
- <Route exact path='/help'>
264
- {auth
265
- ? <Help />
564
+ <Route exact path='/promotions'>
565
+ {(auth || hashKey)
566
+ ? isUserVerifyRequired
567
+ ? <Redirect to='/verify' />
568
+ : <Promotions />
266
569
  : (
267
570
  <Redirect to={{
268
- pathname: '/login',
571
+ pathname: singleBusinessConfig.isActive
572
+ ? `/${singleBusinessConfig.businessSlug}`
573
+ : '/',
269
574
  state: { from: location.pathname || null }
270
575
  }}
271
576
  />
272
577
  )}
273
578
  </Route>
274
- <Route exact path='/:store'>
275
- <BusinessProductsList />
579
+ <Route exact path='/pages/:pageSlug'>
580
+ {isUserVerifyRequired ? (
581
+ <Redirect to='/verify' />
582
+ ) : (
583
+ <Cms />
584
+ )}
585
+ </Route>
586
+ <Route exact path='/pages'>
587
+ {isUserVerifyRequired ? (
588
+ <Redirect to='/verify' />
589
+ ) : (
590
+ <PagesList />
591
+ )}
592
+ </Route>
593
+ <Route exact path='/favorite'>
594
+ {auth && !isKioskApp
595
+ ? <Favorite />
596
+ : (
597
+ <Redirect to='/' />
598
+ )}
599
+ </Route>
600
+ <Route exact path='/sessions'>
601
+ {auth && !isKioskApp
602
+ ? <SessionsList />
603
+ : (
604
+ <Redirect to='/' />
605
+ )}
606
+ </Route>
607
+ <Route exact path='/store'>
608
+ {isUserVerifyRequired ? (
609
+ <Redirect to='/verify' />
610
+ ) : (
611
+ <BusinessProductsList />
612
+ )}
613
+ </Route>
614
+ <Route exact path='/:business_slug'>
615
+ {isUserVerifyRequired ? (
616
+ <Redirect to='/verify' />
617
+ ) : (
618
+ <BusinessProductsList />
619
+ )}
620
+ </Route>
621
+ <Route exact path='/:business_slug/:category_slug/:product_slug'>
622
+ {isUserVerifyRequired ? (
623
+ <Redirect to='/verify' />
624
+ ) : (
625
+ <BusinessProductsList />
626
+ )}
627
+ </Route>
628
+ <Route exact path='/store/:business_slug'>
629
+ {isUserVerifyRequired ? (
630
+ <Redirect to='/verify' />
631
+ ) : (
632
+ <BusinessProductsList />
633
+ )}
634
+ </Route>
635
+ <Route exact path='/store/:business_slug/:category_slug/:product_slug'>
636
+ {isUserVerifyRequired ? (
637
+ <Redirect to='/verify' />
638
+ ) : (
639
+ <BusinessProductsList />
640
+ )}
641
+ </Route>
642
+ <Route exact path='/store/:category_slug/:product_slug'>
643
+ {isUserVerifyRequired ? (
644
+ <Redirect to='/verify' />
645
+ ) : (
646
+ <BusinessProductsList />
647
+ )}
276
648
  </Route>
277
649
  <Route path='*'>
278
650
  <PageNotFound />
@@ -280,20 +652,59 @@ export const App = () => {
280
652
  </Switch>
281
653
  </ScrollToTop>
282
654
  )}
655
+ {!navigator.userAgent.match('CriOS') && (
656
+ <PWAPrompt promptOnVisit={1} timesToShow={100} copyClosePrompt="Close" permanentlyHideOnDismiss={false} />
657
+ )}
283
658
  {!isFooterPage && (
284
659
  <Footer />
285
660
  )}
661
+ {(windowSize.width < 576 && auth) && (
662
+ <NavigationBar />
663
+ )}
286
664
  <Alert
287
665
  title={t('INFORMATION', 'Information')}
288
666
  content={alertState.content}
667
+ links={alertState.links}
289
668
  acceptText={t('ACCEPT', 'Accept')}
290
669
  open={alertState.open}
291
670
  onClose={() => closeAlert()}
292
671
  onCancel={() => closeAlert()}
293
- onAccept={() => acceptAlert()}
672
+ onAccept={() => alertState?.isOnlyAlert ? closeAlert() : acceptAlert()}
294
673
  closeOnBackdrop={false}
295
674
  />
296
- </>
675
+ {lastOrderReview?.isReviewOpen && (
676
+ <Modal
677
+ open={lastOrderReview?.isReviewOpen}
678
+ onClose={handleCloseReivew}
679
+ title={lastOrderReview?.order && reviewModalTitle()}
680
+ width={lastOrderReview?.reviewStatus?.trigger ? '680px' : null}
681
+ >
682
+ <div>
683
+ {
684
+ lastOrderReview?.reviewStatus?.trigger
685
+ ? <ReviewTrigger order={lastOrderReview?.order} handleOpenOrderReview={handleOpenOrderReview} />
686
+ : lastOrderReview?.reviewStatus?.order
687
+ ? <ReviewOrder order={lastOrderReview?.order} defaultStar={lastOrderReview?.defaultStar} closeReviewOrder={closeReviewOrder} setIsReviewed={() => setIsReviewed('isOrderReviewed')} />
688
+ : (lastOrderReview?.reviewStatus?.product
689
+ ? <ReviewProduct order={lastOrderReview?.order} closeReviewProduct={closeReviewProduct} setIsProductReviewed={() => setIsReviewed('isProductReviewed')} />
690
+ : <ReviewDriver order={lastOrderReview?.order} closeReviewDriver={handleCloseReivew} setIsDriverReviewed={() => setIsReviewed('isDriverReviewed')} />)
691
+ }
692
+ </div>
693
+ </Modal>
694
+ )}
695
+ <Modal
696
+ open={businessSignUpSuccessed?.open}
697
+ onClose={() => setBusinessSignUpSuccessed({ open: false, content: {} })}
698
+ title={t('CONGRATULATIONS', 'Congratulations')}
699
+ width={'990px'}
700
+ >
701
+ <SignUpApproval
702
+ content={businessSignUpSuccessed?.content}
703
+ onAccept={() => acceptAlert()}
704
+ onCancel={() => setBusinessSignUpSuccessed({ open: false, content: {} })}
705
+ />
706
+ </Modal>
707
+ </ThemeProvider>
297
708
  )
298
709
  }
299
710
  </>