storefront-layouts 1.0.3 → 1.0.4
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/auth/LoginForm.js +2 -2
- package/dist/components/auth/LoginSheet.js +2 -2
- package/dist/components/auth/login-form-core.js +3 -3
- package/dist/components/auth/login-sheet-header.js +3 -3
- package/dist/components/auth/login-sheet-registry.js +2 -2
- package/dist/components/auth/login-sheet-themes/booking-agenda.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/booking.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/clothing-minimal.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/clothing.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/electronics-grid.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/electronics.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/food-modern.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/food.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/index.js +9 -9
- package/dist/components/auth/login-sheet-themes/motivational-speaker.theme.js +1 -1
- package/dist/components/auth/login-sheet-themes/theme-input-baselines.d.ts +2 -2
- package/dist/components/auth/login-sheet-themes/theme-input-baselines.d.ts.map +1 -1
- package/dist/components/auth/login-sheet-themes/theme-input-baselines.js +2 -2
- package/dist/components/auth/login-sheets/StoreLoginSheetShell.d.ts.map +1 -1
- package/dist/components/auth/login-sheets/StoreLoginSheetShell.js +6 -6
- package/dist/components/auth/use-login-submit.js +3 -3
- package/dist/components/cart/InventoryHoldCountdown.js +2 -2
- package/dist/components/categories/category-masonry-grid.js +3 -3
- package/dist/components/checkout/CheckoutFeeLines.js +1 -1
- package/dist/components/checkout/ShippingOptionsPanel.js +3 -3
- package/dist/components/learning/CertificateTemplates.js +2 -2
- package/dist/components/learning/CertificateViewer.js +3 -3
- package/dist/components/learning/MentorshipProgress.d.ts.map +1 -1
- package/dist/components/learning/MentorshipProgress.js +4 -4
- package/dist/components/product/ProductVariationSelectors.js +1 -1
- package/dist/components/rich-text/CategoryDescription.js +2 -2
- package/dist/components/rich-text/ProductDescription.js +2 -2
- package/dist/components/rich-text/RichTextExcerpt.js +1 -1
- package/dist/components/rich-text/SafeRichHtml.d.ts +8 -11
- package/dist/components/rich-text/SafeRichHtml.d.ts.map +1 -1
- package/dist/components/rich-text/SafeRichHtml.js +3 -5
- package/dist/components/shipping/ProductDeliveryInfoSection.d.ts.map +1 -1
- package/dist/components/shipping/ProductDeliveryInfoSection.js +7 -4
- package/dist/components/shipping/ShippingQuoteAddressForm.js +3 -3
- package/dist/components/ui/alert-modal.js +2 -2
- package/dist/components/ui/avatar-image.js +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/breadcrumbs.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/category-tree.js +2 -2
- package/dist/components/ui/checkout-button.d.ts.map +1 -1
- package/dist/components/ui/checkout-button.js +11 -283
- package/dist/components/ui/guest-checkout-modal.js +3 -3
- package/dist/components/ui/image-skeleton.js +2 -2
- package/dist/components/ui/image-with-fallback.d.ts +3 -1
- package/dist/components/ui/image-with-fallback.d.ts.map +1 -1
- package/dist/components/ui/image-with-fallback.js +55 -139
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/limited-time-offer-badge.js +2 -2
- package/dist/components/ui/loading-skeleton-wrapper.js +1 -1
- package/dist/components/ui/modal.js +2 -2
- package/dist/components/ui/otp-input.js +1 -1
- package/dist/components/ui/out-of-stock-overlay.js +1 -1
- package/dist/components/ui/page-animate-wrapper.js +2 -2
- package/dist/components/ui/page-content-loader.js +2 -2
- package/dist/components/ui/page-loader.js +1 -1
- package/dist/components/ui/product-card.d.ts.map +1 -1
- package/dist/components/ui/product-card.js +17 -17
- package/dist/components/ui/product-rating.js +1 -1
- package/dist/components/ui/product-stock-badge.js +2 -2
- package/dist/components/ui/review-form.js +2 -2
- package/dist/components/ui/route-skeleton-loader.js +6 -6
- package/dist/components/ui/sheet.d.ts +2 -1
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +4 -4
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/skeletons/index.js +5 -5
- package/dist/components/ui/skeletons/product-grid-skeleton.js +1 -1
- package/dist/components/ui/store-logos.d.ts.map +1 -1
- package/dist/components/ui/store-logos.js +4 -4
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/video-player.js +2 -2
- package/dist/editor/alignment-schemas/booking.js +1 -1
- package/dist/editor/alignment-schemas/clothing-minimal.js +1 -1
- package/dist/editor/alignment-schemas/index.js +20 -20
- package/dist/editor/alignment-schemas/lazy-loader.js +1 -1
- package/dist/editor/alignment-schemas/metadata.js +1 -1
- package/dist/editor/alignment-schemas/resolve-canvas-inspector-leaf.js +3 -3
- package/dist/editor/blocks/index.js +3 -3
- package/dist/editor/blocks/migrate-clothing-minimal.js +3 -3
- package/dist/editor/blocks/nav-outline-utils.js +2 -2
- package/dist/editor/blocks/registry.js +1 -1
- package/dist/editor/document/adapter.js +4 -4
- package/dist/editor/document/block-tree.js +1 -1
- package/dist/editor/document/index.js +6 -6
- package/dist/editor/document/validate.js +1 -1
- package/dist/editor/index.js +12 -12
- package/dist/editor/layout-content-loader.js +3 -3
- package/dist/editor/payaza-form/ArrayItemManager.js +2 -2
- package/dist/editor/payaza-form/EditorCanvasPreview.js +5 -5
- package/dist/editor/payaza-form/FieldRenderer.js +17 -17
- package/dist/editor/payaza-form/IframePreviewMessageBridge.js +3 -3
- package/dist/editor/payaza-form/PayazaFormEditor.js +31 -31
- package/dist/editor/payaza-form/PayazaFormEditorFullPage.js +2 -2
- package/dist/editor/payaza-form/SliderArrayEditor.js +3 -3
- package/dist/editor/payaza-form/components/ArrayField.js +1 -1
- package/dist/editor/payaza-form/components/BlockStylesInspector.js +1 -1
- package/dist/editor/payaza-form/components/BlocksField.js +9 -9
- package/dist/editor/payaza-form/components/ButtonField.js +3 -3
- package/dist/editor/payaza-form/components/CanvasGranularInspector.js +11 -11
- package/dist/editor/payaza-form/components/IconField.js +2 -2
- package/dist/editor/payaza-form/components/ImageField.js +1 -1
- package/dist/editor/payaza-form/components/NumberField.js +1 -1
- package/dist/editor/payaza-form/components/RichTextField.js +2 -2
- package/dist/editor/payaza-form/components/SectionField.js +1 -1
- package/dist/editor/payaza-form/components/SectionSchemaInspector.js +3 -3
- package/dist/editor/payaza-form/components/StarRatingField.js +2 -2
- package/dist/editor/payaza-form/components/TextField.js +1 -1
- package/dist/editor/payaza-form/data-merger.js +6 -6
- package/dist/editor/payaza-form/data-transformer.js +3 -3
- package/dist/editor/payaza-form/engine.js +1 -1
- package/dist/editor/payaza-form/examples/custom-widgets.example.js +1 -1
- package/dist/editor/payaza-form/index.js +8 -8
- package/dist/editor/payaza-form/layout-loader.js +2 -2
- package/dist/editor/payaza-form/preview-message-handler.js +3 -3
- package/dist/editor/payaza-form/schema-bridge.js +3 -3
- package/dist/editor/payaza-form/widget-registry.js +1 -1
- package/dist/editor/shared/BlockOutlineTree.js +2 -2
- package/dist/editor/shared/EditorHeader.js +2 -2
- package/dist/editor/shared/EditorNavigator.js +2 -2
- package/dist/editor/shared/IframePreview.js +6 -6
- package/dist/editor/shared/InlineCanvasPreview.js +8 -8
- package/dist/editor/shared/LayoutRenderer.js +1 -1
- package/dist/editor/shared/ResizableSidebar.js +1 -1
- package/dist/editor/shared/index.js +7 -7
- package/dist/hooks/use-analytics.js +3 -3
- package/dist/hooks/use-api.js +1 -1
- package/dist/hooks/use-cart-api.d.ts.map +1 -1
- package/dist/hooks/use-cart-api.js +8 -3
- package/dist/hooks/use-catalog-loader.js +3 -3
- package/dist/hooks/use-catalog-price-range.d.ts +2 -5
- package/dist/hooks/use-catalog-price-range.d.ts.map +1 -1
- package/dist/hooks/use-catalog-price-range.js +20 -5
- package/dist/hooks/use-category-products.d.ts +8 -0
- package/dist/hooks/use-category-products.d.ts.map +1 -0
- package/dist/hooks/use-category-products.js +43 -0
- package/dist/hooks/use-checkout-fees.d.ts +3 -4
- package/dist/hooks/use-checkout-fees.d.ts.map +1 -1
- package/dist/hooks/use-checkout-fees.js +1 -1
- package/dist/hooks/use-content-ready.js +1 -1
- package/dist/hooks/use-featured-products.d.ts +3 -0
- package/dist/hooks/use-featured-products.d.ts.map +1 -0
- package/dist/hooks/use-featured-products.js +25 -0
- package/dist/hooks/use-multi-store-checkout-fees.d.ts +3 -4
- package/dist/hooks/use-multi-store-checkout-fees.d.ts.map +1 -1
- package/dist/hooks/use-multi-store-checkout-fees.js +1 -1
- package/dist/hooks/use-navigation-loading.js +1 -1
- package/dist/hooks/use-payaza-checkout.d.ts +1 -1
- package/dist/hooks/use-payaza-checkout.d.ts.map +1 -1
- package/dist/hooks/use-payaza-checkout.js +9 -3
- package/dist/hooks/use-product-brands.d.ts +5 -0
- package/dist/hooks/use-product-brands.d.ts.map +1 -0
- package/dist/hooks/use-product-brands.js +25 -0
- package/dist/hooks/use-product-by-slug.d.ts +7 -0
- package/dist/hooks/use-product-by-slug.d.ts.map +1 -0
- package/dist/hooks/use-product-by-slug.js +38 -0
- package/dist/hooks/use-product-reviews.d.ts +15 -0
- package/dist/hooks/use-product-reviews.d.ts.map +1 -0
- package/dist/hooks/use-product-reviews.js +75 -0
- package/dist/hooks/use-product-variation-selection.d.ts +2 -8
- package/dist/hooks/use-product-variation-selection.d.ts.map +1 -1
- package/dist/hooks/use-product-variation-selection.js +1 -1
- package/dist/hooks/use-products-api.js +3 -3
- package/dist/hooks/use-shipping-quote.js +2 -2
- package/dist/hooks/use-store-api.js +4 -4
- package/dist/hooks/usePreviewSlideSync.js +1 -1
- package/dist/index.d.ts +62 -74
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -153
- package/dist/layouts/booking/components/BookingHomePage.d.ts.map +1 -1
- package/dist/layouts/booking/components/BookingHomePage.js +68 -74
- package/dist/layouts/booking/components/BookingMultilineHeading.js +1 -1
- package/dist/layouts/booking/components/BookingTestimonialCard.js +2 -2
- package/dist/layouts/booking/components/BookingTestimonialsEmptyState.js +1 -1
- package/dist/layouts/booking/components/booking-footer-defaults.js +2 -2
- package/dist/layouts/booking/index.js +8 -8
- package/dist/layouts/booking/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/booking/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/AboutPage.js +39 -60
- package/dist/layouts/booking/pages/BookPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/BookPage.js +16 -22
- package/dist/layouts/booking/pages/CategoriesPage.js +6 -6
- package/dist/layouts/booking/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/booking/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/CategoryPage.js +17 -26
- package/dist/layouts/booking/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/booking/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/ContactPage.js +5 -12
- package/dist/layouts/booking/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/booking/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/ProductDetailPage.js +203 -150
- package/dist/layouts/booking/pages/ServicesPage.d.ts +1 -1
- package/dist/layouts/booking/pages/ServicesPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/ServicesPage.js +11 -31
- package/dist/layouts/booking-agenda/components/BookingHomePageAgenda.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/components/BookingHomePageAgenda.js +21 -30
- package/dist/layouts/booking-agenda/index.js +8 -8
- package/dist/layouts/booking-agenda/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/booking-agenda/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/AboutPage.js +11 -14
- package/dist/layouts/booking-agenda/pages/BookPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/BookPage.js +15 -21
- package/dist/layouts/booking-agenda/pages/CategoriesPage.js +5 -5
- package/dist/layouts/booking-agenda/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/booking-agenda/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/CategoryPage.js +12 -18
- package/dist/layouts/booking-agenda/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/booking-agenda/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/ContactPage.js +8 -13
- package/dist/layouts/booking-agenda/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/booking-agenda/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/ProductDetailPage.js +202 -149
- package/dist/layouts/booking-agenda/pages/ServicesPage.d.ts +1 -1
- package/dist/layouts/booking-agenda/pages/ServicesPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/ServicesPage.js +8 -23
- package/dist/layouts/clothing/components/ClothingHomePage.d.ts.map +1 -1
- package/dist/layouts/clothing/components/ClothingHomePage.js +199 -136
- package/dist/layouts/clothing/index.js +7 -7
- package/dist/layouts/clothing/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/clothing/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/AboutPage.js +19 -33
- package/dist/layouts/clothing/pages/CategoriesPage.js +8 -8
- package/dist/layouts/clothing/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/clothing/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/CategoryPage.js +15 -41
- package/dist/layouts/clothing/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/clothing/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ContactPage.js +5 -8
- package/dist/layouts/clothing/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/clothing/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ProductDetailPage.js +256 -167
- package/dist/layouts/clothing/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/clothing/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ProductsPage.js +125 -59
- package/dist/layouts/clothing/payaza-bindings.js +2 -2
- package/dist/layouts/clothing-minimal/components/ClothingHomePageMinimal.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/components/ClothingHomePageMinimal.js +32 -131
- package/dist/layouts/clothing-minimal/components/clothing-minimal-block-render.js +8 -8
- package/dist/layouts/clothing-minimal/index.js +7 -7
- package/dist/layouts/clothing-minimal/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/clothing-minimal/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/AboutPage.js +37 -61
- package/dist/layouts/clothing-minimal/pages/CategoriesPage.js +7 -7
- package/dist/layouts/clothing-minimal/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/clothing-minimal/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/CategoryPage.js +13 -18
- package/dist/layouts/clothing-minimal/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/clothing-minimal/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ContactPage.js +5 -8
- package/dist/layouts/clothing-minimal/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductDetailPage.js +202 -143
- package/dist/layouts/clothing-minimal/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ProductsPage.js +126 -57
- package/dist/layouts/electronics/components/ElectronicsCategoriesPage.js +7 -7
- package/dist/layouts/electronics/components/ElectronicsGridProductCard.js +10 -10
- package/dist/layouts/electronics/components/ElectronicsHomePage.d.ts.map +1 -1
- package/dist/layouts/electronics/components/ElectronicsHomePage.js +29 -31
- package/dist/layouts/electronics/components/ElectronicsPageWrapper.js +4 -4
- package/dist/layouts/electronics/components/ElectronicsProductsPage.d.ts.map +1 -1
- package/dist/layouts/electronics/components/ElectronicsProductsPage.js +81 -23
- package/dist/layouts/electronics/components/ElectronicsStoreFooter.js +2 -2
- package/dist/layouts/electronics/components/ElectronicsStoreHeader.js +6 -6
- package/dist/layouts/electronics/index.js +18 -18
- package/dist/layouts/electronics/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/electronics/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/AboutPage.js +11 -14
- package/dist/layouts/electronics/pages/CategoriesPage.js +1 -1
- package/dist/layouts/electronics/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/electronics/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/CategoryPage.js +14 -20
- package/dist/layouts/electronics/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/electronics/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ContactPage.js +8 -13
- package/dist/layouts/electronics/pages/HelpCenterPage.js +1 -1
- package/dist/layouts/electronics/pages/PrivacyPolicyPage.js +1 -1
- package/dist/layouts/electronics/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/electronics/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ProductDetailPage.js +201 -142
- package/dist/layouts/electronics/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/electronics/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ProductsPage.js +119 -49
- package/dist/layouts/electronics/pages/TermsPage.js +1 -1
- package/dist/layouts/electronics/pages/TrackOrderPage.js +4 -4
- package/dist/layouts/electronics-grid/components/ElectronicsGridProductCard.js +10 -10
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.js +75 -33
- package/dist/layouts/electronics-grid/index.js +14 -14
- package/dist/layouts/electronics-grid/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/electronics-grid/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/AboutPage.js +11 -14
- package/dist/layouts/electronics-grid/pages/CategoriesPage.js +1 -1
- package/dist/layouts/electronics-grid/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/electronics-grid/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/CategoryPage.js +14 -20
- package/dist/layouts/electronics-grid/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/electronics-grid/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ContactPage.js +8 -13
- package/dist/layouts/electronics-grid/pages/ElectronicsGridCategoriesPage.js +6 -6
- package/dist/layouts/electronics-grid/pages/HelpCenterPage.js +1 -1
- package/dist/layouts/electronics-grid/pages/PrivacyPolicyPage.js +1 -1
- package/dist/layouts/electronics-grid/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/electronics-grid/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ProductDetailPage.js +201 -142
- package/dist/layouts/electronics-grid/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/electronics-grid/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ProductsPage.js +121 -52
- package/dist/layouts/electronics-grid/pages/TermsPage.js +1 -1
- package/dist/layouts/electronics-grid/pages/TrackOrderPage.js +4 -4
- package/dist/layouts/food/components/FoodHomePage.d.ts.map +1 -1
- package/dist/layouts/food/components/FoodHomePage.js +42 -41
- package/dist/layouts/food/index.js +8 -8
- package/dist/layouts/food/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/food/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/AboutPage.js +44 -45
- package/dist/layouts/food/pages/CategoriesPage.js +6 -6
- package/dist/layouts/food/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/food/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/CategoryPage.js +23 -21
- package/dist/layouts/food/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/food/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ContactPage.js +5 -7
- package/dist/layouts/food/pages/MenuPage.d.ts +1 -1
- package/dist/layouts/food/pages/MenuPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/MenuPage.js +81 -42
- package/dist/layouts/food/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/food/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ProductDetailPage.js +209 -171
- package/dist/layouts/food/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/food/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ProductsPage.js +130 -45
- package/dist/layouts/food-modern/components/FoodHomePageModern.js +10 -10
- package/dist/layouts/food-modern/index.js +8 -8
- package/dist/layouts/food-modern/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/AboutPage.js +11 -14
- package/dist/layouts/food-modern/pages/CategoriesPage.js +5 -5
- package/dist/layouts/food-modern/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/CategoryPage.js +23 -20
- package/dist/layouts/food-modern/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ContactPage.js +5 -7
- package/dist/layouts/food-modern/pages/MenuPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/MenuPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/MenuPage.js +81 -46
- package/dist/layouts/food-modern/pages/ProductDetailPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/ProductDetailPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ProductDetailPage.js +202 -143
- package/dist/layouts/food-modern/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/food-modern/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ProductsPage.js +117 -33
- package/dist/layouts/motivational-speaker/components/MotivationalHomePage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/components/MotivationalHomePage.js +32 -23
- package/dist/layouts/motivational-speaker/components/MotivationalSpeakerPageWrapper.js +1 -1
- package/dist/layouts/motivational-speaker/index.js +9 -9
- package/dist/layouts/motivational-speaker/pages/AboutPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/AboutPage.js +6 -9
- package/dist/layouts/motivational-speaker/pages/CategoryPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/CategoryPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/CategoryPage.js +18 -22
- package/dist/layouts/motivational-speaker/pages/ContactPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ContactPage.js +9 -13
- package/dist/layouts/motivational-speaker/pages/ProductsPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ProductsPage.js +121 -52
- package/dist/layouts/motivational-speaker/pages/ServiceDetailPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/ServiceDetailPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ServiceDetailPage.js +15 -24
- package/dist/layouts/motivational-speaker/pages/ServicesPage.d.ts +1 -1
- package/dist/layouts/motivational-speaker/pages/ServicesPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ServicesPage.js +8 -23
- package/dist/layouts/motivational-speaker/pages/SubscriptionPage.js +7 -7
- package/dist/layouts/shared/components/BaseStoreLayout.js +9 -9
- package/dist/layouts/shared/components/CartLineQuantityControl.js +1 -1
- package/dist/layouts/shared/components/GenericPageWrapper.js +3 -3
- package/dist/layouts/shared/components/ProductPriceFilterSection.js +4 -4
- package/dist/layouts/shared/components/PromoBanner.d.ts +1 -4
- package/dist/layouts/shared/components/PromoBanner.d.ts.map +1 -1
- package/dist/layouts/shared/components/PromoBanner.js +12 -8
- package/dist/layouts/shared/components/StoreFooter.js +10 -10
- package/dist/layouts/shared/components/StoreHeader.js +7 -7
- package/dist/layouts/shared/components/TestimonialCard.d.ts.map +1 -1
- package/dist/layouts/shared/components/TestimonialCard.js +2 -2
- package/dist/layouts/shared/components/headers/BookingAgendaSidebar.js +2 -2
- package/dist/layouts/shared/components/headers/ClothingMinimalHeader.js +11 -11
- package/dist/layouts/shared/components/headers/FoodModernHeader.js +7 -7
- package/dist/layouts/shared/index.js +22 -22
- package/dist/layouts/shared/pages/AccountPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/AccountPage.js +101 -27
- package/dist/layouts/shared/pages/CartPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/CartPage.js +39 -90
- package/dist/layouts/shared/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/CheckoutPage.js +349 -868
- package/dist/layouts/shared/pages/CookiePolicyPage.js +1 -1
- package/dist/layouts/shared/pages/FeatureDisabledPage.js +1 -1
- package/dist/layouts/shared/pages/HelpCenterPage.js +1 -1
- package/dist/layouts/shared/pages/MaintenancePage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/MaintenancePage.js +2 -3
- package/dist/layouts/shared/pages/PortfolioPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/PortfolioPage.js +2 -2
- package/dist/layouts/shared/pages/PrivacyPolicyPage.js +1 -1
- package/dist/layouts/shared/pages/SizeGuidePage.js +1 -1
- package/dist/layouts/shared/pages/StyleGuidePage.js +3 -3
- package/dist/layouts/shared/pages/TeamPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/TeamPage.js +1 -1
- package/dist/layouts/shared/pages/TermsPage.js +1 -1
- package/dist/layouts/shared/pages/TrackOrderPage.js +4 -4
- package/dist/layouts/shared/pages/WishlistPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/WishlistPage.js +44 -29
- package/dist/layouts/shared/wrappers/BookingAgendaLayout.d.ts.map +1 -1
- package/dist/layouts/shared/wrappers/BookingAgendaLayout.js +80 -35
- package/dist/layouts/shared/wrappers/ClothingLayout.js +8 -8
- package/dist/layouts/shared/wrappers/ClothingMinimalLayout.js +7 -7
- package/dist/layouts/shared/wrappers/ElectronicsLayout.js +5 -5
- package/dist/layouts/shared/wrappers/FoodModernLayout.js +6 -6
- package/dist/layouts/shared/wrappers/MotivationalLayout.js +9 -9
- package/dist/layouts/shared/wrappers/StandardLayout.js +8 -8
- package/dist/lib/api.d.ts +3 -4
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +69 -109
- package/dist/lib/auth-context.js +2 -2
- package/dist/lib/content-selectors.d.ts +1 -1
- package/dist/lib/content-selectors.d.ts.map +1 -1
- package/dist/lib/content-selectors.js +8 -0
- package/dist/lib/layout-config-hydration.js +2 -2
- package/dist/lib/loading-context.d.ts.map +1 -1
- package/dist/lib/loading-context.js +11 -21
- package/dist/lib/payaza-checkout.d.ts.map +1 -1
- package/dist/lib/payaza-checkout.js +2 -4
- package/dist/lib/payaza-public-key.d.ts +6 -0
- package/dist/lib/payaza-public-key.d.ts.map +1 -0
- package/dist/lib/payaza-public-key.js +10 -0
- package/dist/lib/rich-html.d.ts +31 -26
- package/dist/lib/rich-html.d.ts.map +1 -1
- package/dist/lib/rich-html.js +1 -0
- package/dist/lib/services/analytics.service.js +1 -1
- package/dist/lib/services/auth.service.js +1 -1
- package/dist/lib/services/booking.service.js +1 -1
- package/dist/lib/services/category.service.js +1 -1
- package/dist/lib/services/checkout.service.d.ts +3 -0
- package/dist/lib/services/checkout.service.d.ts.map +1 -1
- package/dist/lib/services/checkout.service.js +1 -1
- package/dist/lib/services/contact.service.js +1 -1
- package/dist/lib/services/customer.service.js +1 -1
- package/dist/lib/services/fees.service.d.ts +17 -63
- package/dist/lib/services/fees.service.d.ts.map +1 -1
- package/dist/lib/services/fees.service.js +4 -138
- package/dist/lib/services/index.js +13 -13
- package/dist/lib/services/location.service.js +1 -1
- package/dist/lib/services/order.service.js +1 -1
- package/dist/lib/services/payment.service.js +1 -1
- package/dist/lib/services/product.service.d.ts +7 -2
- package/dist/lib/services/product.service.d.ts.map +1 -1
- package/dist/lib/services/product.service.js +13 -1
- package/dist/lib/services/promo.service.js +1 -1
- package/dist/lib/services/review.service.js +1 -1
- package/dist/lib/services/service.service.js +1 -1
- package/dist/lib/services/shipping.service.js +1 -1
- package/dist/lib/services/store.service.js +1 -1
- package/dist/lib/store-config-utils.d.ts +1 -10
- package/dist/lib/store-config-utils.d.ts.map +1 -1
- package/dist/lib/store-config-utils.js +73 -261
- package/dist/lib/store-config.js +1 -1
- package/dist/lib/store-context.d.ts +1 -23
- package/dist/lib/store-context.d.ts.map +1 -1
- package/dist/lib/store-context.js +89 -111
- package/dist/lib/store-types.d.ts +9 -91
- package/dist/lib/store-types.d.ts.map +1 -1
- package/dist/lib/utils/asset-helpers.js +1 -1
- package/dist/lib/utils/catalog-price-bounds.d.ts +16 -6
- package/dist/lib/utils/catalog-price-bounds.d.ts.map +1 -1
- package/dist/lib/utils/catalog-price-bounds.js +58 -14
- package/dist/lib/utils/category-tree.d.ts +9 -0
- package/dist/lib/utils/category-tree.d.ts.map +1 -1
- package/dist/lib/utils/category-tree.js +26 -0
- package/dist/lib/utils/editor-preview.d.ts +5 -0
- package/dist/lib/utils/editor-preview.d.ts.map +1 -1
- package/dist/lib/utils/editor-preview.js +17 -3
- package/dist/lib/utils/fee-calculations.d.ts +5 -1
- package/dist/lib/utils/fee-calculations.d.ts.map +1 -1
- package/dist/lib/utils/fee-calculations.js +28 -31
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +4 -4
- package/dist/lib/utils/product-images.js +1 -1
- package/dist/lib/utils/product-share.js +1 -1
- package/dist/lib/utils/url-helpers.d.ts +6 -0
- package/dist/lib/utils/url-helpers.d.ts.map +1 -1
- package/dist/lib/utils/url-helpers.js +20 -4
- package/dist/preview/LayoutPreview.js +6 -6
- package/dist/preview/PreviewRouter.js +4 -4
- package/dist/preview/canvas/PreviewCanvasEnhancer.js +8 -8
- package/dist/preview/canvas/preview-flush-await.js +1 -1
- package/dist/preview/canvas/preview-isolation.js +1 -1
- package/dist/preview/canvas/preview-route.js +2 -2
- package/dist/preview/index.js +5 -5
- package/dist/styles/index.css +190 -149
- package/package.json +31 -43
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
|
-
import { cn } from "../../lib/utils
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
5
|
const buttonVariants = cva("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "../../lib/utils
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
3
|
function Card({ className, ...props }) {
|
|
4
4
|
return (_jsx("div", { "data-slot": "card", className: cn("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", className), ...props }));
|
|
5
5
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useMemo } from 'react';
|
|
4
4
|
import Link from 'next/link';
|
|
5
|
-
import { buildCategoryTree } from '../../lib/utils/category-tree
|
|
5
|
+
import { buildCategoryTree } from '../../lib/utils/category-tree';
|
|
6
6
|
import { ChevronDown, ChevronRight, Check } from 'lucide-react';
|
|
7
|
-
import { cn, formatDisplayLabel } from '../../lib/utils
|
|
7
|
+
import { cn, formatDisplayLabel } from '../../lib/utils';
|
|
8
8
|
function CategoryItem({ category, level, selectedCategoryIds, onCategoryToggle, mode, onCategorySelect, expandedCategories, onToggleExpand, storeSlug, linkBasePath, }) {
|
|
9
9
|
const hasChildren = category.children && category.children.length > 0;
|
|
10
10
|
const isExpanded = expandedCategories.has(category.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/checkout-button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkout-button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/checkout-button.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,UAAU,mBAAmB;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC1C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACrD;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,QAAqB,EACrB,OAAmB,EACnB,IAAW,GACZ,EAAE,mBAAmB,2CAqCrB"}
|
|
@@ -1,258 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from '../../components/ui/button
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useStore } from '../../lib/store-context.js';
|
|
7
|
-
import { useToast } from '../../components/ui/toast.js';
|
|
8
|
-
import { useState, useRef } from 'react';
|
|
9
|
-
import { GuestCheckoutModal } from './guest-checkout-modal.js';
|
|
10
|
-
import { getGuestUserInfo, saveGuestUserInfo, hasCompleteGuestInfo } from '../../lib/guest-user.js';
|
|
3
|
+
import { Button } from '../../components/ui/button';
|
|
4
|
+
import { useStore } from '../../lib/store-context';
|
|
5
|
+
import { useToast } from '../../components/ui/toast';
|
|
11
6
|
import { useRouter } from 'next/navigation';
|
|
12
|
-
import {
|
|
13
|
-
import { normalizePrice } from '../../lib/utils/index.js';
|
|
14
|
-
import { paymentService, isPaymentConfirmed } from '../../lib/services/payment.service.js';
|
|
15
|
-
import { useAuth } from '../../lib/auth-context.js';
|
|
16
|
-
import { setOrderSuccessJustCompleted } from '../../lib/order-success-cart.js';
|
|
17
|
-
import { getOrCreateIdempotencyKey } from '../../lib/utils/idempotency-key.js';
|
|
18
|
-
import { CHECKOUT_UNAVAILABLE_MESSAGE } from '../../lib/checkout-availability.js';
|
|
7
|
+
import { CHECKOUT_UNAVAILABLE_MESSAGE } from '../../lib/checkout-availability';
|
|
19
8
|
export function CheckoutButton({ storeConfig, className, children = 'Checkout', variant = 'default', size = 'lg', }) {
|
|
20
|
-
const { cart
|
|
9
|
+
const { cart } = useStore();
|
|
21
10
|
const { addToast } = useToast();
|
|
22
|
-
const { user, isAuthenticated } = useAuth();
|
|
23
|
-
const [isProcessing, setIsProcessing] = useState(false);
|
|
24
|
-
const [showGuestModal, setShowGuestModal] = useState(false);
|
|
25
|
-
const [pendingCheckout, setPendingCheckout] = useState(null);
|
|
26
11
|
const router = useRouter();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const search = new URLSearchParams({ orderId, ref: transactionRef });
|
|
32
|
-
if (orderNumber)
|
|
33
|
-
search.set('orderNumber', orderNumber);
|
|
34
|
-
if (customerEmail)
|
|
35
|
-
search.set('email', customerEmail);
|
|
36
|
-
router.push(`/${storeConfig.slug}/order/success?${search.toString()}`);
|
|
37
|
-
};
|
|
38
|
-
const { checkout: initiateCheckout, isLoading } = usePayazaCheckout({
|
|
39
|
-
onSuccess: async (response) => {
|
|
40
|
-
try {
|
|
41
|
-
setIsProcessing(true);
|
|
42
|
-
const transactionRef = response.transactionRef || response.callbackData?.data?.transaction_reference;
|
|
43
|
-
const customerEmail = lastCustomerEmailRef.current || getGuestUserInfo()?.email || '';
|
|
44
|
-
if (!transactionRef) {
|
|
45
|
-
addToast('Payment successful but no transaction reference. Please contact support.', 'info');
|
|
46
|
-
setIsProcessing(false);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
addToast('Verifying payment...', 'info');
|
|
50
|
-
try {
|
|
51
|
-
const immediateVerification = await paymentService.verifyPayment(transactionRef, storeConfig.id);
|
|
52
|
-
if (immediateVerification.verified && isPaymentConfirmed(immediateVerification.paymentStatus)) {
|
|
53
|
-
try {
|
|
54
|
-
if (removeOrderItemsFromCart) {
|
|
55
|
-
await removeOrderItemsFromCart(cart.map((item) => ({
|
|
56
|
-
productId: item.productId,
|
|
57
|
-
variantId: item.variantId,
|
|
58
|
-
quantity: item.quantity,
|
|
59
|
-
})));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (cartError) {
|
|
63
|
-
console.error('[CheckoutButton] Failed to clear cart after order:', cartError);
|
|
64
|
-
}
|
|
65
|
-
redirectToOrderSuccess(immediateVerification.orderId || transactionRef, transactionRef, immediateVerification.orderNumber, customerEmail);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Continue with confirmation flow
|
|
71
|
-
}
|
|
72
|
-
if (response.callbackData) {
|
|
73
|
-
const MAX_RETRIES = 3;
|
|
74
|
-
const RETRY_DELAY = 1000;
|
|
75
|
-
let confirmation;
|
|
76
|
-
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
77
|
-
try {
|
|
78
|
-
confirmation = await paymentService.confirmPaymentFromCallback(response.callbackData);
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
console.error(`[CheckoutButton] Payment confirmation attempt ${attempt} failed:`, error);
|
|
83
|
-
if (attempt < MAX_RETRIES) {
|
|
84
|
-
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY * attempt));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (!confirmation) {
|
|
89
|
-
const polledVerification = await paymentService.pollPaymentStatus(transactionRef, storeConfig.id, { maxAttempts: 3, intervalMs: 1000 });
|
|
90
|
-
if (polledVerification?.verified && isPaymentConfirmed(polledVerification.paymentStatus)) {
|
|
91
|
-
redirectToOrderSuccess(polledVerification.orderId || transactionRef, transactionRef, polledVerification.orderNumber, customerEmail);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
addToast('Payment successful. Verifying transaction...', 'info');
|
|
95
|
-
router.push(`/${storeConfig.slug}/payment/callback?reference=${transactionRef}&storeId=${storeConfig.id}`);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
if (removeOrderItemsFromCart) {
|
|
100
|
-
await removeOrderItemsFromCart(cart.map((item) => ({
|
|
101
|
-
productId: item.productId,
|
|
102
|
-
variantId: item.variantId,
|
|
103
|
-
quantity: item.quantity,
|
|
104
|
-
})));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (cartError) {
|
|
108
|
-
console.error('[CheckoutButton] Failed to clear cart after order:', cartError);
|
|
109
|
-
}
|
|
110
|
-
redirectToOrderSuccess(confirmation.orderId, transactionRef, confirmation.orderNumber, customerEmail);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
router.push(`/${storeConfig.slug}/payment/callback?reference=${transactionRef}&storeId=${storeConfig.id}`);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
console.error('[CheckoutButton] Error processing payment callback:', error);
|
|
117
|
-
const transactionRef = response.transactionRef || response.callbackData?.data?.transaction_reference;
|
|
118
|
-
if (transactionRef) {
|
|
119
|
-
addToast('Payment successful. Verifying transaction...', 'info');
|
|
120
|
-
router.push(`/${storeConfig.slug}/payment/callback?reference=${transactionRef}&storeId=${storeConfig.id}`);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
addToast('Payment successful but verification failed. Please contact support.', 'error');
|
|
124
|
-
setIsProcessing(false);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
onError: (error) => {
|
|
129
|
-
addToast(`Checkout error: ${error}`, 'error');
|
|
130
|
-
setIsProcessing(false);
|
|
131
|
-
},
|
|
132
|
-
onClose: () => {
|
|
133
|
-
// onClose is only called when payment was not successful (user canceled)
|
|
134
|
-
// This is now handled correctly by payaza-checkout.ts tracking payment success state
|
|
135
|
-
addToast('Payment canceled', 'info');
|
|
136
|
-
setIsProcessing(false);
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
const payazaPublicKey = storeConfig.payment?.payazaPublicKey || process.env.NEXT_PUBLIC_PAYAZA_PUBLIC_KEY || '';
|
|
140
|
-
const proceedWithCheckout = async (userInfo) => {
|
|
141
|
-
if (storeConfig.checkoutEnabled === false) {
|
|
142
|
-
addToast(CHECKOUT_UNAVAILABLE_MESSAGE, 'error');
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (cart.length === 0) {
|
|
146
|
-
addToast('Your cart is empty', 'error');
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
setIsProcessing(true);
|
|
150
|
-
// DEMO MODE BYPASS
|
|
151
|
-
if (storeConfig.slug.startsWith('demo/')) {
|
|
152
|
-
setTimeout(() => {
|
|
153
|
-
router.push(`/${storeConfig.slug}/payment/callback?status=success&reference=DEMO-${Date.now()}`);
|
|
154
|
-
}, 1500);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
try {
|
|
158
|
-
// Use authenticated user info if available, otherwise use guest info
|
|
159
|
-
const customerEmail = isAuthenticated && user ? user.email : (userInfo?.email || '');
|
|
160
|
-
const customerFirstName = isAuthenticated && user ? user.firstName : (userInfo?.firstName || '');
|
|
161
|
-
const customerLastName = isAuthenticated && user ? user.lastName : (userInfo?.lastName || '');
|
|
162
|
-
const customerPhone = isAuthenticated && user ? (user.phone || '') : (userInfo?.phone || '');
|
|
163
|
-
lastCustomerEmailRef.current = customerEmail;
|
|
164
|
-
// Step 1: Create order via API before payment
|
|
165
|
-
const checkoutResponse = await checkoutService.processCheckout({
|
|
166
|
-
storeId: storeConfig.id,
|
|
167
|
-
items: cart.map(item => ({
|
|
168
|
-
productId: item.productId,
|
|
169
|
-
quantity: Number(item.quantity) || 1,
|
|
170
|
-
price: normalizePrice(item.price),
|
|
171
|
-
variationId: item.variantId && item.variantId.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
|
|
172
|
-
? item.variantId
|
|
173
|
-
: undefined,
|
|
174
|
-
variantId: item.variantId ?? undefined,
|
|
175
|
-
})),
|
|
176
|
-
customerInfo: {
|
|
177
|
-
email: customerEmail,
|
|
178
|
-
firstName: customerFirstName,
|
|
179
|
-
lastName: customerLastName,
|
|
180
|
-
phone: customerPhone,
|
|
181
|
-
},
|
|
182
|
-
shippingAddress: {
|
|
183
|
-
firstName: customerFirstName,
|
|
184
|
-
lastName: customerLastName,
|
|
185
|
-
address1: isAuthenticated && user?.address ? user.address : 'Address to be provided',
|
|
186
|
-
city: isAuthenticated && user?.city ? user.city : 'City',
|
|
187
|
-
state: isAuthenticated && user?.state ? user.state : 'State',
|
|
188
|
-
zipCode: isAuthenticated && user?.zipCode ? user.zipCode : '00000',
|
|
189
|
-
country: isAuthenticated && user?.country ? user.country : 'Country',
|
|
190
|
-
phone: customerPhone,
|
|
191
|
-
},
|
|
192
|
-
paymentMethod: 'payaza',
|
|
193
|
-
customerId: isAuthenticated && user ? user.id : undefined, // Pass customerId for authenticated users
|
|
194
|
-
}, {
|
|
195
|
-
idempotencyKey: getOrCreateIdempotencyKey(checkoutIdempotencyKeyRef),
|
|
196
|
-
});
|
|
197
|
-
// Backend currency-resolved key first, then store config / env fallback (same as CheckoutPage).
|
|
198
|
-
const resolvedPayazaKey = checkoutResponse.payazaPublicKey || payazaPublicKey;
|
|
199
|
-
if (!resolvedPayazaKey) {
|
|
200
|
-
addToast('Payment gateway not configured for this currency. Please contact support.', 'error');
|
|
201
|
-
setIsProcessing(false);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
// Step 2: Convert cart items to checkout format for Payaza (preserve currency so Payaza uses same currency as displayed)
|
|
205
|
-
const storeCurrency = storeConfig.settings?.currency;
|
|
206
|
-
const checkoutItems = cart.map(item => ({
|
|
207
|
-
product: {
|
|
208
|
-
name: item.product.name,
|
|
209
|
-
price: item.price,
|
|
210
|
-
currency: item.product.currency || item.currency || storeCurrency,
|
|
211
|
-
},
|
|
212
|
-
quantity: item.quantity,
|
|
213
|
-
price: item.price,
|
|
214
|
-
}));
|
|
215
|
-
// Prefer cart/store currency over API response so checkout does not switch to USD
|
|
216
|
-
const displayCurrency = (cart[0]?.currency ?? cart[0]?.product?.currency) || storeCurrency || checkoutResponse.currency;
|
|
217
|
-
// Step 3: Generate Payaza checkout config with order details
|
|
218
|
-
const checkoutConfig = generateCheckoutConfig(checkoutItems, customerEmail, resolvedPayazaKey, {
|
|
219
|
-
firstName: customerFirstName,
|
|
220
|
-
lastName: customerLastName,
|
|
221
|
-
phone: customerPhone,
|
|
222
|
-
callbackUrl: `${typeof window !== 'undefined' ? window.location.origin : ''}/${storeConfig.slug}/payment/callback?storeId=${storeConfig.id}`,
|
|
223
|
-
currency: displayCurrency,
|
|
224
|
-
storeId: storeConfig.id,
|
|
225
|
-
orderId: checkoutResponse.orderId,
|
|
226
|
-
orderNumber: checkoutResponse.orderNumber,
|
|
227
|
-
merchantReference: checkoutResponse.merchantReference || checkoutResponse.orderNumber,
|
|
228
|
-
totalAmount: checkoutResponse.totalAmount,
|
|
229
|
-
connectionMode: checkoutResponse.payazaConnectionMode,
|
|
230
|
-
shippingAddress: {
|
|
231
|
-
firstName: customerFirstName,
|
|
232
|
-
lastName: customerLastName,
|
|
233
|
-
address: isAuthenticated && user?.address ? user.address : 'Address to be provided',
|
|
234
|
-
city: isAuthenticated && user?.city ? user.city : 'City',
|
|
235
|
-
state: isAuthenticated && user?.state ? user.state : 'State',
|
|
236
|
-
country: isAuthenticated && user?.country ? user.country : 'Country',
|
|
237
|
-
zipCode: isAuthenticated && user?.zipCode ? user.zipCode : '00000',
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
// Step 4: Use transaction reference from order
|
|
241
|
-
checkoutConfig.reference = checkoutResponse.transactionReference;
|
|
242
|
-
await initiateCheckout(checkoutConfig);
|
|
243
|
-
}
|
|
244
|
-
catch (error) {
|
|
245
|
-
const err = error;
|
|
246
|
-
const isCollectionsDisabled = err?.response?.status === 403 &&
|
|
247
|
-
(err?.response?.data?.code === 'COLLECTIONS_DISABLED' ||
|
|
248
|
-
err?.response?.data?.message?.toLowerCase().includes('not accepting payments'));
|
|
249
|
-
addToast(isCollectionsDisabled ? CHECKOUT_UNAVAILABLE_MESSAGE : 'Failed to initiate checkout. Please try again.', 'error');
|
|
250
|
-
console.error('Checkout error:', error);
|
|
251
|
-
setIsProcessing(false);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
const handleCheckout = async () => {
|
|
255
|
-
if (storeConfig.checkoutEnabled === false) {
|
|
12
|
+
const checkoutDisabled = storeConfig.checkoutEnabled === false;
|
|
13
|
+
const isDisabled = cart.length === 0 || checkoutDisabled;
|
|
14
|
+
const handleCheckout = () => {
|
|
15
|
+
if (checkoutDisabled) {
|
|
256
16
|
addToast(CHECKOUT_UNAVAILABLE_MESSAGE, 'error');
|
|
257
17
|
return;
|
|
258
18
|
}
|
|
@@ -260,39 +20,7 @@ export function CheckoutButton({ storeConfig, className, children = 'Checkout',
|
|
|
260
20
|
addToast('Your cart is empty', 'error');
|
|
261
21
|
return;
|
|
262
22
|
}
|
|
263
|
-
|
|
264
|
-
if (isAuthenticated && user) {
|
|
265
|
-
await proceedWithCheckout();
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
// For guest users, check if we have complete guest user info
|
|
269
|
-
const guestInfo = getGuestUserInfo();
|
|
270
|
-
if (hasCompleteGuestInfo() && guestInfo) {
|
|
271
|
-
// Proceed directly with guest info
|
|
272
|
-
await proceedWithCheckout(guestInfo);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
// Show modal to collect guest info
|
|
276
|
-
setShowGuestModal(true);
|
|
277
|
-
setPendingCheckout(() => () => {
|
|
278
|
-
const info = getGuestUserInfo();
|
|
279
|
-
if (info) {
|
|
280
|
-
proceedWithCheckout(info);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}
|
|
23
|
+
router.push(`/${storeConfig.slug}/checkout`);
|
|
284
24
|
};
|
|
285
|
-
|
|
286
|
-
// Save guest info to localStorage
|
|
287
|
-
saveGuestUserInfo(userInfo);
|
|
288
|
-
setShowGuestModal(false);
|
|
289
|
-
// Proceed with checkout
|
|
290
|
-
proceedWithCheckout(userInfo);
|
|
291
|
-
};
|
|
292
|
-
const checkoutDisabled = storeConfig.checkoutEnabled === false;
|
|
293
|
-
const isDisabled = isLoading || isProcessing || cart.length === 0 || checkoutDisabled;
|
|
294
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: handleCheckout, disabled: isDisabled, variant: variant, size: size, className: className, title: checkoutDisabled ? CHECKOUT_UNAVAILABLE_MESSAGE : undefined, children: isLoading || isProcessing ? 'Processing...' : checkoutDisabled ? 'Checkout unavailable' : children }), checkoutDisabled && (_jsx("p", { className: "mt-2 text-sm text-muted-foreground text-center", children: CHECKOUT_UNAVAILABLE_MESSAGE })), _jsx(GuestCheckoutModal, { isOpen: showGuestModal, onClose: () => {
|
|
295
|
-
setShowGuestModal(false);
|
|
296
|
-
setPendingCheckout(null);
|
|
297
|
-
}, onSubmit: handleGuestInfoSubmit, initialData: getGuestUserInfo() || undefined })] }));
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: handleCheckout, disabled: isDisabled, variant: variant, size: size, className: className, title: checkoutDisabled ? CHECKOUT_UNAVAILABLE_MESSAGE : undefined, children: checkoutDisabled ? 'Checkout unavailable' : children }), checkoutDisabled && (_jsx("p", { className: "mt-2 text-sm text-muted-foreground text-center", children: CHECKOUT_UNAVAILABLE_MESSAGE }))] }));
|
|
298
26
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { Modal } from './modal
|
|
5
|
-
import { Button } from './button
|
|
4
|
+
import { Modal } from './modal';
|
|
5
|
+
import { Button } from './button';
|
|
6
6
|
import { User, Mail, Phone, ShoppingBag, ShieldCheck, ArrowRight } from 'lucide-react';
|
|
7
|
-
import { cn } from '../../lib/utils
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
8
8
|
export function GuestCheckoutModal({ isOpen, onClose, onSubmit, initialData, }) {
|
|
9
9
|
const [formData, setFormData] = React.useState({
|
|
10
10
|
firstName: initialData?.firstName || '',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { cn } from '../../lib/utils
|
|
4
|
-
import { Skeleton } from './skeleton
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { Skeleton } from './skeleton';
|
|
5
5
|
export function ImageSkeleton({ className, aspectRatio = 'square' }) {
|
|
6
6
|
const aspectRatioClasses = {
|
|
7
7
|
square: 'aspect-square',
|
|
@@ -4,7 +4,9 @@ interface ImageWithFallbackProps extends React.ImgHTMLAttributes<HTMLImageElemen
|
|
|
4
4
|
skeletonAspectRatio?: 'square' | '3/4' | '4/3' | '4/5' | '16/9' | 'auto';
|
|
5
5
|
showSkeletonOnError?: boolean;
|
|
6
6
|
lazy?: boolean;
|
|
7
|
+
/** Mark LCP / above-the-fold images so the browser prioritizes them. */
|
|
8
|
+
priority?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export declare function ImageWithFallback({ src, alt, className, fallbackSrc, fallbackText, skeletonAspectRatio, showSkeletonOnError, lazy, ...props }: ImageWithFallbackProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ImageWithFallback({ src, alt, className, fallbackSrc, fallbackText, skeletonAspectRatio, showSkeletonOnError, lazy, priority, ...props }: ImageWithFallbackProps): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
10
12
|
//# sourceMappingURL=image-with-fallback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-with-fallback.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image-with-fallback.tsx"],"names":[],"mappings":"AAMA,UAAU,sBAAuB,SAAQ,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"image-with-fallback.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image-with-fallback.tsx"],"names":[],"mappings":"AAMA,UAAU,sBAAuB,SAAQ,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAKD,wBAAgB,iBAAiB,CAAC,EAChC,GAAG,EACH,GAAG,EACH,SAAS,EACT,WAAW,EACX,YAAY,EACZ,mBAA8B,EAC9B,mBAA0B,EAC1B,IAAY,EACZ,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,sBAAsB,2CA+GxB"}
|
|
@@ -1,165 +1,81 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect, useRef } from 'react';
|
|
4
|
-
import { cn } from '../../lib/utils
|
|
5
|
-
import { ImageSkeleton } from './image-skeleton
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const trimmed = input.trim();
|
|
11
|
-
return trimmed.length > 0 ? trimmed : undefined;
|
|
12
|
-
}
|
|
13
|
-
if (typeof input === 'object' && input !== null) {
|
|
14
|
-
const obj = input;
|
|
15
|
-
for (const key of ['url', 'src', 'image', 'imageUrl']) {
|
|
16
|
-
const value = obj[key];
|
|
17
|
-
if (typeof value === 'string' && value.trim())
|
|
18
|
-
return value.trim();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
22
|
-
return extractSrcUrl(input[0]);
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
/** Keeps `[data-payaza-*]` on the clickable wrapper so skeletons/overlays still resolve image targets */
|
|
27
|
-
function partitionDataAttrs(props) {
|
|
28
|
-
const dataAttrs = {};
|
|
29
|
-
const imgProps = {};
|
|
30
|
-
for (const [key, val] of Object.entries(props)) {
|
|
31
|
-
if (key.startsWith('data-') && val != null && val !== '') {
|
|
32
|
-
dataAttrs[key] = typeof val === 'string' ? val : String(val);
|
|
33
|
-
}
|
|
34
|
-
else if (val !== undefined) {
|
|
35
|
-
imgProps[key] = val;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return { dataAttrs, imgProps };
|
|
39
|
-
}
|
|
40
|
-
export function ImageWithFallback({ src, alt, className, fallbackSrc, fallbackText, skeletonAspectRatio = 'square', showSkeletonOnError = true, lazy = false, ...props }) {
|
|
41
|
-
const { dataAttrs, imgProps } = partitionDataAttrs(props);
|
|
42
|
-
const initialSrc = extractSrcUrl(src) || extractSrcUrl(fallbackSrc);
|
|
43
|
-
const [isLoading, setIsLoading] = useState(!!initialSrc && !lazy);
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
import { ImageSkeleton } from './image-skeleton';
|
|
6
|
+
const MAX_RETRIES = 2;
|
|
7
|
+
const RETRY_DELAY_MS = 400;
|
|
8
|
+
export function ImageWithFallback({ src, alt, className, fallbackSrc, fallbackText, skeletonAspectRatio = 'square', showSkeletonOnError = true, lazy = false, priority = false, ...props }) {
|
|
9
|
+
const initialSrc = typeof src === 'string' && src.trim() ? src : undefined;
|
|
44
10
|
const [error, setError] = useState(false);
|
|
45
|
-
const [currentSrc, setCurrentSrc] = useState(
|
|
46
|
-
const [
|
|
11
|
+
const [currentSrc, setCurrentSrc] = useState(initialSrc);
|
|
12
|
+
const [reloadKey, setReloadKey] = useState(0);
|
|
47
13
|
const prevSrcRef = useRef(src);
|
|
48
14
|
const prevFallbackRef = useRef(fallbackSrc);
|
|
49
15
|
const hasTriedFallback = useRef(false);
|
|
50
|
-
const
|
|
51
|
-
const
|
|
16
|
+
const retriesRef = useRef(0);
|
|
17
|
+
const retryTimerRef = useRef(null);
|
|
52
18
|
const mountedRef = useRef(false);
|
|
53
19
|
useEffect(() => {
|
|
54
20
|
mountedRef.current = true;
|
|
55
21
|
return () => {
|
|
56
22
|
mountedRef.current = false;
|
|
23
|
+
if (retryTimerRef.current)
|
|
24
|
+
clearTimeout(retryTimerRef.current);
|
|
57
25
|
};
|
|
58
26
|
}, []);
|
|
59
27
|
useEffect(() => {
|
|
60
|
-
|
|
28
|
+
const currentSrcValue = typeof src === 'string' && src.trim() ? src : undefined;
|
|
29
|
+
const hasChanged = currentSrcValue !== prevSrcRef.current || fallbackSrc !== prevFallbackRef.current;
|
|
30
|
+
if (!hasChanged)
|
|
61
31
|
return;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
}, { rootMargin: '100px', threshold: 0.01 });
|
|
75
|
-
observer.observe(containerRef.current);
|
|
76
|
-
return () => observer.disconnect();
|
|
77
|
-
}, [lazy, isInView, src, fallbackSrc]);
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
const currentSrcValue = extractSrcUrl(src);
|
|
80
|
-
const extractedFallback = extractSrcUrl(fallbackSrc);
|
|
81
|
-
const hasChanged = currentSrcValue !== extractSrcUrl(prevSrcRef.current) ||
|
|
82
|
-
extractedFallback !== extractSrcUrl(prevFallbackRef.current);
|
|
83
|
-
if (hasChanged) {
|
|
84
|
-
const newSrc = currentSrcValue || extractedFallback;
|
|
85
|
-
setIsLoading(!!newSrc && !lazy);
|
|
86
|
-
setCurrentSrc(lazy && !isInView ? undefined : newSrc);
|
|
87
|
-
setError(false);
|
|
88
|
-
hasTriedFallback.current = false;
|
|
89
|
-
prevSrcRef.current = src;
|
|
90
|
-
prevFallbackRef.current = fallbackSrc;
|
|
91
|
-
if (imageRef.current) {
|
|
92
|
-
imageRef.current.src = '';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, [src, fallbackSrc, lazy, isInView]);
|
|
96
|
-
const checkAndUpdateImageState = (img, forceCheck = false) => {
|
|
97
|
-
if (!mountedRef.current || !img)
|
|
98
|
-
return false;
|
|
99
|
-
if (img.complete && img.naturalHeight !== 0) {
|
|
100
|
-
if (forceCheck || isLoading) {
|
|
101
|
-
setIsLoading(false);
|
|
102
|
-
setError(false);
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
};
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (!mountedRef.current || !currentSrc || !isLoading)
|
|
110
|
-
return;
|
|
111
|
-
const syncLoadedState = () => {
|
|
112
|
-
if (imageRef.current) {
|
|
113
|
-
checkAndUpdateImageState(imageRef.current, true);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
syncLoadedState();
|
|
117
|
-
const rafId = requestAnimationFrame(syncLoadedState);
|
|
118
|
-
const timeoutId = window.setTimeout(syncLoadedState, 100);
|
|
119
|
-
return () => {
|
|
120
|
-
cancelAnimationFrame(rafId);
|
|
121
|
-
window.clearTimeout(timeoutId);
|
|
122
|
-
};
|
|
123
|
-
}, [currentSrc, isLoading]);
|
|
124
|
-
const handleLoad = () => {
|
|
125
|
-
if (mountedRef.current) {
|
|
126
|
-
setIsLoading(false);
|
|
127
|
-
setError(false);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
32
|
+
if (retryTimerRef.current)
|
|
33
|
+
clearTimeout(retryTimerRef.current);
|
|
34
|
+
const newSrc = currentSrcValue || (fallbackSrc && fallbackSrc.trim() ? fallbackSrc : undefined);
|
|
35
|
+
setCurrentSrc(newSrc);
|
|
36
|
+
setError(false);
|
|
37
|
+
setReloadKey(0);
|
|
38
|
+
hasTriedFallback.current = false;
|
|
39
|
+
retriesRef.current = 0;
|
|
40
|
+
prevSrcRef.current = currentSrcValue;
|
|
41
|
+
prevFallbackRef.current = fallbackSrc;
|
|
42
|
+
}, [src, fallbackSrc]);
|
|
130
43
|
const handleError = () => {
|
|
131
|
-
|
|
132
|
-
|
|
44
|
+
if (!mountedRef.current)
|
|
45
|
+
return;
|
|
46
|
+
if (fallbackSrc && fallbackSrc.trim() && !hasTriedFallback.current && currentSrc !== fallbackSrc) {
|
|
133
47
|
hasTriedFallback.current = true;
|
|
134
|
-
|
|
48
|
+
retriesRef.current = 0;
|
|
49
|
+
setCurrentSrc(fallbackSrc);
|
|
135
50
|
setError(false);
|
|
136
|
-
setIsLoading(true);
|
|
137
51
|
return;
|
|
138
52
|
}
|
|
53
|
+
if (retriesRef.current < MAX_RETRIES && currentSrc) {
|
|
54
|
+
retriesRef.current += 1;
|
|
55
|
+
if (retryTimerRef.current)
|
|
56
|
+
clearTimeout(retryTimerRef.current);
|
|
57
|
+
retryTimerRef.current = setTimeout(() => {
|
|
58
|
+
if (!mountedRef.current)
|
|
59
|
+
return;
|
|
60
|
+
setReloadKey((k) => k + 1);
|
|
61
|
+
setError(false);
|
|
62
|
+
}, RETRY_DELAY_MS * retriesRef.current);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
console.warn('[ImageWithFallback] Image failed to load:', {
|
|
66
|
+
currentSrc,
|
|
67
|
+
originalSrc: src,
|
|
68
|
+
fallbackSrc,
|
|
69
|
+
alt,
|
|
70
|
+
});
|
|
139
71
|
setError(true);
|
|
140
|
-
setIsLoading(false);
|
|
141
72
|
};
|
|
142
|
-
if (!currentSrc
|
|
143
|
-
return
|
|
144
|
-
}
|
|
145
|
-
if (isLoading && currentSrc) {
|
|
146
|
-
return (_jsxs("div", { ref: containerRef, className: cn('relative w-full h-full', className), ...dataAttrs, children: [_jsx("img", { ref: (node) => {
|
|
147
|
-
imageRef.current = node;
|
|
148
|
-
if (node) {
|
|
149
|
-
checkAndUpdateImageState(node, true);
|
|
150
|
-
}
|
|
151
|
-
}, src: currentSrc, alt: alt || 'Product image', className: "absolute inset-0 h-full w-full opacity-0", onLoad: handleLoad, onError: handleError, loading: "eager", decoding: "async", ...imgProps }), _jsx(ImageSkeleton, { className: "absolute inset-0 h-full w-full", aspectRatio: skeletonAspectRatio })] }));
|
|
73
|
+
if (!currentSrc) {
|
|
74
|
+
return _jsx(ImageSkeleton, { className: className, aspectRatio: skeletonAspectRatio });
|
|
152
75
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
return (_jsxs("div", { ref: containerRef, className: cn('flex flex-col items-center justify-center bg-gray-100 text-gray-400 border border-gray-200', className), style: { minHeight: '100px' }, ...dataAttrs, children: [_jsx("svg", { className: "w-1/4 h-1/4 max-w-[48px] max-h-[48px] opacity-20", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }), fallbackText && (_jsx("span", { className: "text-[10px] uppercase tracking-widest font-bold mt-2 opacity-40", children: fallbackText }))] }));
|
|
76
|
+
const showErrorPlaceholder = error && (!showSkeletonOnError || !!fallbackText);
|
|
77
|
+
if (error && showSkeletonOnError && !fallbackText) {
|
|
78
|
+
return _jsx(ImageSkeleton, { className: className, aspectRatio: skeletonAspectRatio });
|
|
158
79
|
}
|
|
159
|
-
return (
|
|
160
|
-
imageRef.current = node;
|
|
161
|
-
if (node) {
|
|
162
|
-
checkAndUpdateImageState(node, true);
|
|
163
|
-
}
|
|
164
|
-
}, src: currentSrc, alt: alt || 'Product image', className: cn('h-full w-full object-cover', className), onLoad: handleLoad, onError: handleError, loading: lazy ? 'lazy' : 'eager', decoding: "async", ...imgProps }) }));
|
|
80
|
+
return (_jsxs("div", { className: cn('relative', className), children: [!error && (_jsx("img", { src: currentSrc, alt: alt || 'Product image', className: cn('absolute inset-0 h-full w-full', className), onError: handleError, loading: lazy && !priority ? 'lazy' : 'eager', decoding: priority ? 'sync' : 'async', fetchPriority: priority ? 'high' : lazy ? 'low' : 'auto', ...props }, `${currentSrc}-${reloadKey}`)), showErrorPlaceholder && (_jsxs("div", { className: cn('flex flex-col items-center justify-center bg-gray-100 text-gray-400 border border-gray-200', className), style: { minHeight: '100px' }, children: [_jsx("svg", { className: "w-1/4 h-1/4 max-w-[48px] max-h-[48px] opacity-20", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }), fallbackText && (_jsx("span", { className: "text-[10px] uppercase tracking-widest font-bold mt-2 opacity-40", children: fallbackText }))] }))] }));
|
|
165
81
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { cn } from "../../lib/utils
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
4
|
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
5
5
|
return (_jsx("input", { type: type, className: cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref, ...props }));
|
|
6
6
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { cn } from '../../lib/utils
|
|
4
|
-
import { formatLimitedOfferEndsAt, isActiveLimitedTimeOffer, } from '../../lib/limited-time-offer
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { formatLimitedOfferEndsAt, isActiveLimitedTimeOffer, } from '../../lib/limited-time-offer';
|
|
5
5
|
export function LimitedTimeOfferBadge({ product, className, compact = false, }) {
|
|
6
6
|
if (!isActiveLimitedTimeOffer(product))
|
|
7
7
|
return null;
|