@akinon/projectzero 2.0.0-beta.20 → 2.0.0-beta.21
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.
- package/CHANGELOG.md +8 -0
- package/app-template/CHANGELOG.md +138 -0
- package/app-template/next.config.mjs +0 -1
- package/app-template/package.json +31 -30
- package/app-template/src/app/[pz]/[...prettyurl]/page.tsx +2 -2
- package/app-template/src/app/[pz]/account/layout.tsx +2 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/blog/[slug]/page.tsx +4 -2
- package/app-template/src/app/[pz]/category/[pk]/page.tsx +11 -1
- package/app-template/src/app/[pz]/group-product/[pk]/page.tsx +2 -2
- package/app-template/src/app/[pz]/layout.tsx +3 -1
- package/app-template/src/app/[pz]/list/page.tsx +11 -1
- package/app-template/src/app/[pz]/page.tsx +13 -35
- package/app-template/src/app/[pz]/pages/[slug]/page.tsx +19 -0
- package/app-template/src/app/[pz]/product/[pk]/page.tsx +2 -2
- package/app-template/src/app/api/barcode-search/route.ts +1 -1
- package/app-template/src/app/api/cache/route.ts +1 -1
- package/app-template/src/app/api/image-proxy/route.ts +1 -1
- package/app-template/src/app/api/logout/route.ts +1 -1
- package/app-template/src/app/api/product-categories/route.ts +1 -1
- package/app-template/src/app/api/similar-product-list/route.ts +1 -1
- package/app-template/src/app/api/similar-products/route.ts +1 -1
- package/app-template/src/app/api/virtual-try-on/route.ts +1 -1
- package/app-template/src/app/api/web-vitals/route.ts +1 -1
- package/app-template/src/components/quantity-selector.tsx +16 -4
- package/app-template/src/components/widget-content.tsx +3 -3
- package/app-template/src/routes/index.ts +6 -6
- package/app-template/src/utils/__tests__/theme-page-context.test.ts +145 -0
- package/app-template/src/utils/theme-page-context.ts +309 -0
- package/app-template/src/views/basket/basket-item.tsx +107 -691
- package/app-template/src/views/basket/index.ts +0 -2
- package/app-template/src/views/basket/summary.tsx +75 -496
- package/app-template/src/views/breadcrumb.tsx +38 -13
- package/app-template/src/views/category/category-header.tsx +66 -289
- package/app-template/src/views/category/category-info.tsx +24 -173
- package/app-template/src/views/category/filters/index.tsx +48 -208
- package/app-template/src/views/category/layout.tsx +5 -7
- package/app-template/src/views/checkout/index.tsx +0 -5
- package/app-template/src/views/checkout/steps/payment/index.tsx +2 -5
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +1 -72
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +40 -171
- package/app-template/src/views/checkout/steps/shipping/address-box.tsx +12 -74
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +45 -128
- package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +27 -232
- package/app-template/src/views/checkout/summary.tsx +29 -303
- package/app-template/src/views/footer.tsx +13 -415
- package/app-template/src/views/guest-login/index.tsx +1 -1
- package/app-template/src/views/header/action-menu.tsx +45 -277
- package/app-template/src/views/header/band.tsx +21 -6
- package/app-template/src/views/header/index.tsx +47 -109
- package/app-template/src/views/header/mini-basket.tsx +45 -820
- package/app-template/src/views/header/navbar.tsx +111 -178
- package/app-template/src/views/header/search/index.tsx +32 -71
- package/app-template/src/views/header/search/results.tsx +65 -127
- package/app-template/src/views/product/accordion-wrapper.tsx +43 -135
- package/app-template/src/views/product/index.ts +1 -1
- package/app-template/src/views/product/layout.tsx +7 -2
- package/app-template/src/views/product/misc-buttons.tsx +25 -339
- package/app-template/src/views/product/product-actions.tsx +8 -137
- package/app-template/src/views/product/product-info.tsx +31 -69
- package/app-template/src/views/product/product-share.tsx +8 -11
- package/app-template/src/views/product/slider.tsx +79 -117
- package/app-template/src/views/product-item/index.tsx +46 -119
- package/app-template/src/widgets/footer-social.tsx +16 -47
- package/app-template/src/widgets/footer-subscription/index.tsx +17 -183
- package/dist/commands/plugins.js +23 -2
- package/package.json +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/pages/[slug]/page.tsx +0 -15
- package/app-template/src/views/basket/basket-summary-context.tsx +0 -560
- package/app-template/src/views/basket/designer-context.tsx +0 -617
- package/app-template/src/views/breadcrumb/breadcrumb-client.tsx +0 -190
- package/app-template/src/views/breadcrumb/breadcrumb-registrar.tsx +0 -286
- package/app-template/src/views/breadcrumb/constants.ts +0 -15
- package/app-template/src/views/breadcrumb/index.tsx +0 -127
- package/app-template/src/views/category/native-widget-context.tsx +0 -257
- package/app-template/src/views/category/product-list-registrar.tsx +0 -665
- package/app-template/src/views/checkout/checkout-address-registrar.tsx +0 -254
- package/app-template/src/views/checkout/checkout-buttons-registrar.tsx +0 -183
- package/app-template/src/views/checkout/checkout-delivery-method-registrar.tsx +0 -259
- package/app-template/src/views/checkout/checkout-payment-options-registrar.tsx +0 -253
- package/app-template/src/views/checkout/checkout-summary-registrar.tsx +0 -183
- package/app-template/src/views/checkout/constants.ts +0 -5
- package/app-template/src/views/checkout/steps/payment/options/masterpass-rest.tsx +0 -15
- package/app-template/src/views/checkout/steps/payment/options/saved-card.tsx +0 -18
- package/app-template/src/views/footer/footer-app-banner-context.tsx +0 -326
- package/app-template/src/views/footer/footer-bottom-context.tsx +0 -215
- package/app-template/src/views/footer/footer-bottom-wrapper.tsx +0 -74
- package/app-template/src/views/footer/footer-layout-constants.ts +0 -35
- package/app-template/src/views/footer/footer-layout-registrar.tsx +0 -342
- package/app-template/src/views/footer/footer-layout-switcher.tsx +0 -110
- package/app-template/src/views/footer/footer-menu-context.tsx +0 -211
- package/app-template/src/views/footer/footer-native-widgets.tsx +0 -60
- package/app-template/src/views/footer/footer-social-context.tsx +0 -254
- package/app-template/src/views/footer/footer-subscription-context.tsx +0 -210
- package/app-template/src/views/footer/footer-utils.ts +0 -43
- package/app-template/src/views/footer/footer-value-props-context.tsx +0 -326
- package/app-template/src/views/footer/logo-settings.ts +0 -183
- package/app-template/src/views/footer/native-widget-config.ts +0 -262
- package/app-template/src/views/footer/subscription-settings.ts +0 -122
- package/app-template/src/views/footer/use-footer-logo.ts +0 -162
- package/app-template/src/views/header/designer-context.tsx +0 -261
- package/app-template/src/views/header/header-announcement-registrar.tsx +0 -267
- package/app-template/src/views/header/header-client-wrapper.tsx +0 -496
- package/app-template/src/views/header/header-content.tsx +0 -1026
- package/app-template/src/views/header/header-currency-registrar.tsx +0 -348
- package/app-template/src/views/header/header-icons-context.tsx +0 -262
- package/app-template/src/views/header/header-language-registrar.tsx +0 -348
- package/app-template/src/views/header/header-layout-context.tsx +0 -143
- package/app-template/src/views/header/header-layout-registrar.tsx +0 -658
- package/app-template/src/views/header/header-logo-context.tsx +0 -228
- package/app-template/src/views/header/header-logo.tsx +0 -118
- package/app-template/src/views/header/header-mini-basket-context.tsx +0 -524
- package/app-template/src/views/header/header-search-registrar.tsx +0 -511
- package/app-template/src/views/header/header-text-slider-registrar.tsx +0 -382
- package/app-template/src/views/header/inline-search.tsx +0 -262
- package/app-template/src/views/header/navbar-menu-context.tsx +0 -219
- package/app-template/src/views/header/search/search-input.tsx +0 -61
- package/app-template/src/views/header/server-settings-parser.ts +0 -1105
- package/app-template/src/views/header/use-header-icons.ts +0 -241
- package/app-template/src/views/header/use-header-logo.ts +0 -213
- package/app-template/src/views/header/use-navbar-menu.ts +0 -179
- package/app-template/src/views/product/accordion-section.tsx +0 -61
- package/app-template/src/views/product/custom-button-group.tsx +0 -69
- package/app-template/src/views/product/favorites-button-section.tsx +0 -69
- package/app-template/src/views/product/find-in-store-section.tsx +0 -60
- package/app-template/src/views/product/product-info-section.tsx +0 -140
- package/app-template/src/views/product/quantity-section.tsx +0 -73
- package/app-template/src/views/product/sale-tag.tsx +0 -10
- package/app-template/src/views/product/share-section.tsx +0 -357
- package/app-template/src/views/product/variants-section.tsx +0 -126
- package/app-template/src/views/product-detail/constants.ts +0 -272
- package/app-template/src/views/product-detail/index.ts +0 -10
- package/app-template/src/views/product-detail/product-detail-registrar.tsx +0 -616
- package/app-template/src/widgets/footer-app-banner.tsx +0 -444
- package/app-template/src/widgets/footer-bottom.tsx +0 -127
- package/app-template/src/widgets/footer-menu-compact.tsx +0 -238
- package/app-template/src/widgets/footer-menu-two.tsx +0 -298
- package/app-template/src/widgets/footer-social-client.tsx +0 -251
- package/app-template/src/widgets/footer-value-props.tsx +0 -201
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { FindInStore } from '@theme/views/find-in-store';
|
|
4
|
-
import
|
|
4
|
+
import useFavButton from '../../hooks/use-fav-button';
|
|
5
|
+
import React, { useState } from 'react';
|
|
5
6
|
import { Button, Icon, Modal } from '@theme/components';
|
|
6
7
|
import { VariantType } from '@akinon/next/types';
|
|
7
8
|
import clsx from 'clsx';
|
|
8
9
|
import { useLocalization } from '@akinon/next/hooks';
|
|
9
|
-
import FavoritesButtonSection from './favorites-button-section';
|
|
10
|
-
import FindInStoreSection from './find-in-store-section';
|
|
11
|
-
import { useProductDetail } from '@theme/views/product-detail';
|
|
12
|
-
import { useSession } from 'next-auth/react';
|
|
13
|
-
import {
|
|
14
|
-
useAddFavoriteMutation,
|
|
15
|
-
useGetFavoritesQuery,
|
|
16
|
-
useRemoveFavoriteMutation
|
|
17
|
-
} from '@akinon/next/data/client/wishlist';
|
|
18
10
|
|
|
19
11
|
interface MiscButtonsProps {
|
|
20
12
|
productPk: number;
|
|
@@ -28,345 +20,39 @@ export default function MiscButtons({
|
|
|
28
20
|
productName
|
|
29
21
|
}: MiscButtonsProps) {
|
|
30
22
|
const { t } = useLocalization();
|
|
31
|
-
const {
|
|
32
|
-
const {
|
|
33
|
-
favoritesButtonStyles,
|
|
34
|
-
favoritesButtonProperties,
|
|
35
|
-
findInStoreStyles,
|
|
36
|
-
findInStoreProperties
|
|
37
|
-
} = useProductDetail();
|
|
23
|
+
const { FavButton } = useFavButton(productPk);
|
|
38
24
|
const [isFindinStoreModalOpen, setIsFindinStoreModalOpen] = useState(false);
|
|
39
25
|
|
|
40
|
-
const { data: favorites } = useGetFavoritesQuery(
|
|
41
|
-
{ limit: 1000 },
|
|
42
|
-
{ skip: status !== 'authenticated' }
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const favoriteItem = useMemo(
|
|
46
|
-
() =>
|
|
47
|
-
favorites?.results?.find(
|
|
48
|
-
(item) => Number(item.product.pk) === Number(productPk)
|
|
49
|
-
),
|
|
50
|
-
[favorites, productPk]
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const [addFavorite] = useAddFavoriteMutation();
|
|
54
|
-
const [removeFavorite] = useRemoveFavoriteMutation();
|
|
55
|
-
|
|
56
|
-
const handleFavoriteClick = useCallback(async () => {
|
|
57
|
-
try {
|
|
58
|
-
if (favoriteItem) {
|
|
59
|
-
await removeFavorite(favoriteItem.pk);
|
|
60
|
-
} else {
|
|
61
|
-
await addFavorite(productPk);
|
|
62
|
-
}
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error('Failed operation:', error);
|
|
65
|
-
}
|
|
66
|
-
}, [favoriteItem, productPk, addFavorite, removeFavorite]);
|
|
67
|
-
|
|
68
|
-
const isActive = Boolean(favoriteItem);
|
|
69
|
-
|
|
70
|
-
const iconName = useMemo(() => {
|
|
71
|
-
const name = isActive
|
|
72
|
-
? favoritesButtonProperties.iconActive || 'fav-on'
|
|
73
|
-
: favoritesButtonProperties.icon || 'fav-off';
|
|
74
|
-
return name;
|
|
75
|
-
}, [isActive, favoritesButtonProperties]);
|
|
76
|
-
|
|
77
|
-
const hasCustomSvgIcon = useMemo(() => {
|
|
78
|
-
return (
|
|
79
|
-
iconName && typeof iconName === 'string' && iconName.includes('<svg')
|
|
80
|
-
);
|
|
81
|
-
}, [iconName]);
|
|
82
|
-
|
|
83
|
-
const buttonStyle = useMemo(
|
|
84
|
-
(): CSSProperties => ({
|
|
85
|
-
fontSize: favoritesButtonStyles['font-size'] || '16px',
|
|
86
|
-
fontWeight: favoritesButtonStyles['font-weight'] || '400',
|
|
87
|
-
color: favoritesButtonStyles.color || '#111827',
|
|
88
|
-
backgroundColor:
|
|
89
|
-
favoritesButtonStyles['background-color'] || 'transparent',
|
|
90
|
-
borderWidth: favoritesButtonStyles['border-width'] || '0px',
|
|
91
|
-
borderColor: favoritesButtonStyles['border-color'] || 'transparent',
|
|
92
|
-
borderStyle: 'solid',
|
|
93
|
-
borderRadius: favoritesButtonStyles['border-radius'] || '0px',
|
|
94
|
-
paddingTop: favoritesButtonStyles['padding-top'] || '16px',
|
|
95
|
-
paddingBottom: favoritesButtonStyles['padding-bottom'] || '16px',
|
|
96
|
-
paddingLeft: favoritesButtonStyles['padding-left'] || '16px',
|
|
97
|
-
paddingRight: favoritesButtonStyles['padding-right'] || '16px',
|
|
98
|
-
height: favoritesButtonStyles.height || 'auto'
|
|
99
|
-
}),
|
|
100
|
-
[favoritesButtonStyles]
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
const iconSize = useMemo(() => {
|
|
104
|
-
const size = favoritesButtonStyles['icon-size'];
|
|
105
|
-
const parsed = parseInt(size);
|
|
106
|
-
return !isNaN(parsed) ? parsed : 20;
|
|
107
|
-
}, [favoritesButtonStyles]);
|
|
108
|
-
|
|
109
|
-
const iconColor = useMemo(
|
|
110
|
-
() => favoritesButtonStyles['icon-color'] || '#6b7280',
|
|
111
|
-
[favoritesButtonStyles]
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const iconActiveColor = useMemo(
|
|
115
|
-
() => favoritesButtonStyles['icon-active-color'] || '#ef4444',
|
|
116
|
-
[favoritesButtonStyles]
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const findInStoreButtonStyle = useMemo(
|
|
120
|
-
(): CSSProperties => ({
|
|
121
|
-
fontSize: findInStoreStyles['button-font-size'] || '16px',
|
|
122
|
-
fontWeight: findInStoreStyles['button-font-weight'] || '400',
|
|
123
|
-
color: findInStoreStyles['button-color'] || '#111827',
|
|
124
|
-
backgroundColor:
|
|
125
|
-
findInStoreStyles['button-background-color'] || 'transparent',
|
|
126
|
-
borderWidth: findInStoreStyles['button-border-width'] || '1px',
|
|
127
|
-
borderColor: findInStoreStyles['button-border-color'] || '#d1d5db',
|
|
128
|
-
borderStyle: 'solid',
|
|
129
|
-
borderRadius: findInStoreStyles['button-border-radius'] || '0px',
|
|
130
|
-
paddingLeft: findInStoreStyles['button-padding-x'] || '48px',
|
|
131
|
-
paddingRight: findInStoreStyles['button-padding-x'] || '48px',
|
|
132
|
-
paddingTop: findInStoreStyles['button-padding-y'] || '16px',
|
|
133
|
-
paddingBottom: findInStoreStyles['button-padding-y'] || '16px',
|
|
134
|
-
height: findInStoreStyles['button-height'] || 'auto'
|
|
135
|
-
}),
|
|
136
|
-
[findInStoreStyles]
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const findInStoreIconSize = useMemo(() => {
|
|
140
|
-
const size = findInStoreStyles['icon-size'];
|
|
141
|
-
const parsed = parseInt(size);
|
|
142
|
-
return !isNaN(parsed) ? parsed : 20;
|
|
143
|
-
}, [findInStoreStyles]);
|
|
144
|
-
|
|
145
|
-
const findInStoreIconColor = useMemo(
|
|
146
|
-
() => findInStoreStyles['icon-color'] || '#111827',
|
|
147
|
-
[findInStoreStyles]
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const findInStoreIconName = useMemo(() => {
|
|
151
|
-
const customIcon = findInStoreProperties.icon;
|
|
152
|
-
if (customIcon) {
|
|
153
|
-
return customIcon;
|
|
154
|
-
}
|
|
155
|
-
return 'store-pin';
|
|
156
|
-
}, [findInStoreProperties]);
|
|
157
|
-
|
|
158
|
-
const hasFindInStoreCustomSvgIcon = useMemo(() => {
|
|
159
|
-
return (
|
|
160
|
-
findInStoreIconName &&
|
|
161
|
-
typeof findInStoreIconName === 'string' &&
|
|
162
|
-
findInStoreIconName.includes('<svg')
|
|
163
|
-
);
|
|
164
|
-
}, [findInStoreIconName]);
|
|
165
|
-
|
|
166
|
-
const showFindInStoreIcon =
|
|
167
|
-
findInStoreProperties.showIcon !== undefined
|
|
168
|
-
? findInStoreProperties.showIcon
|
|
169
|
-
: true;
|
|
170
|
-
|
|
171
|
-
const modalWidth = useMemo(
|
|
172
|
-
() => findInStoreStyles['modal-width'] || '36rem',
|
|
173
|
-
[findInStoreStyles]
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
const modalMaxHeight = useMemo(
|
|
177
|
-
() => findInStoreStyles['modal-max-height'] || '90vh',
|
|
178
|
-
[findInStoreStyles]
|
|
179
|
-
);
|
|
180
|
-
|
|
181
26
|
return (
|
|
182
|
-
<div className="grid grid-cols-1 gap-4
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
iconName && <Icon name={iconName} size={iconSize} />
|
|
202
|
-
)}
|
|
203
|
-
<span className="ml-2">{t('product.add_to_favorites')}</span>
|
|
204
|
-
</button>
|
|
205
|
-
<style jsx global>{`
|
|
206
|
-
.favorites-button-container:hover {
|
|
207
|
-
background-color: ${favoritesButtonStyles[
|
|
208
|
-
'hover-background-color'
|
|
209
|
-
] || 'transparent'};
|
|
210
|
-
color: ${favoritesButtonStyles['hover-text-color'] ||
|
|
211
|
-
favoritesButtonStyles.color ||
|
|
212
|
-
'#111827'};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.favorites-button-container [data-testid='favourites-icon'] i {
|
|
216
|
-
color: ${isActive ? iconActiveColor : iconColor} !important;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.favorites-button-container:hover
|
|
220
|
-
[data-testid='favourites-icon']
|
|
221
|
-
i {
|
|
222
|
-
color: ${favoritesButtonStyles['hover-icon-color'] ||
|
|
223
|
-
(isActive ? iconActiveColor : iconColor)} !important;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.favorites-button-container [data-testid='favourites-icon'] svg {
|
|
227
|
-
fill: currentColor;
|
|
228
|
-
}
|
|
229
|
-
`}</style>
|
|
230
|
-
</div>
|
|
231
|
-
</FavoritesButtonSection>
|
|
232
|
-
<div className="hidden w-px self-stretch bg-black/10 sm:block" />
|
|
233
|
-
<FindInStoreSection>
|
|
234
|
-
<div style={findInStoreButtonStyle} className="find-in-store-container">
|
|
235
|
-
<Button
|
|
236
|
-
appearance="outlined"
|
|
237
|
-
className="group place-self-start h-full hover:bg-transparent sm:border-none"
|
|
238
|
-
data-testid="product-find-in-store"
|
|
239
|
-
onClick={() => setIsFindinStoreModalOpen(true)}
|
|
240
|
-
style={{ all: 'unset', display: 'flex', cursor: 'pointer' }}
|
|
241
|
-
>
|
|
242
|
-
<div className="flex items-center gap-2">
|
|
243
|
-
<span>{t('product.find_in_store.title')}</span>
|
|
244
|
-
{showFindInStoreIcon &&
|
|
245
|
-
(hasFindInStoreCustomSvgIcon ? (
|
|
246
|
-
<div
|
|
247
|
-
className="flex items-center justify-center"
|
|
248
|
-
style={{
|
|
249
|
-
width: findInStoreIconSize,
|
|
250
|
-
height: findInStoreIconSize,
|
|
251
|
-
color: findInStoreIconColor
|
|
252
|
-
}}
|
|
253
|
-
dangerouslySetInnerHTML={{ __html: findInStoreIconName }}
|
|
254
|
-
/>
|
|
255
|
-
) : (
|
|
256
|
-
<Icon
|
|
257
|
-
name={findInStoreIconName}
|
|
258
|
-
size={findInStoreIconSize}
|
|
259
|
-
className="hidden sm:block"
|
|
260
|
-
style={{ color: findInStoreIconColor }}
|
|
261
|
-
/>
|
|
262
|
-
))}
|
|
263
|
-
</div>
|
|
264
|
-
</Button>
|
|
265
|
-
<style jsx global>{`
|
|
266
|
-
.find-in-store-container:hover {
|
|
267
|
-
background-color: ${findInStoreStyles[
|
|
268
|
-
'button-hover-background-color'
|
|
269
|
-
] || 'transparent'};
|
|
270
|
-
color: ${findInStoreStyles['button-hover-text-color'] ||
|
|
271
|
-
findInStoreStyles['button-color'] ||
|
|
272
|
-
'#111827'};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.find-in-store-container:hover
|
|
276
|
-
[data-testid='product-find-in-store']
|
|
277
|
-
svg {
|
|
278
|
-
fill: ${findInStoreStyles['button-hover-icon-color'] ||
|
|
279
|
-
findInStoreIconColor};
|
|
280
|
-
}
|
|
281
|
-
`}</style>
|
|
27
|
+
<div className="grid grid-cols-1 gap-4 place-items-center mb-2 mt-4 sm:grid-cols-[1fr_auto_1fr] sm:my-4 xl:gap-6">
|
|
28
|
+
<FavButton
|
|
29
|
+
label={t('product.add_to_favorites')}
|
|
30
|
+
className="px-1 py-2 text-base hidden sm:flex"
|
|
31
|
+
/>
|
|
32
|
+
<div className="h-5 border border-black hidden sm:block" />
|
|
33
|
+
<Button
|
|
34
|
+
appearance="outlined"
|
|
35
|
+
className="group px-12 py-2 text-xs place-self-start hover:bg-transparent hover:text-secondary-hover sm:text-base sm:border-none sm:px-4"
|
|
36
|
+
data-testid="product-find-in-store"
|
|
37
|
+
onClick={() => setIsFindinStoreModalOpen(true)}
|
|
38
|
+
>
|
|
39
|
+
<div className="flex items-center gap-2">
|
|
40
|
+
<span>{t('product.find_in_store.title')}</span>
|
|
41
|
+
<Icon
|
|
42
|
+
name="store-pin"
|
|
43
|
+
size={20}
|
|
44
|
+
className={clsx('hidden sm:block group-hover:fill-[white]')}
|
|
45
|
+
/>
|
|
282
46
|
</div>
|
|
283
|
-
</
|
|
284
|
-
<style>{`
|
|
285
|
-
#find-in-store-modal > section {
|
|
286
|
-
width: ${modalWidth} !important;
|
|
287
|
-
max-width: ${
|
|
288
|
-
findInStoreStyles['modal-max-width'] || '90vw'
|
|
289
|
-
} !important;
|
|
290
|
-
max-height: ${modalMaxHeight} !important;
|
|
291
|
-
background-color: ${
|
|
292
|
-
findInStoreStyles['modal-background-color'] || 'white'
|
|
293
|
-
} !important;
|
|
294
|
-
border-radius: ${
|
|
295
|
-
findInStoreStyles['modal-border-radius'] || '0.5rem'
|
|
296
|
-
} !important;
|
|
297
|
-
overflow-y: auto !important;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
#find-in-store-modal h3 {
|
|
301
|
-
font-size: ${
|
|
302
|
-
findInStoreStyles['modal-title-font-size'] || '1.25rem'
|
|
303
|
-
} !important;
|
|
304
|
-
font-weight: ${
|
|
305
|
-
findInStoreStyles['modal-title-font-weight'] || '600'
|
|
306
|
-
} !important;
|
|
307
|
-
color: ${
|
|
308
|
-
findInStoreStyles['modal-title-color'] || '#111827'
|
|
309
|
-
} !important;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
#find-in-store-modal button {
|
|
313
|
-
font-size: ${
|
|
314
|
-
findInStoreStyles['modal-button-font-size'] || '14px'
|
|
315
|
-
} !important;
|
|
316
|
-
font-weight: ${
|
|
317
|
-
findInStoreStyles['modal-button-font-weight'] || '500'
|
|
318
|
-
} !important;
|
|
319
|
-
color: ${
|
|
320
|
-
findInStoreStyles['modal-button-color'] || '#ffffff'
|
|
321
|
-
} !important;
|
|
322
|
-
background-color: ${
|
|
323
|
-
findInStoreStyles['modal-button-background-color'] || '#111827'
|
|
324
|
-
} !important;
|
|
325
|
-
border-color: ${
|
|
326
|
-
findInStoreStyles['modal-button-border-color'] || '#111827'
|
|
327
|
-
} !important;
|
|
328
|
-
border-width: ${
|
|
329
|
-
findInStoreStyles['modal-button-border-width'] || '1px'
|
|
330
|
-
} !important;
|
|
331
|
-
border-radius: ${
|
|
332
|
-
findInStoreStyles['modal-button-border-radius'] || '0px'
|
|
333
|
-
} !important;
|
|
334
|
-
padding-left: ${
|
|
335
|
-
findInStoreStyles['modal-button-padding-x'] || '16px'
|
|
336
|
-
} !important;
|
|
337
|
-
padding-right: ${
|
|
338
|
-
findInStoreStyles['modal-button-padding-x'] || '16px'
|
|
339
|
-
} !important;
|
|
340
|
-
padding-top: ${
|
|
341
|
-
findInStoreStyles['modal-button-padding-y'] || '8px'
|
|
342
|
-
} !important;
|
|
343
|
-
padding-bottom: ${
|
|
344
|
-
findInStoreStyles['modal-button-padding-y'] || '8px'
|
|
345
|
-
} !important;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
#find-in-store-modal button:hover {
|
|
349
|
-
background-color: ${
|
|
350
|
-
findInStoreStyles['modal-button-hover-background-color'] ||
|
|
351
|
-
'#374151'
|
|
352
|
-
} !important;
|
|
353
|
-
color: ${
|
|
354
|
-
findInStoreStyles['modal-button-hover-text-color'] || '#ffffff'
|
|
355
|
-
} !important;
|
|
356
|
-
}
|
|
357
|
-
`}</style>
|
|
47
|
+
</Button>
|
|
358
48
|
<Modal
|
|
359
49
|
portalId="find-in-store-modal"
|
|
360
50
|
title={t('product.find_in_store.title')}
|
|
361
51
|
open={isFindinStoreModalOpen}
|
|
362
52
|
setOpen={setIsFindinStoreModalOpen}
|
|
53
|
+
className="w-[22rem] sm:w-[36rem] max-h-[90vh] overflow-y-auto"
|
|
363
54
|
>
|
|
364
|
-
<div
|
|
365
|
-
className="px-6"
|
|
366
|
-
style={{
|
|
367
|
-
padding: findInStoreStyles['modal-padding']
|
|
368
|
-
}}
|
|
369
|
-
>
|
|
55
|
+
<div className="px-6">
|
|
370
56
|
<FindInStore
|
|
371
57
|
productName={productName}
|
|
372
58
|
productPk={productPk}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Button, Icon, Modal } from '@theme/components';
|
|
4
4
|
import { useLocalization } from '@akinon/next/hooks';
|
|
5
5
|
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
6
6
|
import { validateVariantSelection } from '../../utils/variant-validation';
|
|
7
7
|
import { VariantType } from '@akinon/next/types';
|
|
8
|
-
import {
|
|
9
|
-
useProductDetail,
|
|
10
|
-
ADD_TO_CART_SECTION_ID
|
|
11
|
-
} from '@theme/views/product-detail';
|
|
12
8
|
|
|
13
9
|
interface Product {
|
|
14
10
|
pk: number;
|
|
@@ -32,21 +28,6 @@ interface ProductActionsProps {
|
|
|
32
28
|
onCloseModal: () => void;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
/**
|
|
36
|
-
* Format style value - ensures proper CSS unit
|
|
37
|
-
*/
|
|
38
|
-
const formatStyleValue = (
|
|
39
|
-
value: string | number | undefined,
|
|
40
|
-
unit: string = 'px'
|
|
41
|
-
): string | undefined => {
|
|
42
|
-
if (value === undefined || value === null || value === '') return undefined;
|
|
43
|
-
const strValue = String(value);
|
|
44
|
-
if (strValue.endsWith(unit)) return strValue;
|
|
45
|
-
const numValue = parseInt(strValue, 10);
|
|
46
|
-
if (isNaN(numValue)) return strValue;
|
|
47
|
-
return `${numValue}${unit}`;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
31
|
export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
51
32
|
product,
|
|
52
33
|
variants,
|
|
@@ -63,63 +44,6 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
63
44
|
onCloseModal
|
|
64
45
|
}) => {
|
|
65
46
|
const { t } = useLocalization();
|
|
66
|
-
const { isDesigner, selectedSectionId, addToCartStyles } = useProductDetail();
|
|
67
|
-
|
|
68
|
-
const isAddToCartSectionSelected =
|
|
69
|
-
isDesigner && selectedSectionId === ADD_TO_CART_SECTION_ID;
|
|
70
|
-
|
|
71
|
-
// Generate button styles from theme editor
|
|
72
|
-
const buttonStyles = useMemo((): CSSProperties => {
|
|
73
|
-
const styles: CSSProperties = {};
|
|
74
|
-
|
|
75
|
-
if (addToCartStyles['font-size']) {
|
|
76
|
-
styles.fontSize = formatStyleValue(addToCartStyles['font-size']);
|
|
77
|
-
}
|
|
78
|
-
if (addToCartStyles['font-weight']) {
|
|
79
|
-
styles.fontWeight = addToCartStyles['font-weight'];
|
|
80
|
-
}
|
|
81
|
-
if (addToCartStyles.color) {
|
|
82
|
-
styles.color = addToCartStyles.color;
|
|
83
|
-
}
|
|
84
|
-
if (addToCartStyles['background-color']) {
|
|
85
|
-
styles.backgroundColor = addToCartStyles['background-color'];
|
|
86
|
-
}
|
|
87
|
-
if (addToCartStyles['border-color']) {
|
|
88
|
-
styles.borderColor = addToCartStyles['border-color'];
|
|
89
|
-
}
|
|
90
|
-
if (addToCartStyles['border-width']) {
|
|
91
|
-
styles.borderWidth = formatStyleValue(addToCartStyles['border-width']);
|
|
92
|
-
styles.borderStyle = 'solid';
|
|
93
|
-
}
|
|
94
|
-
if (addToCartStyles['border-radius']) {
|
|
95
|
-
styles.borderRadius = formatStyleValue(addToCartStyles['border-radius']);
|
|
96
|
-
}
|
|
97
|
-
if (addToCartStyles.height) {
|
|
98
|
-
styles.height = formatStyleValue(addToCartStyles.height);
|
|
99
|
-
}
|
|
100
|
-
if (addToCartStyles['padding-x']) {
|
|
101
|
-
const paddingX = formatStyleValue(addToCartStyles['padding-x']);
|
|
102
|
-
styles.paddingLeft = paddingX;
|
|
103
|
-
styles.paddingRight = paddingX;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return styles;
|
|
107
|
-
}, [addToCartStyles]);
|
|
108
|
-
|
|
109
|
-
// Generate hover styles as CSS variables
|
|
110
|
-
const hoverStyleVars = useMemo((): Record<string, string> => {
|
|
111
|
-
const vars: Record<string, string> = {};
|
|
112
|
-
|
|
113
|
-
if (addToCartStyles['hover-background-color']) {
|
|
114
|
-
vars['--add-to-cart-hover-bg'] =
|
|
115
|
-
addToCartStyles['hover-background-color'];
|
|
116
|
-
}
|
|
117
|
-
if (addToCartStyles['hover-text-color']) {
|
|
118
|
-
vars['--add-to-cart-hover-color'] = addToCartStyles['hover-text-color'];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return vars;
|
|
122
|
-
}, [addToCartStyles]);
|
|
123
47
|
|
|
124
48
|
const checkoutProviderProps = {
|
|
125
49
|
product,
|
|
@@ -127,8 +51,6 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
127
51
|
addBeforeClick: () => validateVariantSelection(variants).isValid,
|
|
128
52
|
openMiniBasket: false,
|
|
129
53
|
className: clsx([
|
|
130
|
-
'h-12',
|
|
131
|
-
'mb-4',
|
|
132
54
|
'py-2.5',
|
|
133
55
|
'bg-black',
|
|
134
56
|
'relative',
|
|
@@ -149,8 +71,7 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
149
71
|
'after:left-1'
|
|
150
72
|
]),
|
|
151
73
|
onError: (error: any) => {
|
|
152
|
-
const formattedError =
|
|
153
|
-
error?.data?.non_field_errors ||
|
|
74
|
+
const formattedError = error?.data?.non_field_errors ||
|
|
154
75
|
Object.keys(error?.data || {}).map(
|
|
155
76
|
(key) => `${key}: ${error?.data[key].join(', ')}`
|
|
156
77
|
);
|
|
@@ -161,7 +82,7 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
161
82
|
|
|
162
83
|
const handleMainActionClick = () => {
|
|
163
84
|
onClearError();
|
|
164
|
-
|
|
85
|
+
|
|
165
86
|
if (inStock) {
|
|
166
87
|
onAddToCart();
|
|
167
88
|
} else {
|
|
@@ -169,32 +90,6 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
169
90
|
}
|
|
170
91
|
};
|
|
171
92
|
|
|
172
|
-
// Handle designer click to select this section
|
|
173
|
-
const handleDesignerClick = (e: React.MouseEvent) => {
|
|
174
|
-
if (!isDesigner) return;
|
|
175
|
-
|
|
176
|
-
e.stopPropagation();
|
|
177
|
-
window.parent?.postMessage(
|
|
178
|
-
{
|
|
179
|
-
type: 'SELECT_SECTION',
|
|
180
|
-
placeholderId: 'product-detail',
|
|
181
|
-
sectionId: ADD_TO_CART_SECTION_ID
|
|
182
|
-
},
|
|
183
|
-
'*'
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// Combine base styles with theme editor styles
|
|
188
|
-
const combinedButtonStyles: CSSProperties = {
|
|
189
|
-
...buttonStyles,
|
|
190
|
-
...hoverStyleVars
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// Determine if we have custom hover styles
|
|
194
|
-
const hasHoverStyles =
|
|
195
|
-
addToCartStyles['hover-background-color'] ||
|
|
196
|
-
addToCartStyles['hover-text-color'];
|
|
197
|
-
|
|
198
93
|
return (
|
|
199
94
|
<>
|
|
200
95
|
{productError && (
|
|
@@ -203,37 +98,13 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
203
98
|
</div>
|
|
204
99
|
)}
|
|
205
100
|
|
|
206
|
-
{/* Add hover styles via inline style tag when custom hover colors are set */}
|
|
207
|
-
{hasHoverStyles && (
|
|
208
|
-
<style>
|
|
209
|
-
{`
|
|
210
|
-
.add-to-cart-styled:hover {
|
|
211
|
-
${
|
|
212
|
-
addToCartStyles['hover-background-color']
|
|
213
|
-
? `background-color: ${addToCartStyles['hover-background-color']} !important;`
|
|
214
|
-
: ''
|
|
215
|
-
}
|
|
216
|
-
${
|
|
217
|
-
addToCartStyles['hover-text-color']
|
|
218
|
-
? `color: ${addToCartStyles['hover-text-color']} !important;`
|
|
219
|
-
: ''
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
`}
|
|
223
|
-
</style>
|
|
224
|
-
)}
|
|
225
|
-
|
|
226
101
|
<Button
|
|
227
|
-
disabled={
|
|
228
|
-
isAddToCartLoading || isAddToStockAlertLoading || isVariantLoading
|
|
229
|
-
}
|
|
230
|
-
onClick={isDesigner ? handleDesignerClick : handleMainActionClick}
|
|
102
|
+
disabled={isAddToCartLoading || isAddToStockAlertLoading || isVariantLoading}
|
|
231
103
|
className={clsx(
|
|
232
|
-
'w-
|
|
233
|
-
|
|
234
|
-
isAddToCartSectionSelected && 'ring-2 ring-blue-500 ring-offset-2'
|
|
104
|
+
'fixed bottom-0 right-0 w-1/2 h-14 z-[20] flex items-center justify-center fill-primary-foreground',
|
|
105
|
+
'hover:fill-primary sm:relative sm:w-full sm:mt-3 sm:font-semibold sm:h-12'
|
|
235
106
|
)}
|
|
236
|
-
|
|
107
|
+
onClick={handleMainActionClick}
|
|
237
108
|
data-testid="product-add-to-cart"
|
|
238
109
|
>
|
|
239
110
|
{isVariantLoading ? (
|
|
@@ -291,4 +162,4 @@ export const ProductActions: React.FC<ProductActionsProps> = ({
|
|
|
291
162
|
</Modal>
|
|
292
163
|
</>
|
|
293
164
|
);
|
|
294
|
-
};
|
|
165
|
+
};
|