@hszrdm/create-commerce 1.5.0 → 1.6.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/package.json +1 -1
- package/templates/storefront/README.md +35 -12
- package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +3 -2
- package/templates/storefront/src/app/blog/page.tsx +46 -8
- package/templates/storefront/src/app/cart/page.tsx +2 -0
- package/templates/storefront/src/app/cart/shared/[token]/page.tsx +25 -0
- package/templates/storefront/src/app/knowledge-base/page.tsx +46 -8
- package/templates/storefront/src/app/layout.tsx +5 -2
- package/templates/storefront/src/app/legal/page.tsx +18 -2
- package/templates/storefront/src/app/page.tsx +33 -4
- package/templates/storefront/src/app/pages/page.tsx +43 -0
- package/templates/storefront/src/components/add-to-cart.tsx +76 -2
- package/templates/storefront/src/components/analytics.tsx +37 -17
- package/templates/storefront/src/components/cart-provider.tsx +40 -3
- package/templates/storefront/src/components/cart-share-button.tsx +93 -0
- package/templates/storefront/src/components/cms-taxonomy-filters.tsx +86 -0
- package/templates/storefront/src/components/customer-cart-resume-gate.tsx +112 -0
- package/templates/storefront/src/components/fogyasztobarat-embed.tsx +32 -0
- package/templates/storefront/src/components/shared-cart-view.tsx +257 -0
- package/templates/storefront/src/lib/core/catalog.ts +12 -0
- package/templates/storefront/src/lib/core/checkout.ts +86 -4
- package/templates/storefront/src/lib/core/customer-cart-resume.ts +51 -0
- package/templates/storefront/src/lib/core/google-ads.ts +58 -0
- package/templates/storefront/src/lib/core/legal.ts +14 -0
- package/templates/storefront/src/lib/core/shared-cart.ts +37 -0
- package/templates/storefront/src/lib/core/types.ts +18 -0
- package/templates/storefront/src/lib/storefront-routes.ts +9 -0
- package/templates/storefront/src/proxy.ts +7 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Újrahasznosítható, teljes referencia-storefront a MEDUSA WEBSHOP CORE backendhez.
|
|
4
4
|
|
|
5
|
-
A starter külön alkalmazás: nincs a backend root npm workspace-ben, így a Medusa deploy és lockfile nem kap Next.js/Stripe frontend függőségeket. Új webshopnál
|
|
5
|
+
A starter külön alkalmazás: nincs a backend root npm workspace-ben, így a Medusa deploy és lockfile nem kap Next.js/Stripe frontend függőségeket. Új webshopnál a `@hszrdm/create-commerce` generátor a teljes frontendrészt a külön ügyfélprojektbe másolja; ezután elsődlegesen a design/branding réteget kell cserélni, a `src/lib/core` integrációs contractokat és a kész commerce flow komponenseket érdemes megtartani.
|
|
6
6
|
|
|
7
7
|
## Indítás
|
|
8
8
|
|
|
@@ -20,18 +20,25 @@ NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000
|
|
|
20
20
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
szükséges. A payment/shipping/legal/SEO/analytics capability-k a `GET /store/core-config` contractból érkeznek.
|
|
23
|
+
szükséges. A payment/shipping/legal/SEO/analytics/marketing capability-k a `GET /store/core-config` contractból érkeznek.
|
|
24
24
|
|
|
25
25
|
## Beépített storefront flow
|
|
26
26
|
|
|
27
27
|
- store identity és capability bootstrap;
|
|
28
28
|
- teljes terméklista: keresés, kategóriaszűrés, rendezés, lapozás;
|
|
29
29
|
- kategória- és termékoldal Core SEO/JSON-LD contracttal;
|
|
30
|
-
-
|
|
30
|
+
- kiemelt termékek a kezdőlapon a Core `featured-products` contractból, fallbackkel a legújabb termékekre;
|
|
31
|
+
- variáns- és mennyiségválasztás, minimum rendelési mennyiség és Add to Cart;
|
|
32
|
+
- mennyiségi / customer-group ársávok megjelenítése, aktuális sáv és következő kedvezményes küszöb;
|
|
33
|
+
- készlet/backorder állapot és készletértesítő feliratkozás;
|
|
31
34
|
- wishlist guest móddal, account merge-dzsel és saját wishlist oldallal;
|
|
32
35
|
- termékértékelések approved listával, aggregált értékeléssel és bejelentkezett ügyfél review beküldéssel;
|
|
36
|
+
- signed review-request oldal;
|
|
33
37
|
- közös cart state, cart drawer és teljes kosároldal;
|
|
34
38
|
- kupon hozzáadás/eltávolítás;
|
|
39
|
+
- shared cart és abandoned-cart recovery;
|
|
40
|
+
- admin/customer kosár automatikus resume belépés után;
|
|
41
|
+
- tartalmas guest cart + customer cart konfliktusnál explicit választás, csendes felülírás nélkül;
|
|
35
42
|
- region automatikus feloldása a Core alapértelmezett országa alapján;
|
|
36
43
|
- checkout contact + shipping/billing cím;
|
|
37
44
|
- Medusa shipping option választás;
|
|
@@ -41,12 +48,13 @@ szükséges. A payment/shipping/legal/SEO/analytics capability-k a `GET /store/c
|
|
|
41
48
|
- OTP SimplePay redirect + BACK return folytatás;
|
|
42
49
|
- banki átutalás / COD system-provider megkülönböztetés Core metadata markerrel;
|
|
43
50
|
- dinamikus legal dokumentumok kötelező elfogadása;
|
|
51
|
+
- Fogyasztó Barát provider embed a publikus legal contractból;
|
|
44
52
|
- order completion és rendelés-visszaigazolás;
|
|
45
53
|
- banki átutalási adatok a sikeroldalon;
|
|
46
|
-
- login,
|
|
54
|
+
- login, regisztráció és migrált fiók aktiválás;
|
|
47
55
|
- profil, e-mail verification/change, jelszócsere/reset és fióktörlés;
|
|
48
56
|
- címjegyzék CRUD;
|
|
49
|
-
- rendelési előzmények és
|
|
57
|
+
- rendelési előzmények, rendelésrészlet és fulfillment tracking link;
|
|
50
58
|
- return / exchange / claim self-service;
|
|
51
59
|
- CMS referencia UI: blog lista/detail, generic page detail és tudástár lista/detail;
|
|
52
60
|
- newsletter signup a footerben, double-opt-in confirm és leiratkozó oldalakkal;
|
|
@@ -54,27 +62,34 @@ szükséges. A payment/shipping/legal/SEO/analytics capability-k a `GET /store/c
|
|
|
54
62
|
- dinamikus lead/contact form privacy consenttel, honeypottal és opcionális Cloudflare Turnstile támogatással;
|
|
55
63
|
- globális loading/error/404/empty state-ek;
|
|
56
64
|
- toast, share, accessibility preferences, keyboard/focus UX és reduced-motion támogatás;
|
|
65
|
+
- first-party webshop analytics;
|
|
57
66
|
- Consent Mode v2, GA4/GTM és e-commerce tracking;
|
|
67
|
+
- Google Ads purchase conversion GTM dataLayer vagy közvetlen gtag flow-val, marketing consenttel;
|
|
58
68
|
- robots.txt / sitemap.xml proxy és Search Console verification.
|
|
59
69
|
|
|
60
70
|
## Customer-facing Core capability elv
|
|
61
71
|
|
|
62
|
-
A starter
|
|
72
|
+
A starter kötelező szabálya, hogy minden általános, customer-facing Core képességhez legyen design-semleges, ténylegesen működő referencia UI vagy route. Egy helper vagy dokumentált endpoint önmagában nem számít kész storefront-bekötésnek.
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
Az ügyfélprojektekben a vizuális réteg szabadon cserélhető, de a `src/lib/core` contractok és a referencia flow-k mutatják a támogatott integrációt.
|
|
75
|
+
|
|
76
|
+
Admin-, számlázási-, fulfillment-operátori-, audit-, integration-settings-, import/export- és más háttérképességekhez nem tartozik shopper UI, mert azok az Adminhoz, háttérfolyamathoz vagy külső fogyasztóhoz tartoznak.
|
|
77
|
+
|
|
78
|
+
A teljes besorolás a Core repo `docs/STOREFRONT-CAPABILITY-MATRIX.md` fájljában található.
|
|
65
79
|
|
|
66
80
|
## Authority boundary
|
|
67
81
|
|
|
68
82
|
A starter **nem** számol újra:
|
|
69
83
|
|
|
70
|
-
- árat;
|
|
84
|
+
- árat vagy ársávot;
|
|
71
85
|
- kosár végösszeget;
|
|
72
86
|
- adót;
|
|
73
87
|
- promóciót;
|
|
74
88
|
- shipping availability-t vagy árat;
|
|
75
89
|
- payment provider availability-t;
|
|
76
90
|
- after-sales jogosultságot;
|
|
77
|
-
- legal checkout-követelményt
|
|
91
|
+
- legal checkout-követelményt;
|
|
92
|
+
- customer cart lifecycle-t.
|
|
78
93
|
|
|
79
94
|
Ezek source of truth-ja a Medusa/Core backend. A frontend kizárólag a backend által visszaadott adatot jeleníti meg és a contract szerinti műveleteket indítja.
|
|
80
95
|
|
|
@@ -82,7 +97,7 @@ Ezek source of truth-ja a Medusa/Core backend. A frontend kizárólag a backend
|
|
|
82
97
|
|
|
83
98
|
### Stripe
|
|
84
99
|
|
|
85
|
-
A Core publikus
|
|
100
|
+
A Core publikus Stripe publishable key értékéből a starter létrehozza a Stripe Payment Elementet. Secret key és webhook secret soha nem jut a frontendbe.
|
|
86
101
|
|
|
87
102
|
### SimplePay
|
|
88
103
|
|
|
@@ -108,7 +123,7 @@ A Core publikus, secret-safe list endpointjait használjuk:
|
|
|
108
123
|
|
|
109
124
|
A Packeta official widget ügyfél-designban a checkout `packeta.pickupPoint` adapteréhez köthető. A starter nem teszi ki a backend Packeta API credentialt.
|
|
110
125
|
|
|
111
|
-
## Build ellenőrzés
|
|
126
|
+
## Build és parity ellenőrzés
|
|
112
127
|
|
|
113
128
|
A starter önálló app, ezért külön futtasd:
|
|
114
129
|
|
|
@@ -118,4 +133,12 @@ npm run typecheck
|
|
|
118
133
|
npm run build
|
|
119
134
|
```
|
|
120
135
|
|
|
121
|
-
A
|
|
136
|
+
A Core repo gyökerében a `npm run storefront:verify` statikus regressziós teszttel ellenőrzi, hogy a kötelező customer-facing Core capability-k tényleges UI/route bekötése megmaradjon. A `npm run core:verify` ezt is futtatja.
|
|
137
|
+
|
|
138
|
+
## Generator
|
|
139
|
+
|
|
140
|
+
A `@hszrdm/create-commerce` template preparation a teljes `starters/storefront-next` könyvtárat másolja. Nincs külön, könnyen eldriftelő storefront template, ezért az itt működő referencia-flow-k az újonnan generált webshopba automatikusan bekerülnek.
|
|
141
|
+
|
|
142
|
+
## Részletes funkcióleírások
|
|
143
|
+
|
|
144
|
+
A referenciafolyamatok, a saját analitika/Google consent különbsége, a kosármegosztás és az integrációs korlátok a [repository dokumentációjában](../../docs/README.md) találhatók. Ez a hivatkozás a Core forrásrepójára vonatkozik; a generált ügyfélprojekt nem másolja a teljes docs mappát.
|
|
@@ -29,7 +29,8 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
29
29
|
const routes = STOREFRONT_ROUTES[locale]
|
|
30
30
|
const config = await getCoreConfig()
|
|
31
31
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
32
|
-
const
|
|
32
|
+
const regionId = region ? stringValue(region.id) : undefined
|
|
33
|
+
const product = await getProductByHandle(handle, regionId, medusaLocale(locale)).then((result) => result.products[0]).catch(() => null)
|
|
33
34
|
if (!product) notFound()
|
|
34
35
|
const jsonLd = await structuredDataForEntity(config, { type: "product", handle, countryCode }).catch(() => null)
|
|
35
36
|
const variants = asRecords(product.variants)
|
|
@@ -75,7 +76,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
75
76
|
<div><p className="eyebrow">{copy.product}</p><h1 id="product-title">{title}</h1></div>
|
|
76
77
|
<VariantPriceDisplay initialPrice={price} initialCurrency={currency} locale={formatLocale} />
|
|
77
78
|
{product.description ? <p className="product-description">{stringValue(product.description)}</p> : null}
|
|
78
|
-
<AddToCart product={product} config={config} />
|
|
79
|
+
<AddToCart product={product} config={config} regionId={regionId} />
|
|
79
80
|
<div className="button-row product-secondary-actions">
|
|
80
81
|
{productId ? <WishlistButton productId={productId} /> : null}
|
|
81
82
|
<ShareButton title={title} text={stringValue(product.description)} />
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
|
-
import {
|
|
2
|
+
import { CmsTaxonomyFilters } from "@/components/cms-taxonomy-filters"
|
|
3
|
+
import { cmsConfig, listBlogPosts, listCmsTaxonomy } from "@/lib/core/cms"
|
|
3
4
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
|
-
import { blogPostPath, medusaLocale } from "@/lib/storefront-routes"
|
|
5
|
+
import { blogPostPath, medusaLocale, STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
type PageProps = {
|
|
8
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default async function BlogPage({ searchParams }: PageProps) {
|
|
12
|
+
const [locale, params] = await Promise.all([
|
|
13
|
+
requestStorefrontLocale(),
|
|
14
|
+
searchParams,
|
|
15
|
+
])
|
|
8
16
|
const english = locale === "en"
|
|
9
|
-
const
|
|
17
|
+
const apiLocale = medusaLocale(locale)
|
|
18
|
+
const category = firstParam(params.category)
|
|
19
|
+
const tag = firstParam(params.tag)
|
|
20
|
+
|
|
21
|
+
const [config, taxonomy, content] = await Promise.all([
|
|
22
|
+
cmsConfig().catch(() => null),
|
|
23
|
+
listCmsTaxonomy({ locale: apiLocale }).catch(() => ({ terms: [], count: 0 })),
|
|
24
|
+
listBlogPosts({
|
|
25
|
+
locale: apiLocale,
|
|
26
|
+
category: category || undefined,
|
|
27
|
+
tag: tag || undefined,
|
|
28
|
+
limit: 50,
|
|
29
|
+
}).catch(() => ({ entries: [], count: 0, limit: 50, offset: 0 })),
|
|
30
|
+
])
|
|
31
|
+
|
|
32
|
+
const enabledTaxonomies = new Set(config?.taxonomies || [])
|
|
33
|
+
const terms = taxonomy.terms.filter((term) => enabledTaxonomies.has(term.taxonomy))
|
|
34
|
+
const basePath = STOREFRONT_ROUTES[locale].blog
|
|
10
35
|
|
|
11
36
|
return (
|
|
12
37
|
<div className="stack page-section">
|
|
@@ -15,11 +40,24 @@ export default async function BlogPage() {
|
|
|
15
40
|
<h1>{english ? "Blog" : "Blog"}</h1>
|
|
16
41
|
<p className="muted">{english ? "News, guides and useful content from the store." : "Hírek, útmutatók és hasznos tartalmak a webáruháztól."}</p>
|
|
17
42
|
</header>
|
|
18
|
-
|
|
43
|
+
|
|
44
|
+
<CmsTaxonomyFilters
|
|
45
|
+
basePath={basePath}
|
|
46
|
+
terms={terms}
|
|
47
|
+
locale={locale}
|
|
48
|
+
activeCategory={category || undefined}
|
|
49
|
+
activeTag={tag || undefined}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
{content.entries.length ? (
|
|
19
53
|
<div className="cms-grid">
|
|
20
|
-
{entries.map((entry) => <CmsEntryCard key={entry.id} entry={entry} href={blogPostPath(locale, entry.slug)} locale={locale} />)}
|
|
54
|
+
{content.entries.map((entry) => <CmsEntryCard key={entry.id} entry={entry} href={blogPostPath(locale, entry.slug)} locale={locale} />)}
|
|
21
55
|
</div>
|
|
22
|
-
) : <div className="empty-state">{english ? "No published articles
|
|
56
|
+
) : <div className="empty-state">{english ? "No published articles match these filters." : "A kiválasztott szűrőkkel nincs publikált bejegyzés."}</div>}
|
|
23
57
|
</div>
|
|
24
58
|
)
|
|
25
59
|
}
|
|
60
|
+
|
|
61
|
+
function firstParam(value: string | string[] | undefined) {
|
|
62
|
+
return (Array.isArray(value) ? value[0] : value || "").trim()
|
|
63
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CartShareButton } from "@/components/cart-share-button"
|
|
1
2
|
import { CartView } from "@/components/cart-view"
|
|
2
3
|
import { getCoreConfig } from "@/lib/core/client"
|
|
3
4
|
|
|
@@ -7,6 +8,7 @@ export default async function CartPage() {
|
|
|
7
8
|
<div className="stack page-section narrow-page">
|
|
8
9
|
<div className="page-heading"><div><p className="eyebrow">Kosár</p><h1>A kosarad</h1><p className="muted">A végösszeg, kedvezmény és adó minden frissítés után közvetlenül a Medusa cartból érkezik.</p></div></div>
|
|
9
10
|
<section className="panel"><CartView config={config} /></section>
|
|
11
|
+
<CartShareButton config={config} />
|
|
10
12
|
</div>
|
|
11
13
|
)
|
|
12
14
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SharedCartView } from "@/components/shared-cart-view"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
3
|
+
|
|
4
|
+
export default async function SharedCartPage({
|
|
5
|
+
params,
|
|
6
|
+
}: {
|
|
7
|
+
params: Promise<{ token: string }>
|
|
8
|
+
}) {
|
|
9
|
+
const [{ token }, config] = await Promise.all([params, getCoreConfig()])
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className="stack page-section narrow-page">
|
|
13
|
+
<div className="page-heading">
|
|
14
|
+
<div>
|
|
15
|
+
<p className="eyebrow">Kosármegosztás</p>
|
|
16
|
+
<h1>Megosztott kosár</h1>
|
|
17
|
+
<p className="muted">Nézd át az aktuális árakat és készletet, majd töltsd be a kosaradba.</p>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<section className="panel">
|
|
21
|
+
<SharedCartView token={token} config={config} />
|
|
22
|
+
</section>
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
|
-
import {
|
|
2
|
+
import { CmsTaxonomyFilters } from "@/components/cms-taxonomy-filters"
|
|
3
|
+
import { cmsConfig, listCmsTaxonomy, listKnowledgeBaseEntries } from "@/lib/core/cms"
|
|
3
4
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
|
-
import { knowledgeBasePath, medusaLocale } from "@/lib/storefront-routes"
|
|
5
|
+
import { knowledgeBasePath, medusaLocale, STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
type PageProps = {
|
|
8
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default async function KnowledgeBasePage({ searchParams }: PageProps) {
|
|
12
|
+
const [locale, params] = await Promise.all([
|
|
13
|
+
requestStorefrontLocale(),
|
|
14
|
+
searchParams,
|
|
15
|
+
])
|
|
8
16
|
const english = locale === "en"
|
|
9
|
-
const
|
|
17
|
+
const apiLocale = medusaLocale(locale)
|
|
18
|
+
const category = firstParam(params.category)
|
|
19
|
+
const tag = firstParam(params.tag)
|
|
20
|
+
|
|
21
|
+
const [config, taxonomy, content] = await Promise.all([
|
|
22
|
+
cmsConfig().catch(() => null),
|
|
23
|
+
listCmsTaxonomy({ locale: apiLocale }).catch(() => ({ terms: [], count: 0 })),
|
|
24
|
+
listKnowledgeBaseEntries({
|
|
25
|
+
locale: apiLocale,
|
|
26
|
+
category: category || undefined,
|
|
27
|
+
tag: tag || undefined,
|
|
28
|
+
limit: 100,
|
|
29
|
+
}).catch(() => ({ entries: [], count: 0, limit: 100, offset: 0 })),
|
|
30
|
+
])
|
|
31
|
+
|
|
32
|
+
const enabledTaxonomies = new Set(config?.taxonomies || [])
|
|
33
|
+
const terms = taxonomy.terms.filter((term) => enabledTaxonomies.has(term.taxonomy))
|
|
34
|
+
const basePath = STOREFRONT_ROUTES[locale].knowledgeBase
|
|
10
35
|
|
|
11
36
|
return (
|
|
12
37
|
<div className="stack page-section">
|
|
@@ -15,11 +40,24 @@ export default async function KnowledgeBasePage() {
|
|
|
15
40
|
<h1>{english ? "Knowledge base" : "Tudástár"}</h1>
|
|
16
41
|
<p className="muted">{english ? "Answers, guides and practical information." : "Válaszok, útmutatók és gyakorlati információk."}</p>
|
|
17
42
|
</header>
|
|
18
|
-
|
|
43
|
+
|
|
44
|
+
<CmsTaxonomyFilters
|
|
45
|
+
basePath={basePath}
|
|
46
|
+
terms={terms}
|
|
47
|
+
locale={locale}
|
|
48
|
+
activeCategory={category || undefined}
|
|
49
|
+
activeTag={tag || undefined}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
{content.entries.length ? (
|
|
19
53
|
<div className="cms-grid">
|
|
20
|
-
{entries.map((entry) => <CmsEntryCard key={entry.id} entry={entry} href={knowledgeBasePath(locale, entry.slug)} locale={locale} />)}
|
|
54
|
+
{content.entries.map((entry) => <CmsEntryCard key={entry.id} entry={entry} href={knowledgeBasePath(locale, entry.slug)} locale={locale} />)}
|
|
21
55
|
</div>
|
|
22
|
-
) : <div className="empty-state">{english ? "No knowledge-base entries
|
|
56
|
+
) : <div className="empty-state">{english ? "No knowledge-base entries match these filters." : "A kiválasztott szűrőkkel nincs tudástár-bejegyzés."}</div>}
|
|
23
57
|
</div>
|
|
24
58
|
)
|
|
25
59
|
}
|
|
60
|
+
|
|
61
|
+
function firstParam(value: string | string[] | undefined) {
|
|
62
|
+
return (Array.isArray(value) ? value[0] : value || "").trim()
|
|
63
|
+
}
|
|
@@ -7,6 +7,7 @@ import { AccessibilityPreferencesControl, AccessibilityPreferencesProvider } fro
|
|
|
7
7
|
import { AnalyticsGate } from "@/components/analytics"
|
|
8
8
|
import { CartProvider } from "@/components/cart-provider"
|
|
9
9
|
import { ConsentBanner } from "@/components/consent-banner"
|
|
10
|
+
import { CustomerCartResumeGate } from "@/components/customer-cart-resume-gate"
|
|
10
11
|
import { NewsletterSignup } from "@/components/newsletter-signup"
|
|
11
12
|
import { StorefrontHeader } from "@/components/storefront-header"
|
|
12
13
|
import { ToastProvider } from "@/components/toast-provider"
|
|
@@ -61,6 +62,7 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
61
62
|
{en ? "Skip to content" : "Ugrás a tartalomhoz"}
|
|
62
63
|
</a>
|
|
63
64
|
<StorefrontHeader config={config} />
|
|
65
|
+
<CustomerCartResumeGate config={config} />
|
|
64
66
|
<main id="main-content" className="shell main" tabIndex={-1}>{children}</main>
|
|
65
67
|
<footer className="footer">
|
|
66
68
|
<div className="shell footer-newsletter-shell">
|
|
@@ -75,6 +77,7 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
75
77
|
<Link href={routes.products}>{en ? "Products" : "Termékek"}</Link>
|
|
76
78
|
<Link href={routes.blog}>{en ? "Blog" : "Blog"}</Link>
|
|
77
79
|
<Link href={routes.knowledgeBase}>{en ? "Knowledge base" : "Tudástár"}</Link>
|
|
80
|
+
<Link href={routes.cmsPages}>{en ? "Pages" : "Oldalak"}</Link>
|
|
78
81
|
<Link href={routes.quoteRequest}>{en ? "Request a quote" : "Ajánlatkérés"}</Link>
|
|
79
82
|
<Link href={routes.contact}>{en ? "Contact" : "Kapcsolat"}</Link>
|
|
80
83
|
<Link href={routes.account}>{en ? "Account" : "Fiókom"}</Link>
|
|
@@ -83,8 +86,8 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
83
86
|
<AccessibilityPreferencesControl locale={locale} />
|
|
84
87
|
</div>
|
|
85
88
|
</footer>
|
|
86
|
-
<AnalyticsGate analytics={config.analytics} />
|
|
87
|
-
<ConsentBanner enabled={config.features.analytics} />
|
|
89
|
+
<AnalyticsGate analytics={config.analytics} googleAds={config.marketing.google_ads} />
|
|
90
|
+
<ConsentBanner enabled={config.features.analytics || config.features.google_ads} />
|
|
88
91
|
</CartProvider>
|
|
89
92
|
</ToastProvider>
|
|
90
93
|
</AccessibilityPreferencesProvider>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { FogyasztobaratEmbed } from "@/components/fogyasztobarat-embed"
|
|
1
2
|
import { getCoreConfig } from "@/lib/core/client"
|
|
2
|
-
import { listLegalDocuments } from "@/lib/core/legal"
|
|
3
|
+
import { getLegalEmbed, listLegalDocuments } from "@/lib/core/legal"
|
|
3
4
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
4
5
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
5
6
|
|
|
@@ -9,13 +10,28 @@ export default async function LegalPage() {
|
|
|
9
10
|
requestStorefrontLocale(),
|
|
10
11
|
])
|
|
11
12
|
const copy = storefrontCopy(locale)
|
|
12
|
-
const { documents } = await
|
|
13
|
+
const [{ documents }, embed] = await Promise.all([
|
|
14
|
+
listLegalDocuments(config),
|
|
15
|
+
getLegalEmbed().catch(() => ({ enabled: false })),
|
|
16
|
+
])
|
|
17
|
+
const en = locale === "en"
|
|
13
18
|
|
|
14
19
|
return (
|
|
15
20
|
<div className="stack page-section">
|
|
16
21
|
<div className="page-heading">
|
|
17
22
|
<div><p className="eyebrow">{copy.legalEyebrow}</p><h1>{copy.legalTitle}</h1><p className="muted">{copy.legalDescription}</p></div>
|
|
18
23
|
</div>
|
|
24
|
+
|
|
25
|
+
{embed.enabled ? (
|
|
26
|
+
<section className="panel stack-sm">
|
|
27
|
+
<div>
|
|
28
|
+
<p className="eyebrow">{en ? "Consumer information" : "Fogyasztói tájékoztatás"}</p>
|
|
29
|
+
<h2>{en ? "Fogyasztó Barát information" : "Fogyasztó Barát tájékoztató"}</h2>
|
|
30
|
+
</div>
|
|
31
|
+
<FogyasztobaratEmbed embed={embed} />
|
|
32
|
+
</section>
|
|
33
|
+
) : null}
|
|
34
|
+
|
|
19
35
|
{documents.length ? (
|
|
20
36
|
<div className="product-grid">
|
|
21
37
|
{documents.map((document) => (
|
|
@@ -2,7 +2,12 @@ import Link from "next/link"
|
|
|
2
2
|
import { ProductCard } from "@/components/product-card"
|
|
3
3
|
import { getCoreConfig } from "@/lib/core/client"
|
|
4
4
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getProductById,
|
|
7
|
+
listCategories,
|
|
8
|
+
listFeaturedProducts,
|
|
9
|
+
listProducts,
|
|
10
|
+
} from "@/lib/core/catalog"
|
|
6
11
|
import { stringValue } from "@/lib/core/commerce"
|
|
7
12
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
8
13
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
@@ -15,10 +20,28 @@ export default async function HomePage() {
|
|
|
15
20
|
const apiLocale = medusaLocale(locale)
|
|
16
21
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
17
22
|
const regionId = region ? stringValue(region.id) : undefined
|
|
18
|
-
const [
|
|
19
|
-
|
|
23
|
+
const [featuredResult, { product_categories: categories }] = await Promise.all([
|
|
24
|
+
listFeaturedProducts(8, apiLocale).catch(() => ({ products: [], count: 0, limit: 8 })),
|
|
20
25
|
listCategories(apiLocale).catch(() => ({ product_categories: [] })),
|
|
21
26
|
])
|
|
27
|
+
|
|
28
|
+
const featuredProducts = (
|
|
29
|
+
await Promise.all(
|
|
30
|
+
featuredResult.products.map((featured) =>
|
|
31
|
+
getProductById(featured.id, regionId, apiLocale)
|
|
32
|
+
.then((result) => result.product)
|
|
33
|
+
.catch(() => null),
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
).filter((product): product is Record<string, unknown> => Boolean(product))
|
|
37
|
+
|
|
38
|
+
const fallbackProducts = featuredProducts.length
|
|
39
|
+
? []
|
|
40
|
+
: await listProducts({ limit: 8, order: "-created_at", regionId, locale: apiLocale })
|
|
41
|
+
.then((result) => result.products)
|
|
42
|
+
.catch(() => [])
|
|
43
|
+
const products = featuredProducts.length ? featuredProducts : fallbackProducts
|
|
44
|
+
const showingFeatured = featuredProducts.length > 0
|
|
22
45
|
const routes = STOREFRONT_ROUTES[locale]
|
|
23
46
|
|
|
24
47
|
return (
|
|
@@ -45,7 +68,13 @@ export default async function HomePage() {
|
|
|
45
68
|
) : null}
|
|
46
69
|
|
|
47
70
|
<section className="stack-sm">
|
|
48
|
-
<div className="section-heading"
|
|
71
|
+
<div className="section-heading">
|
|
72
|
+
<div>
|
|
73
|
+
<p className="eyebrow">{showingFeatured ? (locale === "en" ? "Featured" : "Kiemelt") : copy.newProducts}</p>
|
|
74
|
+
<h2>{showingFeatured ? (locale === "en" ? "Featured products" : "Kiemelt termékek") : copy.latestProducts}</h2>
|
|
75
|
+
</div>
|
|
76
|
+
<Link className="text-link" href={routes.products}>{copy.fullCatalog}</Link>
|
|
77
|
+
</div>
|
|
49
78
|
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard key={stringValue(product.id)} product={product} config={config} locale={locale} />)}</div> : <div className="empty-state">{copy.noPublishedProducts}</div>}
|
|
50
79
|
</section>
|
|
51
80
|
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
|
+
import { listCmsPages } from "@/lib/core/cms"
|
|
3
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
|
+
import { cmsPagePath, medusaLocale } from "@/lib/storefront-routes"
|
|
5
|
+
|
|
6
|
+
export default async function CmsPagesIndex() {
|
|
7
|
+
const locale = await requestStorefrontLocale()
|
|
8
|
+
const english = locale === "en"
|
|
9
|
+
const { entries } = await listCmsPages({
|
|
10
|
+
locale: medusaLocale(locale),
|
|
11
|
+
limit: 100,
|
|
12
|
+
}).catch(() => ({ entries: [], count: 0, limit: 100, offset: 0 }))
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="stack page-section">
|
|
16
|
+
<header className="stack-sm">
|
|
17
|
+
<p className="eyebrow">{english ? "Information" : "Információ"}</p>
|
|
18
|
+
<h1>{english ? "Pages" : "Oldalak"}</h1>
|
|
19
|
+
<p className="muted">
|
|
20
|
+
{english
|
|
21
|
+
? "Published informational pages managed by the Core CMS."
|
|
22
|
+
: "A Core CMS-ben kezelt, publikált tájékoztató oldalak."}
|
|
23
|
+
</p>
|
|
24
|
+
</header>
|
|
25
|
+
{entries.length ? (
|
|
26
|
+
<div className="cms-grid">
|
|
27
|
+
{entries.map((entry) => (
|
|
28
|
+
<CmsEntryCard
|
|
29
|
+
key={entry.id}
|
|
30
|
+
entry={entry}
|
|
31
|
+
href={cmsPagePath(locale, entry.slug)}
|
|
32
|
+
locale={locale}
|
|
33
|
+
/>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
) : (
|
|
37
|
+
<div className="empty-state">
|
|
38
|
+
{english ? "No published pages yet." : "Még nincs publikált oldal."}
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { useMemo, useState } from "react"
|
|
3
|
+
import { useEffect, useMemo, useState } from "react"
|
|
4
4
|
import { usePathname } from "next/navigation"
|
|
5
5
|
import { QuantityStepper } from "./quantity-stepper"
|
|
6
|
+
import { TierProgressHint } from "./tier-progress-hint"
|
|
6
7
|
import { useToast } from "./toast-provider"
|
|
7
8
|
import { useCart } from "./cart-provider"
|
|
8
9
|
import { subscribeBackInStock } from "@/lib/core/back-in-stock"
|
|
@@ -15,11 +16,26 @@ import {
|
|
|
15
16
|
stringValue,
|
|
16
17
|
} from "@/lib/core/commerce"
|
|
17
18
|
import { humanizeStorefrontError } from "@/lib/core/form-ux"
|
|
19
|
+
import {
|
|
20
|
+
findPricingTierForQuantity,
|
|
21
|
+
formatPricingAmount,
|
|
22
|
+
formatPricingTierRange,
|
|
23
|
+
getVariantPricingTiers,
|
|
24
|
+
type VariantPricingTiers,
|
|
25
|
+
} from "@/lib/core/pricing"
|
|
18
26
|
import { copyText } from "@/lib/core/share"
|
|
19
27
|
import type { CoreConfig } from "@/lib/core/types"
|
|
20
28
|
import { localeFromPathname } from "@/lib/storefront-routes"
|
|
21
29
|
|
|
22
|
-
export function AddToCart({
|
|
30
|
+
export function AddToCart({
|
|
31
|
+
product,
|
|
32
|
+
config,
|
|
33
|
+
regionId,
|
|
34
|
+
}: {
|
|
35
|
+
product: Record<string, unknown>
|
|
36
|
+
config: CoreConfig
|
|
37
|
+
regionId?: string
|
|
38
|
+
}) {
|
|
23
39
|
const pathname = usePathname()
|
|
24
40
|
const locale = localeFromPathname(pathname)
|
|
25
41
|
const en = locale === "en"
|
|
@@ -27,6 +43,7 @@ export function AddToCart({ product, config }: { product: Record<string, unknown
|
|
|
27
43
|
const productMetadata = isRecord(product.metadata) ? product.metadata : {}
|
|
28
44
|
const [variantId, setVariantId] = useState(() => stringValue(variants[0]?.id))
|
|
29
45
|
const [quantity, setQuantity] = useState(() => variantMinimum(variants[0], productMetadata))
|
|
46
|
+
const [pricing, setPricing] = useState<VariantPricingTiers | null>(null)
|
|
30
47
|
const [message, setMessage] = useState<string | null>(null)
|
|
31
48
|
const [success, setSuccess] = useState(false)
|
|
32
49
|
const [alertEmail, setAlertEmail] = useState("")
|
|
@@ -49,6 +66,31 @@ export function AddToCart({ product, config }: { product: Record<string, unknown
|
|
|
49
66
|
? Math.max(1, Math.trunc(inventory))
|
|
50
67
|
: 999
|
|
51
68
|
const sku = stringValue(selected?.sku)
|
|
69
|
+
const currentTier = pricing?.has_tiered_pricing
|
|
70
|
+
? findPricingTierForQuantity(pricing.tiers, quantity)
|
|
71
|
+
: null
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
let active = true
|
|
75
|
+
if (!variantId) {
|
|
76
|
+
setPricing(null)
|
|
77
|
+
return () => { active = false }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setPricing(null)
|
|
81
|
+
void getVariantPricingTiers(variantId, {
|
|
82
|
+
regionId,
|
|
83
|
+
currencyCode: currency,
|
|
84
|
+
})
|
|
85
|
+
.then((result) => {
|
|
86
|
+
if (active) setPricing(result)
|
|
87
|
+
})
|
|
88
|
+
.catch(() => {
|
|
89
|
+
if (active) setPricing(null)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return () => { active = false }
|
|
93
|
+
}, [currency, regionId, variantId])
|
|
52
94
|
|
|
53
95
|
if (!variants.length) {
|
|
54
96
|
return <div className="notice warning" role="status">{en ? "This product has no purchasable variant." : "Ehhez a termékhez nincs megvásárolható variáns."}</div>
|
|
@@ -116,6 +158,38 @@ export function AddToCart({ product, config }: { product: Record<string, unknown
|
|
|
116
158
|
</div>
|
|
117
159
|
</div>
|
|
118
160
|
|
|
161
|
+
{pricing?.has_tiered_pricing && pricing.tiers.length ? (
|
|
162
|
+
<div className="notice stack-sm" aria-label={en ? "Quantity pricing" : "Mennyiségi ársávok"}>
|
|
163
|
+
<div>
|
|
164
|
+
<strong>{en ? "Quantity pricing" : "Mennyiségi ársávok"}</strong>
|
|
165
|
+
<p className="muted small">
|
|
166
|
+
{en
|
|
167
|
+
? "The Core returns the unit prices calculated by Medusa for your current customer context."
|
|
168
|
+
: "A Core a Medusa által, az aktuális vásárlói kontextusra kiszámolt egységárakat jeleníti meg."}
|
|
169
|
+
</p>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="stack-sm">
|
|
172
|
+
{pricing.tiers.map((tier) => {
|
|
173
|
+
const active = currentTier === tier
|
|
174
|
+
return (
|
|
175
|
+
<div className="info-row" key={`${tier.min_quantity}:${tier.max_quantity ?? "max"}`}>
|
|
176
|
+
<span>{formatPricingTierRange(tier)} {en ? "pcs" : "db"}</span>
|
|
177
|
+
<strong>{formatPricingAmount(tier.unit_amount, tier.currency_code, formatLocale)}{active ? (en ? " · current" : " · aktuális") : ""}</strong>
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
})}
|
|
181
|
+
</div>
|
|
182
|
+
<TierProgressHint
|
|
183
|
+
quantity={quantity}
|
|
184
|
+
tiers={pricing.tiers.map((tier) => ({
|
|
185
|
+
minQuantity: tier.min_quantity,
|
|
186
|
+
unitPrice: tier.unit_amount,
|
|
187
|
+
}))}
|
|
188
|
+
locale={locale}
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
) : null}
|
|
192
|
+
|
|
119
193
|
<div className={`stock-status ${purchasable ? "is-available" : "is-unavailable"}`} role="status">
|
|
120
194
|
{purchasable
|
|
121
195
|
? hasKnownInventory && managesInventory
|