ordering-ui-external 2.6.5 → 2.6.8

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.ba64d5c9c7490676feb5.js +1 -0
  2. package/_bundles/{5.ordering-ui.80bc71775c11b08c37b2.js → 5.ordering-ui.ba64d5c9c7490676feb5.js} +1 -1
  3. package/_bundles/{7.ordering-ui.80bc71775c11b08c37b2.js → 7.ordering-ui.ba64d5c9c7490676feb5.js} +2 -2
  4. package/_bundles/ordering-ui.ba64d5c9c7490676feb5.js +2 -0
  5. package/_modules/components/LanguageSelector/index.js +1 -0
  6. package/_modules/components/OrderTypeSelectorHeader/index.js +3 -1
  7. package/_modules/components/SmartAppBanner/index.js +5 -2
  8. package/_modules/contexts/ThemeContext/index.js +1 -1
  9. package/_modules/styles/Select/index.js +14 -2
  10. package/_modules/styles/Selects/index.js +11 -8
  11. package/_modules/themes/callcenterOriginal/src/components/Orders/OrderMetaFields/index.js +1 -1
  12. package/_modules/themes/eight/src/components/AddressForm/index.js +4 -1
  13. package/_modules/themes/eight/src/components/SingleProductCard/index.js +1 -1
  14. package/_modules/themes/five/src/components/BusinessBasicInformation/BusinessInfoComponent.js +168 -0
  15. package/_modules/themes/five/src/components/BusinessBasicInformation/SearchComponent.js +39 -0
  16. package/_modules/themes/five/src/components/BusinessBasicInformation/SocialNetWork.js +19 -0
  17. package/_modules/themes/five/src/components/BusinessBasicInformation/index.js +35 -156
  18. package/_modules/themes/five/src/components/BusinessBasicInformation/styles.js +45 -35
  19. package/_modules/themes/five/src/components/BusinessProductsCategories/index.js +1 -1
  20. package/_modules/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/index.js +1 -1
  21. package/_modules/themes/five/src/components/CardForm/index.js +16 -3
  22. package/_modules/themes/five/src/components/CardForm/styles.js +13 -9
  23. package/_modules/themes/five/src/components/CardFormCustom/cardUtils.js +102 -0
  24. package/_modules/themes/five/src/components/CardFormCustom/index.js +148 -0
  25. package/_modules/themes/five/src/components/CardFormCustom/styles.js +16 -0
  26. package/_modules/themes/five/src/components/CartPopover/styles.js +1 -1
  27. package/_modules/themes/five/src/components/Checkout/index.js +31 -22
  28. package/_modules/themes/five/src/components/LanguageSelector/index.js +4 -1
  29. package/_modules/themes/five/src/components/LoginForm/index.js +11 -8
  30. package/_modules/themes/five/src/components/Modal/styles.js +1 -1
  31. package/_modules/themes/five/src/components/OrderContextUI/index.js +13 -1
  32. package/_modules/themes/five/src/components/OrderDetails/OrderHistory.js +7 -3
  33. package/_modules/themes/five/src/components/OrderDetails/index.js +4 -2
  34. package/_modules/themes/five/src/components/PaymentOptionCard/index.js +84 -0
  35. package/_modules/themes/five/src/components/PaymentOptionStripe/index.js +48 -22
  36. package/_modules/themes/five/src/components/PaymentOptionStripe/styles.js +3 -1
  37. package/_modules/themes/five/src/components/PaymentOptions/index.js +46 -24
  38. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  39. package/_modules/themes/five/src/components/SearchProducts/styles.js +1 -1
  40. package/_modules/themes/five/src/components/UserDetails/index.js +1 -1
  41. package/_modules/themes/five/src/components/UserPopover/styles.js +1 -1
  42. package/_modules/themes/five/src/styles/Select/index.js +4 -2
  43. package/_modules/themes/five/src/styles/Selects/index.js +7 -4
  44. package/_modules/themes/four/src/components/LoginForm/index.js +1 -1
  45. package/_modules/themes/pwa/src/components/MomentPopover/styles.js +1 -1
  46. package/_modules/themes/seven/src/components/ProductForm/productForm.js +3 -1
  47. package/_modules/themes/six/src/components/BusinessesListing/index.js +1 -1
  48. package/index.html +1 -1
  49. package/package.json +4 -2
  50. package/src/components/LanguageSelector/index.js +1 -0
  51. package/src/components/OrderTypeSelectorHeader/index.js +3 -1
  52. package/src/components/SmartAppBanner/index.js +4 -2
  53. package/src/contexts/ThemeContext/index.js +1 -1
  54. package/src/styles/Select/index.js +11 -2
  55. package/src/styles/Selects/index.js +1 -1
  56. package/src/themes/five/src/components/BusinessBasicInformation/BusinessInfoComponent.js +230 -0
  57. package/src/themes/five/src/components/BusinessBasicInformation/SearchComponent.js +40 -0
  58. package/src/themes/five/src/components/BusinessBasicInformation/SocialNetWork.js +10 -0
  59. package/src/themes/five/src/components/BusinessBasicInformation/index.js +39 -247
  60. package/src/themes/five/src/components/BusinessBasicInformation/styles.js +14 -4
  61. package/src/themes/five/src/components/BusinessProductsCategories/index.js +1 -1
  62. package/src/themes/five/src/components/CardForm/index.js +25 -4
  63. package/src/themes/five/src/components/CardForm/styles.js +35 -0
  64. package/src/themes/five/src/components/CardFormCustom/cardUtils.js +111 -0
  65. package/src/themes/five/src/components/CardFormCustom/index.js +161 -0
  66. package/src/themes/five/src/components/CardFormCustom/styles.js +20 -0
  67. package/src/themes/five/src/components/CartPopover/styles.js +1 -1
  68. package/src/themes/five/src/components/Checkout/index.js +34 -25
  69. package/src/themes/five/src/components/LanguageSelector/index.js +2 -1
  70. package/src/themes/five/src/components/LoginForm/index.js +6 -4
  71. package/src/themes/five/src/components/Modal/styles.js +1 -0
  72. package/src/themes/five/src/components/OrderContextUI/index.js +10 -3
  73. package/src/themes/five/src/components/OrderDetails/OrderHistory.js +4 -3
  74. package/src/themes/five/src/components/OrderDetails/index.js +1 -1
  75. package/src/themes/five/src/components/PaymentOptionCard/index.js +70 -0
  76. package/src/themes/five/src/components/PaymentOptionStripe/index.js +46 -20
  77. package/src/themes/five/src/components/PaymentOptionStripe/styles.js +6 -1
  78. package/src/themes/five/src/components/PaymentOptions/index.js +28 -3
  79. package/src/themes/five/src/components/ProductForm/index.js +0 -1
  80. package/src/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  81. package/src/themes/five/src/components/SearchProducts/styles.js +1 -1
  82. package/src/themes/five/src/components/UserDetails/index.js +1 -1
  83. package/src/themes/five/src/components/UserPopover/styles.js +1 -1
  84. package/src/themes/five/src/styles/Select/index.js +3 -2
  85. package/src/themes/five/src/styles/Selects/index.js +1 -1
  86. package/src/themes/pwa/src/components/MomentPopover/styles.js +4 -1
  87. package/template/theme.json +3 -1
  88. package/_bundles/0.ordering-ui.80bc71775c11b08c37b2.js +0 -1
  89. package/_bundles/ordering-ui.80bc71775c11b08c37b2.js +0 -2
  90. /package/_bundles/{1.ordering-ui.80bc71775c11b08c37b2.js → 1.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  91. /package/_bundles/{2.ordering-ui.80bc71775c11b08c37b2.js → 2.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  92. /package/_bundles/{4.ordering-ui.80bc71775c11b08c37b2.js → 4.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  93. /package/_bundles/{6.ordering-ui.80bc71775c11b08c37b2.js → 6.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  94. /package/_bundles/{7.ordering-ui.80bc71775c11b08c37b2.js.LICENSE.txt → 7.ordering-ui.ba64d5c9c7490676feb5.js.LICENSE.txt} +0 -0
  95. /package/_bundles/{8.ordering-ui.80bc71775c11b08c37b2.js → 8.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  96. /package/_bundles/{9.ordering-ui.80bc71775c11b08c37b2.js → 9.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  97. /package/_bundles/{ordering-ui.80bc71775c11b08c37b2.js.LICENSE.txt → ordering-ui.ba64d5c9c7490676feb5.js.LICENSE.txt} +0 -0
@@ -1,6 +1,4 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import Skeleton from 'react-loading-skeleton'
3
- import { StarFill, Facebook, Tiktok, Pinterest, Whatsapp, Instagram, Snapchat } from 'react-bootstrap-icons'
4
2
  import { useTheme } from 'styled-components'
5
3
 
6
4
  import { Modal } from '../Modal'
@@ -8,12 +6,9 @@ import { BusinessInformation } from '../BusinessInformation'
8
6
  import { BusinessReviews } from '../BusinessReviews'
9
7
  import BsInfoCircle from '@meronex/icons/bs/BsInfoCircle'
10
8
 
11
- import { useUtils, useOrder, useLanguage, useConfig } from 'ordering-components-external'
9
+ import { useUtils, useLanguage } from 'ordering-components-external'
12
10
 
13
- import { convertHoursToMinutes, shape, lightenDarkenColor } from '../../../../../utils'
14
- import { Select } from '../../styles/Select'
15
11
  import { MomentContent } from '../MomentContent'
16
- import CgSearch from '@meronex/icons/cg/CgSearch'
17
12
  import { SearchProducts } from '../SearchProducts'
18
13
  import { SearchProducts as SearchProductsStarbucks } from '../../../../six/src/components/BusinessProductsListing/SearchProducts'
19
14
  import {
@@ -21,22 +16,10 @@ import {
21
16
  BusinessContent,
22
17
  WrapperBusinessLogo,
23
18
  BusinessLogo,
24
- BusinessInfo,
25
- BusinessInfoItem,
26
- BusinessInfoContainer,
27
- BusinessInfoContent,
28
- WrapperSearch,
29
- BusinessDetail,
30
19
  BusinessMoreDetail,
31
- TitleWrapper,
32
- RibbonBox,
33
- SearchIconWrapper,
34
20
  SearchComponentContainer,
35
- SocialList,
36
- IconWrapper,
37
21
  BusinessInfoWrapper,
38
- WrapperFloatingSearch,
39
- SearchWrapper
22
+ WrapperFloatingSearch
40
23
  } from './styles'
41
24
  import { BusinessPreorder } from '../BusinessPreorder'
42
25
 
@@ -44,6 +27,8 @@ import dayjs from 'dayjs'
44
27
  import timezone from 'dayjs/plugin/timezone'
45
28
  import isBetween from 'dayjs/plugin/isBetween'
46
29
  import { useWindowSize } from '../../../../../hooks/useWindowSize'
30
+ import { BusinessInfoComponent } from './BusinessInfoComponent'
31
+ import { SearchComponent } from './SearchComponent'
47
32
 
48
33
  dayjs.extend(timezone)
49
34
  dayjs.extend(isBetween)
@@ -63,36 +48,44 @@ export const BusinessBasicInformation = (props) => {
63
48
  handleChangeSortBy,
64
49
  categoryState,
65
50
  errorQuantityProducts,
66
- isCustomerMode
51
+ isCustomerMode,
52
+ isCustomLayout
67
53
  } = props
68
54
  const { business, loading } = businessState
69
55
 
70
56
  const theme = useTheme()
71
- const [orderState] = useOrder()
72
57
  const [, t] = useLanguage()
73
- const [{ parsePrice, parseDistance, optimizeImage }] = useUtils()
58
+ const [{ optimizeImage }] = useUtils()
74
59
  const windowSize = useWindowSize()
75
60
  const [isBusinessReviews, setIsBusinessReviews] = useState(false)
76
61
  const [isPreOrder, setIsPreOrder] = useState(false)
77
62
  const [openSearchProducts, setOpenSearchProducts] = useState(false)
78
- const [{ configs }] = useConfig()
79
- const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
80
63
 
81
64
  const hideLogo = theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
82
- const hideDeliveryFee = theme?.business_view?.components?.header?.components?.business?.components?.fee?.hidden
83
- const hideTime = theme?.business_view?.components?.header?.components?.business?.components?.time?.hidden
84
- const hideReviews = theme?.business_view?.components?.header?.components?.business?.components?.reviews?.hidden
85
- const hideReviewsPopup = theme?.business_view?.components?.header?.components?.reviews?.hidden
86
- const hideDistance = theme?.business_view?.components?.header?.components?.business?.components?.distance?.hidden
87
- const hideSort = theme?.business_view?.components?.header?.components?.business?.components?.sort?.hidden
88
65
  const hideInfoIcon = theme?.business_view?.components?.header?.components?.business?.components?.business_info?.hidden
89
66
 
90
67
  const isInfoShrunken = theme?.business_view?.components?.header?.components?.business?.components?.layout?.position === 'shrunken'
91
68
  const searchLayout = theme?.business_view?.components?.product_search?.components?.layout?.type
92
- const hideCity = theme?.business_view?.components?.header?.components?.business?.components?.city?.hidden
93
69
  const isChew = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
94
- const layoutsWithOldSearch = ['starbucks', 'old', 'floating']
95
- const hideSearch = layoutsWithOldSearch.includes(theme?.business_view?.components?.product_search?.components?.layout?.type)
70
+
71
+ const businessInfoComponentProps = {
72
+ isChew,
73
+ loading,
74
+ business,
75
+ isInfoShrunken,
76
+ isCustomerMode,
77
+ setIsPreOrder,
78
+ setIsBusinessReviews,
79
+ categoryState,
80
+ searchValue,
81
+ errorQuantityProducts,
82
+ setOpenSearchProducts,
83
+ handleChangeSortBy,
84
+ sortByValue,
85
+ sortByOptions,
86
+ isCustomLayout
87
+ }
88
+
96
89
  const getBusinessType = () => {
97
90
  if (Object.keys(business).length <= 0) return t('GENERAL', 'General')
98
91
  const _types = []
@@ -166,217 +159,6 @@ export const BusinessBasicInformation = (props) => {
166
159
  })
167
160
  }, [sortByValue])
168
161
 
169
- const SearchComponent = () => {
170
- return (
171
- <WrapperSearch id='search-component'>
172
- <SearchWrapper>
173
- <SearchIconWrapper
174
- onClick={() => setOpenSearchProducts(true)}
175
- >
176
- <CgSearch />
177
- </SearchIconWrapper>
178
- {!hideSort && (
179
- <Select
180
- notAsync
181
- notReload
182
- options={sortByOptions}
183
- defaultValue={sortByValue}
184
- onChange={(val) => handleChangeSortBy && handleChangeSortBy(val)}
185
- />
186
- )}
187
- </SearchWrapper>
188
- </WrapperSearch>
189
- )
190
- }
191
-
192
- const SocialNetWork = ({ url, icon }) => {
193
- return (
194
- <IconWrapper href={url} target='_blank' rel='noopener noreferrer'>
195
- {icon}
196
- </IconWrapper>
197
- )
198
- }
199
-
200
- const BusinessInfoComponent = () => {
201
- return (
202
- <BusinessInfoContainer isChew={isChew} isFlexEnd={windowSize.width >= 768}>
203
- <BusinessInfoContent>
204
- <BusinessInfo className='info'>
205
- <BusinessInfoItem isInfoShrunken={isInfoShrunken}>
206
- {!loading ? (
207
- <TitleWrapper>
208
- <h2 className='bold' id='business_name'>{business?.name}</h2>
209
- {business?.ribbon?.enabled && (
210
- <RibbonBox
211
- bgColor={business?.ribbon?.color}
212
- colorText={lightenDarkenColor(business?.ribbon?.color)}
213
- borderRibbon={lightenDarkenColor(business?.ribbon?.color)}
214
- isRoundRect={business?.ribbon?.shape === shape?.rectangleRound}
215
- isCapsule={business?.ribbon?.shape === shape?.capsuleShape}
216
- >
217
- {business?.ribbon?.text}
218
- </RibbonBox>
219
- )}
220
- </TitleWrapper>
221
- ) : (
222
- <Skeleton width={isCustomerMode ? 100 : 150} height={isCustomerMode ? 35 : 'auto'} />
223
- )}
224
- {typeof hideCity !== 'undefined' && !hideCity && business?.city?.name && (
225
- <>
226
- {!loading ? (
227
- <p className='type'>{business?.city?.name}</p>
228
- ) : (
229
- <Skeleton width={isCustomerMode ? 100 : 150} />
230
- )}
231
- </>
232
- )}
233
- {!loading ? (
234
- <SocialList>
235
- {business?.facebook_profile && (
236
- <SocialNetWork
237
- url={business?.facebook_profile}
238
- icon={<Facebook />}
239
- />
240
- )}
241
- {business?.instagram_profile && (
242
- <SocialNetWork
243
- url={business?.instagram_profile}
244
- icon={<Instagram />}
245
- />
246
- )}
247
- {business?.tiktok_profile && (
248
- <SocialNetWork
249
- url={business?.tiktok_profile}
250
- icon={<Tiktok />}
251
- />
252
- )}
253
- {business?.pinterest_profile && (
254
- <SocialNetWork
255
- url={business?.pinterest_profile}
256
- icon={<Pinterest />}
257
- />
258
- )}
259
- {business?.whatsapp_number && (
260
- <SocialNetWork
261
- url={business?.whatsapp_number}
262
- icon={<Whatsapp />}
263
- />
264
- )}
265
- {business?.snapchat_profile && (
266
- <SocialNetWork
267
- url={business?.snapchat_profile}
268
- icon={<Snapchat />}
269
- />
270
- )}
271
- </SocialList>
272
- ) : (
273
- <SocialList>
274
- {[...Array(5).keys()].map(i => (
275
- <IconWrapper isSkeleton key={i}>
276
- <Skeleton width={27} height={27} />
277
- </IconWrapper>
278
- ))}
279
- </SocialList>
280
- )}
281
- <BusinessDetail isSkeleton={loading}>
282
- {orderState?.options.type === 1 && !hideDeliveryFee && (
283
- <>
284
- {!loading ? (
285
- <>
286
- <h5>
287
- <span>{t('DELIVERY_FEE', 'Delivery fee')}</span>
288
- {business && parsePrice(business?.delivery_price || 0)}
289
- </h5>
290
- <span className='dot'>•</span>
291
- </>
292
- ) : (
293
- <Skeleton width={isCustomerMode ? 70 : 50} />
294
- )}
295
- </>
296
- )}
297
- {!hideTime && (
298
- <>
299
- {!loading ? (
300
- <>
301
- {orderState?.options?.type === 1 ? (
302
- <>
303
- <h5>
304
- {convertHoursToMinutes(business?.delivery_time)}
305
- </h5>
306
- <span className='dot'>•</span>
307
- </>
308
- ) : (
309
- <>
310
- <h5>
311
- {convertHoursToMinutes(business?.pickup_time)}
312
- </h5>
313
- <span className='dot'>•</span>
314
- </>
315
- )}
316
- </>
317
- ) : (
318
- <Skeleton width={isCustomerMode ? 70 : 50} />
319
- )}
320
- </>
321
- )}
322
- {!hideDistance && (
323
- <>
324
- {!loading ? (
325
- <>
326
- <h5>
327
- {parseDistance(business?.distance || 0)}
328
- </h5>
329
- <span className='dot'>•</span>
330
- </>
331
- ) : (
332
- <Skeleton width={isCustomerMode ? 70 : 50} />
333
- )}
334
- </>
335
- )}
336
- {!hideReviews && (
337
- <>
338
- {!loading ? (
339
- <div className='review'>
340
- <StarFill className='start' />
341
- <p>{business?.reviews?.total}</p>
342
- </div>
343
- ) : (
344
- <Skeleton width={isCustomerMode ? 100 : 50} />
345
- )}
346
- </>
347
- )}
348
- </BusinessDetail>
349
- {
350
- !loading ? (
351
- <div className='preorder-Reviews'>
352
- {isPreOrderSetting && (
353
- <>
354
- <span onClick={() => setIsPreOrder(true)}>{t('PREORDER', 'Preorder')}</span>
355
- <span className='dot'>•</span>
356
- </>
357
- )}
358
- {business.reviews?.reviews && !hideReviewsPopup && <span onClick={() => setIsBusinessReviews(true)}>{t('REVIEWS', 'Reviews')}</span>}
359
- </div>
360
- ) : (
361
- <Skeleton width={isCustomerMode ? 100 : 150} />
362
- )
363
- }
364
- </BusinessInfoItem>
365
- </BusinessInfo>
366
- </BusinessInfoContent>
367
- {!hideSearch &&
368
- (categoryState?.products?.length !== 0 || searchValue) &&
369
- !errorQuantityProducts &&
370
- !isInfoShrunken &&
371
- !business?.professionals?.length &&
372
- // (categoryClicked || windowSize.width >= 993) &&
373
- (
374
- <SearchComponent />
375
- )}
376
- </BusinessInfoContainer>
377
- )
378
- }
379
-
380
162
  return (
381
163
  <>
382
164
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -401,7 +183,10 @@ export const BusinessBasicInformation = (props) => {
401
183
  )}
402
184
  <BusinessInfoWrapper>
403
185
  {(!isInfoShrunken && !isChew) && (
404
- <BusinessInfoComponent />
186
+ <BusinessInfoComponent
187
+ {...businessInfoComponentProps}
188
+
189
+ />
405
190
  )}
406
191
  {(business?.header || business?.logo || loading || isInfoShrunken) && (
407
192
  <BusinessContainer bgimage={business?.header} isSkeleton={isSkeleton} id='container' isClosed={!business?.open} isChew={isChew}>
@@ -416,13 +201,20 @@ export const BusinessBasicInformation = (props) => {
416
201
  </BusinessContent>
417
202
  )}
418
203
  {(isInfoShrunken || isChew) && (
419
- <BusinessInfoComponent />
204
+ <BusinessInfoComponent
205
+ {...businessInfoComponentProps}
206
+ />
420
207
  )}
421
208
  {!loading && (
422
209
  <>
423
210
  {isInfoShrunken && (
424
211
  <SearchComponentContainer>
425
- <SearchComponent />
212
+ <SearchComponent
213
+ setOpenSearchProducts={setOpenSearchProducts}
214
+ handleChangeSortBy={handleChangeSortBy}
215
+ sortByValue={sortByValue}
216
+ sortByOptions={sortByOptions}
217
+ />
426
218
  </SearchComponentContainer>
427
219
  )}
428
220
  {searchLayout === 'floating' && (
@@ -249,7 +249,7 @@ export const WrapperSearch = styled.div`
249
249
  position: fixed;
250
250
  top: 0;
251
251
  right: 0;
252
- z-index: 1002;
252
+ z-index: 10001;
253
253
  width: fit-content;
254
254
  margin-top: 0px;
255
255
  background-color: ${props => props.theme.colors.backgroundPage};
@@ -260,6 +260,7 @@ export const WrapperSearch = styled.div`
260
260
  &.fixed-search {
261
261
  left: 0;
262
262
  width: 100vw;
263
+ z-index: 1002;
263
264
  }
264
265
  }
265
266
  `
@@ -370,17 +371,26 @@ export const TitleWrapper = styled.div`
370
371
  overflow: hidden;
371
372
  white-space: nowrap;
372
373
  text-overflow: ellipsis;
374
+ background: ${({ theme }) => theme?.colors?.white};
373
375
  &.fixed-name {
374
376
  z-index: 1002;
375
377
  position: fixed;
376
378
  top: 0;
377
- width: calc(100vw - 190px);
378
379
  padding: 10px 0;
379
380
  font-size: 18px;
380
- ${props => props.theme?.rtl ? css`
381
+ ${({ isCustomLayout }) => !isCustomLayout ? css`
382
+ width: calc(100vw - 190px);
383
+ ${props => props.theme?.rtl ? css`
381
384
  right: 50px;
382
- ` : css`
385
+ ` : css`
383
386
  left: 50px;
387
+ `}
388
+ ` : css`
389
+ ${props => props.theme?.rtl ? css`
390
+ right: 10px;
391
+ ` : css`
392
+ left: 10px;
393
+ `}
384
394
  `}
385
395
  }
386
396
  @media (min-width: 768px) {
@@ -94,7 +94,7 @@ const BusinessProductsCategoriesUI = (props) => {
94
94
  categoryListsElement.scrollTo({
95
95
  top: 0,
96
96
  left: moveAmount,
97
- behavior: 'smooth'
97
+ behavior: 'auto'
98
98
  })
99
99
  }
100
100
  setSelectedCateogry(category)
@@ -1,7 +1,6 @@
1
1
  import React from 'react'
2
2
  import { CardCvcElement, CardElement, CardExpiryElement, CardNumberElement } from '@stripe/react-stripe-js'
3
- import { CardForm as CardFormController, useLanguage } from 'ordering-components-external'
4
-
3
+ import { CardForm as CardFormController, useLanguage, useValidationFields } from 'ordering-components-external'
5
4
  import {
6
5
  FormStripe,
7
6
  FormRow,
@@ -10,7 +9,9 @@ import {
10
9
  CardNumberField,
11
10
  CardExpiryCvcField,
12
11
  CardExpiryField,
13
- CardCvcField
12
+ CardCvcField,
13
+ CardZipcodeField,
14
+ ZipcodeField
14
15
  } from './styles'
15
16
 
16
17
  import { Button } from '../../styles/Buttons'
@@ -43,10 +44,14 @@ const CardFormUI = (props) => {
43
44
  handleChange,
44
45
  isSplitForm,
45
46
  handleChangeExpiry,
46
- handleChangeCvc
47
+ handleChangeCvc,
48
+ errorZipcode
47
49
  } = props
48
50
 
49
51
  const [, t] = useLanguage()
52
+ const [validationFields] = useValidationFields()
53
+ const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
54
+ const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
50
55
 
51
56
  return (
52
57
  <>
@@ -93,6 +98,22 @@ const CardFormUI = (props) => {
93
98
  <ErrorMessage>{errorCvc}</ErrorMessage>
94
99
  </CardCvcField>
95
100
  </CardExpiryCvcField>
101
+ {zipCodeEnabled && (
102
+ <CardZipcodeField>
103
+ <label>{t('ZIPCODE', 'Zipcode')}</label>
104
+ <ZipcodeField
105
+ name='zipcode'
106
+ placeholder={`${t('ZIPCODE', 'Zipcode')}${zipCodeRequired ? '*' : ''}`}
107
+ options={CARD_ELEMENT_OPTIONS}
108
+ onChange={handleChange}
109
+ pattern='[0-9]'
110
+ type='number'
111
+ />
112
+ {errorZipcode && (
113
+ <ErrorMessage>{t('ZIPCODE_IS_INCOMPLETED', 'The zipcode is incompleted.')}</ErrorMessage>
114
+ )}
115
+ </CardZipcodeField>
116
+ )}
96
117
  </>
97
118
  }
98
119
  </FormRow>
@@ -40,6 +40,10 @@ export const CardCvcField = styled.div`
40
40
  color: #ADB2B9;
41
41
  `
42
42
 
43
+ export const CardZipcodeField = styled.div`
44
+ color: #ADB2B9;
45
+ `
46
+
43
47
  export const CardNumberField = styled.div`
44
48
  width: 100%;
45
49
  color: #ADB2B9;
@@ -98,3 +102,34 @@ export const FormActions = styled.div`
98
102
  }
99
103
  }
100
104
  `
105
+
106
+ export const ZipcodeField = styled.input`
107
+ font-weight: 500;
108
+ font-size: 16px;
109
+ box-sizing: border-box;
110
+ width: 100% !important;
111
+ &:-webkit-autofill {
112
+ color: '#fce883'
113
+ }
114
+ &::placeholder {
115
+ font-weight: 500
116
+ }
117
+ &:focus(){
118
+ box-shadow: rgba(50, 50, 93, 0.109804) 0px 4px 6px,
119
+ rgba(0, 0, 0, 0.0784314) 0px 1px 3px;
120
+ -webkit-transition: all 150ms ease;
121
+ transition: all 150ms ease;
122
+ }
123
+
124
+ &::-webkit-outer-spin-button,
125
+ &::-webkit-inner-spin-button {
126
+ -webkit-appearance: none;
127
+ margin: 0;
128
+ }
129
+
130
+ /* Firefox */
131
+ &[type=number] {
132
+ -moz-appearance: textfield;
133
+ }
134
+
135
+ `
@@ -0,0 +1,111 @@
1
+ import Payment from 'payment'
2
+
3
+ const clearNumber = (value = '') => {
4
+ return value.replace(/\D+/g, '')
5
+ }
6
+
7
+ export const formatCreditCardNumber = (value) => {
8
+ if (!value) {
9
+ return value
10
+ }
11
+
12
+ const issuer = Payment.fns.cardType(value)
13
+ const clearValue = clearNumber(value)
14
+ let nextValue
15
+
16
+ switch (issuer) {
17
+ case 'amex':
18
+ nextValue = `${clearValue.slice(0, 4)} ${clearValue.slice(
19
+ 4,
20
+ 10
21
+ )} ${clearValue.slice(10, 15)}`
22
+ break
23
+ case 'dinersclub':
24
+ nextValue = `${clearValue.slice(0, 4)} ${clearValue.slice(
25
+ 4,
26
+ 10
27
+ )} ${clearValue.slice(10, 14)}`
28
+ break
29
+ default:
30
+ nextValue = `${clearValue.slice(0, 4)} ${clearValue.slice(
31
+ 4,
32
+ 8
33
+ )} ${clearValue.slice(8, 12)} ${clearValue.slice(12, 19)}`
34
+ break
35
+ }
36
+
37
+ return nextValue.trim()
38
+ }
39
+
40
+ export const formatCVC = (value, prevValue, allValues = {}) => {
41
+ const clearValue = clearNumber(value)
42
+ let maxLength = 4
43
+
44
+ if (allValues.number) {
45
+ const issuer = Payment.fns.cardType(allValues.number)
46
+ maxLength = issuer === 'amex' ? 4 : 3
47
+ }
48
+
49
+ return clearValue.slice(0, maxLength)
50
+ }
51
+
52
+ export const formatExpirationDate = (value) => {
53
+ const clearValue = clearNumber(value)
54
+
55
+ if (clearValue.length >= 3) {
56
+ return `${clearValue.slice(0, 2)}/${clearValue.slice(2, 4)}`
57
+ }
58
+
59
+ return clearValue
60
+ }
61
+
62
+ export const getCardType = (number) => {
63
+ // visa
64
+ var re = new RegExp('^4')
65
+ if (number.match(re) != null) {
66
+ return 'Visa'
67
+ }
68
+
69
+ // Mastercard
70
+ // Updated for Mastercard 2017 BINs expansion
71
+ if (/^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$/.test(number)) {
72
+ return 'Mastercard'
73
+ }
74
+ // AMEX
75
+ re = new RegExp('^3[47]')
76
+ if (number.match(re) != null) {
77
+ return 'AMEX'
78
+ }
79
+
80
+ // Discover
81
+ re = new RegExp('^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)')
82
+ if (number.match(re) != null) {
83
+ return 'Discover'
84
+ }
85
+
86
+ // Diners
87
+ re = new RegExp('^36')
88
+ if (number.match(re) != null) {
89
+ return 'Diners'
90
+ }
91
+
92
+ // Diners - Carte Blanche
93
+ re = new RegExp('^30[0-5]')
94
+ if (number.match(re) != null) {
95
+ return 'Diners - Carte Blanche'
96
+ }
97
+
98
+ // JCB
99
+ re = new RegExp('^35(2[89]|[3-8][0-9])')
100
+ if (number.match(re) != null) {
101
+ return 'JCB'
102
+ }
103
+
104
+ // Visa Electron
105
+ re = new RegExp('^(4026|417500|4508|4844|491(3|7))')
106
+ if (number.match(re) != null) {
107
+ return 'Visa Electron'
108
+ }
109
+
110
+ return ''
111
+ }