ordering-ui-external 14.1.46 → 14.1.48

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 (30) hide show
  1. package/_bundles/{0.ordering-ui.247fbb361bb31d72a262.js → 0.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  2. package/_bundles/{1.ordering-ui.247fbb361bb31d72a262.js → 1.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  3. package/_bundles/{2.ordering-ui.247fbb361bb31d72a262.js → 2.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  4. package/_bundles/{4.ordering-ui.247fbb361bb31d72a262.js → 4.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  5. package/_bundles/{5.ordering-ui.247fbb361bb31d72a262.js → 5.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  6. package/_bundles/{6.ordering-ui.247fbb361bb31d72a262.js → 6.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  7. package/_bundles/{7.ordering-ui.247fbb361bb31d72a262.js → 7.ordering-ui.4754b59ff7216a67c8b5.js} +2 -2
  8. package/_bundles/{8.ordering-ui.247fbb361bb31d72a262.js → 8.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  9. package/_bundles/{9.ordering-ui.247fbb361bb31d72a262.js → 9.ordering-ui.4754b59ff7216a67c8b5.js} +1 -1
  10. package/_bundles/ordering-ui.4754b59ff7216a67c8b5.js +2 -0
  11. package/_modules/components/LogoutButton/index.js +1 -7
  12. package/_modules/themes/callcenterOriginal/src/components/Header/index.js +5 -7
  13. package/_modules/themes/callcenterOriginal/src/components/Header/styles.js +8 -12
  14. package/_modules/themes/callcenterOriginal/src/components/HeaderOption/index.js +6 -26
  15. package/_modules/themes/callcenterOriginal/src/components/HeaderOption/styles.js +1 -1
  16. package/_modules/themes/callcenterOriginal/src/components/SidebarMenu/index.js +74 -69
  17. package/_modules/themes/callcenterOriginal/src/components/UserPopover/index.js +30 -21
  18. package/_modules/themes/five/src/components/ProductItemAccordion/index.js +20 -30
  19. package/package.json +2 -2
  20. package/src/components/LogoutButton/index.js +3 -5
  21. package/src/themes/callcenterOriginal/src/components/Header/index.js +14 -12
  22. package/src/themes/callcenterOriginal/src/components/Header/styles.js +18 -40
  23. package/src/themes/callcenterOriginal/src/components/HeaderOption/index.js +30 -51
  24. package/src/themes/callcenterOriginal/src/components/HeaderOption/styles.js +2 -4
  25. package/src/themes/callcenterOriginal/src/components/SidebarMenu/index.js +75 -101
  26. package/src/themes/callcenterOriginal/src/components/UserPopover/index.js +36 -17
  27. package/src/themes/five/src/components/ProductItemAccordion/index.js +20 -27
  28. package/_bundles/ordering-ui.247fbb361bb31d72a262.js +0 -2
  29. /package/_bundles/{7.ordering-ui.247fbb361bb31d72a262.js.LICENSE.txt → 7.ordering-ui.4754b59ff7216a67c8b5.js.LICENSE.txt} +0 -0
  30. /package/_bundles/{ordering-ui.247fbb361bb31d72a262.js.LICENSE.txt → ordering-ui.4754b59ff7216a67c8b5.js.LICENSE.txt} +0 -0
@@ -9,10 +9,13 @@ import AiOutlineHome from '@meronex/icons/ai/AiOutlineHome'
9
9
  import BiStore from '@meronex/icons/bi/BiStore'
10
10
  import FaUserCircle from '@meronex/icons/fa/FaUserCircle'
11
11
  import BiHelpCircle from '@meronex/icons/bi/BiHelpCircle'
12
+ import GiHistogram from '@meronex/icons/gi/GiHistogram'
13
+ import BsGraphUp from '@meronex/icons/bs/BsGraphUp'
12
14
 
13
15
  import { useEvent, useLanguage, useOrder, useSession } from 'ordering-components-external'
14
16
  import { useTheme } from 'styled-components'
15
17
 
18
+ import { capitalize } from '../../../../../utils'
16
19
  import { useWindowSize } from '../../../../../hooks/useWindowSize'
17
20
  import { LogoutButton } from '../../../../../components/LogoutButton'
18
21
  import { Modal } from '../Modal'
@@ -35,9 +38,20 @@ import {
35
38
  MobileMessage
36
39
  } from './styles'
37
40
 
41
+ const extraOptions = [
42
+ { name: 'profile', pathname: '/profile', displayName: 'view account', key: 'view_account' },
43
+ { name: 'help', pathname: '/help', displayName: 'help', key: 'help' }
44
+ ]
45
+
46
+ const adminOptionsDefault = [
47
+ { name: 'orderlist', pathname: '/orderlist', displayName: 'order list', key: 'ORDER_LIST' },
48
+ { name: 'deliveries', pathname: '/deliveries', displayName: 'delivery dashboard', key: 'DELIVERY_DASHBOARD' },
49
+ { name: 'drivers_dashboard', pathname: '/drivers', displayName: 'drivers dashboard', key: 'DRIVERS_DASHBOARD' }
50
+ ]
51
+
38
52
  export const SidebarMenu = (props) => {
39
53
  const { auth, isHideSignup, userCustomer, isCustomerMode } = props
40
- const [{ login }] = useSession()
54
+ const [sessionState, { login }] = useSession()
41
55
  const [events] = useEvent()
42
56
  const [, t] = useLanguage()
43
57
  const [{ options }] = useOrder()
@@ -48,8 +62,6 @@ export const SidebarMenu = (props) => {
48
62
  const [modalPageToShow, setModalPageToShow] = useState(null)
49
63
  const [showMessage, setShowMessage] = useState(false)
50
64
 
51
- const isHome = window.location.pathname === '/' || window.location.pathname === '/home'
52
-
53
65
  const closeModal = () => {
54
66
  setModalIsOpen(false)
55
67
  setModalPageToShow(null)
@@ -104,21 +116,26 @@ export const SidebarMenu = (props) => {
104
116
  }, [width])
105
117
 
106
118
  useEffect(() => {
107
- if(!isCustomerMode) return
119
+ if (!isCustomerMode) return
108
120
  if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
109
121
  setShowMessage(true)
110
122
  }
111
123
  }, [])
112
124
 
125
+ const getMenuIcon = (icon) => {
126
+ const list = {
127
+ profile: <FaRegAddressCard />,
128
+ help: <BiHelpCircle />,
129
+ orderlist: <FaRegListAlt />,
130
+ deliveries: <GiHistogram />,
131
+ drivers_dashboard: <BsGraphUp />
132
+ }
133
+ return list[icon]
134
+ }
135
+
113
136
  return (
114
137
  <>
115
- {props.beforeElements?.map((BeforeElement, i) => (
116
- <React.Fragment key={i}>
117
- {BeforeElement}
118
- </React.Fragment>))}
119
- {props.beforeComponents?.map((BeforeComponent, i) => (
120
- <BeforeComponent key={i} {...props} />))}
121
- {showMessage && (
138
+ {showMessage && (
122
139
  <MobileMessage>
123
140
  <div>
124
141
  <CloseIcon onClick={() => setShowMessage(false)} />
@@ -128,18 +145,13 @@ export const SidebarMenu = (props) => {
128
145
  )}
129
146
  <Container auth={auth}>
130
147
  <IconContent
131
- isHome={isHome}
132
148
  aria-label='menu'
133
149
  onClick={() => actionSidebar(true)}
134
150
  >
135
151
  <IosMenu />
136
152
  </IconContent>
137
- <SidebarContent
138
- id='sidebar_menu'
139
- isHome={isHome}
140
- >
153
+ <SidebarContent id='sidebar_menu'>
141
154
  <MenuClose
142
- isHome={isHome}
143
155
  aria-label='close'
144
156
  onClick={() => actionSidebar(false)}
145
157
  >
@@ -147,17 +159,15 @@ export const SidebarMenu = (props) => {
147
159
  </MenuClose>
148
160
 
149
161
  {userCustomer && (
150
- <MenuLink isHome={isHome} isCustomer={userCustomer}>
162
+ <MenuLink isCustomer={userCustomer}>
151
163
  <WrappContent>
152
164
  <MenuLinkIcon
153
- isHome={isHome}
154
165
  active={false}
155
166
  >
156
167
  <FaUserCircle />
157
168
  </MenuLinkIcon>
158
169
  <MenuLinkText>
159
170
  <TextInfo
160
- isHome={isHome}
161
171
  active={false}
162
172
  >
163
173
  {`${userCustomer?.name} ${userCustomer?.lastname}`}
@@ -172,13 +182,9 @@ export const SidebarMenu = (props) => {
172
182
  </MenuLink>
173
183
  )}
174
184
 
175
- <MenuLink
176
- isHome={isHome}
177
- onClick={() => handleGoToPage({ page: options?.address?.location ? 'search' : 'home' })}
178
- >
185
+ <MenuLink onClick={() => handleGoToPage({ page: options?.address?.location ? 'search' : 'home' })}>
179
186
  <WrappContent>
180
187
  <MenuLinkIcon
181
- isHome={isHome}
182
188
  active={
183
189
  window.location.pathname === '/' ||
184
190
  window.location.pathname === '/home' ||
@@ -193,7 +199,6 @@ export const SidebarMenu = (props) => {
193
199
  </MenuLinkIcon>
194
200
  <MenuLinkText>
195
201
  <TextInfo
196
- isHome={isHome}
197
202
  active={
198
203
  window.location.pathname === '/' ||
199
204
  window.location.pathname === '/home' ||
@@ -217,75 +222,57 @@ export const SidebarMenu = (props) => {
217
222
 
218
223
  {auth && (
219
224
  <>
220
- <MenuLink
221
- isHome={isHome}
222
- onClick={() => handleGoToPage({ page: 'profile' })}
223
- >
224
- <WrappContent>
225
- <MenuLinkIcon
226
- isHome={isHome}
227
- active={
228
- window.location.pathname === '/profile'
229
- }
230
- >
231
- <FaRegAddressCard />
232
- </MenuLinkIcon>
233
- <MenuLinkText>
234
- <TextInfo
235
- isHome={isHome}
236
- active={
237
- window.location.pathname === '/profile'
238
- }
239
- >
240
- {t('PROFILE', 'Profile')}
241
- </TextInfo>
242
- </MenuLinkText>
243
- <MenuLinkSeparator>
244
- <div>
245
- <hr />
246
- </div>
247
- </MenuLinkSeparator>
248
- </WrappContent>
249
- </MenuLink>
250
- <MenuLink
251
- isHome={isHome}
252
- onClick={() => handleGoToPage({ page: 'help' })}
253
- >
254
- <WrappContent>
255
- <MenuLinkIcon
256
- isHome={isHome}
257
- active={
258
- window.location.pathname === '/help'
259
- }
260
- >
261
- <BiHelpCircle />
262
- </MenuLinkIcon>
263
- <MenuLinkText>
264
- <TextInfo
265
- isHome={isHome}
266
- active={
267
- window.location.pathname === '/help'
268
- }
269
- >
270
- {t('HELP', 'help')}
271
- </TextInfo>
272
- </MenuLinkText>
273
- <MenuLinkSeparator>
274
- <div>
275
- <hr />
276
- </div>
277
- </MenuLinkSeparator>
278
- </WrappContent>
279
- </MenuLink>
225
+ {extraOptions.map(option => (
226
+ <MenuLink
227
+ key={option.key}
228
+ onClick={() => handleGoToPage({ page: option.name })}
229
+ >
230
+ <WrappContent>
231
+ <MenuLinkIcon active={window.location.pathname === option.pathname}>
232
+ {getMenuIcon(option.name)}
233
+ </MenuLinkIcon>
234
+ <MenuLinkText>
235
+ <TextInfo active={window.location.pathname === option.pathname}>
236
+ {t((option.key || option.name).toUpperCase(), capitalize(option.displayName || option.name))}
237
+ </TextInfo>
238
+ </MenuLinkText>
239
+ <MenuLinkSeparator>
240
+ <div>
241
+ <hr />
242
+ </div>
243
+ </MenuLinkSeparator>
244
+ </WrappContent>
245
+ </MenuLink>
246
+ ))}
247
+ {sessionState?.user?.level === 0 && adminOptionsDefault.map(option => (
248
+ <MenuLink
249
+ key={option.key}
250
+ onClick={() => handleGoToPage({ page: option.name })}
251
+ >
252
+ <WrappContent>
253
+ <MenuLinkIcon active={window.location.pathname === option.pathname}>
254
+ {getMenuIcon(option.name)}
255
+ </MenuLinkIcon>
256
+ <MenuLinkText>
257
+ <TextInfo active={window.location.pathname === option.pathname}>
258
+ {t((option.key || option.name).toUpperCase(), capitalize(option.displayName || option.name))}
259
+ </TextInfo>
260
+ </MenuLinkText>
261
+ <MenuLinkSeparator>
262
+ <div>
263
+ <hr />
264
+ </div>
265
+ </MenuLinkSeparator>
266
+ </WrappContent>
267
+ </MenuLink>
268
+ ))}
280
269
  {
281
270
  !isCustomerMode && (
282
271
  <MenuLink
283
- isHome={isHome}
284
272
  onClick={() => handleGoToPage({ page: 'orders' })}
285
273
  >
286
274
  <WrappContent>
287
275
  <MenuLinkIcon
288
- isHome={isHome}
289
276
  active={
290
277
  window.location.pathname === '/profile/orders'
291
278
  }
@@ -294,7 +281,6 @@ export const SidebarMenu = (props) => {
294
281
  </MenuLinkIcon>
295
282
  <MenuLinkText>
296
283
  <TextInfo
297
- isHome={isHome}
298
284
  active={
299
285
  window.location.pathname === '/profile/orders'
300
286
  }
@@ -318,19 +304,16 @@ export const SidebarMenu = (props) => {
318
304
  {!auth && (
319
305
  <>
320
306
  <MenuLink
321
- isHome={isHome}
322
307
  onClick={() => handleOpenLoginSignUp('login')}
323
308
  >
324
309
  <WrappContent>
325
310
  <MenuLinkIcon
326
- isHome={isHome}
327
311
  active={modalPageToShow === 'login'}
328
312
  >
329
313
  <AiOutlineLogin />
330
314
  </MenuLinkIcon>
331
315
  <MenuLinkText>
332
316
  <TextInfo
333
- isHome={isHome}
334
317
  active={modalPageToShow === 'login'}
335
318
  >
336
319
  {t('SIGN_IN', 'Sign in')}
@@ -345,19 +328,16 @@ export const SidebarMenu = (props) => {
345
328
  </MenuLink>
346
329
  {!isHideSignup && (
347
330
  <MenuLink
348
- isHome={isHome}
349
331
  onClick={() => handleOpenLoginSignUp('signup')}
350
332
  >
351
333
  <WrappContent>
352
334
  <MenuLinkIcon
353
- isHome={isHome}
354
335
  active={modalPageToShow === 'signup'}
355
336
  >
356
337
  <AiOutlineUserAdd />
357
338
  </MenuLinkIcon>
358
339
  <MenuLinkText>
359
340
  <TextInfo
360
- isHome={isHome}
361
341
  active={modalPageToShow === 'signup'}
362
342
  >
363
343
  {t('SIGNUP', 'Sign up')}
@@ -435,12 +415,6 @@ export const SidebarMenu = (props) => {
435
415
  </Modal>
436
416
  )}
437
417
  </Container>
438
- {props.afterComponents?.map((AfterComponent, i) => (
439
- <AfterComponent key={i} {...props} />))}
440
- {props.afterElements?.map((AfterElement, i) => (
441
- <React.Fragment key={i}>
442
- {AfterElement}
443
- </React.Fragment>))}
444
418
  </>
445
419
  )
446
420
  }
@@ -27,6 +27,12 @@ const extraOptions = [
27
27
  { name: 'help', pathname: '/help', displayName: 'help', key: 'help' }
28
28
  ]
29
29
 
30
+ const adminOptionsDefault = [
31
+ { name: 'orderlist', pathname: '/orderlist', displayName: 'order list', key: 'ORDER_LIST' },
32
+ { name: 'deliveries', pathname: '/deliveries', displayName: 'delivery dashboard', key: 'DELIVERY_DASHBOARD' },
33
+ { name: 'drivers_dashboard', pathname: '/drivers', displayName: 'drivers dashboard', key: 'DRIVERS_DASHBOARD' }
34
+ ]
35
+
30
36
  export const UserPopover = (props) => {
31
37
  const {
32
38
  open,
@@ -58,7 +64,7 @@ export const UserPopover = (props) => {
58
64
  ]
59
65
  })
60
66
 
61
- const { styles, attributes, forceUpdate } = popper
67
+ const { styles, attributes } = popper
62
68
 
63
69
  useEffect(() => {
64
70
  // forceUpdate && forceUpdate()
@@ -99,12 +105,6 @@ export const UserPopover = (props) => {
99
105
  }
100
106
  return (
101
107
  <div style={{ overflow: 'hidden' }}>
102
- {props.beforeElements?.map((BeforeElement, i) => (
103
- <React.Fragment key={i}>
104
- {BeforeElement}
105
- </React.Fragment>))}
106
- {props.beforeComponents?.map((BeforeComponent, i) => (
107
- <BeforeComponent key={i} {...props} />))}
108
108
  <HeaderItem
109
109
  isPhoto={sessionState?.user?.photo}
110
110
  isHome={isHome}
@@ -150,20 +150,39 @@ export const UserPopover = (props) => {
150
150
  ))
151
151
  )
152
152
  }
153
-
154
- <Divider />
155
- {withLogout && (
156
- <PopoverListItemLogout onClose={props.onClose} />
153
+ {!(sessionState?.user?.level === 0) && (
154
+ <>
155
+ <Divider />
156
+ {withLogout && (
157
+ <PopoverListItemLogout onClose={props.onClose} />
158
+ )}
159
+ </>
157
160
  )}
158
161
  </ExtraOptions>
162
+ {sessionState?.user?.level === 0 && (
163
+ <>
164
+ <Divider />
165
+ <ExtraOptions>
166
+ {
167
+ adminOptionsDefault && (adminOptionsDefault.map((option, i) => (
168
+ <PopoverListLink
169
+ key={i}
170
+ active={window.location.pathname === option.pathname}
171
+ onClick={() => handleGoToPage(option.name)}
172
+ >
173
+ {t((option.key || option.name).toUpperCase(), capitalize(option.displayName || option.name))}
174
+ </PopoverListLink>
175
+ )))
176
+ }
177
+ <Divider />
178
+ {withLogout && (
179
+ <PopoverListItemLogout onClose={props.onClose} />
180
+ )}
181
+ </ExtraOptions>
182
+ </>
183
+ )}
159
184
  </PopoverList>
160
185
  </PopoverBody>
161
- {props.afterComponents?.map((AfterComponent, i) => (
162
- <AfterComponent key={i} {...props} />))}
163
- {props.afterElements?.map((AfterElement, i) => (
164
- <React.Fragment key={i}>
165
- {AfterElement}
166
- </React.Fragment>))}
167
186
  </div>
168
187
  )
169
188
  }
@@ -4,7 +4,7 @@ import {
4
4
  Pencil,
5
5
  Trash
6
6
  } from 'react-bootstrap-icons'
7
- import { useUtils, useLanguage, useOrder, useConfig } from 'ordering-components-external'
7
+ import { useUtils, useLanguage, useOrder, useConfig, ProductItemAccordion as ProductItemAccordionController } from 'ordering-components-external'
8
8
  import { useWindowSize } from '../../../../../hooks/useWindowSize'
9
9
  import {
10
10
  AccordionSection,
@@ -31,7 +31,7 @@ import {
31
31
  } from './styles'
32
32
  import { useTheme } from 'styled-components'
33
33
 
34
- export const ProductItemAccordion = (props) => {
34
+ const ProductItemAccordionUI = (props) => {
35
35
  const {
36
36
  isDisabledEdit,
37
37
  isCartPending,
@@ -45,7 +45,8 @@ export const ProductItemAccordion = (props) => {
45
45
  isCheckout,
46
46
  isStore,
47
47
  isConfirmationPage,
48
- toppingsRemoved
48
+ toppingsRemoved,
49
+ productInfo
49
50
  } = props
50
51
  const theme = useTheme()
51
52
  const [, t] = useLanguage()
@@ -66,25 +67,7 @@ export const ProductItemAccordion = (props) => {
66
67
  const showProductImage = !theme?.[viewString]?.components?.cart?.components?.products?.components?.image?.hidden
67
68
  const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
68
69
 
69
- const productInfo = () => {
70
- if (isCartProduct) {
71
- const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
72
- let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
73
-
74
- options = options.map(option => {
75
- option.suboptions = Object.values(option.suboptions ?? {})
76
- return option
77
- })
78
- return {
79
- ...productInfo,
80
- ingredients,
81
- options
82
- }
83
- }
84
- return product
85
- }
86
-
87
- const showArrowIcon = props.showArrowIcon && (productInfo()?.ingredients?.length > 0 || productInfo()?.options?.length > 0 || product?.comment)
70
+ const showArrowIcon = props.showArrowIcon && (productInfo?.ingredients?.length > 0 || productInfo?.options?.length > 0 || product?.comment)
88
71
 
89
72
  const toggleAccordion = (e) => {
90
73
  const isActionsClick = productSelect.current?.contains(e.target) || productActionsEdit.current?.contains(e.target) || productActionsDelete.current?.contains(e.target)
@@ -220,7 +203,7 @@ export const ProductItemAccordion = (props) => {
220
203
  <span>
221
204
  {parsePrice(product.total || product.price)}
222
205
  </span>
223
- {(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || product.comment) && (
206
+ {(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || product.comment) && (
224
207
  <p>
225
208
  <IosArrowDown className={`${setRotate}`} />
226
209
  </p>
@@ -305,19 +288,19 @@ export const ProductItemAccordion = (props) => {
305
288
  ref={content}
306
289
  style={{ maxHeight: `${setHeight}` }}
307
290
  >
308
- {productInfo().ingredients.length > 0 && productInfo().ingredients.some(ingredient => !ingredient.selected) && (
291
+ {productInfo.ingredients.length > 0 && productInfo.ingredients.some(ingredient => !ingredient.selected) && (
309
292
  <ProductOptionsList>
310
293
  <p>{t('INGREDIENTS', 'Ingredients')}</p>
311
- {productInfo().ingredients.map(ingredient => !ingredient.selected && (
294
+ {productInfo.ingredients.map(ingredient => !ingredient.selected && (
312
295
  <li className='ingredient' key={ingredient.id}>
313
296
  <span>{t('NO', 'No')} {ingredient.name}</span>
314
297
  </li>
315
298
  ))}
316
299
  </ProductOptionsList>
317
300
  )}
318
- {productInfo().options.length > 0 && (
301
+ {productInfo.options.length > 0 && (
319
302
  <ProductOptionsList>
320
- {productInfo().options.sort((a, b) => a.rank - b.rank).map(option => (
303
+ {productInfo.options.sort((a, b) => a.rank - b.rank).map(option => (
321
304
  <li key={option.id}>
322
305
  <p>{option.name}</p>
323
306
  <ProductOptionsList className='suboption'>
@@ -373,3 +356,13 @@ export const ProductItemAccordion = (props) => {
373
356
  </>
374
357
  )
375
358
  }
359
+
360
+ export const ProductItemAccordion = (props) => {
361
+ const productItemAccordion = {
362
+ ...props,
363
+ UIComponent: ProductItemAccordionUI
364
+ }
365
+ return (
366
+ <ProductItemAccordionController {...productItemAccordion} />
367
+ )
368
+ }