storefront-layouts 1.0.17 → 1.0.19
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/ui/category-tree.d.ts +5 -1
- package/dist/components/ui/category-tree.d.ts.map +1 -1
- package/dist/components/ui/category-tree.js +36 -12
- package/dist/components/ui/product-card.d.ts +1 -1
- package/dist/components/ui/product-card.d.ts.map +1 -1
- package/dist/components/ui/product-card.js +15 -15
- package/dist/editor/alignment-schemas/booking.d.ts.map +1 -1
- package/dist/editor/alignment-schemas/booking.js +104 -61
- package/dist/editor/alignment-schemas/clothing-minimal.d.ts.map +1 -1
- package/dist/editor/alignment-schemas/clothing-minimal.js +74 -30
- package/dist/editor/alignment-schemas/clothing.d.ts.map +1 -1
- package/dist/editor/alignment-schemas/clothing.js +87 -32
- package/dist/editor/alignment-schemas/food.d.ts.map +1 -1
- package/dist/editor/alignment-schemas/food.js +103 -48
- package/dist/editor/payaza-form/PayazaFormEditor.d.ts.map +1 -1
- package/dist/editor/payaza-form/PayazaFormEditor.js +13 -1
- package/dist/editor/payaza-form/components/ImageField.d.ts.map +1 -1
- package/dist/editor/payaza-form/components/ImageField.js +1 -1
- package/dist/editor/payaza-form/components/ToggleField.d.ts.map +1 -1
- package/dist/editor/payaza-form/components/ToggleField.js +2 -1
- package/dist/editor/payaza-form/data-merger.d.ts.map +1 -1
- package/dist/editor/payaza-form/data-merger.js +61 -9
- package/dist/editor/shared/EditorHeader.d.ts.map +1 -1
- package/dist/editor/shared/EditorHeader.js +20 -25
- package/dist/editor/shared/IframePreview.d.ts.map +1 -1
- package/dist/editor/shared/IframePreview.js +46 -22
- package/dist/hooks/use-payaza-checkout.d.ts.map +1 -1
- package/dist/hooks/use-payaza-checkout.js +0 -2
- package/dist/layouts/booking/components/booking-about-defaults.d.ts +16 -0
- package/dist/layouts/booking/components/booking-about-defaults.d.ts.map +1 -1
- package/dist/layouts/booking/components/booking-about-defaults.js +171 -1
- package/dist/layouts/booking/components/booking-footer-defaults.d.ts +2 -2
- package/dist/layouts/booking/components/booking-footer-defaults.d.ts.map +1 -1
- package/dist/layouts/booking/components/booking-footer-defaults.js +5 -8
- package/dist/layouts/booking/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/AboutPage.js +51 -35
- package/dist/layouts/booking/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/booking/pages/ContactPage.js +2 -2
- package/dist/layouts/booking-agenda/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/AboutPage.js +22 -30
- package/dist/layouts/booking-agenda/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/booking-agenda/pages/ContactPage.js +2 -2
- package/dist/layouts/clothing/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/AboutPage.js +40 -17
- package/dist/layouts/clothing/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ContactPage.js +3 -3
- package/dist/layouts/clothing/pages/ProductsPage.d.ts.map +1 -1
- package/dist/layouts/clothing/pages/ProductsPage.js +18 -4
- package/dist/layouts/clothing/styles/clothing.css +28 -1
- package/dist/layouts/clothing-minimal/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/AboutPage.js +41 -34
- package/dist/layouts/clothing-minimal/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/clothing-minimal/pages/ContactPage.js +2 -2
- package/dist/layouts/electronics/components/ElectronicsStoreFooter.d.ts.map +1 -1
- package/dist/layouts/electronics/components/ElectronicsStoreFooter.js +1 -1
- package/dist/layouts/electronics/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/AboutPage.js +13 -25
- package/dist/layouts/electronics/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/electronics/pages/ContactPage.js +2 -2
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/components/ElectronicsHomePageGrid.js +1 -1
- package/dist/layouts/electronics-grid/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/AboutPage.js +13 -25
- package/dist/layouts/electronics-grid/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/electronics-grid/pages/ContactPage.js +2 -2
- package/dist/layouts/food/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/AboutPage.js +48 -52
- package/dist/layouts/food/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/food/pages/ContactPage.js +2 -2
- package/dist/layouts/food-modern/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/AboutPage.js +16 -26
- package/dist/layouts/food-modern/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/food-modern/pages/ContactPage.js +2 -2
- package/dist/layouts/motivational-speaker/pages/AboutPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/AboutPage.js +15 -25
- package/dist/layouts/motivational-speaker/pages/ContactPage.d.ts.map +1 -1
- package/dist/layouts/motivational-speaker/pages/ContactPage.js +2 -2
- package/dist/layouts/shared/about-story-media.d.ts +27 -0
- package/dist/layouts/shared/about-story-media.d.ts.map +1 -0
- package/dist/layouts/shared/about-story-media.js +46 -0
- package/dist/layouts/shared/components/StoreFooter.d.ts.map +1 -1
- package/dist/layouts/shared/components/StoreFooter.js +4 -6
- package/dist/layouts/shared/components/StoreHeader.d.ts.map +1 -1
- package/dist/layouts/shared/components/StoreHeader.js +60 -6
- package/dist/layouts/shared/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/layouts/shared/pages/CheckoutPage.js +0 -78
- package/dist/layouts/shared/wrappers/ClothingLayout.d.ts.map +1 -1
- package/dist/layouts/shared/wrappers/ClothingLayout.js +17 -0
- package/dist/lib/mock-stores.js +1 -1
- package/dist/lib/payaza-checkout.d.ts.map +1 -1
- package/dist/lib/payaza-checkout.js +0 -33
- package/dist/lib/preview-data.d.ts.map +1 -1
- package/dist/lib/preview-data.js +3 -2
- package/dist/lib/utils/category-tree.d.ts +2 -0
- package/dist/lib/utils/category-tree.d.ts.map +1 -1
- package/dist/lib/utils/category-tree.js +15 -0
- package/dist/lib/utils/footer-nav-defaults.d.ts +11 -2
- package/dist/lib/utils/footer-nav-defaults.d.ts.map +1 -1
- package/dist/lib/utils/footer-nav-defaults.js +29 -22
- package/dist/styles/index.css +203 -212
- package/package.json +1 -1
|
@@ -28,12 +28,14 @@ const getNavIcon = (label) => {
|
|
|
28
28
|
return LayoutGrid;
|
|
29
29
|
return null;
|
|
30
30
|
};
|
|
31
|
-
import { useState, useEffect, useRef } from 'react';
|
|
31
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
32
|
+
import { createPortal } from 'react-dom';
|
|
32
33
|
import { usePathname } from 'next/navigation';
|
|
33
34
|
import { cn, formatStoreDisplayName } from '../../../lib/utils/index.js';
|
|
34
35
|
import { useAuth } from '../../../lib/auth-context.js';
|
|
35
36
|
import { StoreLogo } from '../../../components/ui/store-logos.js';
|
|
36
37
|
import { useStore } from '../../../lib/store-context.js';
|
|
38
|
+
import { resolveStoreHeaderNavLinks } from '../../../lib/utils/footer-nav-defaults.js';
|
|
37
39
|
import { getLogoUrl } from '../../../lib/utils/asset-helpers.js';
|
|
38
40
|
import { AvatarImage } from '../../../components/ui/avatar-image.js';
|
|
39
41
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
@@ -46,6 +48,9 @@ function headerNavLinkClass(isDarkTheme) {
|
|
|
46
48
|
export function StoreHeader({ storeConfig: initialConfig, cartItemCount = 0 }) {
|
|
47
49
|
const { store, wishlist, setIsCartOpen, cartCount: storeCartCount } = useStore();
|
|
48
50
|
const storeConfig = store || initialConfig;
|
|
51
|
+
const isClothingLayout = storeConfig.layout === 'clothing';
|
|
52
|
+
const catalogueMenuRadius = isClothingLayout ? 'rounded-sm' : 'rounded-2xl';
|
|
53
|
+
const catalogueItemRadius = isClothingLayout ? 'rounded-sm' : 'rounded-xl';
|
|
49
54
|
const wishlistCount = wishlist.length;
|
|
50
55
|
const displayCartCount = storeCartCount > 0 ? storeCartCount : cartItemCount;
|
|
51
56
|
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
|
@@ -57,6 +62,9 @@ export function StoreHeader({ storeConfig: initialConfig, cartItemCount = 0 }) {
|
|
|
57
62
|
const { isAuthenticated, user, openLogin } = useAuth();
|
|
58
63
|
const [mounted, setMounted] = useState(false);
|
|
59
64
|
const searchInputRef = useRef(null);
|
|
65
|
+
const catalogueRef = useRef(null);
|
|
66
|
+
const catalogueButtonRef = useRef(null);
|
|
67
|
+
const [catalogueAnchor, setCatalogueAnchor] = useState(null);
|
|
60
68
|
// Filter to show only parent categories (no parentId)
|
|
61
69
|
const allCategories = storeConfig.categories || [];
|
|
62
70
|
const parentCategories = allCategories.filter(cat => !cat.parentId);
|
|
@@ -73,9 +81,42 @@ export function StoreHeader({ storeConfig: initialConfig, cartItemCount = 0 }) {
|
|
|
73
81
|
searchInputRef.current.focus();
|
|
74
82
|
}
|
|
75
83
|
}, [searchOpen]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!isCatalogueOpen)
|
|
86
|
+
return;
|
|
87
|
+
const onPointerDown = (event) => {
|
|
88
|
+
if (catalogueRef.current && !catalogueRef.current.contains(event.target)) {
|
|
89
|
+
setIsCatalogueOpen(false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
document.addEventListener('mousedown', onPointerDown);
|
|
93
|
+
return () => document.removeEventListener('mousedown', onPointerDown);
|
|
94
|
+
}, [isCatalogueOpen]);
|
|
95
|
+
const syncCatalogueAnchor = useCallback(() => {
|
|
96
|
+
const el = catalogueButtonRef.current;
|
|
97
|
+
if (!el)
|
|
98
|
+
return;
|
|
99
|
+
const rect = el.getBoundingClientRect();
|
|
100
|
+
setCatalogueAnchor({ top: rect.bottom + 6, left: rect.left + rect.width / 2 });
|
|
101
|
+
}, []);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!isCatalogueOpen) {
|
|
104
|
+
setCatalogueAnchor(null);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
syncCatalogueAnchor();
|
|
108
|
+
const onLayout = () => syncCatalogueAnchor();
|
|
109
|
+
window.addEventListener('scroll', onLayout, true);
|
|
110
|
+
window.addEventListener('resize', onLayout);
|
|
111
|
+
return () => {
|
|
112
|
+
window.removeEventListener('scroll', onLayout, true);
|
|
113
|
+
window.removeEventListener('resize', onLayout);
|
|
114
|
+
};
|
|
115
|
+
}, [isCatalogueOpen, syncCatalogueAnchor]);
|
|
76
116
|
const primaryColor = storeConfig.branding.primaryColor;
|
|
77
117
|
const storeDisplayName = formatStoreDisplayName(storeConfig.name);
|
|
78
118
|
const isDarkTheme = storeConfig.branding.theme === 'dark' || storeConfig.type === 'electronics';
|
|
119
|
+
const { allLinks: headerNavLinks, centerLinks: centerNavLinks, contactLink } = resolveStoreHeaderNavLinks(storeConfig);
|
|
79
120
|
if (!mounted) {
|
|
80
121
|
return null;
|
|
81
122
|
}
|
|
@@ -84,8 +125,8 @@ export function StoreHeader({ storeConfig: initialConfig, cartItemCount = 0 }) {
|
|
|
84
125
|
: scrolled ? 'rgba(255, 255, 255, 0.98)' : 'rgba(255, 255, 255, 0.9)';
|
|
85
126
|
return (_jsxs(_Fragment, { children: [_jsx("header", { "data-section": "header", className: cn("sticky top-0 z-[60] w-full transition-all duration-500 backdrop-blur-xl border-b", scrolled
|
|
86
127
|
? "shadow-lg border-gray-100 dark:border-white/5 py-0 sm:py-1"
|
|
87
|
-
: "border-transparent py-0 sm:py-2.5"), style: { backgroundColor: headerBg }, children: _jsx("div", { className: "container mx-auto px-3 sm:px-6 lg:px-8", children: _jsxs("div", { className: "flex h-12 items-center gap-2 sm:gap-3 sm:h-14 lg:h-16", children: [_jsx("div", { className: "flex items-center flex-shrink-0 z-20", children: _jsxs(Link, { href: `/${storeConfig.slug}`, className: "flex items-center gap-3 group", children: [_jsx(StoreLogo, { storeConfig: storeConfig, className: "h-8 w-8 transition-transform duration-500 group-hover:scale-105 sm:h-9 sm:w-9 lg:h-10 lg:w-10", alt: storeDisplayName }), !getLogoUrl(storeConfig) && (_jsx("span", { className: cn("text-xl font-bold tracking-tight transition-colors hidden xl:block", isDarkTheme ? "text-white" : "text-gray-900"), children: storeDisplayName }))] }) }), _jsx("nav", { className: "hidden lg:flex flex-1 min-w-0 items-center justify-center gap-1 overflow-hidden px-2 pr-
|
|
88
|
-
const menuItems =
|
|
128
|
+
: "border-transparent py-0 sm:py-2.5"), style: { backgroundColor: headerBg }, children: _jsx("div", { className: "container mx-auto px-3 sm:px-6 lg:px-8", children: _jsxs("div", { className: "flex h-12 items-center gap-2 sm:gap-3 sm:h-14 lg:h-16", children: [_jsx("div", { className: "flex items-center flex-shrink-0 z-20", children: _jsxs(Link, { href: `/${storeConfig.slug}`, className: "flex items-center gap-3 group", children: [_jsx(StoreLogo, { storeConfig: storeConfig, className: "h-8 w-8 transition-transform duration-500 group-hover:scale-105 sm:h-9 sm:w-9 lg:h-10 lg:w-10", alt: storeDisplayName }), !getLogoUrl(storeConfig) && (_jsx("span", { className: cn("text-xl font-bold tracking-tight transition-colors hidden xl:block", isDarkTheme ? "text-white" : "text-gray-900"), children: storeDisplayName }))] }) }), _jsx("nav", { className: "hidden lg:flex flex-1 min-w-0 items-center justify-center gap-1 overflow-hidden px-2 pr-2 mr-1", children: (() => {
|
|
129
|
+
const menuItems = centerNavLinks;
|
|
89
130
|
const categories = parentCategories;
|
|
90
131
|
// Logic to determine how many categories to show directly
|
|
91
132
|
// Max total top-level items (menu + categories)
|
|
@@ -96,12 +137,25 @@ export function StoreHeader({ storeConfig: initialConfig, cartItemCount = 0 }) {
|
|
|
96
137
|
const overflowCategories = categories.slice(categoriesToShowCount);
|
|
97
138
|
return (_jsxs(_Fragment, { children: [menuItems.map((item, index) => {
|
|
98
139
|
return (_jsx(Link, { href: `/${storeConfig.slug}${item.href}`, className: headerNavLinkClass(isDarkTheme), children: item.label }, `nav-${index}-${item.href}`));
|
|
99
|
-
}), categoriesToDisplay.map((cat) => (_jsx(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: headerNavLinkClass(isDarkTheme), children: cat.name }, `cat-direct-${cat.id}`))), overflowCategories.length > 0 && (_jsxs("div", { className: "relative
|
|
100
|
-
|
|
140
|
+
}), categoriesToDisplay.map((cat) => (_jsx(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: headerNavLinkClass(isDarkTheme), children: cat.name }, `cat-direct-${cat.id}`))), overflowCategories.length > 0 && (_jsxs("div", { ref: catalogueRef, className: "relative", onMouseEnter: () => setIsCatalogueOpen(true), onMouseLeave: () => setIsCatalogueOpen(false), children: [_jsxs("button", { ref: catalogueButtonRef, type: "button", "aria-expanded": isCatalogueOpen, "aria-haspopup": "menu", className: headerNavLinkClass(isDarkTheme), onClick: () => {
|
|
141
|
+
setIsCatalogueOpen((open) => {
|
|
142
|
+
const next = !open;
|
|
143
|
+
if (next)
|
|
144
|
+
syncCatalogueAnchor();
|
|
145
|
+
return next;
|
|
146
|
+
});
|
|
147
|
+
}, children: [categoriesToDisplay.length > 0 ? "More" : "Catalogue", _jsx(ChevronDown, { className: cn("w-3.5 h-3.5 transition-transform duration-300", isCatalogueOpen && "rotate-180") })] }), mounted &&
|
|
148
|
+
typeof document !== 'undefined' &&
|
|
149
|
+
isCatalogueOpen &&
|
|
150
|
+
catalogueAnchor &&
|
|
151
|
+
createPortal(_jsx(AnimatePresence, { children: _jsx(motion.div, { initial: { opacity: 0, y: 8, scale: 0.98 }, animate: { opacity: 1, y: 0, scale: 1 }, exit: { opacity: 0, y: 8, scale: 0.98 }, transition: { duration: 0.15 }, style: { top: catalogueAnchor.top, left: catalogueAnchor.left }, className: cn('fixed z-[100] w-64 -translate-x-1/2 p-3 shadow-2xl border backdrop-blur-2xl', catalogueMenuRadius, isDarkTheme ? 'bg-black/90 border-white/10' : 'bg-white/95 border-gray-100'), children: _jsx("div", { className: "grid gap-1 overflow-y-auto max-h-[70vh]", children: overflowCategories.map((cat) => (_jsxs(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: cn('flex items-center justify-between px-4 py-3 transition-all group/item', catalogueItemRadius, isDarkTheme ? 'hover:bg-white/5' : 'hover:bg-gray-50'), onClick: () => setIsCatalogueOpen(false), children: [_jsx("span", { className: cn('text-sm font-medium', isDarkTheme
|
|
152
|
+
? 'text-gray-300 group-hover/item:text-white'
|
|
153
|
+
: 'text-gray-600 group-hover/item:text-black'), children: cat.name }), _jsx(ChevronRight, { className: "w-4 h-4 opacity-0 -translate-x-2 group-hover/item:opacity-100 group-hover/item:translate-x-0 transition-all text-gray-400" })] }, `cat-overflow-${cat.id}`))) }) }) }), document.body)] }))] }));
|
|
154
|
+
})() }), _jsxs("div", { className: "flex items-center gap-0.5 sm:gap-1 lg:gap-2 flex-shrink-0 z-30 ml-auto lg:ml-0 lg:pl-1 bg-inherit", children: [contactLink && (_jsx(Link, { href: `/${storeConfig.slug}${contactLink.href}`, className: cn(headerNavLinkClass(isDarkTheme), 'hidden lg:inline-flex flex-shrink-0 relative z-40 mr-0.5'), children: contactLink.label })), _jsx(Button, { variant: "ghost", size: "icon", className: cn("h-9 w-9 sm:h-10 sm:w-10 rounded-full transition-all relative", isDarkTheme ? "hover:bg-white/10 text-gray-300" : "hover:bg-gray-100 text-gray-600", searchOpen && "bg-transparent shadow-none"), onClick: () => setSearchOpen(true), children: _jsx(Search, { className: "h-5 w-5" }) }), storeConfig.features.wishlist && (_jsx(Link, { href: `/${storeConfig.slug}/wishlist`, children: _jsxs(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 sm:h-10 sm:w-10 relative rounded-full group hover:bg-red-50 dark:hover:bg-red-900/10", children: [_jsx(Heart, { className: cn("h-5 w-5 transition-all group-hover:scale-110", wishlistCount > 0 && "fill-red-500 text-red-500") }), wishlistCount > 0 && (_jsx("span", { className: "absolute -top-1 -right-1 h-4 w-4 text-[9px] font-bold text-white rounded-full flex items-center justify-center shadow-lg", style: { backgroundColor: primaryColor }, children: wishlistCount }))] }) })), storeConfig.layout === 'motivational-speaker' && isAuthenticated && (_jsx(Link, { href: `/${storeConfig.slug}/account?tab=learning`, children: _jsxs(Button, { variant: "ghost", size: "icon", className: cn("h-9 w-9 sm:h-10 sm:w-10 relative rounded-full group transition-all", isDarkTheme ? "hover:bg-blue-900/20 text-blue-400" : "hover:bg-blue-50 text-blue-600"), children: [_jsx(BookOpen, { className: "h-5 w-5 transition-all group-hover:scale-110" }), _jsx("span", { className: "sr-only", children: "My Learning" })] }) })), storeConfig.features.cart && (_jsxs(Button, { type: "button", variant: "ghost", size: "icon", onClick: () => setIsCartOpen(true), className: "h-9 w-9 sm:h-10 sm:w-10 relative rounded-full group hover:bg-gray-100 dark:hover:bg-white/10", "aria-label": "Open shopping bag", children: [_jsx(ShoppingCart, { className: "h-5 w-5 group-hover:scale-110 transition-all" }), displayCartCount > 0 && (_jsx("span", { className: "absolute -top-1 -right-1 h-4 w-4 text-[9px] font-bold text-white rounded-full flex items-center justify-center shadow-lg", style: { backgroundColor: primaryColor }, children: displayCartCount }))] })), isAuthenticated ? (_jsx(Link, { href: `/${storeConfig.slug}/account`, children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 sm:h-10 sm:w-10 rounded-full overflow-hidden border-2 border-transparent hover:border-gray-200 transition-all", children: _jsx(AvatarImage, { src: user?.avatar, alt: "User", size: 32 }) }) })) : (_jsx(Button, { className: "ml-1 hidden sm:block h-10 px-6 rounded-full font-bold text-xs uppercase tracking-widest transition-all shadow-md hover:shadow-lg active:scale-95", style: { backgroundColor: primaryColor, color: 'white' }, onClick: () => openLogin({
|
|
101
155
|
callbackUrl: pathname || `/${storeConfig.slug}`,
|
|
102
156
|
}), children: storeConfig.headerConfig?.loginButtonText || 'Log In' })), _jsx(Button, { variant: "ghost", size: "icon", className: "lg:hidden h-9 w-9 sm:h-10 sm:w-10 rounded-full", onClick: () => setMobileMenuOpen(true), children: _jsx(Menu, { className: "h-6 w-6" }) })] })] }) }) }), _jsx(AnimatePresence, { children: searchOpen && (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "fixed inset-0 z-[100] flex flex-col items-center justify-start pt-24 px-4 bg-white/80 dark:bg-black/80 backdrop-blur-2xl", children: _jsxs(motion.div, { initial: { y: -20, opacity: 0 }, animate: { y: 0, opacity: 1 }, exit: { y: -20, opacity: 0 }, className: "w-full max-w-3xl relative", children: [_jsxs("div", { className: "relative flex items-center group", children: [_jsx(Search, { className: "absolute left-6 h-6 w-6 text-gray-400 group-focus-within:text-black dark:group-focus-within:text-white transition-colors" }), _jsx("input", { ref: searchInputRef, type: "text", placeholder: storeConfig.headerConfig?.searchPlaceholder || "Search products, categories, guides...", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), className: cn("w-full pl-16 pr-24 py-6 text-2xl md:text-3xl font-light bg-transparent border-b-2 border-gray-200 dark:border-white/10 focus:outline-none focus:border-black dark:focus:border-white transition-all", isDarkTheme ? "text-white placeholder-gray-600" : "text-black placeholder-gray-300"), onKeyDown: (e) => e.key === 'Escape' && setSearchOpen(false) }), _jsxs("div", { className: "absolute right-0 flex items-center gap-2", children: [searchQuery && (_jsx(Button, { variant: "ghost", size: "icon", onClick: () => setSearchQuery(''), className: "h-10 w-10 rounded-full", children: _jsx(X, { className: "h-5 w-5 text-gray-400" }) })), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => setSearchOpen(false), className: "text-xs font-bold uppercase tracking-widest text-gray-400 hover:text-black dark:hover:text-white", children: "Esc" })] })] }), _jsxs("div", { className: "mt-12 grid grid-cols-1 md:grid-cols-2 gap-12", children: [_jsxs("div", { className: "space-y-6", children: [_jsx("h4", { className: "text-[10px] font-black uppercase tracking-[0.3em] text-gray-400", children: "Quick Links" }), _jsx("div", { className: "flex flex-wrap gap-2", children: ['Courses', 'Mentorship', 'Free Guides', 'Memberships', 'Contact'].map((tag) => (_jsx("button", { className: cn("px-4 py-2 rounded-full text-sm border transition-all", isDarkTheme
|
|
103
157
|
? "border-white/10 hover:border-white text-gray-400 hover:text-white"
|
|
104
|
-
: "border-gray-200 hover:border-black text-gray-600 hover:text-black"), children: tag }, tag))) })] }), _jsxs("div", { className: "space-y-6", children: [_jsx("h4", { className: "text-[10px] font-black uppercase tracking-[0.3em] text-gray-400", children: "Popular Categories" }), _jsx("div", { className: "grid gap-3", children: parentCategories.map((cat) => (_jsxs(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: "flex items-center gap-3 group", onClick: () => setSearchOpen(false), children: [_jsx("div", { className: "w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/5 flex items-center justify-center group-hover:scale-110 transition-transform", children: _jsx(ChevronRight, { className: "w-4 h-4 text-gray-400" }) }), _jsx("span", { className: "text-lg font-medium text-gray-500 group-hover:text-black dark:group-hover:text-white transition-colors", children: cat.name })] }, cat.id))) })] })] })] }) })) }), _jsx(AnimatePresence, { children: mobileMenuOpen && (_jsxs("div", { className: "fixed inset-0 z-[100] lg:hidden", children: [_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "absolute inset-0 bg-black/60 backdrop-blur-md", onClick: () => setMobileMenuOpen(false) }), _jsxs(motion.nav, { initial: { x: '100%' }, animate: { x: 0 }, exit: { x: '100%' }, transition: { type: "spring", damping: 25, stiffness: 200 }, className: cn("absolute right-0 top-0 bottom-0 w-[300px] shadow-2xl p-8 flex flex-col", isDarkTheme ? "bg-black text-white" : "bg-white text-black"), children: [_jsxs("div", { className: "flex items-center justify-between mb-12", children: [_jsx(StoreLogo, { storeConfig: storeConfig, className: "h-8 w-8" }), _jsx(Button, { variant: "ghost", size: "icon", onClick: () => setMobileMenuOpen(false), children: _jsx(X, { className: "h-6 w-6" }) })] }), _jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
158
|
+
: "border-gray-200 hover:border-black text-gray-600 hover:text-black"), children: tag }, tag))) })] }), _jsxs("div", { className: "space-y-6", children: [_jsx("h4", { className: "text-[10px] font-black uppercase tracking-[0.3em] text-gray-400", children: "Popular Categories" }), _jsx("div", { className: "grid gap-3", children: parentCategories.map((cat) => (_jsxs(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: "flex items-center gap-3 group", onClick: () => setSearchOpen(false), children: [_jsx("div", { className: "w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/5 flex items-center justify-center group-hover:scale-110 transition-transform", children: _jsx(ChevronRight, { className: "w-4 h-4 text-gray-400" }) }), _jsx("span", { className: "text-lg font-medium text-gray-500 group-hover:text-black dark:group-hover:text-white transition-colors", children: cat.name })] }, cat.id))) })] })] })] }) })) }), _jsx(AnimatePresence, { children: mobileMenuOpen && (_jsxs("div", { className: "fixed inset-0 z-[100] lg:hidden", children: [_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "absolute inset-0 bg-black/60 backdrop-blur-md", onClick: () => setMobileMenuOpen(false) }), _jsxs(motion.nav, { initial: { x: '100%' }, animate: { x: 0 }, exit: { x: '100%' }, transition: { type: "spring", damping: 25, stiffness: 200 }, className: cn("absolute right-0 top-0 bottom-0 w-[300px] shadow-2xl p-8 flex flex-col", isDarkTheme ? "bg-black text-white" : "bg-white text-black"), children: [_jsxs("div", { className: "flex items-center justify-between mb-12", children: [_jsx(StoreLogo, { storeConfig: storeConfig, className: "h-8 w-8" }), _jsx(Button, { variant: "ghost", size: "icon", onClick: () => setMobileMenuOpen(false), children: _jsx(X, { className: "h-6 w-6" }) })] }), _jsxs("div", { className: "flex flex-col gap-8", children: [headerNavLinks.map((item, i) => {
|
|
105
159
|
return (_jsx(Link, { href: `/${storeConfig.slug}${item.href}`, className: "text-3xl font-bold tracking-tight hover:opacity-50 transition-opacity flex items-center gap-4", onClick: () => setMobileMenuOpen(false), children: item.label }, i));
|
|
106
160
|
}), _jsxs("div", { className: "pt-8 space-y-4 border-t border-gray-100 dark:border-white/10", children: [_jsx("h4", { className: "text-[10px] font-black uppercase tracking-[0.3em] text-gray-400", children: "Catalogue" }), _jsx("div", { className: "grid gap-4", children: parentCategories.map((cat) => (_jsx(Link, { href: `/${storeConfig.slug}/categories/${cat.slug}`, className: "text-lg font-medium text-gray-500 hover:text-black dark:hover:text-white hover:underline underline-offset-4 transition-colors", onClick: () => setMobileMenuOpen(false), children: cat.name }, cat.id))) })] })] }), _jsxs("div", { className: "mt-auto pt-8 border-t border-gray-100 dark:border-white/10 flex flex-col gap-6", children: [!isAuthenticated ? (_jsx(Button, { className: "w-full h-14 rounded-full font-bold text-sm uppercase tracking-widest shadow-xl", style: { backgroundColor: primaryColor, color: 'white' }, onClick: () => {
|
|
107
161
|
setMobileMenuOpen(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/shared/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiChD,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,CAAC;CAC1B;AA8LD,wBAAgB,YAAY,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,+
|
|
1
|
+
{"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../../../src/layouts/shared/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiChD,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,CAAC;CAC1B;AA8LD,wBAAgB,YAAY,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,+BAomD9D"}
|
|
@@ -283,14 +283,12 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
283
283
|
setLoading(false);
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
|
-
console.log('[Checkout] SDK callback received, verifying payment...');
|
|
287
286
|
addToast('Verifying payment...', 'info');
|
|
288
287
|
// Step 1: Immediate check if webhook already processed payment (no delay)
|
|
289
288
|
let immediateVerification;
|
|
290
289
|
try {
|
|
291
290
|
immediateVerification = await paymentService.verifyPayment(transactionRef, storeConfig.id);
|
|
292
291
|
if (immediateVerification.verified && immediateVerification.paymentStatus === 'completed') {
|
|
293
|
-
console.log('[Checkout] Payment already completed by webhook, proceeding to success page');
|
|
294
292
|
const orderId = immediateVerification.orderId || transactionRef;
|
|
295
293
|
const orderNumber = immediateVerification.orderNumber || '';
|
|
296
294
|
router.push(`/${storeConfig.slug}/order/success?orderId=${orderId}&ref=${transactionRef}${orderNumber ? `&orderNumber=${orderNumber}` : ''}`);
|
|
@@ -298,12 +296,10 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
298
296
|
}
|
|
299
297
|
}
|
|
300
298
|
catch (error) {
|
|
301
|
-
console.log('[Checkout] Immediate verification failed, proceeding with confirmation');
|
|
302
299
|
}
|
|
303
300
|
// Step 2: If webhook hasn't processed yet, immediately confirm from callback data
|
|
304
301
|
// We have the callback data from Payaza, so we can confirm immediately instead of waiting
|
|
305
302
|
if (response.callbackData) {
|
|
306
|
-
console.log('[Checkout] Processing Payaza callback confirmation immediately');
|
|
307
303
|
// Retry logic for payment confirmation
|
|
308
304
|
const MAX_RETRIES = 3;
|
|
309
305
|
const RETRY_DELAY = 1000; // 1 second
|
|
@@ -314,37 +310,30 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
314
310
|
// Confirm payment with backend and trigger order processing
|
|
315
311
|
confirmation = await paymentService.confirmPaymentFromCallback(response.callbackData);
|
|
316
312
|
if (confirmation.alreadyProcessed) {
|
|
317
|
-
console.log('[Checkout] Payment already processed, redirecting to success page');
|
|
318
313
|
}
|
|
319
314
|
else {
|
|
320
|
-
console.log('[Checkout] Payment confirmed, order processing initiated');
|
|
321
315
|
}
|
|
322
316
|
// Success - break out of retry loop
|
|
323
317
|
break;
|
|
324
318
|
}
|
|
325
319
|
catch (error) {
|
|
326
320
|
lastError = error;
|
|
327
|
-
console.error(`[Checkout] Payment confirmation attempt ${attempt} failed:`, error);
|
|
328
321
|
// If this is not the last attempt, wait before retrying
|
|
329
322
|
if (attempt < MAX_RETRIES) {
|
|
330
|
-
console.log(`[Checkout] Retrying payment confirmation in ${RETRY_DELAY}ms...`);
|
|
331
323
|
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY * attempt)); // Exponential backoff
|
|
332
324
|
}
|
|
333
325
|
}
|
|
334
326
|
}
|
|
335
327
|
// If all retries failed, do a short poll to catch webhook processing (max 3 seconds)
|
|
336
328
|
if (!confirmation) {
|
|
337
|
-
console.log('[Checkout] Confirmation failed, doing short poll for webhook processing...');
|
|
338
329
|
try {
|
|
339
330
|
const polledVerification = await paymentService.pollPaymentStatus(transactionRef, storeConfig.id, {
|
|
340
331
|
maxAttempts: 3, // Poll for max 3 seconds (3 * 1s)
|
|
341
332
|
intervalMs: 1000, // Poll every 1 second
|
|
342
333
|
onProgress: (attempt, maxAttempts) => {
|
|
343
|
-
console.log(`[Checkout] Polling for webhook (${attempt}/${maxAttempts})...`);
|
|
344
334
|
}
|
|
345
335
|
});
|
|
346
336
|
if (polledVerification && polledVerification.verified && polledVerification.paymentStatus === 'completed') {
|
|
347
|
-
console.log('[Checkout] Payment completed by webhook, proceeding to success page');
|
|
348
337
|
const orderId = polledVerification.orderId || transactionRef;
|
|
349
338
|
const orderNumber = polledVerification.orderNumber || '';
|
|
350
339
|
router.push(`/${storeConfig.slug}/order/success?orderId=${orderId}&ref=${transactionRef}${orderNumber ? `&orderNumber=${orderNumber}` : ''}`);
|
|
@@ -352,10 +341,8 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
352
341
|
}
|
|
353
342
|
}
|
|
354
343
|
catch (pollError) {
|
|
355
|
-
console.error('[Checkout] Polling also failed:', pollError);
|
|
356
344
|
}
|
|
357
345
|
// Final fallback: Redirect to callback page for manual verification
|
|
358
|
-
console.log('[Checkout] Redirecting to callback page for verification');
|
|
359
346
|
addToast('Payment successful. Verifying transaction...', 'info');
|
|
360
347
|
router.push(`/${storeConfig.slug}/payment/callback?reference=${transactionRef}&storeId=${storeConfig.id}`);
|
|
361
348
|
return;
|
|
@@ -368,7 +355,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
368
355
|
}
|
|
369
356
|
else {
|
|
370
357
|
// Fallback: Use transaction reference to verify payment
|
|
371
|
-
console.log('[Checkout] No callback data, verifying payment with transaction reference:', response.transactionRef);
|
|
372
358
|
if (response.transactionRef) {
|
|
373
359
|
// Redirect to callback page for verification and confirmation
|
|
374
360
|
router.push(`/${storeConfig.slug}/payment/callback?reference=${response.transactionRef}&storeId=${storeConfig.id}`);
|
|
@@ -380,7 +366,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
380
366
|
}
|
|
381
367
|
}
|
|
382
368
|
catch (error) {
|
|
383
|
-
console.error('[Checkout] Error processing payment callback:', error);
|
|
384
369
|
// Fallback: Try to redirect to callback page for verification
|
|
385
370
|
const transactionRef = response.transactionRef || response.callbackData?.data?.transaction_reference;
|
|
386
371
|
if (transactionRef) {
|
|
@@ -682,7 +667,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
682
667
|
}
|
|
683
668
|
}
|
|
684
669
|
catch (error) {
|
|
685
|
-
console.warn('[Checkout] Fee preview unavailable:', error);
|
|
686
670
|
if (!cancelled) {
|
|
687
671
|
setFeePreview(null);
|
|
688
672
|
lastFeePreviewKeyRef.current = null;
|
|
@@ -812,7 +796,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
812
796
|
// Validate currency availability
|
|
813
797
|
const hasCurrency = storeConfig.settings?.currency || checkoutItems.some(item => item.product.currency);
|
|
814
798
|
if (!hasCurrency) {
|
|
815
|
-
console.warn('[Checkout] No currency found, will use USD fallback');
|
|
816
799
|
}
|
|
817
800
|
return { isValid: true };
|
|
818
801
|
};
|
|
@@ -838,11 +821,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
838
821
|
let checkoutConfig;
|
|
839
822
|
try {
|
|
840
823
|
// Step 1: Create order via API before payment
|
|
841
|
-
console.log('[Checkout] Step 1: Creating order via API', {
|
|
842
|
-
storeId: storeConfig.id,
|
|
843
|
-
itemCount: checkoutItems.length,
|
|
844
|
-
customerEmail: formData.email,
|
|
845
|
-
});
|
|
846
824
|
try {
|
|
847
825
|
checkoutResponse = await checkoutService.processCheckout({
|
|
848
826
|
storeId: storeConfig.id,
|
|
@@ -877,12 +855,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
877
855
|
displayCurrency: currency,
|
|
878
856
|
chargeCurrency: currency,
|
|
879
857
|
});
|
|
880
|
-
console.log('[Checkout] Step 1: Order created successfully', {
|
|
881
|
-
orderId: checkoutResponse.orderId,
|
|
882
|
-
orderNumber: checkoutResponse.orderNumber,
|
|
883
|
-
currency: checkoutResponse.currency,
|
|
884
|
-
transactionReference: checkoutResponse.transactionReference,
|
|
885
|
-
});
|
|
886
858
|
const isFreeOrderResponse = checkoutResponse.paymentNotRequired === true ||
|
|
887
859
|
(checkoutResponse.totalAmount != null && Number(checkoutResponse.totalAmount) <= 0);
|
|
888
860
|
if (isFreeOrderResponse) {
|
|
@@ -893,16 +865,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
893
865
|
}
|
|
894
866
|
}
|
|
895
867
|
catch (apiError) {
|
|
896
|
-
console.error('[Checkout] Step 1: API call failed', {
|
|
897
|
-
error: apiError,
|
|
898
|
-
message: apiError?.message,
|
|
899
|
-
status: apiError?.status,
|
|
900
|
-
data: apiError?.data,
|
|
901
|
-
requestData: {
|
|
902
|
-
storeId: storeConfig.id,
|
|
903
|
-
itemCount: checkoutItems.length,
|
|
904
|
-
},
|
|
905
|
-
});
|
|
906
868
|
if (apiError?.status === 0 || apiError?.code === 'ECONNABORTED' || apiError?.message?.includes('timeout')) {
|
|
907
869
|
addToast('Unable to connect to server. Please check your internet connection.', 'error');
|
|
908
870
|
}
|
|
@@ -923,13 +885,11 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
923
885
|
effectivePayazaPublicKey = requireCheckoutPayazaPublicKey(checkoutResponse);
|
|
924
886
|
}
|
|
925
887
|
catch (error) {
|
|
926
|
-
console.error('[Checkout] No Payaza public key from backend', error);
|
|
927
888
|
addToast(error instanceof Error ? error.message : 'Payment gateway not configured. Please contact support.', 'error');
|
|
928
889
|
setLoading(false);
|
|
929
890
|
return;
|
|
930
891
|
}
|
|
931
892
|
// Step 2: Convert checkout items to Payaza format
|
|
932
|
-
console.log('[Checkout] Step 2: Converting checkout items to Payaza format');
|
|
933
893
|
try {
|
|
934
894
|
const payazaItems = checkoutItems.map(item => ({
|
|
935
895
|
product: {
|
|
@@ -940,13 +900,7 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
940
900
|
quantity: item.quantity,
|
|
941
901
|
price: item.price,
|
|
942
902
|
}));
|
|
943
|
-
console.log('[Checkout] Step 2: Items converted', { itemCount: payazaItems.length });
|
|
944
903
|
// Step 3: Generate Payaza checkout config with order details
|
|
945
|
-
console.log('[Checkout] Step 3: Generating Payaza checkout config', {
|
|
946
|
-
currency: checkoutResponse.currency || storeConfig.settings?.currency,
|
|
947
|
-
orderId: checkoutResponse.orderId,
|
|
948
|
-
orderNumber: checkoutResponse.orderNumber,
|
|
949
|
-
});
|
|
950
904
|
checkoutConfig = generateCheckoutConfig(payazaItems, formData.email, effectivePayazaPublicKey, {
|
|
951
905
|
firstName: formData.firstName,
|
|
952
906
|
lastName: formData.lastName,
|
|
@@ -969,27 +923,14 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
969
923
|
zipCode: formData.postalCode,
|
|
970
924
|
},
|
|
971
925
|
});
|
|
972
|
-
console.log('[Checkout] Step 3: Checkout config generated', {
|
|
973
|
-
amount: checkoutConfig.amount,
|
|
974
|
-
currency: checkoutConfig.currency,
|
|
975
|
-
reference: checkoutConfig.reference,
|
|
976
|
-
});
|
|
977
926
|
}
|
|
978
927
|
catch (configError) {
|
|
979
|
-
console.error('[Checkout] Step 2-3: Config generation failed', {
|
|
980
|
-
error: configError,
|
|
981
|
-
message: configError?.message,
|
|
982
|
-
stack: configError?.stack,
|
|
983
|
-
});
|
|
984
928
|
addToast(configError?.message || 'Invalid checkout configuration. Please contact support.', 'error');
|
|
985
929
|
setLoading(false);
|
|
986
930
|
return;
|
|
987
931
|
}
|
|
988
932
|
// Step 4: Use transaction reference from order
|
|
989
933
|
checkoutConfig.reference = checkoutResponse.transactionReference;
|
|
990
|
-
console.log('[Checkout] Step 4: Transaction reference set', {
|
|
991
|
-
reference: checkoutConfig.reference,
|
|
992
|
-
});
|
|
993
934
|
// Step 5: Save address if requested (for authenticated users)
|
|
994
935
|
if (isAuthenticated && saveNewAddress && !selectedAddressId) {
|
|
995
936
|
try {
|
|
@@ -1009,7 +950,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
1009
950
|
isDefault: savedAddresses.length === 0, // Set as default if it's the first address
|
|
1010
951
|
label: addressLabel || undefined,
|
|
1011
952
|
});
|
|
1012
|
-
console.log('[Checkout] Address saved successfully');
|
|
1013
953
|
// Refresh addresses list
|
|
1014
954
|
const addresses = await customerService.getAddresses();
|
|
1015
955
|
setSavedAddresses(addresses);
|
|
@@ -1018,17 +958,14 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
1018
958
|
addToast('Address saved successfully!', 'success');
|
|
1019
959
|
}
|
|
1020
960
|
catch (addressError) {
|
|
1021
|
-
console.error('[Checkout] Failed to save address:', addressError);
|
|
1022
961
|
addToast('Failed to save address. You can save it later from your account.', 'error');
|
|
1023
962
|
// Don't block checkout if address save fails - just log the error
|
|
1024
963
|
// User can save address later from their account
|
|
1025
964
|
}
|
|
1026
965
|
}
|
|
1027
966
|
// Step 6: Initiate Payaza checkout
|
|
1028
|
-
console.log('[Checkout] Step 6: Initiating Payaza checkout');
|
|
1029
967
|
try {
|
|
1030
968
|
await initiateCheckout(checkoutConfig);
|
|
1031
|
-
console.log('[Checkout] Step 6: Payaza checkout initiated successfully');
|
|
1032
969
|
// Clear buyNowItem after successful checkout initiation
|
|
1033
970
|
// The item has been processed and order created
|
|
1034
971
|
if (effectiveBuyNowItem) {
|
|
@@ -1036,15 +973,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
1036
973
|
}
|
|
1037
974
|
}
|
|
1038
975
|
catch (sdkError) {
|
|
1039
|
-
console.error('[Checkout] Step 5: Payaza SDK initiation failed', {
|
|
1040
|
-
error: sdkError,
|
|
1041
|
-
message: sdkError?.message,
|
|
1042
|
-
config: {
|
|
1043
|
-
amount: checkoutConfig.amount,
|
|
1044
|
-
currency: checkoutConfig.currency,
|
|
1045
|
-
publicKey: checkoutConfig.publicKey?.substring(0, 20) + '...',
|
|
1046
|
-
},
|
|
1047
|
-
});
|
|
1048
976
|
if (sdkError?.message?.includes('SDK not loaded') || sdkError?.message?.includes('PayazaCheckout')) {
|
|
1049
977
|
addToast('Payment system is loading. Please wait a moment and try again.', 'error');
|
|
1050
978
|
}
|
|
@@ -1059,12 +987,6 @@ export function CheckoutPage({ storeConfig }) {
|
|
|
1059
987
|
}
|
|
1060
988
|
}
|
|
1061
989
|
catch (error) {
|
|
1062
|
-
console.error('[Checkout] Unexpected error in checkout flow', {
|
|
1063
|
-
error,
|
|
1064
|
-
message: error?.message,
|
|
1065
|
-
stack: error?.stack,
|
|
1066
|
-
name: error?.name,
|
|
1067
|
-
});
|
|
1068
990
|
addToast('Failed to initiate checkout. Please try again.', 'error');
|
|
1069
991
|
setLoading(false);
|
|
1070
992
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClothingLayout.d.ts","sourceRoot":"","sources":["../../../../src/layouts/shared/wrappers/ClothingLayout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClothingLayout.d.ts","sourceRoot":"","sources":["../../../../src/layouts/shared/wrappers/ClothingLayout.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AASvD,OAAO,oCAAoC,CAAC;AAE5C,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,mBAAmB,+BAmE5E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { StoreHeader } from '../components/StoreHeader.js';
|
|
4
5
|
import { StoreFooter } from '../components/StoreFooter.js';
|
|
5
6
|
import { PageAnimateWrapper } from '../../../components/ui/page-animate-wrapper.js';
|
|
@@ -13,6 +14,19 @@ import '../../clothing/styles/clothing.css';
|
|
|
13
14
|
export function ClothingLayout({ children, storeConfig }) {
|
|
14
15
|
const { cartCount } = useStore();
|
|
15
16
|
const { isBackendLoading } = useLoading();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const root = document.documentElement;
|
|
19
|
+
root.dataset.storeLayout = 'clothing';
|
|
20
|
+
root.style.setProperty('--radius', '0.125rem');
|
|
21
|
+
root.style.setProperty('--radius-2xl', '0.25rem');
|
|
22
|
+
root.style.setProperty('--radius-3xl', '0.375rem');
|
|
23
|
+
return () => {
|
|
24
|
+
delete root.dataset.storeLayout;
|
|
25
|
+
root.style.removeProperty('--radius');
|
|
26
|
+
root.style.removeProperty('--radius-2xl');
|
|
27
|
+
root.style.removeProperty('--radius-3xl');
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
16
30
|
const shouldShowHeader = storeConfig.headerConfig?.show ?? true;
|
|
17
31
|
const bgPrimary = getThemeColor(storeConfig, 'background', 'primary', '#FFFFFF');
|
|
18
32
|
const bgSecondary = getThemeColor(storeConfig, 'background', 'secondary', '#FAFAFA');
|
|
@@ -39,6 +53,9 @@ export function ClothingLayout({ children, storeConfig }) {
|
|
|
39
53
|
'--theme-border-secondary': borderSecondary,
|
|
40
54
|
'--theme-accent-hover': accentHover,
|
|
41
55
|
...(accentFocus ? { '--theme-accent-focus': accentFocus } : {}),
|
|
56
|
+
'--radius': '0.125rem',
|
|
57
|
+
'--radius-2xl': '0.25rem',
|
|
58
|
+
'--radius-3xl': '0.375rem',
|
|
42
59
|
};
|
|
43
60
|
return (_jsx(AlertModalProvider, { children: _jsxs("div", { "data-layout": "clothing", className: "layout-clothing min-h-screen flex flex-col bg-white text-gray-900", style: cssVariables, children: [shouldShowHeader && _jsx(StoreHeader, { storeConfig: storeConfig, cartItemCount: cartCount }), _jsxs("main", { className: "flex-1 relative", children: [isBackendLoading && _jsx(PageContentLoader, {}), _jsx(PageAnimateWrapper, { children: children })] }), _jsx(StoreFooter, { storeConfig: storeConfig })] }) }));
|
|
44
61
|
}
|
package/dist/lib/mock-stores.js
CHANGED
|
@@ -503,7 +503,7 @@ export const mockStores = [
|
|
|
503
503
|
price: 85,
|
|
504
504
|
duration: 45,
|
|
505
505
|
categoryId: 'cat2',
|
|
506
|
-
image: 'https://
|
|
506
|
+
image: 'https://images.unsplash.com/photo-1487412947147-5cebf100ffc2?w=800&q=80',
|
|
507
507
|
},
|
|
508
508
|
{
|
|
509
509
|
id: 's4',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payaza-checkout.d.ts","sourceRoot":"","sources":["../../src/lib/payaza-checkout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD,8FAA8F;AAC9F,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,CAGnF;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM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,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kKAAkK;IAClK,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,eAAe,CAAC,EAAE;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,KACA,oBA2GF,CAAC"}
|
|
@@ -157,8 +157,6 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
157
157
|
catch {
|
|
158
158
|
throw new Error(`Invalid currency code: ${config.currency}. Currency must be a valid 3-letter ISO 4217 code (e.g., USD, NGN, KES, GHS)`);
|
|
159
159
|
}
|
|
160
|
-
console.log('[Payaza] Initiating checkout with npm package...');
|
|
161
|
-
console.log('[Payaza] SDK verified ready, proceeding with checkout setup');
|
|
162
160
|
if (!Number.isFinite(config.amount) || config.amount <= 0) {
|
|
163
161
|
throw new Error('Invalid payment amount. Please refresh and try again.');
|
|
164
162
|
}
|
|
@@ -174,25 +172,17 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
174
172
|
const normalizedPhone = config.phone ? normalizePhoneForPayaza(config.phone) : '';
|
|
175
173
|
// Generate transaction reference
|
|
176
174
|
const reference = config.reference || `PL${Math.floor((Math.random() * 10000000) + 1)}`;
|
|
177
|
-
console.log('[Payaza] Transaction reference:', reference);
|
|
178
175
|
// Determine connection mode — backend config is authoritative; default Live
|
|
179
176
|
if (!config.publicKey) {
|
|
180
177
|
throw new Error('Payment gateway not configured. Please contact support.');
|
|
181
178
|
}
|
|
182
179
|
const connectionMode = normalizeConnectionMode(config.connectionMode);
|
|
183
|
-
console.log('[Payaza] Connection mode:', connectionMode, config.connectionMode ? '(from backend config)' : '(default Live)');
|
|
184
180
|
// Build comprehensive additional_details metadata
|
|
185
181
|
// This data will be available in Payaza webhooks and transaction responses
|
|
186
182
|
const additionalDetails = {
|
|
187
183
|
// Merge any custom metadata first
|
|
188
184
|
...(config.metadata || {}),
|
|
189
185
|
};
|
|
190
|
-
console.log('[Payaza] Building checkout configuration...', {
|
|
191
|
-
amount: config.amount,
|
|
192
|
-
currency: validatedCurrency,
|
|
193
|
-
email: config.email,
|
|
194
|
-
connectionMode,
|
|
195
|
-
});
|
|
196
186
|
// Core order identifiers
|
|
197
187
|
if (config.storeId) {
|
|
198
188
|
additionalDetails.storeId = config.storeId;
|
|
@@ -265,9 +255,7 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
265
255
|
payazaConfig.callback_url = config.callbackUrl;
|
|
266
256
|
}
|
|
267
257
|
// Create checkout instance
|
|
268
|
-
console.log('[Payaza] Calling setup() from payaza-web-sdk...');
|
|
269
258
|
const payazaCheckout = PayazaCheckout.setup(payazaConfig);
|
|
270
|
-
console.log('[Payaza] PayazaCheckout instance created successfully');
|
|
271
259
|
// Track payment success state to prevent misleading "Payment canceled" message
|
|
272
260
|
// when checkout window closes after successful payment
|
|
273
261
|
let paymentSuccessful = false;
|
|
@@ -503,16 +491,13 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
503
491
|
});
|
|
504
492
|
// Set onClose handler: always call config.onClose() so UI loading state clears
|
|
505
493
|
payazaCheckout.setOnClose(() => {
|
|
506
|
-
console.log('[Payaza] Checkout closed', { paymentSuccessful });
|
|
507
494
|
handleClose();
|
|
508
495
|
});
|
|
509
496
|
// Show the popup
|
|
510
|
-
console.log('[Payaza] Showing checkout popup');
|
|
511
497
|
try {
|
|
512
498
|
stopIframeObserver = observePayazaIframeInsertion();
|
|
513
499
|
payazaCheckout.showPopup();
|
|
514
500
|
patchPayazaIframesInDom();
|
|
515
|
-
console.log('[Payaza] Checkout popup opened successfully');
|
|
516
501
|
// Fallback: poll for Payaza loader removal (actual load) and iframe close.
|
|
517
502
|
if (typeof document !== 'undefined' && document.querySelector) {
|
|
518
503
|
const checkLoadedAndClose = setInterval(() => {
|
|
@@ -533,10 +518,8 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
533
518
|
}
|
|
534
519
|
}
|
|
535
520
|
if (!iframe && !closeHandled && !paymentSuccessful) {
|
|
536
|
-
console.log('[Payaza] Fallback: Payaza iframe no longer in DOM, waiting for SDK callback...');
|
|
537
521
|
setTimeout(() => {
|
|
538
522
|
if (!closeHandled && !paymentSuccessful) {
|
|
539
|
-
console.log('[Payaza] Fallback: no success callback received, treating checkout as closed');
|
|
540
523
|
handleClose();
|
|
541
524
|
}
|
|
542
525
|
}, 2500);
|
|
@@ -553,16 +536,6 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
553
536
|
return;
|
|
554
537
|
stopIframeObserver?.();
|
|
555
538
|
stopIframeObserver = null;
|
|
556
|
-
console.error('[Payaza] Loader timeout: checkout overlay did not clear', {
|
|
557
|
-
keyPrefix: config.publicKey?.substring(0, 8),
|
|
558
|
-
amount: config.amount,
|
|
559
|
-
currency: validatedCurrency,
|
|
560
|
-
connectionMode,
|
|
561
|
-
email: config.email,
|
|
562
|
-
reference,
|
|
563
|
-
loaderStillVisible,
|
|
564
|
-
iframePresent,
|
|
565
|
-
});
|
|
566
539
|
teardownPayazaCheckoutDom();
|
|
567
540
|
closeHandled = true;
|
|
568
541
|
clearCloseCheckInterval();
|
|
@@ -576,7 +549,6 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
576
549
|
}
|
|
577
550
|
}
|
|
578
551
|
catch (popupError) {
|
|
579
|
-
console.error('[Payaza] Failed to show popup:', popupError);
|
|
580
552
|
// Call onError if popup fails to open
|
|
581
553
|
if (config.onError) {
|
|
582
554
|
config.onError('Failed to open payment popup. Please check if popups are blocked in your browser.');
|
|
@@ -591,11 +563,6 @@ export const initiatePayazaCheckout = async (config) => {
|
|
|
591
563
|
};
|
|
592
564
|
}
|
|
593
565
|
catch (error) {
|
|
594
|
-
console.error('[Payaza] Checkout initiation error:', {
|
|
595
|
-
error,
|
|
596
|
-
message: error instanceof Error ? error.message : 'Unknown error',
|
|
597
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
598
|
-
});
|
|
599
566
|
// Throw error instead of returning error object - let the caller handle it
|
|
600
567
|
// This ensures errors are properly propagated and not masked
|
|
601
568
|
throw error instanceof Error ? error : new Error('Failed to initialize checkout');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-data.d.ts","sourceRoot":"","sources":["../../src/lib/preview-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;GASG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAgShD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,WAAW,CA2XpD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAmPnD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,WAAW,CA+JtD;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,WAAW,
|
|
1
|
+
{"version":3,"file":"preview-data.d.ts","sourceRoot":"","sources":["../../src/lib/preview-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;GASG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAgShD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,WAAW,CA2XpD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAmPnD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,WAAW,CA+JtD;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,WAAW,CA6O3D;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,WAAW,CA2JzD;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,WAAW,CAme3D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAiSvD;AAED;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,WAAW,CAiP/D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAiCzE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqBvE"}
|