@hszrdm/create-commerce 1.7.0 → 1.8.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/package.json +1 -1
- package/templates/backend/.env.example +13 -0
- package/templates/backend/package.json +1 -1
- package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +5 -1
- package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +14 -5
- package/templates/storefront/src/app/[countryCode]/products/page.tsx +10 -1
- package/templates/storefront/src/app/account/orders/[id]/page.tsx +17 -2
- package/templates/storefront/src/app/checkout/success/page.tsx +5 -0
- package/templates/storefront/src/app/documents/page.tsx +27 -0
- package/templates/storefront/src/app/layout.tsx +8 -1
- package/templates/storefront/src/components/add-to-cart.tsx +16 -14
- package/templates/storefront/src/components/arukereso-backlink.tsx +43 -0
- package/templates/storefront/src/components/arukereso-trusted-shop-widget.tsx +81 -0
- package/templates/storefront/src/components/arukereso-trusted-shop.tsx +71 -0
- package/templates/storefront/src/components/cart-view.tsx +4 -2
- package/templates/storefront/src/components/category-documents.tsx +18 -0
- package/templates/storefront/src/components/checkout-analytics.tsx +22 -0
- package/templates/storefront/src/components/document-list.tsx +47 -0
- package/templates/storefront/src/components/google-ads-cart-remarketing.tsx +71 -0
- package/templates/storefront/src/components/google-ads-purchase.tsx +37 -0
- package/templates/storefront/src/components/price-display.tsx +39 -0
- package/templates/storefront/src/components/product-card.tsx +7 -6
- package/templates/storefront/src/components/product-documents.tsx +18 -0
- package/templates/storefront/src/components/product-view-tracker.tsx +17 -2
- package/templates/storefront/src/components/reorder-button.tsx +74 -0
- package/templates/storefront/src/components/variant-price-display.tsx +7 -11
- package/templates/storefront/src/lib/core/catalog.ts +6 -2
- package/templates/storefront/src/lib/core/commerce.ts +51 -0
- package/templates/storefront/src/lib/core/documents.ts +37 -0
- package/templates/storefront/src/lib/core/google-ads.ts +154 -7
- package/templates/storefront/src/lib/core/reorder.ts +26 -0
- package/templates/storefront/src/lib/storefront-routes.ts +3 -0
- package/templates/storefront/src/proxy.ts +2 -0
package/package.json
CHANGED
|
@@ -366,6 +366,19 @@ MPL_TRACKING_ACCOUNT_CODE=
|
|
|
366
366
|
MPL_PUSH_READ_WINDOW_MS=8000
|
|
367
367
|
MPL_TRACKING_LANGUAGE=hu
|
|
368
368
|
|
|
369
|
+
CSOMAGPIAC_ENABLED=false
|
|
370
|
+
CSOMAGPIAC_LIVE=false
|
|
371
|
+
CSOMAGPIAC_API_URL=
|
|
372
|
+
CSOMAGPIAC_TOKEN=
|
|
373
|
+
CSOMAGPIAC_USERNAME=
|
|
374
|
+
CSOMAGPIAC_PASSWORD=
|
|
375
|
+
CSOMAGPIAC_PICKUP_POINT_ID=
|
|
376
|
+
CSOMAGPIAC_PRICE_HUF=1990
|
|
377
|
+
CSOMAGPIAC_FREE_SHIPPING_THRESHOLD_HUF=
|
|
378
|
+
CSOMAGPIAC_TIMEOUT_MS=15000
|
|
379
|
+
CSOMAGPIAC_DEFAULT_WEIGHT_KG=1
|
|
380
|
+
CSOMAGPIAC_LABEL_FORMAT=A4
|
|
381
|
+
|
|
369
382
|
# -----------------------------------------------------------------------------
|
|
370
383
|
# Product feeds / trust widgets - optional
|
|
371
384
|
# -----------------------------------------------------------------------------
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { notFound } from "next/navigation"
|
|
2
|
+
import { CategoryDocuments } from "@/components/category-documents"
|
|
2
3
|
import { ProductCard } from "@/components/product-card"
|
|
3
4
|
import { getCoreConfig } from "@/lib/core/client"
|
|
4
5
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
@@ -22,14 +23,16 @@ export default async function CategoryPage({ params }: { params: Promise<{ count
|
|
|
22
23
|
const config = await getCoreConfig()
|
|
23
24
|
const category = await getCategoryByHandle(handle, apiLocale).then((result) => result.product_categories[0]).catch(() => null)
|
|
24
25
|
if (!category) notFound()
|
|
26
|
+
const categoryId = stringValue(category.id)
|
|
25
27
|
const [jsonLd, region] = await Promise.all([
|
|
26
28
|
structuredDataForEntity(config, { type: "category", handle, countryCode }).catch(() => null),
|
|
27
29
|
checkoutApi(config).resolveDefaultRegion().catch(() => null),
|
|
28
30
|
])
|
|
29
31
|
const products = await listProducts({
|
|
30
|
-
categoryId
|
|
32
|
+
categoryId,
|
|
31
33
|
order: "-created_at",
|
|
32
34
|
regionId: region ? stringValue(region.id) : undefined,
|
|
35
|
+
countryCode: config.store.default_country,
|
|
33
36
|
locale: apiLocale,
|
|
34
37
|
limit: 48,
|
|
35
38
|
}).then((result) => result.products).catch(() => [])
|
|
@@ -39,6 +42,7 @@ export default async function CategoryPage({ params }: { params: Promise<{ count
|
|
|
39
42
|
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
|
|
40
43
|
<div className="page-heading"><div><p className="eyebrow">{copy.category}</p><h1>{stringValue(category.name)}</h1>{category.description ? <p className="muted">{stringValue(category.description)}</p> : null}</div></div>
|
|
41
44
|
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard config={config} product={product} locale={locale} key={stringValue(product.id)} />)}</div> : <div className="empty-state">{copy.emptyCategory}</div>}
|
|
45
|
+
{categoryId ? <CategoryDocuments categoryId={categoryId} locale={apiLocale} /> : null}
|
|
42
46
|
</div>
|
|
43
47
|
)
|
|
44
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { notFound } from "next/navigation"
|
|
2
2
|
import { AddToCart } from "@/components/add-to-cart"
|
|
3
3
|
import { Breadcrumbs } from "@/components/breadcrumbs"
|
|
4
|
+
import { ProductDocuments } from "@/components/product-documents"
|
|
4
5
|
import { ProductGallery } from "@/components/product-gallery"
|
|
5
6
|
import { ProductReviews } from "@/components/product-reviews"
|
|
6
7
|
import { ProductViewTracker } from "@/components/product-view-tracker"
|
|
@@ -10,7 +11,8 @@ import { WishlistButton } from "@/components/wishlist-button"
|
|
|
10
11
|
import { getCoreConfig } from "@/lib/core/client"
|
|
11
12
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
12
13
|
import { getProductByHandle } from "@/lib/core/catalog"
|
|
13
|
-
import { asRecords, productVariantCurrency,
|
|
14
|
+
import { asRecords, productVariantCurrency, productVariantPriceBreakdown, stringValue } from "@/lib/core/commerce"
|
|
15
|
+
import { googleAdsRemarketingItemFromProduct } from "@/lib/core/google-ads"
|
|
14
16
|
import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
|
|
15
17
|
import { ecommerceItemFromProduct } from "@/lib/core/tracking"
|
|
16
18
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
@@ -30,14 +32,20 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
30
32
|
const config = await getCoreConfig()
|
|
31
33
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
32
34
|
const regionId = region ? stringValue(region.id) : undefined
|
|
33
|
-
const product = await getProductByHandle(
|
|
35
|
+
const product = await getProductByHandle(
|
|
36
|
+
handle,
|
|
37
|
+
regionId,
|
|
38
|
+
medusaLocale(locale),
|
|
39
|
+
config.store.default_country,
|
|
40
|
+
).then((result) => result.products[0]).catch(() => null)
|
|
34
41
|
if (!product) notFound()
|
|
35
42
|
const jsonLd = await structuredDataForEntity(config, { type: "product", handle, countryCode }).catch(() => null)
|
|
36
43
|
const variants = asRecords(product.variants)
|
|
37
44
|
const first = variants[0]
|
|
38
|
-
const price =
|
|
45
|
+
const price = productVariantPriceBreakdown(first, config.store.default_currency)
|
|
39
46
|
const currency = productVariantCurrency(first, config.store.default_currency)
|
|
40
47
|
const tracking = ecommerceItemFromProduct({ product, variant: first, currency })
|
|
48
|
+
const remarketingItem = googleAdsRemarketingItemFromProduct({ product, variant: first }) || tracking.item
|
|
41
49
|
const images = asRecords(product.images)
|
|
42
50
|
const productId = stringValue(product.id)
|
|
43
51
|
const title = stringValue(product.title)
|
|
@@ -57,7 +65,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
57
65
|
return (
|
|
58
66
|
<div className="stack page-section">
|
|
59
67
|
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
|
|
60
|
-
<ProductViewTracker analytics={config.analytics} item={tracking.item} currency={tracking.currency} value={tracking.value} />
|
|
68
|
+
<ProductViewTracker analytics={config.analytics} googleAds={config.marketing.google_ads} item={tracking.item} googleAdsItem={remarketingItem} currency={tracking.currency} value={tracking.value} />
|
|
61
69
|
<Breadcrumbs
|
|
62
70
|
label={locale === "en" ? "Breadcrumb" : "Morzsanavigáció"}
|
|
63
71
|
items={[
|
|
@@ -74,7 +82,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
74
82
|
/>
|
|
75
83
|
<section className="product-copy stack" aria-labelledby="product-title">
|
|
76
84
|
<div><p className="eyebrow">{copy.product}</p><h1 id="product-title">{title}</h1></div>
|
|
77
|
-
<VariantPriceDisplay initialPrice={price}
|
|
85
|
+
<VariantPriceDisplay initialPrice={price} locale={formatLocale} />
|
|
78
86
|
{product.description ? <p className="product-description">{stringValue(product.description)}</p> : null}
|
|
79
87
|
<AddToCart product={product} config={config} regionId={regionId} />
|
|
80
88
|
<div className="button-row product-secondary-actions">
|
|
@@ -84,6 +92,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
84
92
|
<div className="product-meta">{product.subtitle ? <span>{stringValue(product.subtitle)}</span> : null}{product.material ? <span>{copy.material}: {stringValue(product.material)}</span> : null}{product.origin_country ? <span>{copy.origin}: {stringValue(product.origin_country)}</span> : null}</div>
|
|
85
93
|
</section>
|
|
86
94
|
</div>
|
|
95
|
+
{productId ? <ProductDocuments productId={productId} locale={medusaLocale(locale)} /> : null}
|
|
87
96
|
{productId ? <ProductReviews productId={productId} locale={locale} /> : null}
|
|
88
97
|
</div>
|
|
89
98
|
)
|
|
@@ -23,7 +23,16 @@ export default async function ProductsPage({ params, searchParams }: { params: P
|
|
|
23
23
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
24
24
|
const regionId = region ? stringValue(region.id) : undefined
|
|
25
25
|
const [{ products, count = 0 }, categoryResult] = await Promise.all([
|
|
26
|
-
listProducts({
|
|
26
|
+
listProducts({
|
|
27
|
+
q: query.q,
|
|
28
|
+
categoryId: query.category,
|
|
29
|
+
order: sortMap[query.sort || "newest"] || sortMap.newest,
|
|
30
|
+
regionId,
|
|
31
|
+
countryCode: config.store.default_country,
|
|
32
|
+
locale: apiLocale,
|
|
33
|
+
limit,
|
|
34
|
+
offset: (page - 1) * limit,
|
|
35
|
+
}),
|
|
27
36
|
listCategories(apiLocale).catch(() => ({ product_categories: [] })),
|
|
28
37
|
])
|
|
29
38
|
const categories = categoryResult.product_categories
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { OrderDetail } from "@/components/order-detail"
|
|
2
|
+
import { ReorderButton } from "@/components/reorder-button"
|
|
2
3
|
import { getCoreConfig } from "@/lib/core/client"
|
|
4
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
3
5
|
|
|
4
6
|
export default async function AccountOrderPage({ params }: { params: Promise<{ id: string }> }) {
|
|
5
7
|
const { id } = await params
|
|
6
|
-
const config = await
|
|
7
|
-
|
|
8
|
+
const [config, locale] = await Promise.all([
|
|
9
|
+
getCoreConfig(),
|
|
10
|
+
requestStorefrontLocale(),
|
|
11
|
+
])
|
|
12
|
+
return (
|
|
13
|
+
<div className="stack page-section">
|
|
14
|
+
<div className="button-row">
|
|
15
|
+
<ReorderButton orderId={id} />
|
|
16
|
+
<span className="muted small">
|
|
17
|
+
{locale === "en" ? "Using current prices and availability." : "Aktuális árakkal és készlettel."}
|
|
18
|
+
</span>
|
|
19
|
+
</div>
|
|
20
|
+
<OrderDetail config={config} orderId={id} />
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
8
23
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Link from "next/link"
|
|
2
2
|
import { notFound } from "next/navigation"
|
|
3
|
+
import { ArukeresoTrustedShop } from "@/components/arukereso-trusted-shop"
|
|
4
|
+
import { GoogleAdsPurchase } from "@/components/google-ads-purchase"
|
|
3
5
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
4
6
|
import { endpoint, getCoreConfig, medusaFetch } from "@/lib/core/client"
|
|
5
7
|
import { asRecords, formatMoney, isRecord, stringValue, type JsonRecord } from "@/lib/core/commerce"
|
|
@@ -37,6 +39,9 @@ export default async function CheckoutSuccessPage({ searchParams }: { searchPara
|
|
|
37
39
|
|
|
38
40
|
return (
|
|
39
41
|
<div className="stack page-section narrow-page">
|
|
42
|
+
<GoogleAdsPurchase googleAds={config.marketing.google_ads} order={order} />
|
|
43
|
+
<ArukeresoTrustedShop orderId={orderId} />
|
|
44
|
+
|
|
40
45
|
<section className="success-hero panel stack">
|
|
41
46
|
<div className="success-icon">✓</div>
|
|
42
47
|
<div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DocumentList } from "@/components/document-list"
|
|
2
|
+
import { getDocuments } from "@/lib/core/documents"
|
|
3
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
|
+
import { medusaLocale } from "@/lib/storefront-routes"
|
|
5
|
+
|
|
6
|
+
export async function generateMetadata() {
|
|
7
|
+
const locale = await requestStorefrontLocale()
|
|
8
|
+
return { title: locale === "en" ? "Documents" : "Dokumentumok" }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default async function DocumentsPage() {
|
|
12
|
+
const locale = await requestStorefrontLocale()
|
|
13
|
+
const apiLocale = medusaLocale(locale)
|
|
14
|
+
const en = locale === "en"
|
|
15
|
+
const payload = await getDocuments({ locale: apiLocale }).catch(() => ({ documents: [], count: 0 }))
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="stack page-section">
|
|
19
|
+
<div className="stack" style={{ gap: ".5rem" }}>
|
|
20
|
+
<p className="eyebrow">{en ? "Downloads" : "Letöltések"}</p>
|
|
21
|
+
<h1>{en ? "Documents" : "Dokumentumok"}</h1>
|
|
22
|
+
<p className="muted">{en ? "Documents published by the store in one place." : "A webáruház által közzétett dokumentumok egy helyen."}</p>
|
|
23
|
+
</div>
|
|
24
|
+
<DocumentList documents={payload.documents} locale={apiLocale} />
|
|
25
|
+
</div>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -5,9 +5,12 @@ import type { Metadata } from "next"
|
|
|
5
5
|
import Link from "next/link"
|
|
6
6
|
import { AccessibilityPreferencesControl, AccessibilityPreferencesProvider } from "@/components/accessibility-preferences"
|
|
7
7
|
import { AnalyticsGate } from "@/components/analytics"
|
|
8
|
+
import { ArukeresoBacklink } from "@/components/arukereso-backlink"
|
|
9
|
+
import { ArukeresoTrustedShopWidget } from "@/components/arukereso-trusted-shop-widget"
|
|
8
10
|
import { CartProvider } from "@/components/cart-provider"
|
|
9
11
|
import { ConsentBanner } from "@/components/consent-banner"
|
|
10
12
|
import { CustomerCartResumeGate } from "@/components/customer-cart-resume-gate"
|
|
13
|
+
import { GoogleAdsCartRemarketing } from "@/components/google-ads-cart-remarketing"
|
|
11
14
|
import { NewsletterSignup } from "@/components/newsletter-signup"
|
|
12
15
|
import { StorefrontHeader } from "@/components/storefront-header"
|
|
13
16
|
import { ToastProvider } from "@/components/toast-provider"
|
|
@@ -58,6 +61,7 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
58
61
|
<AccessibilityPreferencesProvider>
|
|
59
62
|
<ToastProvider locale={locale}>
|
|
60
63
|
<CartProvider config={config}>
|
|
64
|
+
<GoogleAdsCartRemarketing googleAds={config.marketing.google_ads} />
|
|
61
65
|
<a className="skip-link" href="#main-content">
|
|
62
66
|
{en ? "Skip to content" : "Ugrás a tartalomhoz"}
|
|
63
67
|
</a>
|
|
@@ -72,11 +76,14 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
72
76
|
<div>
|
|
73
77
|
<strong>{config.store.name}</strong>
|
|
74
78
|
<p className="muted small">Powered by HSZRDM Commerce</p>
|
|
79
|
+
<ArukeresoTrustedShopWidget />
|
|
80
|
+
<ArukeresoBacklink />
|
|
75
81
|
</div>
|
|
76
82
|
<nav className="footer-nav" aria-label={en ? "Footer navigation" : "Lábléc navigáció"}>
|
|
77
83
|
<Link href={routes.products}>{en ? "Products" : "Termékek"}</Link>
|
|
78
|
-
<Link href={routes.blog}>
|
|
84
|
+
<Link href={routes.blog}>Blog</Link>
|
|
79
85
|
<Link href={routes.knowledgeBase}>{en ? "Knowledge base" : "Tudástár"}</Link>
|
|
86
|
+
<Link href={routes.documents}>{en ? "Documents" : "Dokumentumok"}</Link>
|
|
80
87
|
<Link href={routes.cmsPages}>{en ? "Pages" : "Oldalak"}</Link>
|
|
81
88
|
<Link href={routes.quoteRequest}>{en ? "Request a quote" : "Ajánlatkérés"}</Link>
|
|
82
89
|
<Link href={routes.contact}>{en ? "Contact" : "Kapcsolat"}</Link>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useState } from "react"
|
|
4
4
|
import { usePathname } from "next/navigation"
|
|
5
|
+
import { PriceDisplay } from "./price-display"
|
|
5
6
|
import { QuantityStepper } from "./quantity-stepper"
|
|
6
7
|
import { TierProgressHint } from "./tier-progress-hint"
|
|
7
8
|
import { useToast } from "./toast-provider"
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
formatMoney,
|
|
13
14
|
numberValue,
|
|
14
15
|
productVariantCurrency,
|
|
15
|
-
|
|
16
|
+
productVariantPriceBreakdown,
|
|
16
17
|
stringValue,
|
|
17
18
|
} from "@/lib/core/commerce"
|
|
18
19
|
import { humanizeStorefrontError } from "@/lib/core/form-ux"
|
|
@@ -53,7 +54,7 @@ export function AddToCart({
|
|
|
53
54
|
const { addItem, mutating } = useCart()
|
|
54
55
|
const { showToast } = useToast()
|
|
55
56
|
const selected = variants.find((variant) => stringValue(variant.id) === variantId) || variants[0]
|
|
56
|
-
const price =
|
|
57
|
+
const price = productVariantPriceBreakdown(selected, config.store.default_currency)
|
|
57
58
|
const currency = productVariantCurrency(selected, config.store.default_currency)
|
|
58
59
|
const formatLocale = en ? "en-US" : "hu-HU"
|
|
59
60
|
const minQuantity = variantMinimum(selected, productMetadata)
|
|
@@ -106,8 +107,7 @@ export function AddToCart({
|
|
|
106
107
|
onChange={(event) => {
|
|
107
108
|
const nextId = event.target.value
|
|
108
109
|
const next = variants.find((variant) => stringValue(variant.id) === nextId)
|
|
109
|
-
const nextPrice =
|
|
110
|
-
const nextCurrency = productVariantCurrency(next, config.store.default_currency)
|
|
110
|
+
const nextPrice = productVariantPriceBreakdown(next, config.store.default_currency)
|
|
111
111
|
setVariantId(nextId)
|
|
112
112
|
setQuantity(variantMinimum(next, productMetadata))
|
|
113
113
|
setMessage(null)
|
|
@@ -119,20 +119,22 @@ export function AddToCart({
|
|
|
119
119
|
variantId: nextId,
|
|
120
120
|
imageUrl: variantImageUrl(next),
|
|
121
121
|
price: nextPrice,
|
|
122
|
-
currency: nextCurrency,
|
|
123
122
|
},
|
|
124
123
|
}))
|
|
125
124
|
}
|
|
126
125
|
}}
|
|
127
126
|
>
|
|
128
|
-
{variants.map((variant) =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
{variants.map((variant) => {
|
|
128
|
+
const variantPrice = productVariantPriceBreakdown(variant, config.store.default_currency)
|
|
129
|
+
return (
|
|
130
|
+
<option key={stringValue(variant.id)} value={stringValue(variant.id)}>
|
|
131
|
+
{stringValue(variant.title || variant.sku || variant.id)}
|
|
132
|
+
{Number.isFinite(variantPrice.amount)
|
|
133
|
+
? ` – ${formatMoney(variantPrice.grossAmount, variantPrice.currency, formatLocale)}`
|
|
134
|
+
: ""}
|
|
135
|
+
</option>
|
|
136
|
+
)
|
|
137
|
+
})}
|
|
136
138
|
</select>
|
|
137
139
|
</label>
|
|
138
140
|
) : null}
|
|
@@ -154,7 +156,7 @@ export function AddToCart({
|
|
|
154
156
|
</div>
|
|
155
157
|
<div className="buy-price">
|
|
156
158
|
<span className="muted">{en ? "Selected price" : "Kiválasztott ár"}</span>
|
|
157
|
-
|
|
159
|
+
{Number.isFinite(price.amount) ? <PriceDisplay price={price} locale={formatLocale} compact /> : <strong>—</strong>}
|
|
158
160
|
</div>
|
|
159
161
|
</div>
|
|
160
162
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react"
|
|
4
|
+
import { medusaFetch } from "@/lib/core/client"
|
|
5
|
+
|
|
6
|
+
type BacklinkResponse = {
|
|
7
|
+
enabled: boolean
|
|
8
|
+
code: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ArukeresoBacklink() {
|
|
12
|
+
const [code, setCode] = useState("")
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let cancelled = false
|
|
16
|
+
|
|
17
|
+
void (async () => {
|
|
18
|
+
try {
|
|
19
|
+
const data = await medusaFetch<BacklinkResponse>("/store/arukereso/backlink", {
|
|
20
|
+
cache: "no-store",
|
|
21
|
+
})
|
|
22
|
+
if (cancelled || !data.enabled || !data.code) return
|
|
23
|
+
setCode(data.code)
|
|
24
|
+
} catch {
|
|
25
|
+
// A backlink hibája nem zavarhatja a storefront működését.
|
|
26
|
+
}
|
|
27
|
+
})()
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
cancelled = true
|
|
31
|
+
}
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
if (!code) return null
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
data-arukereso-backlink
|
|
39
|
+
suppressHydrationWarning
|
|
40
|
+
dangerouslySetInnerHTML={{ __html: code }}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react"
|
|
4
|
+
import { medusaFetch } from "@/lib/core/client"
|
|
5
|
+
|
|
6
|
+
type WidgetResponse = {
|
|
7
|
+
enabled: boolean
|
|
8
|
+
code: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ArukeresoTrustedShopWidget() {
|
|
12
|
+
const hostRef = useRef<HTMLDivElement>(null)
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let cancelled = false
|
|
16
|
+
const host = hostRef.current
|
|
17
|
+
if (!host) return
|
|
18
|
+
|
|
19
|
+
void (async () => {
|
|
20
|
+
try {
|
|
21
|
+
const data = await medusaFetch<WidgetResponse>("/store/arukereso/widget", {
|
|
22
|
+
cache: "no-store",
|
|
23
|
+
})
|
|
24
|
+
if (cancelled || !data.enabled || !data.code) return
|
|
25
|
+
mountOfficialWidget(host, data.code)
|
|
26
|
+
} catch {
|
|
27
|
+
// A badge/widget hibája nem zavarhatja a storefront működését.
|
|
28
|
+
}
|
|
29
|
+
})()
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
cancelled = true
|
|
33
|
+
host.replaceChildren()
|
|
34
|
+
}
|
|
35
|
+
}, [])
|
|
36
|
+
|
|
37
|
+
return <div ref={hostRef} data-arukereso-trusted-shop-widget />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function mountOfficialWidget(host: HTMLDivElement, code: string) {
|
|
41
|
+
const template = document.createElement("template")
|
|
42
|
+
template.innerHTML = code
|
|
43
|
+
|
|
44
|
+
const scripts = Array.from(template.content.querySelectorAll("script"))
|
|
45
|
+
for (const script of scripts) script.remove()
|
|
46
|
+
|
|
47
|
+
host.replaceChildren(template.content.cloneNode(true))
|
|
48
|
+
|
|
49
|
+
for (const original of scripts) {
|
|
50
|
+
const src = original.getAttribute("src")
|
|
51
|
+
if (!src || !isAllowedUrl(src)) continue
|
|
52
|
+
|
|
53
|
+
const script = document.createElement("script")
|
|
54
|
+
script.src = new URL(src, "https://www.arukereso.hu").toString()
|
|
55
|
+
script.async = original.async !== false
|
|
56
|
+
script.defer = original.defer
|
|
57
|
+
for (const attr of Array.from(original.attributes)) {
|
|
58
|
+
if (["src", "async", "defer"].includes(attr.name.toLowerCase())) continue
|
|
59
|
+
if (attr.name.toLowerCase().startsWith("on")) continue
|
|
60
|
+
script.setAttribute(attr.name, attr.value)
|
|
61
|
+
}
|
|
62
|
+
host.appendChild(script)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isAllowedUrl(value: string) {
|
|
67
|
+
try {
|
|
68
|
+
const url = new URL(value, "https://www.arukereso.hu")
|
|
69
|
+
return (
|
|
70
|
+
url.protocol === "https:" &&
|
|
71
|
+
[
|
|
72
|
+
"arukereso.hu",
|
|
73
|
+
"www.arukereso.hu",
|
|
74
|
+
"assets.arukereso.com",
|
|
75
|
+
"static.arukereso.hu",
|
|
76
|
+
].includes(url.hostname.toLowerCase())
|
|
77
|
+
)
|
|
78
|
+
} catch {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useEffect } from "react"
|
|
4
|
+
import { medusaRawFetch } from "@/lib/core/client"
|
|
5
|
+
|
|
6
|
+
const STORAGE_PREFIX = "hszrdm:arukereso-trusted-shop:v2:"
|
|
7
|
+
|
|
8
|
+
type TrustedShopResponse = {
|
|
9
|
+
token: string
|
|
10
|
+
web_api_key: string
|
|
11
|
+
process_url: string
|
|
12
|
+
script_url: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type AkuWindow = Window & {
|
|
16
|
+
aku_request_done?: (w: unknown, c: string) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function ArukeresoTrustedShop({ orderId }: { orderId: string }) {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!orderId || typeof window === "undefined") return
|
|
22
|
+
|
|
23
|
+
const storageKey = `${STORAGE_PREFIX}${orderId}`
|
|
24
|
+
if (window.localStorage.getItem(storageKey) === "sent") return
|
|
25
|
+
|
|
26
|
+
let cancelled = false
|
|
27
|
+
let script: HTMLScriptElement | null = null
|
|
28
|
+
const target = window as AkuWindow
|
|
29
|
+
const previousCallback = target.aku_request_done
|
|
30
|
+
|
|
31
|
+
void (async () => {
|
|
32
|
+
try {
|
|
33
|
+
const response = await medusaRawFetch(
|
|
34
|
+
`/store/arukereso/trusted-shop/${encodeURIComponent(orderId)}`,
|
|
35
|
+
{ method: "POST", body: JSON.stringify({}) },
|
|
36
|
+
)
|
|
37
|
+
if (cancelled || response.status === 204 || !response.ok) return
|
|
38
|
+
|
|
39
|
+
const data = (await response.json()) as TrustedShopResponse
|
|
40
|
+
if (!data.token || !data.web_api_key || !data.process_url || !data.script_url) return
|
|
41
|
+
|
|
42
|
+
let processed = false
|
|
43
|
+
target.aku_request_done = (_w, c) => {
|
|
44
|
+
if (processed || cancelled) return
|
|
45
|
+
processed = true
|
|
46
|
+
|
|
47
|
+
const image = new Image()
|
|
48
|
+
image.onload = () => window.localStorage.setItem(storageKey, "sent")
|
|
49
|
+
image.src = `${data.process_url}?Token=${encodeURIComponent(data.token)}&WebApiKey=${encodeURIComponent(data.web_api_key)}&C=${encodeURIComponent(String(c || Date.now()))}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
script = document.createElement("script")
|
|
53
|
+
script.type = "text/javascript"
|
|
54
|
+
script.src = data.script_url
|
|
55
|
+
script.async = true
|
|
56
|
+
;(document.head || document.body).appendChild(script)
|
|
57
|
+
} catch {
|
|
58
|
+
// A Trusted Shop mérés hibája nem akadályozhatja a sikeres rendelési oldalt.
|
|
59
|
+
}
|
|
60
|
+
})()
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
cancelled = true
|
|
64
|
+
if (script?.parentNode) script.parentNode.removeChild(script)
|
|
65
|
+
if (target.aku_request_done === previousCallback) return
|
|
66
|
+
target.aku_request_done = previousCallback
|
|
67
|
+
}
|
|
68
|
+
}, [orderId])
|
|
69
|
+
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Link from "next/link"
|
|
4
4
|
import { usePathname } from "next/navigation"
|
|
5
5
|
import { useState } from "react"
|
|
6
|
+
import { PriceDisplay } from "./price-display"
|
|
6
7
|
import { QuantityStepper } from "./quantity-stepper"
|
|
7
8
|
import { useToast } from "./toast-provider"
|
|
8
9
|
import { useCart } from "./cart-provider"
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
cartTaxTotal,
|
|
16
17
|
cartTotal,
|
|
17
18
|
formatMoney,
|
|
18
|
-
|
|
19
|
+
linePriceBreakdown,
|
|
19
20
|
numberValue,
|
|
20
21
|
stringValue,
|
|
21
22
|
} from "@/lib/core/commerce"
|
|
@@ -78,6 +79,7 @@ export function CartView({ config, compact = false }: { config: CoreConfig; comp
|
|
|
78
79
|
const thumbnail = stringValue(item.thumbnail)
|
|
79
80
|
const title = stringValue(item.product_title || item.title)
|
|
80
81
|
const variantId = stringValue(item.variant_id)
|
|
82
|
+
const price = linePriceBreakdown(item, currency)
|
|
81
83
|
return (
|
|
82
84
|
<div className="cart-line" key={id}>
|
|
83
85
|
<div className="cart-line-image">
|
|
@@ -86,7 +88,7 @@ export function CartView({ config, compact = false }: { config: CoreConfig; comp
|
|
|
86
88
|
<div className="cart-line-copy">
|
|
87
89
|
<strong>{title}</strong>
|
|
88
90
|
{item.variant_title ? <span className="muted">{stringValue(item.variant_title)}</span> : null}
|
|
89
|
-
<
|
|
91
|
+
<PriceDisplay price={price} locale={formatLocale} compact />
|
|
90
92
|
</div>
|
|
91
93
|
<QuantityStepper
|
|
92
94
|
value={quantity}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DocumentList } from "@/components/document-list"
|
|
2
|
+
import { getDocuments } from "@/lib/core/documents"
|
|
3
|
+
|
|
4
|
+
export async function CategoryDocuments({ categoryId, locale = "hu-HU" }: { categoryId: string; locale?: string }) {
|
|
5
|
+
const en = locale.toLowerCase().startsWith("en")
|
|
6
|
+
const payload = await getDocuments({ categoryId, locale }).catch(() => ({ documents: [], count: 0 }))
|
|
7
|
+
if (!payload.documents.length) return null
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<section className="stack" aria-labelledby="category-documents-title">
|
|
11
|
+
<div>
|
|
12
|
+
<p className="eyebrow">{en ? "Downloads" : "Letöltések"}</p>
|
|
13
|
+
<h2 id="category-documents-title">{en ? "Documents" : "Dokumentumok"}</h2>
|
|
14
|
+
</div>
|
|
15
|
+
<DocumentList documents={payload.documents} locale={locale} />
|
|
16
|
+
</section>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
import { useEffect, useMemo, useRef } from "react"
|
|
4
4
|
import { useCart } from "./cart-provider"
|
|
5
5
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
6
|
+
import { COOKIE_CONSENT_EVENT } from "@/lib/core/consent"
|
|
7
|
+
import {
|
|
8
|
+
googleAdsRemarketingFromSource,
|
|
9
|
+
trackGoogleAdsRemarketing,
|
|
10
|
+
} from "@/lib/core/google-ads"
|
|
6
11
|
import type { CoreConfig } from "@/lib/core/types"
|
|
7
12
|
|
|
8
13
|
export function CheckoutAnalytics({ config }: { config: CoreConfig }) {
|
|
@@ -19,5 +24,22 @@ export function CheckoutAnalytics({ config }: { config: CoreConfig }) {
|
|
|
19
24
|
})
|
|
20
25
|
}, [api, cart, cartId])
|
|
21
26
|
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!cart || !cartId) return
|
|
29
|
+
|
|
30
|
+
const send = () => {
|
|
31
|
+
trackGoogleAdsRemarketing(
|
|
32
|
+
config.marketing.google_ads,
|
|
33
|
+
"begin_checkout",
|
|
34
|
+
googleAdsRemarketingFromSource(cart),
|
|
35
|
+
{ dedupeKey: cartId, sessionDedupe: true },
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
send()
|
|
40
|
+
window.addEventListener(COOKIE_CONSENT_EVENT, send)
|
|
41
|
+
return () => window.removeEventListener(COOKIE_CONSENT_EVENT, send)
|
|
42
|
+
}, [cart, cartId, config.marketing.google_ads])
|
|
43
|
+
|
|
22
44
|
return null
|
|
23
45
|
}
|