storefront-layouts 1.0.9 → 1.0.13
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/dist/components/shipping/ProductDeliveryInfoSection.d.ts.map +1 -1
- package/dist/components/shipping/ProductDeliveryInfoSection.js +10 -3
- package/dist/components/ui/address-selector.d.ts.map +1 -1
- package/dist/components/ui/address-selector.js +4 -3
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/checkout-button.d.ts.map +1 -1
- package/dist/components/ui/checkout-button.js +2 -1
- package/dist/components/ui/product-card.d.ts.map +1 -1
- package/dist/components/ui/product-card.js +15 -4
- package/dist/components/ui/route-skeleton-loader.d.ts.map +1 -1
- package/dist/components/ui/route-skeleton-loader.js +6 -2
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/skeletons/checkout-skeleton.js +1 -1
- package/dist/editor/blocks/defaults/clothing-minimal-home.js +1 -1
- package/dist/editor/blocks/migrate-clothing-minimal.js +1 -1
- package/dist/hooks/use-pdp-variation.d.ts +57 -0
- package/dist/hooks/use-pdp-variation.d.ts.map +1 -0
- package/dist/hooks/use-pdp-variation.js +69 -0
- package/dist/hooks/use-product-by-slug.d.ts.map +1 -1
- package/dist/hooks/use-product-by-slug.js +0 -5
- package/dist/hooks/use-product-variation-selection.js +1 -1
- package/dist/hooks/use-shipping-quote.d.ts +1 -0
- package/dist/hooks/use-shipping-quote.d.ts.map +1 -1
- package/dist/hooks/use-shipping-quote.js +3 -0
- package/dist/layouts/booking/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/booking-agenda/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/clothing/components/ClothingHomePage.d.ts.map +1 -1
- package/dist/layouts/clothing/components/ClothingHomePage.js +40 -2
- package/dist/layouts/clothing/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ProductDetailPage.js +127 -209
- package/dist/layouts/clothing/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ProductsPage.js +2 -5
- package/dist/layouts/clothing-minimal/components/ClothingHomePageMinimal.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/components/ClothingHomePageMinimal.js +5 -3
- package/dist/layouts/clothing-minimal/components/clothing-minimal-block-render.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/components/clothing-minimal-block-render.js +13 -4
- package/dist/layouts/clothing-minimal/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/clothing-minimal/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductsPage.js +2 -5
- package/dist/layouts/electronics/components/ElectronicsGridProductCard.js +1 -1
- package/dist/layouts/electronics/components/ElectronicsStoreHeader.d.ts.map +1 -1
- package/dist/layouts/electronics/components/ElectronicsStoreHeader.js +10 -9
- package/dist/layouts/electronics/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/electronics/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ProductsPage.js +2 -5
- package/dist/layouts/electronics-grid/components/ElectronicsGridProductCard.js +1 -1
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.js +4 -5
- package/dist/layouts/electronics-grid/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/electronics-grid/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ProductsPage.js +2 -5
- package/dist/layouts/food/pages/MenuPage.js +1 -1
- package/dist/layouts/food/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ProductDetailPage.js +37 -140
- package/dist/layouts/food/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ProductsPage.js +2 -5
- package/dist/layouts/food-modern/pages/MenuPage.js +1 -1
- package/dist/layouts/food-modern/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ProductDetailPage.js +130 -223
- package/dist/layouts/food-modern/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ProductsPage.js +2 -5
- package/dist/layouts/motivational-speaker/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ProductsPage.js +2 -5
- package/dist/layouts/shared/components/PdpColorSwatch.d.ts +11 -0
- package/dist/layouts/shared/components/PdpColorSwatch.d.ts.map +1 -0
- package/dist/layouts/shared/components/PdpColorSwatch.js +29 -0
- package/dist/layouts/shared/components/PdpVariationSelectors.d.ts +13 -0
- package/dist/layouts/shared/components/PdpVariationSelectors.d.ts.map +1 -0
- package/dist/layouts/shared/components/PdpVariationSelectors.js +65 -0
- package/dist/layouts/shared/components/StoreCartSheet.d.ts +8 -0
- package/dist/layouts/shared/components/StoreCartSheet.d.ts.map +1 -0
- package/dist/layouts/shared/components/StoreCartSheet.js +16 -0
- package/dist/layouts/shared/components/StoreHeader.d.ts.map +1 -1
- package/dist/layouts/shared/components/StoreHeader.js +13 -12
- package/dist/layouts/shared/components/headers/ClothingMinimalHeader.d.ts.map +1 -1
- package/dist/layouts/shared/components/headers/ClothingMinimalHeader.js +5 -7
- package/dist/layouts/shared/pages/CartPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/CartPage.js +6 -5
- package/dist/layouts/shared/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/CheckoutPage.js +209 -107
- package/dist/layouts/shared/product-category-filter-chip.d.ts +2 -0
- package/dist/layouts/shared/product-category-filter-chip.d.ts.map +1 -0
- package/dist/layouts/shared/product-category-filter-chip.js +6 -0
- package/dist/lib/pdp-cart-actions.d.ts +5 -0
- package/dist/lib/pdp-cart-actions.d.ts.map +1 -0
- package/dist/lib/pdp-cart-actions.js +19 -0
- package/dist/lib/product-variation-utils.d.ts +17 -0
- package/dist/lib/product-variation-utils.d.ts.map +1 -1
- package/dist/lib/product-variation-utils.js +193 -14
- package/dist/lib/services/checkout.service.d.ts +11 -0
- package/dist/lib/services/checkout.service.d.ts.map +1 -1
- package/dist/lib/services/shipping.service.d.ts +3 -0
- package/dist/lib/services/shipping.service.d.ts.map +1 -1
- package/dist/lib/store-config-utils.d.ts.map +1 -1
- package/dist/lib/store-config-utils.js +104 -11
- package/dist/lib/store-context.d.ts.map +1 -1
- package/dist/lib/store-context.js +23 -8
- package/dist/lib/utils/asset-helpers.d.ts +2 -0
- package/dist/lib/utils/asset-helpers.d.ts.map +1 -1
- package/dist/lib/utils/asset-helpers.js +24 -0
- package/dist/styles/index.css +143 -45
- package/package.json +8 -2
|
@@ -5,8 +5,8 @@ import { useProductReviews } from '../../../hooks/use-product-reviews.js';
|
|
|
5
5
|
import { Button } from '../../../components/ui/button.js';
|
|
6
6
|
import { Breadcrumbs } from '../../../components/ui/breadcrumbs.js';
|
|
7
7
|
import { Modal } from '../../../components/ui/modal.js';
|
|
8
|
-
import { ShoppingCart, Heart, Star, CheckCircle, ThumbsUp, User, Minus, Plus,
|
|
9
|
-
import { useState, useMemo, useEffect } from 'react';
|
|
8
|
+
import { ShoppingCart, Heart, Star, CheckCircle, ThumbsUp, User, Minus, Plus, Share2, Info } from 'lucide-react';
|
|
9
|
+
import { useState, useMemo, useEffect, useCallback } from 'react';
|
|
10
10
|
import { useStore } from '../../../lib/store-context.js';
|
|
11
11
|
import { useToast } from '../../../components/ui/toast.js';
|
|
12
12
|
import { useRouter } from 'next/navigation';
|
|
@@ -23,8 +23,12 @@ import { ButtonLoader } from '../../../components/ui/page-loader.js';
|
|
|
23
23
|
import { extractImageUrls } from '../../../lib/store-config-utils.js';
|
|
24
24
|
import { OutOfStockOverlay } from '../../../components/ui/out-of-stock-overlay.js';
|
|
25
25
|
import { cn, formatCurrency, filterActiveProducts, isEditorPreviewMode, resolvePdpProduct } from '../../../lib/utils/index.js';
|
|
26
|
+
import { usePdpVariation } from '../../../hooks/use-pdp-variation.js';
|
|
27
|
+
import { buildPdpBuyNowItem } from '../../../lib/pdp-cart-actions.js';
|
|
28
|
+
import { assertVariationSelected } from '../../../lib/product-variation-utils.js';
|
|
26
29
|
import { shippingService } from '../../../lib/services/shipping.service.js';
|
|
27
30
|
import { ProductDeliveryInfoSection } from '../../../components/shipping/ProductDeliveryInfoSection';
|
|
31
|
+
import { PdpVariationSelectors } from '../../shared/components/PdpVariationSelectors';
|
|
28
32
|
import { formatDateSafe } from '../../../utils/date';
|
|
29
33
|
// Helper function to format date
|
|
30
34
|
const formatDate = (dateString) => {
|
|
@@ -116,21 +120,11 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
116
120
|
addToast('Failed to update wishlist', 'error');
|
|
117
121
|
}
|
|
118
122
|
};
|
|
119
|
-
|
|
120
|
-
const colorVariants = product?.variants?.filter(v => v.name === 'Color') || [];
|
|
121
|
-
const sizeVariants = product?.variants?.filter(v => v.name === 'Size') || [];
|
|
122
|
-
// Initialize state with defaults
|
|
123
|
+
const { optionGroups, selectedAttributes, setAttribute, isOptionAvailable, selectedVariation, galleryImages, displayPrice, displayCompareAt, displaySKU, isOutOfStock, getOptionImage, } = usePdpVariation(product);
|
|
123
124
|
const [selectedImage, setSelectedImage] = useState(0);
|
|
124
|
-
// Ensure selectedImage is within bounds when images change
|
|
125
125
|
useEffect(() => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const timer = setTimeout(() => setSelectedImage(0), 0);
|
|
129
|
-
return () => clearTimeout(timer);
|
|
130
|
-
}
|
|
131
|
-
}, [product, selectedImage]);
|
|
132
|
-
const [selectedColor, setSelectedColor] = useState(colorVariants.length > 0 ? colorVariants[0].value : null);
|
|
133
|
-
const [selectedSize, setSelectedSize] = useState(sizeVariants.length > 0 ? sizeVariants[0].value : null);
|
|
126
|
+
setSelectedImage(0);
|
|
127
|
+
}, [selectedVariation?.id, galleryImages.join('|')]);
|
|
134
128
|
const [quantity, setQuantity] = useState(1);
|
|
135
129
|
const [showAllReviews, setShowAllReviews] = useState(false);
|
|
136
130
|
const [isReviewModalOpen, setIsReviewModalOpen] = useState(false);
|
|
@@ -151,6 +145,102 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
151
145
|
const [shippingError, setShippingError] = useState(null);
|
|
152
146
|
const [freeShippingEligible, setFreeShippingEligible] = useState(false);
|
|
153
147
|
const [freeShippingThreshold, setFreeShippingThreshold] = useState(undefined);
|
|
148
|
+
const calculateShipping = useCallback(async () => {
|
|
149
|
+
if (!product || !shippingAddress.country || !shippingAddress.city) {
|
|
150
|
+
setShippingError('Please provide country and city to calculate shipping');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
setIsCalculatingShipping(true);
|
|
154
|
+
setShippingError(null);
|
|
155
|
+
try {
|
|
156
|
+
const currency = product.currency || storeConfig.settings?.currency || 'USD';
|
|
157
|
+
const subtotal = displayPrice * quantity;
|
|
158
|
+
const result = await shippingService.calculateShipping({
|
|
159
|
+
storeId: storeConfig.id,
|
|
160
|
+
address: {
|
|
161
|
+
country: shippingAddress.country,
|
|
162
|
+
city: shippingAddress.city,
|
|
163
|
+
zipCode: shippingAddress.zipCode,
|
|
164
|
+
},
|
|
165
|
+
items: [{ productId: product.id, quantity }],
|
|
166
|
+
subtotal,
|
|
167
|
+
currency,
|
|
168
|
+
});
|
|
169
|
+
setShippingMethods(result.methods || []);
|
|
170
|
+
setFreeShippingEligible(result.freeShippingEligible || false);
|
|
171
|
+
setFreeShippingThreshold(result.freeShippingThreshold);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.error('Shipping calculation error:', error);
|
|
175
|
+
setShippingError(error instanceof Error ? error.message : 'Failed to calculate shipping. Please try again.');
|
|
176
|
+
setShippingMethods([]);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
setIsCalculatingShipping(false);
|
|
180
|
+
}
|
|
181
|
+
}, [
|
|
182
|
+
product,
|
|
183
|
+
shippingAddress.country,
|
|
184
|
+
shippingAddress.city,
|
|
185
|
+
shippingAddress.zipCode,
|
|
186
|
+
quantity,
|
|
187
|
+
displayPrice,
|
|
188
|
+
storeConfig.id,
|
|
189
|
+
storeConfig.settings?.currency,
|
|
190
|
+
]);
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
const loadAddresses = async () => {
|
|
193
|
+
if (isAuthenticated) {
|
|
194
|
+
try {
|
|
195
|
+
const addresses = await customerService.getAddresses();
|
|
196
|
+
setSavedAddresses(addresses);
|
|
197
|
+
if (addresses.length > 0) {
|
|
198
|
+
const defaultAddress = addresses.find((a) => a.isDefault) || addresses[0];
|
|
199
|
+
if (defaultAddress) {
|
|
200
|
+
setShippingAddress({
|
|
201
|
+
country: defaultAddress.country || '',
|
|
202
|
+
city: defaultAddress.city || '',
|
|
203
|
+
zipCode: defaultAddress.zipCode || '',
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
console.error('Failed to load addresses:', error);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
loadAddresses();
|
|
214
|
+
}, [isAuthenticated]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (!shippingAddress.country || !shippingAddress.city || !product)
|
|
217
|
+
return;
|
|
218
|
+
const timer = setTimeout(() => {
|
|
219
|
+
calculateShipping();
|
|
220
|
+
}, 500);
|
|
221
|
+
return () => clearTimeout(timer);
|
|
222
|
+
}, [
|
|
223
|
+
shippingAddress.country,
|
|
224
|
+
shippingAddress.city,
|
|
225
|
+
shippingAddress.zipCode,
|
|
226
|
+
quantity,
|
|
227
|
+
product?.id,
|
|
228
|
+
displayPrice,
|
|
229
|
+
calculateShipping,
|
|
230
|
+
]);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (product && storeConfig?.id) {
|
|
233
|
+
trackEvent({
|
|
234
|
+
eventType: 'product_view',
|
|
235
|
+
metadata: {
|
|
236
|
+
productId: product.id,
|
|
237
|
+
productName: product.name,
|
|
238
|
+
categoryId: product.categoryId,
|
|
239
|
+
price: displayPrice,
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}, [product?.id, storeConfig?.id, displayPrice, trackEvent]);
|
|
154
244
|
const handleSubmitReview = async (e) => {
|
|
155
245
|
e.preventDefault();
|
|
156
246
|
if (!product?.id)
|
|
@@ -189,8 +279,6 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
189
279
|
if (!product) {
|
|
190
280
|
return (_jsx("div", { className: "min-h-screen bg-white flex items-center justify-center p-8", children: _jsxs("div", { className: "text-center", children: [_jsx("h1", { className: "text-2xl font-bold mb-2", children: "Product Not Found" }), _jsx("p", { className: "text-gray-600 mb-4", children: "The product you're looking for doesn't exist." })] }) }));
|
|
191
281
|
}
|
|
192
|
-
// Use SKU for display, fallback to generated SKU from slug if not available
|
|
193
|
-
const displaySKU = product.sku || product.slug?.toUpperCase().replace(/-/g, '').substring(0, 12).padEnd(8, 'X') || 'N/A';
|
|
194
282
|
// Build category breadcrumb path with all parent categories
|
|
195
283
|
const buildCategoryPath = (categoryId) => {
|
|
196
284
|
if (!categoryId)
|
|
@@ -224,42 +312,7 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
224
312
|
// Extract product images - product.images should already be string[] from transformation,
|
|
225
313
|
// but handle edge cases where it might still be in object format
|
|
226
314
|
// Use the comprehensive extraction utility from store-config-utils for consistency
|
|
227
|
-
const productImages = (
|
|
228
|
-
// Debug: Log the raw product.images to understand its format
|
|
229
|
-
if (process.env.NODE_ENV === 'development') {
|
|
230
|
-
console.log('[ProductDetailPage] Raw product.images:', {
|
|
231
|
-
productId: product.id,
|
|
232
|
-
productName: product.name,
|
|
233
|
-
images: product.images,
|
|
234
|
-
imagesType: typeof product.images,
|
|
235
|
-
imagesIsArray: Array.isArray(product.images),
|
|
236
|
-
imagesLength: Array.isArray(product.images) ? product.images.length : 'N/A',
|
|
237
|
-
firstItem: Array.isArray(product.images) && product.images.length > 0 ? product.images[0] : 'N/A',
|
|
238
|
-
firstItemType: Array.isArray(product.images) && product.images.length > 0 ? typeof product.images[0] : 'N/A'
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
// If already an array of strings (normal case after transformation)
|
|
242
|
-
if (Array.isArray(product.images) && product.images.length > 0) {
|
|
243
|
-
const firstItem = product.images[0];
|
|
244
|
-
if (typeof firstItem === 'string') {
|
|
245
|
-
const filtered = product.images.filter((img) => typeof img === 'string' && img.trim().length > 0);
|
|
246
|
-
if (process.env.NODE_ENV === 'development') {
|
|
247
|
-
console.log('[ProductDetailPage] Using string array directly:', { count: filtered.length, firstImage: filtered[0]?.substring(0, 100) });
|
|
248
|
-
}
|
|
249
|
-
return filtered;
|
|
250
|
-
}
|
|
251
|
-
// If array but not strings, extract using utility
|
|
252
|
-
if (process.env.NODE_ENV === 'development') {
|
|
253
|
-
console.log('[ProductDetailPage] Array but not strings, using extractImageUrls');
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// Use the comprehensive extraction utility for any other format (objects, nested structures, etc.)
|
|
257
|
-
const extracted = extractImageUrls(product.images);
|
|
258
|
-
if (process.env.NODE_ENV === 'development') {
|
|
259
|
-
console.log('[ProductDetailPage] Extracted using utility:', { count: extracted.length, firstImage: extracted[0]?.substring(0, 100) });
|
|
260
|
-
}
|
|
261
|
-
return extracted;
|
|
262
|
-
})();
|
|
315
|
+
const productImages = galleryImages.length > 0 ? galleryImages : extractImageUrls(product.images);
|
|
263
316
|
// For gallery, use actual images only (don't duplicate to fill 5 slots)
|
|
264
317
|
const displayImages = productImages.slice(0, 5);
|
|
265
318
|
const hasMoreImages = productImages.length > 5;
|
|
@@ -284,20 +337,6 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
284
337
|
});
|
|
285
338
|
}
|
|
286
339
|
}
|
|
287
|
-
// Color swatch mapping
|
|
288
|
-
const colorSwatches = {
|
|
289
|
-
'White': '#FFFFFF',
|
|
290
|
-
'Black': '#000000',
|
|
291
|
-
'Gray': '#808080',
|
|
292
|
-
'Grey': '#808080',
|
|
293
|
-
'Blue': '#3B82F6',
|
|
294
|
-
'Red': '#EF4444',
|
|
295
|
-
'Green': '#10B981',
|
|
296
|
-
'Yellow': '#FBBF24',
|
|
297
|
-
'Brown': '#92400E',
|
|
298
|
-
'Navy': '#1E3A8A',
|
|
299
|
-
'Beige': '#F5F5DC',
|
|
300
|
-
};
|
|
301
340
|
// Reviews loaded from API (product payload does not include review rows)
|
|
302
341
|
const displayedReviews = showAllReviews ? reviews : reviews.slice(0, 3);
|
|
303
342
|
const hasMoreReviews = reviews.length > 3;
|
|
@@ -306,7 +345,6 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
306
345
|
? reviews.reduce((sum, review) => sum + review.rating, 0) / reviews.length
|
|
307
346
|
: Number(product.rating) || 0;
|
|
308
347
|
// Out of stock check
|
|
309
|
-
const isOutOfStock = !product.inStock;
|
|
310
348
|
// Calculate rating distribution
|
|
311
349
|
const ratingDistribution = [5, 4, 3, 2, 1].map(rating => {
|
|
312
350
|
const count = reviews.filter(r => Math.round(r.rating) === rating).length;
|
|
@@ -316,29 +354,19 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
316
354
|
percentage: reviews.length > 0 ? (count / reviews.length) * 100 : 0,
|
|
317
355
|
};
|
|
318
356
|
});
|
|
319
|
-
const handleAddToCart = () => {
|
|
357
|
+
const handleAddToCart = async () => {
|
|
320
358
|
if (isOutOfStock) {
|
|
321
359
|
addToast('This product is currently out of stock', 'error');
|
|
322
360
|
return;
|
|
323
361
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const sizeMatch = !selectedSize || attrs.size === selectedSize;
|
|
332
|
-
return colorMatch && sizeMatch;
|
|
333
|
-
});
|
|
334
|
-
variationId = matchingVariation?.id;
|
|
362
|
+
try {
|
|
363
|
+
assertVariationSelected(product, selectedVariation, selectedAttributes);
|
|
364
|
+
await addToCart(product, quantity, selectedVariation?.id);
|
|
365
|
+
addToast(`${product.name} added to cart`, 'success');
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
addToast(error instanceof Error ? error.message : 'Could not add to cart', 'error');
|
|
335
369
|
}
|
|
336
|
-
// Fallback to composite string for backward compatibility if no variation found
|
|
337
|
-
const variantId = variationId || (selectedColor || selectedSize
|
|
338
|
-
? [selectedColor, selectedSize].filter(Boolean).join(' / ')
|
|
339
|
-
: undefined);
|
|
340
|
-
addToCart(product, quantity, variantId);
|
|
341
|
-
addToast(`${product.name} added to cart`, 'success');
|
|
342
370
|
};
|
|
343
371
|
const handleBuyNow = async () => {
|
|
344
372
|
if (isOutOfStock) {
|
|
@@ -350,43 +378,14 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
350
378
|
}
|
|
351
379
|
setIsBuyNowLoading(true);
|
|
352
380
|
try {
|
|
353
|
-
|
|
354
|
-
// Note: StoreProduct uses 'variants' not 'variations'
|
|
355
|
-
let variationId;
|
|
356
|
-
let variantName;
|
|
357
|
-
if (product.variants && Array.isArray(product.variants) && product.variants.length > 0) {
|
|
358
|
-
const matchingVariation = product.variants.find((variation) => {
|
|
359
|
-
const attrs = variation.attributes || {};
|
|
360
|
-
const colorMatch = !selectedColor || attrs.color === selectedColor;
|
|
361
|
-
const sizeMatch = !selectedSize || attrs.size === selectedSize;
|
|
362
|
-
return colorMatch && sizeMatch;
|
|
363
|
-
});
|
|
364
|
-
variationId = matchingVariation?.id;
|
|
365
|
-
variantName = matchingVariation?.name || matchingVariation?.value;
|
|
366
|
-
}
|
|
367
|
-
// Fallback to composite string for backward compatibility if no variation found
|
|
368
|
-
const variantId = variationId || (selectedColor || selectedSize
|
|
369
|
-
? [selectedColor, selectedSize].filter(Boolean).join(' / ')
|
|
370
|
-
: undefined);
|
|
371
|
-
// Create buy now item (don't add to cart)
|
|
372
|
-
const buyNowItemId = variantId ? `${product.id}-${variantId}` : product.id;
|
|
373
|
-
const buyNowItem = {
|
|
374
|
-
id: buyNowItemId,
|
|
375
|
-
productId: product.id,
|
|
376
|
-
quantity,
|
|
377
|
-
variantId,
|
|
378
|
-
variantName: variantName || variantId,
|
|
379
|
-
price: product.price,
|
|
380
|
-
product
|
|
381
|
-
};
|
|
382
|
-
// Set buy now item and navigate directly to checkout
|
|
381
|
+
const buyNowItem = buildPdpBuyNowItem(product, quantity, selectedVariation, displayPrice, selectedAttributes);
|
|
383
382
|
setBuyNowItem(buyNowItem);
|
|
384
383
|
// Navigate to checkout page for direct checkout
|
|
385
384
|
router.push(`/${storeConfig.slug}/checkout`);
|
|
386
385
|
}
|
|
387
386
|
catch (error) {
|
|
388
387
|
console.error('Buy Now error:', error);
|
|
389
|
-
addToast('Failed to proceed to checkout. Please try again.', 'error');
|
|
388
|
+
addToast(error instanceof Error ? error.message : 'Failed to proceed to checkout. Please try again.', 'error');
|
|
390
389
|
}
|
|
391
390
|
finally {
|
|
392
391
|
setIsBuyNowLoading(false);
|
|
@@ -399,116 +398,24 @@ export function ProductDetailPage({ storeConfig: initialConfig, productSlug }) {
|
|
|
399
398
|
// Note: This is now only used for other flows, not buy now
|
|
400
399
|
// Buy now now redirects to checkout page
|
|
401
400
|
};
|
|
402
|
-
// Calculate shipping when address is provided
|
|
403
|
-
const calculateShipping = async () => {
|
|
404
|
-
if (!product || !shippingAddress.country || !shippingAddress.city) {
|
|
405
|
-
setShippingError('Please provide country and city to calculate shipping');
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
setIsCalculatingShipping(true);
|
|
409
|
-
setShippingError(null);
|
|
410
|
-
try {
|
|
411
|
-
const currency = product.currency || storeConfig.settings?.currency || 'USD';
|
|
412
|
-
const subtotal = product.price * quantity;
|
|
413
|
-
const result = await shippingService.calculateShipping({
|
|
414
|
-
storeId: storeConfig.id,
|
|
415
|
-
address: {
|
|
416
|
-
country: shippingAddress.country,
|
|
417
|
-
city: shippingAddress.city,
|
|
418
|
-
zipCode: shippingAddress.zipCode,
|
|
419
|
-
},
|
|
420
|
-
items: [{
|
|
421
|
-
productId: product.id,
|
|
422
|
-
quantity: quantity,
|
|
423
|
-
}],
|
|
424
|
-
subtotal: subtotal,
|
|
425
|
-
currency: currency,
|
|
426
|
-
});
|
|
427
|
-
setShippingMethods(result.methods || []);
|
|
428
|
-
setFreeShippingEligible(result.freeShippingEligible || false);
|
|
429
|
-
setFreeShippingThreshold(result.freeShippingThreshold);
|
|
430
|
-
}
|
|
431
|
-
catch (error) {
|
|
432
|
-
console.error('Shipping calculation error:', error);
|
|
433
|
-
setShippingError(error.message || 'Failed to calculate shipping. Please try again.');
|
|
434
|
-
setShippingMethods([]);
|
|
435
|
-
}
|
|
436
|
-
finally {
|
|
437
|
-
setIsCalculatingShipping(false);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
// Load saved addresses for authenticated users and auto-populate shipping address
|
|
441
|
-
useEffect(() => {
|
|
442
|
-
const loadAddresses = async () => {
|
|
443
|
-
if (isAuthenticated) {
|
|
444
|
-
try {
|
|
445
|
-
const addresses = await customerService.getAddresses();
|
|
446
|
-
setSavedAddresses(addresses);
|
|
447
|
-
// Auto-populate with default address or first address if available
|
|
448
|
-
if (addresses.length > 0) {
|
|
449
|
-
const defaultAddress = addresses.find(a => a.isDefault) || addresses[0];
|
|
450
|
-
if (defaultAddress) {
|
|
451
|
-
setShippingAddress({
|
|
452
|
-
country: defaultAddress.country || '',
|
|
453
|
-
city: defaultAddress.city || '',
|
|
454
|
-
zipCode: defaultAddress.zipCode || '',
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
catch (error) {
|
|
460
|
-
console.error('Failed to load addresses:', error);
|
|
461
|
-
// Don't show error toast - addresses are optional
|
|
462
|
-
// Users can still manually enter shipping address
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
loadAddresses();
|
|
467
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
468
|
-
}, [isAuthenticated]);
|
|
469
|
-
// Auto-calculate shipping when address fields are filled (debounced)
|
|
470
|
-
useEffect(() => {
|
|
471
|
-
if (!shippingAddress.country || !shippingAddress.city || !product) {
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
const timer = setTimeout(() => {
|
|
475
|
-
calculateShipping();
|
|
476
|
-
}, 500); // Debounce 500ms
|
|
477
|
-
return () => clearTimeout(timer);
|
|
478
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
479
|
-
}, [shippingAddress.country, shippingAddress.city, shippingAddress.zipCode, quantity, product?.id, product?.price]);
|
|
480
|
-
// Track product view
|
|
481
|
-
useEffect(() => {
|
|
482
|
-
if (product && storeConfig?.id) {
|
|
483
|
-
trackEvent({
|
|
484
|
-
eventType: 'product_view',
|
|
485
|
-
metadata: {
|
|
486
|
-
productId: product.id,
|
|
487
|
-
productName: product.name,
|
|
488
|
-
categoryId: product.categoryId,
|
|
489
|
-
price: product.price,
|
|
490
|
-
},
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
}, [product?.id, storeConfig?.id, trackEvent]);
|
|
494
401
|
return (_jsxs("div", { className: "min-h-screen bg-white", children: [_jsxs("div", { "data-content-ready": true, className: "container mx-auto px-4 sm:px-6 lg:px-8 py-8 lg:py-12 max-w-7xl", children: [_jsx("div", { className: "mb-6", children: _jsx(Breadcrumbs, { items: breadcrumbItems }) }), _jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-16 mb-20", children: [_jsxs("div", { className: "relative lg:sticky lg:top-24 self-start z-0", children: [_jsxs("div", { className: "relative aspect-square bg-gray-50 rounded-xl overflow-hidden mb-4 border border-gray-100 shadow-sm group", children: [_jsx(ImageWithFallback, { "data-product-image": true, src: displayImages[selectedImage] || displayImages[0] || productImages[0], alt: product.name, className: cn("w-full h-full object-cover transition-transform duration-300 group-hover:scale-105", isOutOfStock && "grayscale"), skeletonAspectRatio: "square" }), isOutOfStock && (_jsx(OutOfStockOverlay, { badgePosition: "center" }))] }), displayImages.length > 0 && (_jsxs("div", { className: "grid grid-cols-5 gap-2", children: [displayImages.map((image, index) => (_jsx("button", { onClick: () => setSelectedImage(Math.min(index, displayImages.length - 1)), className: `aspect-square rounded-lg overflow-hidden border-2 transition-all ${selectedImage === index
|
|
495
402
|
? 'border-gray-900 ring-2 ring-gray-900 ring-offset-2'
|
|
496
403
|
: 'border-gray-200 hover:border-gray-300'}`, children: _jsx(ImageWithFallback, { src: image, alt: `${product.name} view ${index + 1}`, className: cn("w-full h-full object-cover", isOutOfStock && "grayscale"), skeletonAspectRatio: "square" }) }, index))), hasMoreImages && (_jsxs("div", { className: "aspect-square rounded-lg border-2 border-gray-200 bg-gray-50 flex items-center justify-center text-xs text-gray-500 font-medium", children: ["+", productImages.length - 5, " more"] }))] }))] }), _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center justify-between mb-2", children: [_jsx("span", { className: "text-sm font-semibold text-gray-700 uppercase tracking-wide", children: (() => {
|
|
497
404
|
const brandMatch = product.name.match(/\b(Sony|Samsung|Apple|LG|Dell|HP|Microsoft|Logitech|Razer|Corsair|Asus|Acer|Lenovo)\b/i);
|
|
498
405
|
return brandMatch ? brandMatch[1] : storeConfig.name;
|
|
499
|
-
})() }), _jsx("button", { onClick: handleShare, className: "text-gray-400 hover:text-gray-900 transition-colors p-2 rounded-full hover:bg-gray-100", title: "Share this product", children: _jsx(Share2, { className: "h-5 w-5" }) })] }), _jsx("h1", { "data-product-name": true, className: "text-3xl sm:text-4xl lg:text-5xl font-bold text-gray-900 mb-3 leading-tight tracking-tight", children: product.name }), _jsxs("p", { className: "text-sm text-gray-500 mb-6 font-mono", children: ["SKU: ", displaySKU] }), _jsx("div", { className: "mb-4 flex items-center gap-2", children:
|
|
500
|
-
const colorValue = variant.value;
|
|
501
|
-
const swatchColor = colorSwatches[colorValue] || '#CCCCCC';
|
|
502
|
-
const isSelected = selectedColor === colorValue;
|
|
503
|
-
return (_jsx("button", { onClick: () => setSelectedColor(colorValue), className: `relative w-12 h-12 rounded-full border-2 transition-all ${isSelected
|
|
504
|
-
? 'border-gray-900 ring-2 ring-gray-900 ring-offset-2 scale-105'
|
|
505
|
-
: 'border-gray-200 hover:border-gray-300'}`, style: { backgroundColor: swatchColor }, title: colorValue, children: isSelected && (_jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: _jsx(CheckCircle, { className: `h-5 w-5 ${['White', 'Beige', 'Yellow'].includes(colorValue) ? 'text-gray-900' : 'text-white'} drop-shadow-sm` }) })) }, variant.id));
|
|
506
|
-
}) })] })), sizeVariants.length > 0 && (_jsxs("div", { className: "mb-8", children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-sm font-semibold text-gray-900", children: "Size:" }), _jsx("span", { className: "text-sm text-gray-600", children: selectedSize || 'Select Size' })] }), _jsxs("a", { href: `/${storeConfig.slug}/size-guide`, target: "_blank", rel: "noopener noreferrer", className: "flex items-center gap-1.5 text-xs font-medium text-gray-600 hover:text-gray-900 underline decoration-gray-400 underline-offset-4", children: [_jsx(Ruler, { className: "h-3.5 w-3.5" }), " Size guide"] })] }), _jsx("div", { className: "grid grid-cols-4 sm:grid-cols-5 gap-2.5", children: sizeVariants.map((variant) => {
|
|
507
|
-
const isSelected = selectedSize === variant.value;
|
|
508
|
-
return (_jsx("button", { onClick: () => setSelectedSize(variant.value), className: `px-4 py-3 rounded-lg border-2 text-sm font-semibold transition-all ${isSelected
|
|
509
|
-
? 'bg-gray-900 text-white border-gray-900 shadow-md transform -translate-y-0.5'
|
|
510
|
-
: 'bg-white text-gray-700 border-gray-200 hover:border-gray-300 hover:bg-gray-50'}`, children: variant.value }, variant.id));
|
|
511
|
-
}) })] })), _jsxs("div", { className: "flex flex-col gap-4 mb-8", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("span", { className: "text-sm font-semibold text-gray-900", children: "Quantity" }), _jsxs("div", { className: "flex items-center border border-gray-300 rounded-lg", children: [_jsx("button", { className: "p-3 text-gray-600 hover:bg-gray-100 rounded-l-lg disabled:opacity-50", onClick: () => setQuantity(Math.max(1, quantity - 1)), disabled: quantity <= 1, children: _jsx(Minus, { className: "h-4 w-4" }) }), _jsx("span", { className: "w-12 text-center font-semibold text-gray-900", children: quantity }), _jsx("button", { className: "p-3 text-gray-600 hover:bg-gray-100 rounded-r-lg", onClick: () => setQuantity(quantity + 1), children: _jsx(Plus, { className: "h-4 w-4" }) })] })] }), _jsxs("div", { className: "flex flex-col sm:flex-row gap-3 mt-2", children: [_jsx(Button, { "data-add-to-cart": true, size: "lg", onClick: handleAddToCart, disabled: isCartLoading || isOutOfStock, className: "flex-1 bg-white border-2 border-gray-900 text-gray-900 hover:bg-gray-50 rounded-full h-14 text-base font-bold shadow-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed", children: isCartLoading ? (_jsxs(_Fragment, { children: [_jsx(ButtonLoader, { className: "mr-2" }), "Adding..."] })) : (_jsxs(_Fragment, { children: [_jsx(ShoppingCart, { className: "h-5 w-5 mr-2" }), "Add to Cart"] })) }), _jsx(Button, { size: "lg", onClick: handleBuyNow, disabled: isOutOfStock || isBuyNowLoading || isCartLoading, className: "flex-1 bg-gray-900 hover:bg-gray-800 text-white rounded-full h-14 text-base font-bold shadow-lg hover:shadow-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed", children: isBuyNowLoading || isCartLoading ? (_jsxs(_Fragment, { children: [_jsx(ButtonLoader, { className: "mr-2" }), "Adding..."] })) : ('Buy Now') }), storeConfig.features.wishlist && (_jsx(Button, { variant: "outline", size: "lg", onClick: handleWishlistClick, disabled: isWishlistLoading || !product, className: cn("h-14 w-14 rounded-full border-2 transition-all disabled:opacity-50 disabled:cursor-not-allowed", product && isInWishlist(product.id)
|
|
406
|
+
})() }), _jsx("button", { onClick: handleShare, className: "text-gray-400 hover:text-gray-900 transition-colors p-2 rounded-full hover:bg-gray-100", title: "Share this product", children: _jsx(Share2, { className: "h-5 w-5" }) })] }), _jsx("h1", { "data-product-name": true, className: "text-3xl sm:text-4xl lg:text-5xl font-bold text-gray-900 mb-3 leading-tight tracking-tight", children: product.name }), _jsxs("p", { className: "text-sm text-gray-500 mb-6 font-mono", children: ["SKU: ", displaySKU] }), _jsx("div", { className: "mb-4 flex items-center gap-2", children: !isOutOfStock ? (_jsxs("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800", children: [_jsx(CheckCircle, { className: "w-3 h-3 mr-1" }), "In Stock"] })) : (_jsxs("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800", children: [_jsx(Info, { className: "w-3 h-3 mr-1" }), "Out of Stock"] })) }), _jsxs("div", { className: "mb-8", children: [_jsxs("div", { className: "flex items-baseline gap-4", children: [_jsx("span", { "data-product-price": true, className: "text-4xl lg:text-5xl font-bold text-gray-900", children: formatCurrency(displayPrice, product.currency || 'USD') }), displayCompareAt != null && displayCompareAt > displayPrice && (_jsx("span", { className: "text-2xl text-gray-500 line-through", children: formatCurrency(displayCompareAt, product.currency || 'USD') }))] }), displayCompareAt != null && displayCompareAt > displayPrice && (_jsxs("span", { className: "inline-block mt-2 bg-red-100 text-red-700 text-xs font-bold px-2 py-1 rounded", children: ["SAVE ", Math.round(((displayCompareAt - displayPrice) / displayCompareAt) * 100), "%"] }))] }), _jsx(PdpVariationSelectors, { optionGroups: optionGroups, selectedAttributes: selectedAttributes, setAttribute: setAttribute, isOptionAvailable: isOptionAvailable, getOptionImage: getOptionImage, storeSlug: storeConfig.slug, showSizeGuide: productDetailConfig?.showSizeGuide !== false, onAfterClearAttribute: () => setQuantity(1) }), _jsxs("div", { className: "flex flex-col gap-4 mb-8", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("span", { className: "text-sm font-semibold text-gray-900", children: "Quantity" }), _jsxs("div", { className: "flex items-center border border-gray-300 rounded-lg", children: [_jsx("button", { className: "p-3 text-gray-600 hover:bg-gray-100 rounded-l-lg disabled:opacity-50", onClick: () => setQuantity(Math.max(1, quantity - 1)), disabled: quantity <= 1, children: _jsx(Minus, { className: "h-4 w-4" }) }), _jsx("span", { className: "w-12 text-center font-semibold text-gray-900", children: quantity }), _jsx("button", { className: "p-3 text-gray-600 hover:bg-gray-100 rounded-r-lg", onClick: () => setQuantity(quantity + 1), children: _jsx(Plus, { className: "h-4 w-4" }) })] })] }), _jsxs("div", { className: "flex flex-row items-stretch gap-2 sm:gap-3 mt-2 w-full", children: [_jsx(Button, { "data-add-to-cart": true, variant: "outline", size: "lg", onClick: handleAddToCart, disabled: isCartLoading || isOutOfStock, className: "flex-1 min-w-0 bg-white border-2 border-gray-900 text-gray-900 hover:bg-gray-50 rounded-full h-12 sm:h-14 px-3 sm:px-6 text-sm sm:text-base font-bold [&_svg]:text-gray-900 shadow-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed", children: isCartLoading ? (_jsxs(_Fragment, { children: [_jsx(ButtonLoader, { className: "mr-1.5 sm:mr-2" }), "Adding..."] })) : (_jsxs(_Fragment, { children: [_jsx(ShoppingCart, { className: "h-4 w-4 sm:h-5 sm:w-5 mr-1.5 sm:mr-2 shrink-0 text-gray-900" }), "Add to Cart"] })) }), _jsx(Button, { size: "lg", onClick: handleBuyNow, disabled: isOutOfStock || isBuyNowLoading || isCartLoading, className: "flex-1 min-w-0 bg-gray-900 hover:bg-gray-800 text-white rounded-full h-12 sm:h-14 px-3 sm:px-6 text-sm sm:text-base font-bold shadow-lg hover:shadow-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed", children: isBuyNowLoading || isCartLoading ? (_jsxs(_Fragment, { children: [_jsx(ButtonLoader, { className: "mr-1.5 sm:mr-2" }), "Adding..."] })) : ('Buy Now') }), storeConfig.features.wishlist && (_jsx(Button, { variant: "outline", size: "lg", onClick: handleWishlistClick, disabled: isWishlistLoading || !product, className: cn("h-12 w-12 sm:h-14 sm:w-14 shrink-0 rounded-full border-2 transition-all disabled:opacity-50 disabled:cursor-not-allowed", product && isInWishlist(product.id)
|
|
512
407
|
? "border-red-500 bg-red-50 text-red-500 hover:bg-red-100"
|
|
513
|
-
: "border-gray-200 hover:border-gray-300 hover:bg-gray-50"), children: isWishlistLoading ? (_jsx(ButtonLoader, { className: "h-5 w-5" })) : (_jsx(Heart, { className: cn("h-5 w-5", product && isInWishlist(product.id) && "fill-current") })) }))] })] }), _jsx(ProductDeliveryInfoSection, { storeConfig: storeConfig, currency: storeConfig.settings?.currency || 'USD', productCurrency: product.currency, productPrice:
|
|
408
|
+
: "border-gray-200 hover:border-gray-300 hover:bg-gray-50"), children: isWishlistLoading ? (_jsx(ButtonLoader, { className: "h-5 w-5" })) : (_jsx(Heart, { className: cn("h-5 w-5", product && isInWishlist(product.id) && "fill-current") })) }))] })] }), _jsx(ProductDeliveryInfoSection, { storeConfig: storeConfig, currency: storeConfig.settings?.currency || 'USD', productCurrency: product.currency, productPrice: displayPrice, quantity: quantity, shippingAddress: shippingAddress, updateShippingAddress: (patch) => setShippingAddress((prev) => ({ ...prev, ...patch })), shippingMethods: shippingMethods, isCalculatingShipping: isCalculatingShipping, shippingError: shippingError, freeShippingEligible: freeShippingEligible, freeShippingThreshold: freeShippingThreshold, onToast: addToast }), product.description && (_jsxs("div", { className: "mb-8", children: [_jsx("h2", { className: "text-lg font-semibold text-gray-900 mb-3", children: "Description" }), _jsxs("div", { className: "prose prose-sm max-w-none text-gray-600 leading-relaxed", children: [_jsx(SafeRichHtml, { value: product.description, fallbackPlain: "", as: "div" }), _jsxs("ul", { className: "list-disc pl-5 space-y-1 mt-2", children: [_jsx("li", { children: "Premium quality material" }), _jsx("li", { children: "Comfortable fit for all-day wear" }), _jsx("li", { children: "Durable stitching and finish" })] })] })] })), product.specifications && Object.keys(product.specifications).length > 0 && (_jsxs("div", { className: "mb-8", children: [_jsx("h2", { className: "text-lg font-semibold text-gray-900 mb-4", children: "Specifications" }), _jsx("dl", { className: "grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-4", children: Object.entries(product.specifications).map(([key, value]) => (_jsxs("div", { className: "flex flex-col p-3 bg-gray-50 rounded-lg", children: [_jsx("dt", { className: "text-xs text-gray-500 font-medium uppercase tracking-wider mb-1", children: key }), _jsx("dd", { className: "text-sm font-bold text-gray-900", children: value })] }, key))) })] }))] })] }), _jsx("div", { className: "mt-20 pt-16 border-t border-gray-200", children: _jsxs("div", { className: "max-w-4xl", children: [_jsxs("div", { className: "flex flex-col sm:flex-row items-start sm:items-center justify-between gap-6 mb-10", children: [_jsxs("div", { className: "flex-1", children: [_jsx("h2", { className: "text-2xl lg:text-3xl font-bold text-gray-900 mb-4", children: "Customer Reviews" }), reviewCount > 0 && averageRating > 0 && (_jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(StarRating, { rating: averageRating, size: "lg" }), _jsx("span", { className: "text-2xl font-bold text-gray-900", children: averageRating.toFixed(1) }), _jsx("span", { className: "text-lg text-gray-500", children: "out of 5" })] }), _jsx("span", { className: "text-gray-300", children: "|" }), _jsxs("span", { className: "text-lg text-gray-600", children: [reviewCount, " ", reviewCount === 1 ? 'review' : 'reviews'] })] }))] }), reviewCount > 0 && (_jsx(Button, { onClick: () => {
|
|
409
|
+
if (!isAuthenticated) {
|
|
410
|
+
openLogin({ onSuccess: () => setIsReviewModalOpen(true) });
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
setIsReviewModalOpen(true);
|
|
414
|
+
}, className: "rounded-full shrink-0 bg-gray-900 hover:bg-gray-800 text-white", children: "Write a Review" }))] }), ratingDistribution.some(r => r.count > 0) && (_jsxs("div", { className: "mb-10 p-6 bg-gray-50 rounded-xl border border-gray-100", children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 mb-5", children: "Rating Breakdown" }), _jsx("div", { className: "space-y-3", children: ratingDistribution.map(({ rating, count, percentage }) => (_jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "flex items-center gap-1.5 w-20", children: [_jsx("span", { className: "text-sm font-semibold text-gray-900", children: rating }), _jsx(Star, { className: "h-4 w-4 fill-gray-900 text-gray-900" })] }), _jsx("div", { className: "flex-1 h-2.5 bg-gray-200 rounded-full overflow-hidden", children: _jsx("div", { className: "h-full bg-gradient-to-r from-gray-700 to-gray-900 rounded-full transition-all duration-500", style: { width: `${percentage}%` } }) }), _jsx("span", { className: "text-sm font-medium text-gray-700 w-12 text-right", children: count })] }, rating))) })] })), reviews.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "space-y-6", children: displayedReviews.map((review) => (_jsx(ReviewCard, { review: review }, review.id))) }), hasMoreReviews && !showAllReviews && (_jsx("div", { className: "mt-8 text-center", children: _jsxs(Button, { variant: "outline", onClick: () => setShowAllReviews(true), className: "px-8 rounded-full h-12 border-gray-300", children: ["Show All ", reviews.length, " Reviews"] }) }))] })) : (_jsxs("div", { className: "text-center py-12 bg-gray-50 rounded-xl border border-dashed border-gray-300", children: [_jsx("div", { className: "inline-flex items-center justify-center w-12 h-12 rounded-full bg-white shadow-sm mb-4", children: _jsx(Star, { className: "h-6 w-6 text-gray-400" }) }), _jsx("h3", { className: "text-lg font-semibold text-gray-900 mb-2", children: "No Reviews Yet" }), _jsx("p", { className: "text-gray-500 max-w-sm mx-auto mb-6", children: "Be the first to review this product and help other customers make informed decisions." }), _jsx(Button, { onClick: () => {
|
|
415
|
+
if (!isAuthenticated) {
|
|
416
|
+
openLogin({ onSuccess: () => setIsReviewModalOpen(true) });
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
setIsReviewModalOpen(true);
|
|
420
|
+
}, className: "bg-gray-900 hover:bg-gray-800 text-white", children: "Write a Review" })] }))] }) }), relatedProducts.length > 0 && (_jsxs("div", { className: "mt-20 pt-16 border-t border-gray-200", children: [_jsx("h2", { className: "text-2xl lg:text-3xl font-bold text-gray-900 mb-8", children: "You Might Also Like" }), _jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6", children: relatedProducts.map((relatedProduct) => (_jsx("div", { className: "h-[400px]", children: _jsx(ProductCard, { product: relatedProduct, storeSlug: storeConfig.slug, onAddToCart: (p) => addToCart(p, 1), onQuickView: handleQuickView, className: "h-full" }) }, relatedProduct.id))) })] }))] }), _jsx(Modal, { isOpen: isReviewModalOpen, onClose: () => setIsReviewModalOpen(false), title: "Write a Review", children: _jsxs("form", { onSubmit: handleSubmitReview, className: "space-y-4", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Rating" }), _jsxs("div", { className: "flex items-center gap-1", children: [[1, 2, 3, 4, 5].map((star) => (_jsxs("div", { className: "relative group", children: [_jsx("button", { type: "button", onClick: () => setNewReview({ ...newReview, rating: star - 0.5 }), className: "absolute top-0 left-0 w-1/2 h-full z-20 focus:outline-none", title: `${star - 0.5} stars` }), _jsx("button", { type: "button", onClick: () => setNewReview({ ...newReview, rating: star }), className: "absolute top-0 right-0 w-1/2 h-full z-20 focus:outline-none", title: `${star} stars` }), _jsxs("div", { className: "relative pointer-events-none transition-transform group-hover:scale-110", children: [_jsx(Star, { className: "h-8 w-8 text-gray-200 fill-gray-200" }), newReview.rating >= star - 0.5 && (_jsx("div", { className: "absolute inset-0 overflow-hidden", style: { width: newReview.rating === star - 0.5 ? '50%' : '100%' }, children: _jsx(Star, { className: "h-8 w-8 text-gray-900 fill-gray-900" }) }))] })] }, star))), _jsx("span", { className: "ml-3 text-lg font-medium text-gray-900 w-12", children: newReview.rating })] })] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "title", className: "block text-sm font-medium text-gray-700 mb-1", children: "Review Title" }), _jsx("input", { type: "text", id: "title", required: true, className: "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-black", placeholder: "Summarize your thoughts", value: newReview.title, onChange: (e) => setNewReview({ ...newReview, title: e.target.value }) })] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "comment", className: "block text-sm font-medium text-gray-700 mb-1", children: "Review" }), _jsx("textarea", { id: "comment", required: true, rows: 4, className: "w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-black", placeholder: "What did you like or dislike?", value: newReview.comment, onChange: (e) => setNewReview({ ...newReview, comment: e.target.value }) })] }), _jsxs("div", { className: "pt-4 flex justify-end gap-3", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => setIsReviewModalOpen(false), children: "Cancel" }), _jsx(Button, { type: "submit", className: "bg-black text-white hover:bg-gray-800", children: "Submit Review" })] })] }) }), _jsx(GuestCheckoutModal, { isOpen: showGuestModal, onClose: () => setShowGuestModal(false), onSubmit: handleGuestInfoSubmit, initialData: getGuestUserInfo() || undefined })] }));
|
|
514
421
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/electronics-grid/pages/ProductsPage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductsPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/electronics-grid/pages/ProductsPage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AAkC9D,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,CAAC;CAC1B;AAivBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,+BAMpD"}
|
|
@@ -20,6 +20,7 @@ import { filterActiveProducts } from '../../../lib/utils/index.js';
|
|
|
20
20
|
import { getAllCategoryIds, flattenCategoryTree, buildCategoryTree } from '../../../lib/utils/category-tree.js';
|
|
21
21
|
import { getBannerImage, getLayoutText } from '../../../lib/utils/asset-helpers.js';
|
|
22
22
|
import { shouldUseAPI } from '../../../lib/utils/demo-detection.js';
|
|
23
|
+
import { productCategoryFilterChipClass } from '../../shared/product-category-filter-chip';
|
|
23
24
|
import { useCatalogPriceRange } from '../../../hooks/use-catalog-price-range.js';
|
|
24
25
|
import { getApiPriceFilterActive, isWithinActivePriceRange } from '../../../lib/utils/catalog-price-bounds.js';
|
|
25
26
|
import { buildFilteredProductQuery, getFilteredProductQueryKey, productMatchesCategoryIds, productMatchesCategorySlug, } from '../../../lib/utils/filtered-product-query.js';
|
|
@@ -309,11 +310,7 @@ function ProductsPageContent({ storeConfig }) {
|
|
|
309
310
|
element?.scrollIntoView({ behavior: 'smooth' });
|
|
310
311
|
}, children: primaryButtonText })), secondaryButtonText && secondaryButtonText.trim() !== '' && (_jsx(Button, { className: `h-12 px-8 rounded-full text-base font-medium shadow-lg hover:shadow-xl transition-all duration-300 transform hover:-translate-y-1 ${categoryHeaderImage ? 'bg-white/10 backdrop-blur-md text-white border border-white/30 hover:bg-white/20' : 'bg-gray-100 text-gray-900 hover:bg-gray-200 border border-gray-200'}`, onClick: () => {
|
|
311
312
|
window.location.href = `/${storeConfig.slug}/categories`;
|
|
312
|
-
}, children: secondaryButtonText }))] })] }) }) })] }), _jsxs("div", { "data-content-ready": true, className: "container mx-auto px-4 sm:px-6 lg:px-8 py-8", children: [_jsxs("div", { className: "flex gap-3 mb-8 overflow-x-auto pb-2 scrollbar-hide", children: [_jsx("button", { onClick: () => setSelectedCategoryFilter(null), className: `
|
|
313
|
-
? 'bg-gray-900 text-white hover:bg-blue-600'
|
|
314
|
-
: 'bg-gray-100 text-gray-700 hover:bg-blue-50 hover:text-blue-600'}`, children: "All" }), categories.map((category) => (_jsx("button", { onClick: () => setSelectedCategoryFilter(selectedCategoryFilter === category.slug ? null : category.slug), className: `px-6 py-2.5 rounded-lg text-sm font-semibold whitespace-nowrap transition-all ${selectedCategoryFilter === category.slug
|
|
315
|
-
? 'bg-gray-900 text-white hover:bg-blue-600'
|
|
316
|
-
: 'bg-gray-100 text-gray-700 hover:bg-blue-50 hover:text-blue-600'}`, children: category.name }, category.id)))] }), _jsxs("div", { id: "product-grid", className: "grid grid-cols-1 lg:grid-cols-4 gap-8", children: [_jsxs("aside", { className: "hidden lg:block col-span-1 space-y-8 sticky top-24 h-fit max-h-[calc(100vh-8rem)] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent", children: [_jsxs("div", { className: "flex items-center justify-between pb-4 border-b border-gray-100", children: [_jsx("h2", { className: "text-xl font-bold text-gray-900", children: "Filters" }), hasActiveFilters && (_jsxs("button", { onClick: clearAllFilters, className: "text-xs font-medium text-red-500 hover:text-red-700 flex items-center gap-1", children: [_jsx(RotateCcw, { className: "h-3 w-3" }), " Reset"] }))] }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide mb-4", children: "Availability" }), _jsxs("label", { className: "flex items-center gap-3 cursor-pointer group p-2 -ml-2 rounded-lg hover:bg-gray-50 transition-colors", children: [_jsx("div", { className: `w-5 h-5 rounded border flex items-center justify-center transition-colors ${showInStockOnly ? 'bg-black border-black' : 'border-gray-300 group-hover:border-black'}`, children: showInStockOnly && _jsx(Check, { className: "h-3 w-3 text-white" }) }), _jsx("input", { type: "checkbox", className: "hidden", checked: showInStockOnly, onChange: () => setShowInStockOnly(!showInStockOnly) }), _jsx("span", { className: "text-sm text-gray-700 font-medium", children: "In Stock Only" })] })] }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide", children: "Brand" }), selectedBrands.length > 0 && (_jsx("button", { onClick: () => setSelectedBrands([]), className: "text-xs text-gray-600 hover:text-blue-600 font-medium transition-colors", children: "Clear" }))] }), brands.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [(showMoreBrands ? brands : brands.slice(0, 6)).map((brand) => (_jsx("label", { className: "flex items-center justify-between cursor-pointer group hover:bg-blue-50 hover:text-blue-600 p-2 rounded-lg -ml-2 -mr-2 transition-colors", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("input", { type: "checkbox", checked: selectedBrands.includes(brand), onChange: () => setSelectedBrands(prev => prev.includes(brand) ? prev.filter(b => b !== brand) : [...prev, brand]), className: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" }), _jsx("span", { className: "text-sm text-gray-700 font-medium group-hover:text-blue-600", children: brand })] }) }, brand))), brands.length > 6 && (_jsx("button", { onClick: () => setShowMoreBrands(!showMoreBrands), className: "text-sm text-gray-600 hover:text-blue-600 font-medium mt-2 flex items-center gap-1 transition-colors", children: showMoreBrands ? _jsxs(_Fragment, { children: ["Show less ", _jsx(ChevronUp, { className: "h-4 w-4" })] }) : _jsxs(_Fragment, { children: ["Show more ", _jsx(ChevronDown, { className: "h-4 w-4" })] }) }))] })) : (_jsx("p", { className: "text-xs text-gray-500 italic", children: "No brands available" }))] }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide mb-4", children: "Category" }), _jsx(CategoryTree, { categories: categories, selectedCategoryIds: selectedCategories, onCategoryToggle: (categoryId, isSelected) => {
|
|
313
|
+
}, children: secondaryButtonText }))] })] }) }) })] }), _jsxs("div", { "data-content-ready": true, className: "container mx-auto px-4 sm:px-6 lg:px-8 py-8", children: [_jsxs("div", { className: "flex gap-3 mb-8 overflow-x-auto pb-2 scrollbar-hide", children: [_jsx("button", { onClick: () => setSelectedCategoryFilter(null), className: productCategoryFilterChipClass(!selectedCategoryFilter), children: "All" }), categories.map((category) => (_jsx("button", { onClick: () => setSelectedCategoryFilter(selectedCategoryFilter === category.slug ? null : category.slug), className: productCategoryFilterChipClass(selectedCategoryFilter === category.slug), children: category.name }, category.id)))] }), _jsxs("div", { id: "product-grid", className: "grid grid-cols-1 lg:grid-cols-4 gap-8", children: [_jsxs("aside", { className: "hidden lg:block col-span-1 space-y-8 sticky top-24 h-fit max-h-[calc(100vh-8rem)] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent", children: [_jsxs("div", { className: "flex items-center justify-between pb-4 border-b border-gray-100", children: [_jsx("h2", { className: "text-xl font-bold text-gray-900", children: "Filters" }), hasActiveFilters && (_jsxs("button", { onClick: clearAllFilters, className: "text-xs font-medium text-red-500 hover:text-red-700 flex items-center gap-1", children: [_jsx(RotateCcw, { className: "h-3 w-3" }), " Reset"] }))] }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide mb-4", children: "Availability" }), _jsxs("label", { className: "flex items-center gap-3 cursor-pointer group p-2 -ml-2 rounded-lg hover:bg-gray-50 transition-colors", children: [_jsx("div", { className: `w-5 h-5 rounded border flex items-center justify-center transition-colors ${showInStockOnly ? 'bg-black border-black' : 'border-gray-300 group-hover:border-black'}`, children: showInStockOnly && _jsx(Check, { className: "h-3 w-3 text-white" }) }), _jsx("input", { type: "checkbox", className: "hidden", checked: showInStockOnly, onChange: () => setShowInStockOnly(!showInStockOnly) }), _jsx("span", { className: "text-sm text-gray-700 font-medium", children: "In Stock Only" })] })] }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide", children: "Brand" }), selectedBrands.length > 0 && (_jsx("button", { onClick: () => setSelectedBrands([]), className: "text-xs text-gray-600 hover:text-blue-600 font-medium transition-colors", children: "Clear" }))] }), brands.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [(showMoreBrands ? brands : brands.slice(0, 6)).map((brand) => (_jsx("label", { className: "flex items-center justify-between cursor-pointer group hover:bg-blue-50 hover:text-blue-600 p-2 rounded-lg -ml-2 -mr-2 transition-colors", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("input", { type: "checkbox", checked: selectedBrands.includes(brand), onChange: () => setSelectedBrands(prev => prev.includes(brand) ? prev.filter(b => b !== brand) : [...prev, brand]), className: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" }), _jsx("span", { className: "text-sm text-gray-700 font-medium group-hover:text-blue-600", children: brand })] }) }, brand))), brands.length > 6 && (_jsx("button", { onClick: () => setShowMoreBrands(!showMoreBrands), className: "text-sm text-gray-600 hover:text-blue-600 font-medium mt-2 flex items-center gap-1 transition-colors", children: showMoreBrands ? _jsxs(_Fragment, { children: ["Show less ", _jsx(ChevronUp, { className: "h-4 w-4" })] }) : _jsxs(_Fragment, { children: ["Show more ", _jsx(ChevronDown, { className: "h-4 w-4" })] }) }))] })) : (_jsx("p", { className: "text-xs text-gray-500 italic", children: "No brands available" }))] }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-gray-900 uppercase tracking-wide mb-4", children: "Category" }), _jsx(CategoryTree, { categories: categories, selectedCategoryIds: selectedCategories, onCategoryToggle: (categoryId, isSelected) => {
|
|
317
314
|
setSelectedCategories(prev => isSelected
|
|
318
315
|
? [...prev, categoryId]
|
|
319
316
|
: prev.filter(id => id !== categoryId));
|
|
@@ -133,7 +133,7 @@ export function MenuPage({ storeConfig: initialConfig, categorySlug }) {
|
|
|
133
133
|
? "text-white border-transparent shadow-md transform scale-105"
|
|
134
134
|
: "bg-white text-gray-600 border-gray-200 hover:bg-gray-100 hover:border-gray-300"), style: !selectedCategory ? { backgroundColor: primaryColor } : {}, children: "All Items" }), categories.map((category) => (_jsx("button", { onClick: () => setSelectedCategory(category.slug), className: cn("px-4 py-2 rounded-full text-sm font-bold whitespace-nowrap transition-all border flex-shrink-0 select-none", selectedCategory === category.slug
|
|
135
135
|
? "text-white border-transparent shadow-md transform scale-105"
|
|
136
|
-
: "bg-white text-gray-600 border-gray-200 hover:bg-gray-100 hover:border-gray-300"), style: selectedCategory === category.slug ? { backgroundColor: primaryColor } : {}, children: category.name }, category.id)))] })] })] }) }) }), _jsxs("div", { className: "container mx-auto px-4 sm:px-6 lg:px-8 py-12", children: [selectedCategory && (_jsx("div", { className: "mb-8 animate-fade-in", children: _jsxs("h2", { className: "text-2xl font-bold text-gray-900 capitalize flex items-center gap-3", children: [categories.find(c => c.slug === selectedCategory)?.name || 'Category', _jsxs("span", { className: "text-sm font-normal text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full", children: [filteredItems.length, " items"] })] }) })), _jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8", children: filteredItems.map((item, index) => (_jsxs(Card, { className: "group overflow-hidden hover:shadow-xl transition-all duration-300 border-gray-100 flex flex-col h-full bg-white rounded-2xl", children: [_jsxs("div", { className: "relative aspect-[4/3] overflow-hidden", children: [_jsx(ImageWithFallback, { src: item.image, alt: item.name, className: "w-full h-full object-cover transition-transform duration-700 group-hover:scale-110", skeletonAspectRatio: "4/3" }), _jsx("div", { className: "absolute inset-0 bg-gradient-to-t from-black/60 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-end justify-center pb-6", children: _jsx(Button, { className: "rounded-full font-bold shadow-lg transform translate-y-4 group-hover:translate-y-0 transition-transform duration-300", style: { backgroundColor: primaryColor, color: 'white' }, children: "
|
|
136
|
+
: "bg-white text-gray-600 border-gray-200 hover:bg-gray-100 hover:border-gray-300"), style: selectedCategory === category.slug ? { backgroundColor: primaryColor } : {}, children: category.name }, category.id)))] })] })] }) }) }), _jsxs("div", { className: "container mx-auto px-4 sm:px-6 lg:px-8 py-12", children: [selectedCategory && (_jsx("div", { className: "mb-8 animate-fade-in", children: _jsxs("h2", { className: "text-2xl font-bold text-gray-900 capitalize flex items-center gap-3", children: [categories.find(c => c.slug === selectedCategory)?.name || 'Category', _jsxs("span", { className: "text-sm font-normal text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full", children: [filteredItems.length, " items"] })] }) })), _jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8", children: filteredItems.map((item, index) => (_jsxs(Card, { className: "group overflow-hidden hover:shadow-xl transition-all duration-300 border-gray-100 flex flex-col h-full bg-white rounded-2xl", children: [_jsxs("div", { className: "relative aspect-[4/3] overflow-hidden", children: [_jsx(ImageWithFallback, { src: item.image, alt: item.name, className: "w-full h-full object-cover transition-transform duration-700 group-hover:scale-110", skeletonAspectRatio: "4/3" }), _jsx("div", { className: "absolute inset-0 bg-gradient-to-t from-black/60 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-end justify-center pb-6", children: _jsx(Button, { className: "rounded-full font-bold shadow-lg transform translate-y-4 group-hover:translate-y-0 transition-transform duration-300", style: { backgroundColor: primaryColor, color: 'white' }, children: "Add to cart" }) }), index % 3 === 0 && (_jsxs("div", { className: "absolute top-3 right-3 bg-white/90 backdrop-blur text-gray-900 text-[10px] font-bold px-2 py-1 rounded-full shadow-sm flex items-center gap-1", children: [_jsx(Star, { className: "w-3 h-3 fill-yellow-400 text-yellow-400" }), " Popular"] }))] }), _jsxs(CardContent, { className: "p-6 flex-1 flex flex-col", children: [_jsxs("div", { className: "flex justify-between items-start mb-2", children: [_jsx("h3", { className: "font-bold text-lg text-gray-900 leading-tight", children: item.name }), _jsx("span", { className: "font-black text-lg text-gray-900 whitespace-nowrap ml-2", children: formatCurrency(item.price, item.currency || storeConfig.settings?.currency || 'USD') })] }), _jsx(RichTextExcerpt, { value: item.description, as: "p", className: "text-gray-500 text-sm mb-4 line-clamp-2 leading-relaxed flex-1" }), item.dietaryInfo && item.dietaryInfo.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2 mb-6", children: item.dietaryInfo.map((info) => {
|
|
137
137
|
const Icon = dietaryIcons[info.toLowerCase()] || Info;
|
|
138
138
|
return (_jsxs("span", { className: "inline-flex items-center gap-1 text-[10px] uppercase font-bold px-2 py-1 rounded bg-gray-50 text-gray-500 border border-gray-100", children: [_jsx(Icon, { className: "w-3 h-3" }), info] }, info));
|
|
139
139
|
}) })), _jsxs(Button, { className: "w-full rounded-xl font-bold h-11 shadow-sm hover:shadow-md transition-all active:scale-[0.98]", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/food/pages/ProductDetailPage.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAA8C,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/food/pages/ProductDetailPage.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAA8C,MAAM,mBAAmB,CAAC;AAkC5F,UAAU,sBAAsB;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAsHD,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,sBAAsB,+BAq6BpG"}
|