ordering-ui-external 1.7.2 → 1.8.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 (171) hide show
  1. package/_bundles/{0.ordering-ui.f9c3deec77a8e21645ed.js → 0.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  2. package/_bundles/{1.ordering-ui.f9c3deec77a8e21645ed.js → 1.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  3. package/_bundles/2.ordering-ui.cf9ba81c5417ae8af84a.js +1 -0
  4. package/_bundles/{4.ordering-ui.f9c3deec77a8e21645ed.js → 4.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  5. package/_bundles/{5.ordering-ui.f9c3deec77a8e21645ed.js → 5.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  6. package/_bundles/{6.ordering-ui.f9c3deec77a8e21645ed.js → 6.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  7. package/_bundles/{7.ordering-ui.f9c3deec77a8e21645ed.js → 7.ordering-ui.cf9ba81c5417ae8af84a.js} +2 -2
  8. package/_bundles/{7.ordering-ui.f9c3deec77a8e21645ed.js.LICENSE.txt → 7.ordering-ui.cf9ba81c5417ae8af84a.js.LICENSE.txt} +0 -0
  9. package/_bundles/{8.ordering-ui.f9c3deec77a8e21645ed.js → 8.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  10. package/_bundles/{9.ordering-ui.f9c3deec77a8e21645ed.js → 9.ordering-ui.cf9ba81c5417ae8af84a.js} +1 -1
  11. package/_bundles/ordering-ui.cf9ba81c5417ae8af84a.js +2 -0
  12. package/_bundles/{ordering-ui.f9c3deec77a8e21645ed.js.LICENSE.txt → ordering-ui.cf9ba81c5417ae8af84a.js.LICENSE.txt} +0 -0
  13. package/_modules/components/BusinessInformation/index.js +4 -8
  14. package/_modules/components/OrdersOption/styles.js +4 -2
  15. package/_modules/components/Pagination/index.js +100 -0
  16. package/_modules/components/Pagination/styles.js +56 -0
  17. package/_modules/components/SmartAppBanner/index.js +2 -1
  18. package/_modules/components/VerticalOrdersLayout/SingleOrderCard/index.js +92 -0
  19. package/_modules/components/VerticalOrdersLayout/index.js +115 -41
  20. package/_modules/components/VerticalOrdersLayout/styles.js +25 -11
  21. package/_modules/index.js +7 -0
  22. package/_modules/themes/five/src/components/AccordionDropdown/index.js +15 -4
  23. package/_modules/themes/five/src/components/AccordionDropdown/styles.js +14 -4
  24. package/_modules/themes/five/src/components/AddressList/styles.js +2 -2
  25. package/_modules/themes/five/src/components/BusinessBasicInformation/index.js +17 -10
  26. package/_modules/themes/five/src/components/BusinessBasicInformation/styles.js +48 -42
  27. package/_modules/themes/five/src/components/BusinessListingSearch/index.js +5 -1
  28. package/_modules/themes/five/src/components/BusinessProductsCategories/index.js +0 -3
  29. package/_modules/themes/five/src/components/BusinessProductsCategories/layouts/groceries/index.js +22 -13
  30. package/_modules/themes/five/src/components/BusinessProductsCategories/layouts/groceries/styles.js +15 -7
  31. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +3 -0
  32. package/_modules/themes/five/src/components/BusinessTypeFilter/index.js +15 -5
  33. package/_modules/themes/five/src/components/BusinessesListing/index.js +6 -13
  34. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +66 -40
  35. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +13 -7
  36. package/_modules/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/index.js +16 -7
  37. package/_modules/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/styles.js +21 -15
  38. package/_modules/themes/five/src/components/CardForm/index.js +17 -3
  39. package/_modules/themes/five/src/components/CardForm/styles.js +14 -6
  40. package/_modules/themes/five/src/components/CartPopover/index.js +6 -4
  41. package/_modules/themes/five/src/components/CartPopover/styles.js +4 -2
  42. package/_modules/themes/five/src/components/Footer/index.js +16 -6
  43. package/_modules/themes/five/src/components/Footer/styles.js +11 -9
  44. package/_modules/themes/five/src/components/Header/index.js +14 -9
  45. package/_modules/themes/five/src/components/Header/styles.js +64 -44
  46. package/_modules/themes/five/src/components/HeaderOption/index.js +9 -2
  47. package/_modules/themes/five/src/components/HeaderOption/styles.js +8 -2
  48. package/_modules/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +9 -3
  49. package/_modules/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/styles.js +5 -3
  50. package/_modules/themes/five/src/components/HorizontalOrdersLayout/index.js +9 -19
  51. package/_modules/themes/five/src/components/HorizontalOrdersLayout/styles.js +23 -19
  52. package/_modules/themes/five/src/components/InputPhoneNumber/index.js +1 -0
  53. package/_modules/themes/five/src/components/LoginForm/index.js +3 -2
  54. package/_modules/themes/five/src/components/MyOrders/index.js +24 -56
  55. package/_modules/themes/five/src/components/MyOrders/styles.js +1 -1
  56. package/_modules/themes/five/src/components/OrderDetails/index.js +5 -2
  57. package/_modules/themes/five/src/components/OrderDetails/styles.js +24 -24
  58. package/_modules/themes/five/src/components/OrderItAgain/styles.js +6 -2
  59. package/_modules/themes/five/src/components/OrdersOption/index.js +18 -18
  60. package/_modules/themes/five/src/components/OrdersOption/styles.js +2 -2
  61. package/_modules/themes/five/src/components/PageBanner/index.js +50 -0
  62. package/_modules/themes/five/src/components/PageBanner/styles.js +18 -0
  63. package/_modules/themes/five/src/components/Pagination/index.js +99 -0
  64. package/_modules/themes/five/src/components/Pagination/styles.js +56 -0
  65. package/_modules/themes/five/src/components/ProductForm/index.js +39 -23
  66. package/_modules/themes/five/src/components/ProductForm/styles.js +74 -38
  67. package/_modules/themes/five/src/components/Promotions/index.js +7 -2
  68. package/_modules/themes/five/src/components/Promotions/styles.js +16 -14
  69. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +31 -10
  70. package/_modules/themes/five/src/components/RenderProductsLayout/styles.js +19 -11
  71. package/_modules/themes/five/src/components/SidebarMenu/styles.js +1 -1
  72. package/_modules/themes/five/src/components/SignUpForm/index.js +3 -2
  73. package/_modules/themes/five/src/components/SingleOrderCard/index.js +7 -17
  74. package/_modules/themes/five/src/components/SingleProductCard/index.js +7 -298
  75. package/_modules/themes/five/src/components/SingleProductCard/layouts/original/index.js +310 -0
  76. package/_modules/themes/five/src/components/SingleProductCard/{styles.js → layouts/original/styles.js} +37 -33
  77. package/_modules/themes/five/src/components/SingleProductCard/layouts/starbucks/index.js +305 -0
  78. package/_modules/themes/five/src/components/SingleProductCard/layouts/starbucks/styles.js +143 -0
  79. package/_modules/themes/five/src/components/StripeElementsForm/index.js +1 -0
  80. package/_modules/themes/five/src/components/UserPopover/index.js +3 -1
  81. package/_modules/themes/five/src/components/UserPopover/styles.js +4 -3
  82. package/_modules/themes/five/src/components/UserProfileForm/styles.js +5 -8
  83. package/_modules/themes/six/src/components/BusinessController/index.js +81 -15
  84. package/_modules/themes/six/src/components/BusinessController/styles.js +58 -30
  85. package/_modules/themes/six/src/components/BusinessProductsListing/SearchProducts/index.js +5 -3
  86. package/_modules/themes/six/src/components/BusinessesMap/styles.js +1 -1
  87. package/_modules/themes/six/src/components/SearchBar/index.js +19 -10
  88. package/_modules/themes/six/src/components/SearchBar/styles.js +44 -16
  89. package/index-template.js +3 -1
  90. package/package.json +2 -2
  91. package/src/components/BusinessInformation/index.js +3 -8
  92. package/src/components/OrdersOption/styles.js +5 -5
  93. package/src/components/Pagination/index.js +107 -0
  94. package/src/components/Pagination/styles.js +106 -0
  95. package/src/components/SmartAppBanner/index.js +1 -0
  96. package/src/components/VerticalOrdersLayout/SingleOrderCard/index.js +89 -0
  97. package/src/components/VerticalOrdersLayout/index.js +86 -48
  98. package/src/components/VerticalOrdersLayout/styles.js +66 -22
  99. package/src/index.js +2 -0
  100. package/src/themes/five/src/components/AccordionDropdown/index.js +19 -6
  101. package/src/themes/five/src/components/AccordionDropdown/styles.js +25 -1
  102. package/src/themes/five/src/components/AddressList/styles.js +2 -0
  103. package/src/themes/five/src/components/BusinessBasicInformation/index.js +21 -11
  104. package/src/themes/five/src/components/BusinessBasicInformation/styles.js +9 -3
  105. package/src/themes/five/src/components/BusinessListingSearch/index.js +1 -0
  106. package/src/themes/five/src/components/BusinessProductsCategories/index.js +0 -2
  107. package/src/themes/five/src/components/BusinessProductsCategories/layouts/groceries/index.js +23 -12
  108. package/src/themes/five/src/components/BusinessProductsCategories/layouts/groceries/styles.js +12 -4
  109. package/src/themes/five/src/components/BusinessProductsListing/index.js +3 -0
  110. package/src/themes/five/src/components/BusinessTypeFilter/index.js +15 -5
  111. package/src/themes/five/src/components/BusinessesListing/index.js +5 -5
  112. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +54 -25
  113. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +40 -26
  114. package/src/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/index.js +19 -6
  115. package/src/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/styles.js +38 -3
  116. package/src/themes/five/src/components/CardForm/index.js +49 -8
  117. package/src/themes/five/src/components/CardForm/styles.js +20 -2
  118. package/src/themes/five/src/components/CartPopover/index.js +2 -1
  119. package/src/themes/five/src/components/CartPopover/styles.js +3 -3
  120. package/src/themes/five/src/components/Footer/index.js +15 -6
  121. package/src/themes/five/src/components/Footer/styles.js +15 -14
  122. package/src/themes/five/src/components/Header/index.js +6 -4
  123. package/src/themes/five/src/components/Header/styles.js +14 -11
  124. package/src/themes/five/src/components/HeaderOption/index.js +13 -10
  125. package/src/themes/five/src/components/HeaderOption/styles.js +2 -2
  126. package/src/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +22 -10
  127. package/src/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/styles.js +8 -0
  128. package/src/themes/five/src/components/HorizontalOrdersLayout/index.js +24 -36
  129. package/src/themes/five/src/components/HorizontalOrdersLayout/styles.js +12 -1
  130. package/src/themes/five/src/components/InputPhoneNumber/index.js +1 -0
  131. package/src/themes/five/src/components/LoginForm/index.js +2 -1
  132. package/src/themes/five/src/components/MyOrders/index.js +20 -62
  133. package/src/themes/five/src/components/MyOrders/styles.js +1 -2
  134. package/src/themes/five/src/components/OrderDetails/index.js +9 -0
  135. package/src/themes/five/src/components/OrderDetails/styles.js +0 -55
  136. package/src/themes/five/src/components/OrderItAgain/styles.js +18 -0
  137. package/src/themes/five/src/components/OrdersOption/index.js +10 -16
  138. package/src/themes/five/src/components/OrdersOption/styles.js +1 -3
  139. package/src/themes/five/src/components/PageBanner/index.js +58 -0
  140. package/src/themes/five/src/components/PageBanner/styles.js +58 -0
  141. package/src/themes/five/src/components/Pagination/index.js +106 -0
  142. package/src/themes/five/src/components/Pagination/styles.js +106 -0
  143. package/src/themes/five/src/components/ProductForm/index.js +108 -84
  144. package/src/themes/five/src/components/ProductForm/styles.js +94 -12
  145. package/src/themes/five/src/components/Promotions/index.js +22 -16
  146. package/src/themes/five/src/components/Promotions/styles.js +10 -4
  147. package/src/themes/five/src/components/RenderProductsLayout/index.js +94 -66
  148. package/src/themes/five/src/components/RenderProductsLayout/styles.js +23 -22
  149. package/src/themes/five/src/components/SidebarMenu/styles.js +1 -1
  150. package/src/themes/five/src/components/SignUpForm/index.js +2 -1
  151. package/src/themes/five/src/components/SingleOrderCard/index.js +0 -21
  152. package/src/themes/five/src/components/SingleProductCard/index.js +7 -300
  153. package/src/themes/five/src/components/SingleProductCard/layouts/original/index.js +312 -0
  154. package/src/themes/five/src/components/SingleProductCard/{styles.js → layouts/original/styles.js} +9 -6
  155. package/src/themes/five/src/components/SingleProductCard/layouts/starbucks/index.js +313 -0
  156. package/src/themes/five/src/components/SingleProductCard/layouts/starbucks/styles.js +353 -0
  157. package/src/themes/five/src/components/StripeElementsForm/index.js +1 -0
  158. package/src/themes/five/src/components/UserPopover/index.js +2 -0
  159. package/src/themes/five/src/components/UserPopover/styles.js +2 -2
  160. package/src/themes/five/src/components/UserProfileForm/styles.js +3 -11
  161. package/src/themes/six/src/components/BusinessController/index.js +163 -62
  162. package/src/themes/six/src/components/BusinessController/styles.js +53 -14
  163. package/src/themes/six/src/components/BusinessProductsListing/SearchProducts/index.js +3 -1
  164. package/src/themes/six/src/components/BusinessesMap/styles.js +1 -1
  165. package/src/themes/six/src/components/SearchBar/index.js +27 -8
  166. package/src/themes/six/src/components/SearchBar/styles.js +33 -2
  167. package/template/app.js +364 -364
  168. package/template/assets/images/chew_logo.png +0 -0
  169. package/template/components/HelmetTags/index.js +5 -4
  170. package/_bundles/2.ordering-ui.f9c3deec77a8e21645ed.js +0 -1
  171. package/_bundles/ordering-ui.f9c3deec77a8e21645ed.js +0 -2
@@ -1,309 +1,16 @@
1
- import React, { useRef, useState } from 'react'
2
- import Skeleton from 'react-loading-skeleton'
3
- import { useLanguage, useConfig, useOrder, useUtils, useSession, useOrderingTheme, SingleProductCard as SingleProductCardController } from 'ordering-components-external'
4
- import { shape } from '../../../../../utils'
5
- import { useIntersectionObserver } from '../../../../../hooks/useIntersectionObserver'
6
- import { Heart as DisLike, HeartFill as Like } from 'react-bootstrap-icons'
1
+ import React from 'react'
7
2
  import { useTheme } from 'styled-components'
8
- import { Modal } from '../Modal'
9
- import { LoginForm } from '../LoginForm'
10
- import { SignUpForm } from '../SignUpForm'
11
- import { ForgotPasswordForm } from '../ForgotPasswordForm'
12
- import { Alert } from '../Confirm'
3
+ import { SingleProductCard as SingleProductCardOriginal } from './layouts/original'
4
+ import { SingleProductCard as SingleProductCardStarbucks } from './layouts/starbucks'
13
5
 
14
- import {
15
- CardContainer,
16
- CardInfo,
17
- WrapLogo,
18
- CardLogo,
19
- SoldOut,
20
- PriceWrapper,
21
- QuantityContainer,
22
- RibbonBox,
23
- TitleWrapper,
24
- LastOrder,
25
- SkeletonCardInfo,
26
- SkeletonCardLogo
27
- } from './styles'
28
- import { Button } from '../../styles/Buttons'
29
-
30
- const SingleProductCardUI = (props) => {
31
- const {
32
- product,
33
- isSoldOut,
34
- isSkeleton,
35
- onProductClick,
36
- isCartOnProductsList,
37
- useCustomFunctionality,
38
- onCustomClick,
39
- customText,
40
- customStyle,
41
- useKioskApp,
42
- productAddedToCartLength,
43
- handleFavoriteProduct,
44
- isFavorite,
45
- isPreviously
46
- } = props
47
-
48
- const [, t] = useLanguage()
49
- const [$element, isObserved] = useIntersectionObserver()
50
- const [stateConfig] = useConfig()
51
- const [{ parsePrice, optimizeImage, parseDate }] = useUtils()
52
- const [orderState] = useOrder()
53
- const [{ auth }, { login }] = useSession()
54
- const [orderingTheme] = useOrderingTheme()
6
+ export const SingleProductCard = (props) => {
55
7
  const theme = useTheme()
56
- const favoriteRef = useRef(null)
57
-
58
- const [isModalOpen, setIsModalOpen] = useState(false)
59
- const [modalPageToShow, setModalPageToShow] = useState(null)
60
- const [alertState, setAlertState] = useState({ open: false, content: [] })
61
-
62
- const editMode = typeof product?.code !== 'undefined'
63
- const isObservedValidation = isObserved || useKioskApp
64
-
65
- const removeToBalance = editMode ? product?.quantity : 0
66
-
67
- const cartProducts = Object.values(orderState.carts).reduce((products, _cart) => [...products, ..._cart?.products], [])
68
- const productBalance = cartProducts.reduce((sum, _product) => sum + (_product.id === product?.id ? _product.quantity : 0), 0)
69
-
70
- const totalBalance = (productBalance || 0) - removeToBalance
71
-
72
- const maxCartProductConfig = (stateConfig.configs.max_product_amount ? parseInt(stateConfig.configs.max_product_amount) : 100) - totalBalance
73
-
74
- const hideAddButton = theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden ?? true
75
- // const productsRows = theme?.layouts?.business_view?.components?.products?.components?.layout?.rows
76
-
77
- let maxCartProductInventory = (product?.inventoried ? product?.quantity : undefined) - totalBalance
78
- maxCartProductInventory = !isNaN(maxCartProductInventory) ? maxCartProductInventory : maxCartProductConfig
79
-
80
- const maxProductQuantity = Math.min(maxCartProductConfig, maxCartProductInventory)
81
-
82
- const handleClickProduct = (e) => {
83
- if (favoriteRef?.current?.contains(e.target)) return
84
- if (productAddedToCartLength && product?.maximum_per_order && productAddedToCartLength >= product?.maximum_per_order) {
85
- setAlertState({
86
- open: true,
87
- content: [t('PRODUCT_ON_MAXIMUM_ORDER', 'The product is on maximum order')]
88
- })
89
- return
90
- }
91
-
92
- if (isFavorite) {
93
- onProductClick && onProductClick()
94
- return
95
- }
96
- (!isSkeleton && !useCustomFunctionality && onProductClick && onProductClick(product, product?.business?.slug)) ||
97
- (useCustomFunctionality && onCustomClick && onCustomClick())
98
- }
99
-
100
- const closeAlert = () => {
101
- setAlertState({
102
- open: false,
103
- content: []
104
- })
105
- }
106
-
107
- const handleChangeFavorite = () => {
108
- if (auth) {
109
- handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
110
- } else {
111
- setModalPageToShow('login')
112
- setIsModalOpen(true)
113
- }
114
- }
115
-
116
- const closeAuthModal = () => {
117
- setIsModalOpen(false)
118
- setModalPageToShow(null)
119
- }
120
-
121
- const handleSuccessLogin = (user) => {
122
- if (user) {
123
- closeAuthModal()
124
- }
125
- }
126
-
127
- const handleCustomModalClick = (e, { page }) => {
128
- e.preventDefault()
129
- setModalPageToShow(page)
130
- }
131
-
132
- const handleSuccessSignup = (user) => {
133
- login({
134
- user,
135
- token: user?.session?.access_token
136
- })
137
- }
8
+ const layout = theme?.business_view?.components?.products?.components?.layout?.type || 'original'
138
9
 
139
10
  return (
140
11
  <>
141
- <CardContainer
142
- ref={$element}
143
- soldOut={isSoldOut || maxProductQuantity <= 0}
144
- onClick={handleClickProduct}
145
- isCartOnProductsList={isCartOnProductsList}
146
- style={useCustomFunctionality && customStyle}
147
- className='product-card'
148
- isShowAddButt={!useCustomFunctionality && !hideAddButton && !isSkeleton}
149
- // productsRows={productsRows}
150
- >
151
- {isObservedValidation ? (
152
- <div>
153
- {!useCustomFunctionality && (
154
- <>
155
- {!isSkeleton && productAddedToCartLength > 0 && (
156
- <QuantityContainer>
157
- <span>{productAddedToCartLength}</span>
158
- </QuantityContainer>
159
- )}
160
- <CardInfo soldOut={isSoldOut || maxProductQuantity <= 0} isBgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')} oneLine={isPreviously}>
161
- <TitleWrapper>
162
- {!isSkeleton ? (<h1>{product?.name}</h1>) : (<Skeleton width={100} />)}
163
- {!useKioskApp && !isPreviously && (
164
- !isSkeleton ? (
165
- <span onClick={() => handleChangeFavorite()} ref={favoriteRef}>
166
- {product?.favorite ? <Like /> : <DisLike />}
167
- </span>
168
- ) : (<Skeleton width={16} height={16} />)
169
- )}
170
- </TitleWrapper>
171
- {!isSkeleton ? (
172
- <PriceWrapper>
173
- <span>{product?.price ? parsePrice(product?.price) : ''}</span>
174
- {!(isSoldOut || maxProductQuantity <= 0) && (
175
- <span className='off-price'>{product?.offer_price && product?.in_offer ? parsePrice(product?.offer_price) : ''}</span>
176
- )}
177
- </PriceWrapper>
178
- ) : (
179
- <Skeleton width={100} />
180
- )}
181
- {!isSkeleton ? (<p>{product?.description}</p>) : (<Skeleton width={100} />)}
182
- {isPreviously && (!isSkeleton ? (<LastOrder>{t('LAST_ORDERED_ON', 'Last ordered on')} {parseDate(product?.last_ordered_date, { outputFormat: 'MMM DD, YYYY' })}</LastOrder>) : (<Skeleton width={80} />))}
183
- </CardInfo>
184
- {!isSkeleton ? (
185
- <WrapLogo isBgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')}>
186
- {product?.ribbon?.enabled && (
187
- <RibbonBox
188
- bgColor={product?.ribbon?.color}
189
- isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
190
- isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
191
- >
192
- {product?.ribbon?.text}
193
- </RibbonBox>
194
- )}
195
- <CardLogo
196
- className='image'
197
- soldOut={isSoldOut || maxProductQuantity <= 0}
198
- bgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')}
199
- />
200
- </WrapLogo>
201
- ) : (
202
- <Skeleton height={75} width={75} />
203
- )}
204
- {(isSoldOut || maxProductQuantity <= 0) && <SoldOut isBottom={product?.ribbon?.enabled}>{t('SOLD_OUT', 'SOLD OUT')}</SoldOut>}
205
- </>
206
- )}
207
- {useCustomFunctionality && customText && (
208
- <span style={{ fontSize: 16, fontWeight: 500 }}>{customText}</span>
209
- )}
210
- </div>
211
- ) : (
212
- <div>
213
- <SkeletonCardInfo>
214
- <Skeleton width={100} />
215
- <Skeleton width={100} />
216
- <Skeleton width={100} />
217
- </SkeletonCardInfo>
218
- <SkeletonCardLogo>
219
- <Skeleton height={75} width={75} />
220
- </SkeletonCardLogo>
221
- </div>
222
- )}
223
- {!useCustomFunctionality && !hideAddButton && !isSkeleton && (
224
- <Button outline color='primary' disabled={productAddedToCartLength && product?.maximum_per_order && productAddedToCartLength >= product?.maximum_per_order}>
225
- {t('ADD', 'Add')}
226
- </Button>
227
- )}
228
- </CardContainer>
229
- <Modal
230
- open={isModalOpen}
231
- onRemove={() => closeAuthModal()}
232
- onClose={() => closeAuthModal()}
233
- width='50%'
234
- authModal
235
- >
236
- {modalPageToShow === 'login' && (
237
- <LoginForm
238
- handleSuccessLogin={handleSuccessLogin}
239
- elementLinkToSignup={
240
- <a
241
- onClick={
242
- (e) => handleCustomModalClick(e, { page: 'signup' })
243
- } href='#'
244
- >{t('CREATE_ACCOUNT', theme?.defaultLanguages?.CREATE_ACCOUNT || 'Create account')}
245
- </a>
246
- }
247
- elementLinkToForgotPassword={
248
- <a
249
- onClick={
250
- (e) => handleCustomModalClick(e, { page: 'forgotpassword' })
251
- } href='#'
252
- >{t('RESET_PASSWORD', theme?.defaultLanguages?.RESET_PASSWORD || 'Reset password')}
253
- </a>
254
- }
255
- useLoginByCellphone
256
- isPopup
257
- />
258
- )}
259
- {modalPageToShow === 'signup' && (
260
- <SignUpForm
261
- elementLinkToLogin={
262
- <a
263
- onClick={
264
- (e) => handleCustomModalClick(e, { page: 'login' })
265
- } href='#'
266
- >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
267
- </a>
268
- }
269
- useLoginByCellphone
270
- useChekoutFileds
271
- handleSuccessSignup={handleSuccessSignup}
272
- isPopup
273
- closeModal={() => closeAuthModal()}
274
- />
275
- )}
276
- {modalPageToShow === 'forgotpassword' && (
277
- <ForgotPasswordForm
278
- elementLinkToLogin={
279
- <a
280
- onClick={
281
- (e) => handleCustomModalClick(e, { page: 'login' })
282
- } href='#'
283
- >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
284
- </a>
285
- }
286
- isPopup
287
- />
288
- )}
289
- </Modal>
290
- <Alert
291
- title={t('PRODUCT', 'Product')}
292
- content={alertState.content}
293
- acceptText={t('ACCEPT', 'Accept')}
294
- open={alertState.open}
295
- onClose={() => closeAlert()}
296
- onAccept={() => closeAlert()}
297
- closeOnBackdrop={false}
298
- />
12
+ {layout === 'original' && <SingleProductCardOriginal {...props} />}
13
+ {layout === 'starbucks' && <SingleProductCardStarbucks {...props} />}
299
14
  </>
300
15
  )
301
16
  }
302
-
303
- export const SingleProductCard = (props) => {
304
- const singleProductCardProps = {
305
- ...props,
306
- UIComponent: SingleProductCardUI
307
- }
308
- return <SingleProductCardController {...singleProductCardProps} />
309
- }
@@ -0,0 +1,312 @@
1
+ import React, { useRef, useState } from 'react'
2
+ import Skeleton from 'react-loading-skeleton'
3
+ import { useLanguage, useConfig, useOrder, useUtils, useSession, useOrderingTheme, SingleProductCard as SingleProductCardController } from 'ordering-components-external'
4
+ import { shape } from '../../../../../../../utils'
5
+ import { useIntersectionObserver } from '../../../../../../../hooks/useIntersectionObserver'
6
+ import { Heart as DisLike, HeartFill as Like } from 'react-bootstrap-icons'
7
+ import { useTheme } from 'styled-components'
8
+ import { Modal } from '../../../Modal'
9
+ import { LoginForm } from '../../../LoginForm'
10
+ import { SignUpForm } from '../../../SignUpForm'
11
+ import { ForgotPasswordForm } from '../../../ForgotPasswordForm'
12
+ import { Alert } from '../../../Confirm'
13
+
14
+ import {
15
+ CardContainer,
16
+ CardInfo,
17
+ WrapLogo,
18
+ CardLogo,
19
+ SoldOut,
20
+ PriceWrapper,
21
+ QuantityContainer,
22
+ RibbonBox,
23
+ TitleWrapper,
24
+ LastOrder,
25
+ SkeletonCardInfo,
26
+ SkeletonCardLogo
27
+ } from './styles'
28
+ import { Button } from '../../../../styles/Buttons'
29
+
30
+ const SingleProductCardUI = (props) => {
31
+ const {
32
+ product,
33
+ isSoldOut,
34
+ isSkeleton,
35
+ onProductClick,
36
+ isCartOnProductsList,
37
+ useCustomFunctionality,
38
+ onCustomClick,
39
+ customText,
40
+ customStyle,
41
+ useKioskApp,
42
+ productAddedToCartLength,
43
+ handleFavoriteProduct,
44
+ isFavorite,
45
+ isPreviously,
46
+ } = props
47
+
48
+ const [, t] = useLanguage()
49
+ const [$element, isObserved] = useIntersectionObserver()
50
+ const [stateConfig] = useConfig()
51
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils()
52
+ const [orderState] = useOrder()
53
+ const [{ auth }, { login }] = useSession()
54
+ const [orderingTheme] = useOrderingTheme()
55
+ const theme = useTheme()
56
+ const favoriteRef = useRef(null)
57
+
58
+ const [isModalOpen, setIsModalOpen] = useState(false)
59
+ const [modalPageToShow, setModalPageToShow] = useState(null)
60
+ const [alertState, setAlertState] = useState({ open: false, content: [] })
61
+
62
+ const editMode = typeof product?.code !== 'undefined'
63
+ const isObservedValidation = isObserved || useKioskApp
64
+
65
+ const removeToBalance = editMode ? product?.quantity : 0
66
+
67
+ const cartProducts = Object.values(orderState.carts).reduce((products, _cart) => [...products, ..._cart?.products], [])
68
+ const productBalance = cartProducts.reduce((sum, _product) => sum + (_product.id === product?.id ? _product.quantity : 0), 0)
69
+
70
+ const totalBalance = (productBalance || 0) - removeToBalance
71
+
72
+ const maxCartProductConfig = (stateConfig.configs.max_product_amount ? parseInt(stateConfig.configs.max_product_amount) : 100) - totalBalance
73
+
74
+ const hideAddButton = theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden ?? true
75
+ // const productsRows = theme?.layouts?.business_view?.components?.products?.components?.layout?.rows
76
+
77
+ let maxCartProductInventory = (product?.inventoried ? product?.quantity : undefined) - totalBalance
78
+ maxCartProductInventory = !isNaN(maxCartProductInventory) ? maxCartProductInventory : maxCartProductConfig
79
+
80
+ const maxProductQuantity = Math.min(maxCartProductConfig, maxCartProductInventory)
81
+
82
+ const handleClickProduct = (e) => {
83
+ if (favoriteRef?.current?.contains(e.target)) return
84
+ if (productAddedToCartLength && product?.maximum_per_order && productAddedToCartLength >= product?.maximum_per_order) {
85
+ setAlertState({
86
+ open: true,
87
+ content: [t('PRODUCT_ON_MAXIMUM_ORDER', 'The product is on maximum order')]
88
+ })
89
+ return
90
+ }
91
+
92
+ if (isFavorite) {
93
+ onProductClick && onProductClick()
94
+ return
95
+ }
96
+ (!isSkeleton && !useCustomFunctionality && onProductClick && onProductClick(product, product?.business?.slug)) ||
97
+ (useCustomFunctionality && onCustomClick && onCustomClick())
98
+ }
99
+
100
+ const closeAlert = () => {
101
+ setAlertState({
102
+ open: false,
103
+ content: []
104
+ })
105
+ }
106
+
107
+ const handleChangeFavorite = () => {
108
+ if (auth) {
109
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
110
+ } else {
111
+ setModalPageToShow('login')
112
+ setIsModalOpen(true)
113
+ }
114
+ }
115
+
116
+ const closeAuthModal = () => {
117
+ setIsModalOpen(false)
118
+ setModalPageToShow(null)
119
+ }
120
+
121
+ const handleSuccessLogin = (user) => {
122
+ if (user) {
123
+ closeAuthModal()
124
+ }
125
+ }
126
+
127
+ const handleCustomModalClick = (e, { page }) => {
128
+ e.preventDefault()
129
+ setModalPageToShow(page)
130
+ }
131
+
132
+ const handleSuccessSignup = (user) => {
133
+ login({
134
+ user,
135
+ token: user?.session?.access_token
136
+ })
137
+ }
138
+
139
+ return (
140
+ <>
141
+ <CardContainer
142
+ ref={$element}
143
+ soldOut={isSoldOut || maxProductQuantity <= 0}
144
+ onClick={handleClickProduct}
145
+ isCartOnProductsList={isCartOnProductsList}
146
+ style={useCustomFunctionality && customStyle}
147
+ className='product-card'
148
+ isShowAddButt={!useCustomFunctionality && !hideAddButton && !isSkeleton}
149
+ // productsRows={productsRows}
150
+ >
151
+ {isObservedValidation ? (
152
+ <div>
153
+ {!useCustomFunctionality && (
154
+ <>
155
+ {!isSkeleton && productAddedToCartLength > 0 && (
156
+ <QuantityContainer>
157
+ <span>{productAddedToCartLength}</span>
158
+ </QuantityContainer>
159
+ )}
160
+ <CardInfo soldOut={isSoldOut || maxProductQuantity <= 0} isBgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')} oneLine={isPreviously}>
161
+ <TitleWrapper>
162
+ {!isSkeleton ? (<h1>{product?.name}</h1>) : (<Skeleton width={100} />)}
163
+ {!useKioskApp && !isPreviously && (
164
+ !isSkeleton ? (
165
+ <span onClick={() => handleChangeFavorite()} ref={favoriteRef}>
166
+ {product?.favorite ? <Like /> : <DisLike />}
167
+ </span>
168
+ ) : (<Skeleton width={16} height={16} />)
169
+ )}
170
+ </TitleWrapper>
171
+ {!isSkeleton ? (
172
+ <PriceWrapper>
173
+ <span>{product?.price ? parsePrice(product?.price) : ''}</span>
174
+ {!(isSoldOut || maxProductQuantity <= 0) && (
175
+ <span className='off-price'>{product?.offer_price && product?.in_offer ? parsePrice(product?.offer_price) : ''}</span>
176
+ )}
177
+ </PriceWrapper>
178
+ ) : (
179
+ <Skeleton width={100} />
180
+ )}
181
+ {!isSkeleton ? (<p>{product?.description}</p>) : (<Skeleton width={100} />)}
182
+ {isPreviously && (!isSkeleton ? (<LastOrder>{t('LAST_ORDERED_ON', 'Last ordered on')} {parseDate(product?.last_ordered_date, { outputFormat: 'MMM DD, YYYY' })}</LastOrder>) : (<Skeleton width={80} />))}
183
+ </CardInfo>
184
+ {!isSkeleton ? (
185
+ <WrapLogo
186
+ className='order-it-again-logo'
187
+ isBgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')}
188
+ >
189
+ {product?.ribbon?.enabled && (
190
+ <RibbonBox
191
+ bgColor={product?.ribbon?.color}
192
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
193
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
194
+ >
195
+ {product?.ribbon?.text}
196
+ </RibbonBox>
197
+ )}
198
+ <CardLogo
199
+ className='image'
200
+ soldOut={isSoldOut || maxProductQuantity <= 0}
201
+ bgimage={optimizeImage(product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')}
202
+ />
203
+ </WrapLogo>
204
+ ) : (
205
+ <Skeleton height={75} width={75} />
206
+ )}
207
+ {(isSoldOut || maxProductQuantity <= 0) && <SoldOut isBottom={product?.ribbon?.enabled}>{t('SOLD_OUT', 'SOLD OUT')}</SoldOut>}
208
+ </>
209
+ )}
210
+ {useCustomFunctionality && customText && (
211
+ <span style={{ fontSize: 16, fontWeight: 500 }}>{customText}</span>
212
+ )}
213
+ </div>
214
+ ) : (
215
+ <div>
216
+ <SkeletonCardInfo>
217
+ <Skeleton width={100} />
218
+ <Skeleton width={100} />
219
+ <Skeleton width={100} />
220
+ </SkeletonCardInfo>
221
+ <SkeletonCardLogo>
222
+ <Skeleton height={75} width={75} />
223
+ </SkeletonCardLogo>
224
+ </div>
225
+ )}
226
+ {!useCustomFunctionality && !hideAddButton && !isSkeleton && (
227
+ <Button outline color='primary' disabled={productAddedToCartLength && product?.maximum_per_order && productAddedToCartLength >= product?.maximum_per_order}>
228
+ {t('ADD', 'Add')}
229
+ </Button>
230
+ )}
231
+ </CardContainer>
232
+ <Modal
233
+ open={isModalOpen}
234
+ onRemove={() => closeAuthModal()}
235
+ onClose={() => closeAuthModal()}
236
+ width='50%'
237
+ authModal
238
+ >
239
+ {modalPageToShow === 'login' && (
240
+ <LoginForm
241
+ handleSuccessLogin={handleSuccessLogin}
242
+ elementLinkToSignup={
243
+ <a
244
+ onClick={
245
+ (e) => handleCustomModalClick(e, { page: 'signup' })
246
+ } href='#'
247
+ >{t('CREATE_ACCOUNT', theme?.defaultLanguages?.CREATE_ACCOUNT || 'Create account')}
248
+ </a>
249
+ }
250
+ elementLinkToForgotPassword={
251
+ <a
252
+ onClick={
253
+ (e) => handleCustomModalClick(e, { page: 'forgotpassword' })
254
+ } href='#'
255
+ >{t('RESET_PASSWORD', theme?.defaultLanguages?.RESET_PASSWORD || 'Reset password')}
256
+ </a>
257
+ }
258
+ useLoginByCellphone
259
+ isPopup
260
+ />
261
+ )}
262
+ {modalPageToShow === 'signup' && (
263
+ <SignUpForm
264
+ elementLinkToLogin={
265
+ <a
266
+ onClick={
267
+ (e) => handleCustomModalClick(e, { page: 'login' })
268
+ } href='#'
269
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
270
+ </a>
271
+ }
272
+ useLoginByCellphone
273
+ useChekoutFileds
274
+ handleSuccessSignup={handleSuccessSignup}
275
+ isPopup
276
+ closeModal={() => closeAuthModal()}
277
+ />
278
+ )}
279
+ {modalPageToShow === 'forgotpassword' && (
280
+ <ForgotPasswordForm
281
+ elementLinkToLogin={
282
+ <a
283
+ onClick={
284
+ (e) => handleCustomModalClick(e, { page: 'login' })
285
+ } href='#'
286
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
287
+ </a>
288
+ }
289
+ isPopup
290
+ />
291
+ )}
292
+ </Modal>
293
+ <Alert
294
+ title={t('PRODUCT', 'Product')}
295
+ content={alertState.content}
296
+ acceptText={t('ACCEPT', 'Accept')}
297
+ open={alertState.open}
298
+ onClose={() => closeAlert()}
299
+ onAccept={() => closeAlert()}
300
+ closeOnBackdrop={false}
301
+ />
302
+ </>
303
+ )
304
+ }
305
+
306
+ export const SingleProductCard = (props) => {
307
+ const singleProductCardProps = {
308
+ ...props,
309
+ UIComponent: SingleProductCardUI
310
+ }
311
+ return <SingleProductCardController {...singleProductCardProps} />
312
+ }
@@ -4,7 +4,6 @@ import styled, { css } from 'styled-components'
4
4
  export const CardContainer = styled.div`
5
5
  ${({ isShowAddButt }) => css`
6
6
  min-height: ${isShowAddButt ? '162px' : '110px'};
7
- max-height: ${isShowAddButt ? '162px' : '110px'};
8
7
  `}
9
8
  background: ${({ soldOut }) => soldOut ? '#6c757d33' : '#FFF'};
10
9
  border: 1px solid #E9ECEF;
@@ -21,6 +20,7 @@ export const CardContainer = styled.div`
21
20
  button {
22
21
  width: 100%;
23
22
  margin-top: 10px;
23
+ padding: 4px;
24
24
  }
25
25
  ${({ productsRows }) => productsRows ? css`
26
26
  width: ${() => productsRows === 3 ? 'calc(33% - 20px)' : 'calc(50% - 20px)'};
@@ -88,6 +88,9 @@ export const CardInfo = styled.div`
88
88
  > * {
89
89
  margin: 3px;
90
90
  }
91
+ ${({ theme }) => theme?.business_view?.components?.products?.components?.layout?.type === 'pfchangs' && css`
92
+
93
+ `}
91
94
  p {
92
95
  color: #909BA9;
93
96
  text-align: left;
@@ -122,11 +125,11 @@ export const CardInfo = styled.div`
122
125
 
123
126
  export const WrapLogo = styled.div`
124
127
  position: relative;
125
- max-width: 86px;
126
- max-height: 86px;
127
- height: 86px;
128
+ max-width: 120px;
129
+ max-height: 120px;
130
+ height: 120px;
128
131
  ${({ isBgimage }) => isBgimage && css`
129
- width: 86px;
132
+ width: 120px;
130
133
  `}
131
134
  margin-left: 5px;
132
135
  ${props => props.theme?.rtl && css`
@@ -142,7 +145,7 @@ const CardLogoStyled = styled.div`
142
145
  background-size: cover;
143
146
  background-position: center;
144
147
  object-fit: cover;
145
- min-height: 86px;
148
+ min-height: 120px;
146
149
  border-radius: 10px;
147
150
  `
148
151
  export const CardLogo = (props) => {