create-brainerce-store 1.18.0 → 1.20.0
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/LICENSE +0 -0
- package/dist/index.js +31 -9
- package/messages/en.json +366 -362
- package/messages/he.json +366 -362
- package/package.json +8 -8
- package/templates/nextjs/base/next.config.ts +31 -31
- package/templates/nextjs/base/scripts/fetch-store-info.mjs +81 -81
- package/templates/nextjs/base/src/app/.well-known/apple-developer-merchantid-domain-association/route.ts +26 -26
- package/templates/nextjs/base/src/app/account/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/account/page.tsx +122 -122
- package/templates/nextjs/base/src/app/api/auth/logout/route.ts +14 -14
- package/templates/nextjs/base/src/app/api/auth/me/route.ts +56 -56
- package/templates/nextjs/base/src/app/api/auth/oauth-callback/route.ts +59 -59
- package/templates/nextjs/base/src/app/api/auth/reset-callback/route.ts +41 -41
- package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +77 -77
- package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +198 -198
- package/templates/nextjs/base/src/app/auth/callback/page.tsx +92 -92
- package/templates/nextjs/base/src/app/cart/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/cart/page.tsx +204 -204
- package/templates/nextjs/base/src/app/checkout/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/checkout/page.tsx +860 -860
- package/templates/nextjs/base/src/app/forgot-password/page.tsx +112 -112
- package/templates/nextjs/base/src/app/layout.tsx.ejs +75 -0
- package/templates/nextjs/base/src/app/login/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/login/page.tsx +59 -59
- package/templates/nextjs/base/src/app/order-confirmation/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/order-confirmation/page.tsx +17 -0
- package/templates/nextjs/base/src/app/payment-complete/page.tsx +59 -0
- package/templates/nextjs/base/src/app/products/[slug]/page.tsx +67 -67
- package/templates/nextjs/base/src/app/products/[slug]/product-client-section.tsx +486 -486
- package/templates/nextjs/base/src/app/products/layout.tsx +18 -18
- package/templates/nextjs/base/src/app/products/page.tsx +431 -431
- package/templates/nextjs/base/src/app/register/layout.tsx +9 -9
- package/templates/nextjs/base/src/app/register/page.tsx +65 -65
- package/templates/nextjs/base/src/app/reset-password/page.tsx +132 -132
- package/templates/nextjs/base/src/app/robots.ts +14 -14
- package/templates/nextjs/base/src/app/sitemap.ts +25 -25
- package/templates/nextjs/base/src/app/verify-email/page.tsx +258 -258
- package/templates/nextjs/base/src/components/account/address-book.tsx +432 -432
- package/templates/nextjs/base/src/components/account/order-history.tsx +350 -350
- package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +137 -137
- package/templates/nextjs/base/src/components/auth/register-form.tsx +232 -232
- package/templates/nextjs/base/src/components/cart/cart-bundle-offer.tsx +247 -111
- package/templates/nextjs/base/src/components/cart/cart-item.tsx +153 -153
- package/templates/nextjs/base/src/components/cart/cart-upgrade-banner.tsx +142 -142
- package/templates/nextjs/base/src/components/cart/free-shipping-bar.tsx +59 -59
- package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +415 -415
- package/templates/nextjs/base/src/components/checkout/order-bump-card.tsx +243 -83
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +49 -3
- package/templates/nextjs/base/src/components/layout/footer.tsx +41 -41
- package/templates/nextjs/base/src/components/layout/header.tsx +336 -336
- package/templates/nextjs/base/src/components/layout/language-switcher.tsx.ejs +63 -0
- package/templates/nextjs/base/src/components/products/discount-badge.tsx +22 -22
- package/templates/nextjs/base/src/components/products/frequently-bought-together.tsx +202 -202
- package/templates/nextjs/base/src/components/products/product-card.tsx +218 -218
- package/templates/nextjs/base/src/components/products/recommendation-section.tsx +107 -107
- package/templates/nextjs/base/src/components/products/stock-badge.tsx +63 -63
- package/templates/nextjs/base/src/components/products/variant-selector.tsx +292 -292
- package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +72 -72
- package/templates/nextjs/base/src/i18n.ts.ejs +21 -0
- package/templates/nextjs/base/src/lib/auth.ts +149 -149
- package/templates/nextjs/base/src/lib/brainerce.ts.ejs +9 -0
- package/templates/nextjs/base/src/lib/translations.ts.ejs +31 -0
- package/templates/nextjs/base/src/middleware.ts.ejs +81 -0
- package/templates/nextjs/base/src/providers/store-provider.tsx.ejs +41 -0
- package/templates/nextjs/base/src/lib/translations.ts +0 -11
- package/templates/nextjs/base/src/middleware.ts +0 -25
|
@@ -1,83 +1,243 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
|
+
import Image from 'next/image';
|
|
5
|
+
import type { OrderBump, RecommendationVariant } from 'brainerce';
|
|
6
|
+
import { formatPrice, getVariantOptions } from 'brainerce';
|
|
7
|
+
import { useStoreInfo } from '@/providers/store-provider';
|
|
8
|
+
import { useTranslations } from '@/lib/translations';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
interface OrderBumpCardProps {
|
|
12
|
+
bump: OrderBump;
|
|
13
|
+
isAdded: boolean;
|
|
14
|
+
onToggle: (bumpId: string, add: boolean, variantId?: string) => void;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function OrderBumpCard({ bump, isAdded, onToggle, loading, className }: OrderBumpCardProps) {
|
|
20
|
+
const { storeInfo } = useStoreInfo();
|
|
21
|
+
const t = useTranslations('checkout');
|
|
22
|
+
const currency = storeInfo?.currency || 'USD';
|
|
23
|
+
const [selectedVariantId, setSelectedVariantId] = useState<string | null>(null);
|
|
24
|
+
|
|
25
|
+
const product = bump.bumpProduct;
|
|
26
|
+
const variants = product.variants;
|
|
27
|
+
const requiresSelection = bump.requiresVariantSelection && variants && variants.length > 0;
|
|
28
|
+
|
|
29
|
+
// Build attribute groups from variants for pill selector
|
|
30
|
+
const attributeGroups = useMemo(() => {
|
|
31
|
+
if (!requiresSelection || !variants) return [];
|
|
32
|
+
const groups = new Map<string, Set<string>>();
|
|
33
|
+
for (const v of variants) {
|
|
34
|
+
const opts = getVariantOptions(v as any);
|
|
35
|
+
for (const opt of opts) {
|
|
36
|
+
if (!groups.has(opt.name)) groups.set(opt.name, new Set());
|
|
37
|
+
groups.get(opt.name)!.add(opt.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Array.from(groups.entries()).map(([name, values]) => ({
|
|
41
|
+
name,
|
|
42
|
+
values: Array.from(values),
|
|
43
|
+
}));
|
|
44
|
+
}, [requiresSelection, variants]);
|
|
45
|
+
|
|
46
|
+
// Track selected attributes
|
|
47
|
+
const [selectedAttrs, setSelectedAttrs] = useState<Record<string, string>>({});
|
|
48
|
+
|
|
49
|
+
// Find matching variant based on selected attributes
|
|
50
|
+
const selectedVariant = useMemo(() => {
|
|
51
|
+
if (!requiresSelection || !variants) return null;
|
|
52
|
+
return (
|
|
53
|
+
variants.find((v) => {
|
|
54
|
+
const opts = getVariantOptions(v as any);
|
|
55
|
+
return attributeGroups.every((group) => {
|
|
56
|
+
const opt = opts.find((o) => o.name === group.name);
|
|
57
|
+
return opt && selectedAttrs[group.name] === opt.value;
|
|
58
|
+
});
|
|
59
|
+
}) ?? null
|
|
60
|
+
);
|
|
61
|
+
}, [requiresSelection, variants, selectedAttrs, attributeGroups]);
|
|
62
|
+
|
|
63
|
+
// Update selectedVariantId when variant match changes
|
|
64
|
+
const effectiveVariantId = selectedVariant?.id ?? selectedVariantId;
|
|
65
|
+
|
|
66
|
+
function handleAttrSelect(attrName: string, value: string) {
|
|
67
|
+
const next = { ...selectedAttrs, [attrName]: value };
|
|
68
|
+
setSelectedAttrs(next);
|
|
69
|
+
// Find matching variant with new selection
|
|
70
|
+
if (variants) {
|
|
71
|
+
const match = variants.find((v) => {
|
|
72
|
+
const opts = getVariantOptions(v as any);
|
|
73
|
+
return attributeGroups.every((group) => {
|
|
74
|
+
const opt = opts.find((o) => o.name === group.name);
|
|
75
|
+
return opt && next[group.name] === opt.value;
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
setSelectedVariantId(match?.id ?? null);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Compute display price
|
|
83
|
+
const { displayOriginal, displayDiscounted } = useMemo(() => {
|
|
84
|
+
let effectivePrice: number;
|
|
85
|
+
if (selectedVariant) {
|
|
86
|
+
const vSale = selectedVariant.salePrice ? parseFloat(selectedVariant.salePrice) : null;
|
|
87
|
+
const vPrice = selectedVariant.price ? parseFloat(selectedVariant.price) : null;
|
|
88
|
+
effectivePrice = vSale ?? vPrice ?? parseFloat(bump.originalPrice);
|
|
89
|
+
} else {
|
|
90
|
+
effectivePrice = parseFloat(bump.originalPrice);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let discounted: number | null = null;
|
|
94
|
+
if (bump.discountType && bump.discountValue) {
|
|
95
|
+
const dv = parseFloat(bump.discountValue);
|
|
96
|
+
if (bump.discountType === 'PERCENTAGE') {
|
|
97
|
+
discounted = effectivePrice * (1 - dv / 100);
|
|
98
|
+
} else {
|
|
99
|
+
discounted = Math.max(0, effectivePrice - dv);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { displayOriginal: effectivePrice, displayDiscounted: discounted };
|
|
104
|
+
}, [selectedVariant, bump.originalPrice, bump.discountType, bump.discountValue]);
|
|
105
|
+
|
|
106
|
+
// Check if selected variant is out of stock
|
|
107
|
+
const isOos =
|
|
108
|
+
selectedVariant?.inventory?.trackingMode !== 'NOT_TRACKED' &&
|
|
109
|
+
selectedVariant?.inventory?.available != null &&
|
|
110
|
+
selectedVariant.inventory.available <= 0;
|
|
111
|
+
|
|
112
|
+
// Locked variant label
|
|
113
|
+
const lockedLabel =
|
|
114
|
+
bump.lockedVariant?.name ??
|
|
115
|
+
(bump.lockedVariant?.attributes
|
|
116
|
+
? Object.values(bump.lockedVariant.attributes).join(' / ')
|
|
117
|
+
: null);
|
|
118
|
+
|
|
119
|
+
const firstImage = product.images?.[0];
|
|
120
|
+
const imageUrl = firstImage
|
|
121
|
+
? typeof firstImage === 'string'
|
|
122
|
+
? firstImage
|
|
123
|
+
: firstImage.url
|
|
124
|
+
: null;
|
|
125
|
+
|
|
126
|
+
const canToggle = !requiresSelection || !!effectiveVariantId;
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div
|
|
130
|
+
className={cn(
|
|
131
|
+
'border-border hover:border-primary/50 rounded-lg border p-3 transition-colors',
|
|
132
|
+
isAdded && 'border-primary bg-primary/5',
|
|
133
|
+
loading && 'pointer-events-none opacity-60',
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
>
|
|
137
|
+
<label className="flex cursor-pointer items-start gap-3">
|
|
138
|
+
<input
|
|
139
|
+
type="checkbox"
|
|
140
|
+
checked={isAdded}
|
|
141
|
+
onChange={() => {
|
|
142
|
+
if (canToggle) {
|
|
143
|
+
onToggle(bump.id, !isAdded, effectiveVariantId ?? undefined);
|
|
144
|
+
}
|
|
145
|
+
}}
|
|
146
|
+
disabled={loading || !canToggle || isOos}
|
|
147
|
+
className="mt-1 h-4 w-4 shrink-0 rounded"
|
|
148
|
+
/>
|
|
149
|
+
|
|
150
|
+
{/* Image */}
|
|
151
|
+
{imageUrl && (
|
|
152
|
+
<div className="bg-muted relative h-10 w-10 shrink-0 overflow-hidden rounded">
|
|
153
|
+
<Image src={imageUrl} alt={product.name} fill sizes="40px" className="object-cover" />
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{/* Content */}
|
|
158
|
+
<div className="min-w-0 flex-1">
|
|
159
|
+
<p className="text-foreground text-sm font-medium">{bump.title}</p>
|
|
160
|
+
{bump.description && (
|
|
161
|
+
<p className="text-muted-foreground mt-0.5 text-xs">{bump.description}</p>
|
|
162
|
+
)}
|
|
163
|
+
|
|
164
|
+
{/* Locked variant label */}
|
|
165
|
+
{lockedLabel && <p className="text-muted-foreground mt-0.5 text-xs">{lockedLabel}</p>}
|
|
166
|
+
|
|
167
|
+
{/* Price */}
|
|
168
|
+
<div className="mt-1 flex items-center gap-2">
|
|
169
|
+
{displayDiscounted != null ? (
|
|
170
|
+
<>
|
|
171
|
+
<span className="text-muted-foreground text-xs line-through">
|
|
172
|
+
{formatPrice(displayOriginal, { currency }) as string}
|
|
173
|
+
</span>
|
|
174
|
+
<span className="text-foreground text-sm font-semibold">
|
|
175
|
+
{formatPrice(displayDiscounted, { currency }) as string}
|
|
176
|
+
</span>
|
|
177
|
+
</>
|
|
178
|
+
) : (
|
|
179
|
+
<span className="text-foreground text-sm font-semibold">
|
|
180
|
+
{formatPrice(displayOriginal, { currency }) as string}
|
|
181
|
+
</span>
|
|
182
|
+
)}
|
|
183
|
+
{requiresSelection && !effectiveVariantId && (
|
|
184
|
+
<span className="text-muted-foreground text-xs">
|
|
185
|
+
{t('selectOptions') || 'Select options'}
|
|
186
|
+
</span>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</label>
|
|
191
|
+
|
|
192
|
+
{/* Compact variant selector */}
|
|
193
|
+
{requiresSelection && !isAdded && (
|
|
194
|
+
<div className="ms-7 mt-2 space-y-1.5">
|
|
195
|
+
{attributeGroups.map((group) => (
|
|
196
|
+
<div key={group.name} className="flex flex-wrap items-center gap-1.5">
|
|
197
|
+
<span className="text-muted-foreground text-xs">{group.name}:</span>
|
|
198
|
+
{group.values.map((value) => {
|
|
199
|
+
const isSelected = selectedAttrs[group.name] === value;
|
|
200
|
+
// Check if this value leads to any available variant
|
|
201
|
+
const variantForValue = variants?.find((v) => {
|
|
202
|
+
const opts = getVariantOptions(v as any);
|
|
203
|
+
const matchesValue = opts.some((o) => o.name === group.name && o.value === value);
|
|
204
|
+
if (!matchesValue) return false;
|
|
205
|
+
// Check other selected attrs
|
|
206
|
+
return Object.entries(selectedAttrs).every(([k, sv]) => {
|
|
207
|
+
if (k === group.name) return true;
|
|
208
|
+
return opts.some((o) => o.name === k && o.value === sv);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
const isVariantOos =
|
|
212
|
+
variantForValue?.inventory?.trackingMode !== 'NOT_TRACKED' &&
|
|
213
|
+
variantForValue?.inventory?.available != null &&
|
|
214
|
+
variantForValue.inventory.available <= 0;
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<button
|
|
218
|
+
key={value}
|
|
219
|
+
type="button"
|
|
220
|
+
onClick={() => handleAttrSelect(group.name, value)}
|
|
221
|
+
disabled={isVariantOos}
|
|
222
|
+
className={cn(
|
|
223
|
+
'rounded-full border px-2.5 py-0.5 text-xs transition-colors',
|
|
224
|
+
isSelected
|
|
225
|
+
? 'border-primary bg-primary text-primary-foreground'
|
|
226
|
+
: 'border-border text-foreground hover:border-primary/50',
|
|
227
|
+
isVariantOos && 'cursor-not-allowed line-through opacity-40'
|
|
228
|
+
)}
|
|
229
|
+
>
|
|
230
|
+
{value}
|
|
231
|
+
</button>
|
|
232
|
+
);
|
|
233
|
+
})}
|
|
234
|
+
</div>
|
|
235
|
+
))}
|
|
236
|
+
{isOos && effectiveVariantId && (
|
|
237
|
+
<p className="text-destructive text-xs">{t('outOfStock') || 'Out of stock'}</p>
|
|
238
|
+
)}
|
|
239
|
+
</div>
|
|
240
|
+
)}
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
@@ -154,7 +154,12 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
|
|
|
154
154
|
initialized.current = true;
|
|
155
155
|
|
|
156
156
|
const client = getClient();
|
|
157
|
-
|
|
157
|
+
// For iframe-based providers, redirect inside the iframe goes to a
|
|
158
|
+
// lightweight callback page that sends postMessage to the parent window.
|
|
159
|
+
// For redirect-based providers, go straight to order-confirmation.
|
|
160
|
+
const iframeSuccessUrl = `${window.location.origin}/payment-complete?checkout_id=${checkoutId}`;
|
|
161
|
+
const iframeFailedUrl = `${window.location.origin}/payment-complete?checkout_id=${checkoutId}&failed=true`;
|
|
162
|
+
const redirectSuccessUrl = `${window.location.origin}/order-confirmation?checkout_id=${checkoutId}`;
|
|
158
163
|
const cancelUrl = `${window.location.origin}/checkout?checkout_id=${checkoutId}&canceled=true`;
|
|
159
164
|
|
|
160
165
|
let sdkInitDone = false;
|
|
@@ -315,8 +320,19 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
|
|
|
315
320
|
});
|
|
316
321
|
|
|
317
322
|
// C) Create payment intent (starts wallet timer)
|
|
318
|
-
|
|
319
|
-
|
|
323
|
+
// Wait for provider info so we can choose the right success URL:
|
|
324
|
+
// iframe providers redirect inside the iframe to /payment-complete (postMessage),
|
|
325
|
+
// redirect providers go straight to /order-confirmation.
|
|
326
|
+
const intentPromise = providerPromise
|
|
327
|
+
.then((providerSdk) => {
|
|
328
|
+
const isIframe = providerSdk?.renderType === 'iframe';
|
|
329
|
+
const successUrl = isIframe ? iframeSuccessUrl : redirectSuccessUrl;
|
|
330
|
+
const failedUrl = isIframe ? iframeFailedUrl : cancelUrl;
|
|
331
|
+
return client.createPaymentIntent(checkoutId, {
|
|
332
|
+
successUrl,
|
|
333
|
+
cancelUrl: failedUrl,
|
|
334
|
+
});
|
|
335
|
+
})
|
|
320
336
|
.then((intent) => {
|
|
321
337
|
setPaymentIntent(intent);
|
|
322
338
|
return intent;
|
|
@@ -341,6 +357,36 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
|
|
|
341
357
|
window.location.href = intent.clientSecret;
|
|
342
358
|
return;
|
|
343
359
|
}
|
|
360
|
+
|
|
361
|
+
// Iframe mode: listen for postMessage from the /payment-complete callback
|
|
362
|
+
// page that loads inside the iframe after the provider redirects on completion.
|
|
363
|
+
if (sdk.renderType === 'iframe') {
|
|
364
|
+
const handleMessage = (event: MessageEvent) => {
|
|
365
|
+
if (event.origin !== window.location.origin) return;
|
|
366
|
+
if (event.data?.type !== 'brainerce:payment-complete') return;
|
|
367
|
+
|
|
368
|
+
const params = event.data.data as Record<string, string> | undefined;
|
|
369
|
+
if (params?.failed === 'true') {
|
|
370
|
+
setError(t('paymentError'));
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Map provider-specific params to normalized format for
|
|
375
|
+
// server-side verification (e.g. CardCom lowprofilecode → paymentIntentId)
|
|
376
|
+
const lowProfileCode = params?.lowprofilecode || params?.LowProfileCode;
|
|
377
|
+
const normalized: Record<string, unknown> = { ...params };
|
|
378
|
+
if (lowProfileCode) {
|
|
379
|
+
normalized.paymentIntentId = lowProfileCode;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Trigger server-side verification + order creation
|
|
383
|
+
handleSuccess(normalized);
|
|
384
|
+
};
|
|
385
|
+
window.addEventListener('message', handleMessage);
|
|
386
|
+
cleanups.push(() => window.removeEventListener('message', handleMessage));
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
344
390
|
if (sdk.renderType !== 'sdk-widget' || !sdk.globalName) return;
|
|
345
391
|
|
|
346
392
|
// Store for retryRender from onError callback
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import Link from 'next/link';
|
|
4
|
-
import { useTranslations } from '@/lib/translations';
|
|
5
|
-
import { useStoreInfo, useAuth } from '@/providers/store-provider';
|
|
6
|
-
|
|
7
|
-
export function Footer() {
|
|
8
|
-
const t = useTranslations('common');
|
|
9
|
-
const tn = useTranslations('nav');
|
|
10
|
-
const { storeInfo } = useStoreInfo();
|
|
11
|
-
const { isLoggedIn } = useAuth();
|
|
12
|
-
const year = new Date().getFullYear();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<footer className="border-border bg-background border-t">
|
|
16
|
-
<div className="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
|
|
17
|
-
<div className="flex flex-col items-center justify-between gap-4 sm:flex-row">
|
|
18
|
-
<p className="text-muted-foreground text-sm">
|
|
19
|
-
{year} {storeInfo?.name || t('store')}. {t('allRightsReserved')}
|
|
20
|
-
</p>
|
|
21
|
-
<nav className="flex items-center gap-4">
|
|
22
|
-
<Link
|
|
23
|
-
href="/products"
|
|
24
|
-
className="text-muted-foreground hover:text-foreground text-sm transition-colors"
|
|
25
|
-
>
|
|
26
|
-
{tn('products')}
|
|
27
|
-
</Link>
|
|
28
|
-
{isLoggedIn && (
|
|
29
|
-
<Link
|
|
30
|
-
href="/account"
|
|
31
|
-
className="text-muted-foreground hover:text-foreground text-sm transition-colors"
|
|
32
|
-
>
|
|
33
|
-
{tn('account')}
|
|
34
|
-
</Link>
|
|
35
|
-
)}
|
|
36
|
-
</nav>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</footer>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useTranslations } from '@/lib/translations';
|
|
5
|
+
import { useStoreInfo, useAuth } from '@/providers/store-provider';
|
|
6
|
+
|
|
7
|
+
export function Footer() {
|
|
8
|
+
const t = useTranslations('common');
|
|
9
|
+
const tn = useTranslations('nav');
|
|
10
|
+
const { storeInfo } = useStoreInfo();
|
|
11
|
+
const { isLoggedIn } = useAuth();
|
|
12
|
+
const year = new Date().getFullYear();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<footer className="border-border bg-background border-t">
|
|
16
|
+
<div className="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
|
|
17
|
+
<div className="flex flex-col items-center justify-between gap-4 sm:flex-row">
|
|
18
|
+
<p className="text-muted-foreground text-sm">
|
|
19
|
+
{year} {storeInfo?.name || t('store')}. {t('allRightsReserved')}
|
|
20
|
+
</p>
|
|
21
|
+
<nav className="flex items-center gap-4">
|
|
22
|
+
<Link
|
|
23
|
+
href="/products"
|
|
24
|
+
className="text-muted-foreground hover:text-foreground text-sm transition-colors"
|
|
25
|
+
>
|
|
26
|
+
{tn('products')}
|
|
27
|
+
</Link>
|
|
28
|
+
{isLoggedIn && (
|
|
29
|
+
<Link
|
|
30
|
+
href="/account"
|
|
31
|
+
className="text-muted-foreground hover:text-foreground text-sm transition-colors"
|
|
32
|
+
>
|
|
33
|
+
{tn('account')}
|
|
34
|
+
</Link>
|
|
35
|
+
)}
|
|
36
|
+
</nav>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</footer>
|
|
40
|
+
);
|
|
41
|
+
}
|