@@ -7,8 +7,13 @@ import { ProductNotFound } from '~/components/ProductNotFound/ProductNotFound';
7
7
import { ProductSlider } from '~/components/ProductSlider/ProductSlider' ;
8
8
import { Divider } from '~/components/UI/Divider/Divider' ;
9
9
import { useRandomProductsLoader } from '~/routes/layout' ;
10
- import { ACTIONS_CONTEXT , IMAGE_PLACHEHOLDER } from '~/shared/constants' ;
10
+ import {
11
+ ACTIONS_CONTEXT ,
12
+ IMAGE_PLACHEHOLDER ,
13
+ STORE_CONTEXT ,
14
+ } from '~/shared/constants' ;
11
15
import { generateDocumentHead } from '~/shared/utils' ;
16
+ import { getCartProductQuantity } from '~/store/selectors' ;
12
17
import type { Product } from '~/types/product' ;
13
18
14
19
export const useProductLoader = routeLoader$ (
@@ -26,6 +31,7 @@ export const useProductLoader = routeLoader$(
26
31
export default component$ ( ( ) => {
27
32
const product = useProductLoader ( ) ;
28
33
const t = useTranslate ( ) ;
34
+ const store = useContext ( STORE_CONTEXT ) ;
29
35
const actions = useContext ( ACTIONS_CONTEXT ) ;
30
36
31
37
if ( ! product . value ) {
@@ -124,67 +130,6 @@ export default component$(() => {
124
130
</ div >
125
131
</ div >
126
132
</ div >
127
- { /* <div class='md:-order-1 overflow-hidden flex-shrink-0 basis-auto'>
128
- <div class='items-center relative flex-col h-full inline-flex hidden md:inline-flex'>
129
- <button
130
- type='button'
131
- class='inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-1.5 gap-1.5 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 ring-1 ring-primary-700 hover:shadow-md active:shadow shadow hover:ring-primary-800 active:ring-primary-900 disabled:ring-1 disabled:ring-disabled-300 disabled:bg-white/50 absolute !rounded-full bg-white z-10 top-4 rotate-90 disabled:!hidden !ring-neutral-500 !text-neutral-500'
132
- data-testid='button'
133
- aria-label='Previous'
134
- >
135
- <svg
136
- viewBox='0 0 24 24'
137
- data-testid='chevron-left'
138
- xmlns='http://www.w3.org/2000/svg'
139
- class='inline-block fill-current w-6 h-6 undefined'
140
- >
141
- <path d='M14.706 17.297a.998.998 0 0 0 0-1.41l-3.876-3.885 3.877-3.885a.998.998 0 0 0-1.412-1.41l-4.588 4.588a1 1 0 0 0 0 1.414l4.588 4.588a.997.997 0 0 0 1.41 0Z'></path>
142
- </svg>
143
- </button>
144
- <div class="flex-row w-full items-center md:flex-col md:h-full md:px-0 md:scroll-pl-4 snap-y snap-mandatory flex gap-0.5 md:gap-2 overflow-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:'none'] [scrollbar-width:'none'] motion-safe:scroll-smooth overflow-y-auto flex flex-col gap-4">
145
- <button
146
- type='button'
147
- aria-current='true'
148
- aria-label='Go to slide 1'
149
- class='w-20 h-[88px] relative shrink-0 pb-1 border-b-4 snap-start cursor-pointer transition-colors flex-grow-0 border-primary-700'
150
- >
151
- <Image
152
- loading='eager'
153
- layout='fixed'
154
- width={80}
155
- height={80}
156
- data-testid='image-slot'
157
- class='object-cover rounded-md aspect-square w-full h-full'
158
- src={product.value.primaryImage.url}
159
- alt={product.value.primaryImage.alt}
160
- />
161
- </button>
162
- </div>
163
- <button
164
- type='button'
165
- class='inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-1.5 gap-1.5 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 ring-1 ring-primary-700 hover:shadow-md active:shadow shadow hover:ring-primary-800 active:ring-primary-900 disabled:ring-1 disabled:ring-disabled-300 disabled:bg-white/50 absolute !rounded-full bg-white z-10 bottom-4 rotate-90 disabled:!hidden !ring-neutral-500 !text-neutral-500'
166
- data-testid='button'
167
- aria-label='Next'
168
- >
169
- <svg
170
- viewBox='0 0 24 24'
171
- data-testid='chevron-right'
172
- xmlns='http://www.w3.org/2000/svg'
173
- class='inline-block fill-current w-6 h-6 undefined'
174
- >
175
- <path d='M8.705 17.297a.998.998 0 0 1-.001-1.41l3.876-3.885-3.876-3.885a.998.998 0 0 1 1.412-1.41l4.587 4.588a1 1 0 0 1 0 1.414l-4.587 4.588a.997.997 0 0 1-1.411 0Z'></path>
176
- </svg>
177
- </button>
178
- </div>
179
- <div class='flex md:hidden gap-0.5' role='group'>
180
- <button
181
- type='button'
182
- aria-current='true'
183
- aria-label='Go to slide 1'
184
- class='relative shrink-0 pb-1 border-b-4 cursor-pointer transition-colors flex-grow border-primary-700'
185
- ></button>
186
- </div>
187
- </div> */ }
188
133
</ div >
189
134
</ section >
190
135
< section class = 'mb-10 grid-in-right md:mb-0' >
@@ -252,7 +197,7 @@ export default component$(() => {
252
197
and off
253
198
</ p >
254
199
< div class = 'py-4 mb-4 border-gray-200 border-y' >
255
- < div class = 'inline-flex items-center justify-center rounded-md font-normal text-primary-800 bg-primary-100 text-sm p-1.5 gap-1.5 w-full mb-4 ' >
200
+ < div class = 'inline-flex items-center justify-center rounded-md font-normal text-primary-800 bg-primary-100 text-sm p-1.5 gap-1.5 w-full' >
256
201
< svg
257
202
viewBox = '0 0 24 24'
258
203
data-testid = 'shopping-cart-checkout'
@@ -261,59 +206,10 @@ export default component$(() => {
261
206
>
262
207
< path d = 'M7 22c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 0 1 5 20c0-.55.196-1.02.588-1.413A1.926 1.926 0 0 1 7 18c.55 0 1.02.196 1.412.587C8.804 18.98 9 19.45 9 20s-.196 1.02-.588 1.413A1.926 1.926 0 0 1 7 22Zm10 0c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 0 1 15 20c0-.55.196-1.02.588-1.413A1.926 1.926 0 0 1 17 18c.55 0 1.02.196 1.413.587.391.392.587.863.587 1.413s-.196 1.02-.587 1.413A1.926 1.926 0 0 1 17 22ZM11.3 9.3a.948.948 0 0 1-.275-.7.95.95 0 0 1 .275-.7l.875-.9H9a.968.968 0 0 1-.713-.287A.968.968 0 0 1 8 6c0-.283.096-.52.287-.713A.968.968 0 0 1 9 5h3.175l-.9-.9a.916.916 0 0 1-.287-.7c.008-.267.112-.5.312-.7.2-.183.433-.28.7-.288.267-.008.5.088.7.288l2.6 2.6c.1.1.17.208.212.325.042.117.063.242.063.375s-.02.258-.063.375a.878.878 0 0 1-.212.325l-2.6 2.6a.977.977 0 0 1-.688.287.93.93 0 0 1-.712-.287ZM7 17c-.767 0-1.346-.33-1.737-.988-.392-.658-.396-1.312-.013-1.962L6.6 11.6 3 4H2a.968.968 0 0 1-.712-.288A.968.968 0 0 1 1 3c0-.283.096-.52.288-.712A.968.968 0 0 1 2 2h1.65c.183 0 .358.05.525.15a.93.93 0 0 1 .375.425L8.525 11h7.025l3.6-6.5A.973.973 0 0 1 20 4a.94.94 0 0 1 .863.487.937.937 0 0 1 .012.988L17.3 11.95c-.183.333-.43.592-.738.775A1.945 1.945 0 0 1 15.55 13H8.1L7 15h11a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.712A.968.968 0 0 1 18 17H7Z' > </ path >
263
208
</ svg >
264
- 1 product in cart
209
+ { getCartProductQuantity ( store . cart , product . value . id ) } { ' ' }
210
+ product in cart
265
211
</ div >
266
- < div class = 'flex flex-col md:flex-row flex-wrap gap-4' >
267
- < div
268
- data-testid = 'quantitySelector'
269
- class = 'inline-flex flex-col items-center h-12 min-w-[145px] flex-grow flex-shrink-0 basis-0'
270
- >
271
- < div class = 'flex border border-neutral-300 rounded-md h-full w-full' >
272
- < button
273
- type = 'button'
274
- class = 'inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-2 gap-2 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 disabled:bg-transparent rounded-r-none'
275
- data-testid = 'quantitySelectorDecreaseButton'
276
- aria-controls = ':r1:'
277
- aria-label = 'Decrease value'
278
- >
279
- < svg
280
- viewBox = '0 0 24 24'
281
- data-testid = 'remove'
282
- xmlns = 'http://www.w3.org/2000/svg'
283
- class = 'inline-block fill-current w-6 h-6 undefined'
284
- >
285
- < path d = 'M6 13a.968.968 0 0 1-.713-.288A.967.967 0 0 1 5 12a.97.97 0 0 1 .287-.713A.97.97 0 0 1 6 11h12a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.712A.965.965 0 0 1 18 13H6Z' > </ path >
286
- </ svg >
287
- </ button >
288
- < input
289
- data-testid = 'quantitySelectorInput'
290
- id = ':r1:'
291
- type = 'number'
292
- role = 'spinbutton'
293
- class = 'appearance-none flex-1 mx-2 w-8 text-center bg-transparent font-medium [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-inner-spin-button]:display-none [&::-webkit-inner-spin-button]:m-0 [&::-webkit-outer-spin-button]:display-none [&::-webkit-outer-spin-button]:m-0 [-moz-appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none disabled:placeholder-disabled-900 focus-visible:outline focus-visible:outline-offset focus-visible:rounded-sm'
294
- min = '1'
295
- max = '999'
296
- aria-label = 'Quantity Selector'
297
- value = '1'
298
- />
299
- < button
300
- type = 'button'
301
- class = 'inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-2 gap-2 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 disabled:bg-transparent rounded-l-none'
302
- data-testid = 'quantitySelectorIncreaseButton'
303
- aria-controls = ':r1:'
304
- aria-label = 'Increase value'
305
- >
306
- < svg
307
- viewBox = '0 0 24 24'
308
- data-testid = 'add'
309
- xmlns = 'http://www.w3.org/2000/svg'
310
- class = 'inline-block fill-current w-6 h-6 undefined'
311
- >
312
- < path d = 'M12 19a.965.965 0 0 1-.712-.288A.965.965 0 0 1 11 18v-5H6a.968.968 0 0 1-.713-.288A.967.967 0 0 1 5 12a.97.97 0 0 1 .287-.713A.97.97 0 0 1 6 11h5V6c0-.283.096-.521.288-.713A.967.967 0 0 1 12 5a.97.97 0 0 1 .713.287A.97.97 0 0 1 13 6v5h5a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.712A.965.965 0 0 1 18 13h-5v5a.97.97 0 0 1-.287.712A.968.968 0 0 1 12 19Z' > </ path >
313
- </ svg >
314
- </ button >
315
- </ div >
316
- </ div >
212
+ < div class = 'flex justify-center mt-4 gap-x-4' >
317
213
< SfButton
318
214
type = 'button'
319
215
size = 'sm'
@@ -327,8 +223,6 @@ export default component$(() => {
327
223
< SfIconShoppingCart size = 'sm' class = 'w-5 h-5' />
328
224
</ div >
329
225
</ SfButton >
330
- </ div >
331
- < div class = 'flex justify-center mt-4 gap-x-4' >
332
226
< button
333
227
type = 'button'
334
228
class = 'inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed leading-5 text-sm py-1.5 px-3 gap-1.5 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 disabled:bg-transparent'
0 commit comments