@hszrdm/create-commerce 1.0.2 → 1.1.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/bin/create-commerce.mjs +9 -2
- package/package.json +1 -1
- package/src/cli.mjs +2 -2
- package/templates/backend/.env.example +66 -7
- package/templates/backend/medusa-config.ts +17 -1
- package/templates/backend/package.json +2 -1
- package/templates/backend/src/scripts/core-init.ts +13 -1
- package/templates/storefront/next-env.d.ts +4 -1
- package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +9 -3
- package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +9 -5
- package/templates/storefront/src/app/[countryCode]/products/page.tsx +17 -10
- package/templates/storefront/src/app/checkout/page.tsx +12 -3
- package/templates/storefront/src/app/checkout/success/page.tsx +58 -18
- package/templates/storefront/src/app/layout.tsx +10 -3
- package/templates/storefront/src/app/legal/page.tsx +11 -5
- package/templates/storefront/src/app/page.tsx +18 -12
- package/templates/storefront/src/app/reset-password/page.tsx +8 -2
- package/templates/storefront/src/components/account-dashboard.tsx +197 -76
- package/templates/storefront/src/components/add-to-cart.tsx +24 -10
- package/templates/storefront/src/components/cart-provider.tsx +29 -12
- package/templates/storefront/src/components/cart-view.tsx +28 -20
- package/templates/storefront/src/components/checkout-analytics.tsx +23 -0
- package/templates/storefront/src/components/checkout-flow.tsx +354 -102
- package/templates/storefront/src/components/order-detail.tsx +84 -45
- package/templates/storefront/src/components/product-card.tsx +16 -8
- package/templates/storefront/src/components/reset-password-form.tsx +19 -13
- package/templates/storefront/src/components/storefront-header.tsx +25 -11
- package/templates/storefront/src/components/stripe-payment.tsx +20 -4
- package/templates/storefront/src/lib/core/catalog.ts +37 -5
- package/templates/storefront/src/lib/core/client.ts +5 -0
- package/templates/storefront/src/lib/core/cms.ts +112 -0
- package/templates/storefront/src/lib/core/commerce.ts +14 -4
- package/templates/storefront/src/lib/core/leads.ts +50 -0
- package/templates/storefront/src/lib/core/pricing.ts +68 -0
- package/templates/storefront/src/lib/core/quotes.ts +43 -0
- package/templates/storefront/src/lib/core/seo.ts +44 -6
- package/templates/storefront/src/lib/storefront-copy.ts +435 -0
- package/templates/storefront/src/lib/storefront-locale-server.ts +11 -0
- package/templates/storefront/src/lib/storefront-routes.ts +91 -0
- package/templates/storefront/src/proxy.ts +142 -0
- package/templates/storefront/tsconfig.json +23 -5
package/bin/create-commerce.mjs
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { existsSync, statfsSync } from "node:fs"
|
|
4
|
-
import { dirname, resolve } from "node:path"
|
|
3
|
+
import { existsSync, readFileSync, statfsSync } from "node:fs"
|
|
4
|
+
import { dirname, join, resolve } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
5
6
|
import { main } from "../src/cli.mjs"
|
|
6
7
|
|
|
8
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
|
|
9
|
+
const packageVersion = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")).version
|
|
7
10
|
const argv = process.argv.slice(2)
|
|
8
11
|
|
|
12
|
+
if (!argv.some((arg) => arg === "--core-version" || arg.startsWith("--core-version="))) {
|
|
13
|
+
argv.push("--core-version", packageVersion)
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
try {
|
|
10
17
|
ensureFreeDiskSpace(argv)
|
|
11
18
|
await main(argv)
|
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -191,7 +191,7 @@ async function collectSettings(projectName, flags) {
|
|
|
191
191
|
cookieSecret: secret(48),
|
|
192
192
|
integrationEncryptionKey: secret(48),
|
|
193
193
|
shippingWebhookSecret: secret(48),
|
|
194
|
-
coreVersion: clean(flags["core-version"] || "1.0.
|
|
194
|
+
coreVersion: clean(flags["core-version"] || "1.0.3"),
|
|
195
195
|
}
|
|
196
196
|
} finally {
|
|
197
197
|
rl?.close()
|
|
@@ -582,5 +582,5 @@ function bool(value) {
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
function printHelp() {
|
|
585
|
-
console.log(`HSZRDM Commerce project generator\n\nHasználat:\n npx @hszrdm/create-commerce <project-name> [opciók]\n\nFő opciók:\n --name <név>\n --slug <slug>\n --locale hu-HU\n --country HU\n --currency HUF\n --backend-url http://localhost:9000\n --storefront-url http://localhost:3000\n --admin-email <email>\n --admin-password <password>\n --database-url postgres://...\n --redis-url redis://...\n --postgres-port <port>\n --redis-port <port>\n --core-version 1.0.
|
|
585
|
+
console.log(`HSZRDM Commerce project generator\n\nHasználat:\n npx @hszrdm/create-commerce <project-name> [opciók]\n\nFő opciók:\n --name <név>\n --slug <slug>\n --locale hu-HU\n --country HU\n --currency HUF\n --backend-url http://localhost:9000\n --storefront-url http://localhost:3000\n --admin-email <email>\n --admin-password <password>\n --database-url postgres://...\n --redis-url redis://...\n --postgres-port <port>\n --redis-port <port>\n --core-version 1.0.3\n --non-interactive\n --force\n\nInfrastruktúra:\n Ha --database-url és --redis-url meg van adva, a generátor Dockert nem használ.\n Ha nincsenek megadva, Docker Compose a fallback.\n\nFejlesztői kapcsolók:\n --skip-install\n --skip-docker\n --skip-bootstrap\n --skip-verify\n --skip-git\n\nLokális Core package teszthez:\n HSZRDM_CORE_PACKAGE=/abs/path/to/packages/core npx @hszrdm/create-commerce test-shop\n`)
|
|
586
586
|
}
|
|
@@ -49,8 +49,12 @@ SHIPPING_WEBHOOK_SECRET=
|
|
|
49
49
|
# -----------------------------------------------------------------------------
|
|
50
50
|
STORE_NAME=Example Store
|
|
51
51
|
STORE_SLUG=example-store
|
|
52
|
+
# Medusa content locale. Native Translation Module is enabled by HSZRDM Core.
|
|
52
53
|
STORE_LOCALE=hu-HU
|
|
54
|
+
# Comma-separated Store locales provisioned by `core:init`.
|
|
55
|
+
STORE_SUPPORTED_LOCALES=hu-HU,en-US
|
|
53
56
|
STORE_DEFAULT_CURRENCY=HUF
|
|
57
|
+
# Commercial country/region context. This is intentionally separate from locale.
|
|
54
58
|
STORE_DEFAULT_COUNTRY=HU
|
|
55
59
|
# Direct/reference admin customization fallback.
|
|
56
60
|
VITE_ADMIN_BRAND_NAME=HSZRDM Commerce
|
|
@@ -78,30 +82,85 @@ AFTER_SALES_CLAIMS_ENABLED=true
|
|
|
78
82
|
AFTER_SALES_POLICY_URL=
|
|
79
83
|
AFTER_SALES_RETURN_INSTRUCTIONS=
|
|
80
84
|
|
|
85
|
+
# -----------------------------------------------------------------------------
|
|
86
|
+
# RFQ / quote requests
|
|
87
|
+
# -----------------------------------------------------------------------------
|
|
88
|
+
# Generic B2B / custom-product quote layer. The storefront may build any design
|
|
89
|
+
# on top of /store/quote-requests and /store/quote-requests/config.
|
|
90
|
+
QUOTE_REQUESTS_ENABLED=true
|
|
91
|
+
QUOTE_EMAIL_ENABLED=true
|
|
92
|
+
# One or more merchant recipients, separated with comma or semicolon.
|
|
93
|
+
QUOTE_ADMIN_EMAILS=
|
|
94
|
+
# Optional JSON array of additional fields exposed by the Core quote config.
|
|
95
|
+
# Supported types: text, textarea, number, boolean, select.
|
|
96
|
+
# Example:
|
|
97
|
+
# QUOTE_EXTRA_FIELDS_JSON=[{"key":"delivery_deadline","label":"Kért szállítási határidő","type":"text","required":false},{"key":"industry","label":"Iparág","type":"select","required":false,"options":["Élelmiszer","Ipar","Kereskedelem"]}]
|
|
98
|
+
QUOTE_EXTRA_FIELDS_JSON=
|
|
99
|
+
|
|
100
|
+
# -----------------------------------------------------------------------------
|
|
101
|
+
# Lead / web form backend
|
|
102
|
+
# -----------------------------------------------------------------------------
|
|
103
|
+
# Generic backend for contact, callback, B2B lead and project-specific forms.
|
|
104
|
+
LEADS_ENABLED=true
|
|
105
|
+
LEAD_EMAIL_ENABLED=true
|
|
106
|
+
LEAD_CUSTOMER_EMAIL_ENABLED=false
|
|
107
|
+
LEAD_ADMIN_EMAILS=
|
|
108
|
+
LEAD_HONEYPOT_FIELD=website
|
|
109
|
+
LEAD_RATE_LIMIT_MAX=8
|
|
110
|
+
LEAD_RATE_LIMIT_WINDOW_SECONDS=600
|
|
111
|
+
# Optional dedicated HMAC secret for anonymized request fingerprints. If empty,
|
|
112
|
+
# COOKIE_SECRET is used. Raw IP addresses are never persisted by the lead module.
|
|
113
|
+
LEAD_SPAM_HASH_SECRET=
|
|
114
|
+
# Optional Cloudflare Turnstile. Both values are required to enable it.
|
|
115
|
+
LEAD_TURNSTILE_SITE_KEY=
|
|
116
|
+
LEAD_TURNSTILE_SECRET_KEY=
|
|
117
|
+
LEAD_PRIVACY_POLICY_VERSION=1
|
|
118
|
+
LEAD_PRIVACY_POLICY_URL=
|
|
119
|
+
LEAD_PRIVACY_POLICY_LABEL=Elfogadom az adatkezelési tájékoztatót.
|
|
120
|
+
# Optional JSON array defining one or more forms and custom fields.
|
|
121
|
+
# Empty = built-in `contact` form with name, email and message required.
|
|
122
|
+
LEAD_FORMS_JSON=
|
|
123
|
+
|
|
124
|
+
# -----------------------------------------------------------------------------
|
|
125
|
+
# CMS / blog engine
|
|
126
|
+
# -----------------------------------------------------------------------------
|
|
127
|
+
# Generic content engine for blog posts, pages, guides, news and custom types.
|
|
128
|
+
CMS_ENABLED=true
|
|
129
|
+
# Empty = STORE_LOCALE, then hu-HU fallback.
|
|
130
|
+
CMS_DEFAULT_LOCALE=
|
|
131
|
+
# Optional JSON array of content types shown to storefront/admin integrations.
|
|
132
|
+
# Content entries still store a free-form content_type, so projects can add
|
|
133
|
+
# project-specific types without changing the Core schema.
|
|
134
|
+
# Example:
|
|
135
|
+
# CMS_CONTENT_TYPES_JSON=[{"key":"blog_post","label":"Blogbejegyzés"},{"key":"page","label":"Oldal"},{"key":"guide","label":"Tudástár"}]
|
|
136
|
+
CMS_CONTENT_TYPES_JSON=
|
|
137
|
+
|
|
81
138
|
# -----------------------------------------------------------------------------
|
|
82
139
|
# Technical SEO - optional overrides
|
|
83
140
|
# -----------------------------------------------------------------------------
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
# value intentionally differs from the store default.
|
|
141
|
+
# Country remains the commercial region country. Locale controls public language
|
|
142
|
+
# and localized URL segments independently.
|
|
87
143
|
SEO_STOREFRONT_URL=
|
|
88
144
|
SEO_STORE_NAME=
|
|
89
145
|
SEO_ORGANIZATION_NAME=
|
|
90
146
|
SEO_ORGANIZATION_LOGO_URL=
|
|
91
147
|
SEO_DEFAULT_COUNTRY=
|
|
92
148
|
SEO_DEFAULT_CURRENCY=
|
|
149
|
+
SEO_DEFAULT_LOCALE=hu
|
|
150
|
+
SEO_SUPPORTED_LOCALES=hu,en
|
|
93
151
|
|
|
94
152
|
# Optional explicit Medusa region / sales channel for Product Offer JSON-LD.
|
|
95
153
|
SEO_REGION_ID=
|
|
96
154
|
SEO_SALES_CHANNEL_ID=
|
|
97
155
|
|
|
98
|
-
|
|
99
|
-
|
|
156
|
+
# Defaults generate /hu/termekek/... and /en/products/... from the same template.
|
|
157
|
+
SEO_PRODUCT_PATH_TEMPLATE=/{locale}/{products_segment}/{handle}
|
|
158
|
+
SEO_CATEGORY_PATH_TEMPLATE=/{locale}/{categories_segment}/{handle}
|
|
100
159
|
|
|
101
160
|
# Empty = enabled only in NODE_ENV=production. Set explicitly only when needed.
|
|
102
161
|
SEO_ALLOW_INDEXING=
|
|
103
|
-
# Extra comma-separated Disallow paths. Core defaults already include
|
|
104
|
-
#
|
|
162
|
+
# Extra comma-separated Disallow paths. Core defaults already include both HU and
|
|
163
|
+
# EN account/cart/checkout paths plus the legacy aliases.
|
|
105
164
|
SEO_ROBOTS_DISALLOW=
|
|
106
165
|
|
|
107
166
|
# -----------------------------------------------------------------------------
|
|
@@ -8,4 +8,20 @@ const envFile =
|
|
|
8
8
|
|
|
9
9
|
loadEnv(envFile, process.cwd())
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const baseConfig = createHszrdmCommerceConfig()
|
|
12
|
+
const configuredPlugins = (
|
|
13
|
+
baseConfig as typeof baseConfig & {
|
|
14
|
+
plugins?: Array<{ resolve: string; options?: Record<string, unknown> }>
|
|
15
|
+
}
|
|
16
|
+
).plugins || []
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
...baseConfig,
|
|
20
|
+
plugins: [
|
|
21
|
+
...configuredPlugins,
|
|
22
|
+
{
|
|
23
|
+
resolve: "@medusajs/draft-order",
|
|
24
|
+
options: {},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
}
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"start:prod": "cd .medusa/server && medusa start"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@hszrdm/core": "1.
|
|
20
|
+
"@hszrdm/core": "1.1.0",
|
|
21
21
|
"@medusajs/admin-sdk": "2.21.2",
|
|
22
22
|
"@medusajs/cli": "2.21.2",
|
|
23
|
+
"@medusajs/draft-order": "2.21.2",
|
|
23
24
|
"@medusajs/framework": "2.21.2",
|
|
24
25
|
"@medusajs/medusa": "2.21.2",
|
|
25
26
|
"@medusajs/ui": "4.2.6",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ExecArgs } from "@medusajs/framework/types"
|
|
2
2
|
import coreInit from "@hszrdm/core/scripts/core-init"
|
|
3
|
+
import ensureLocales from "@hszrdm/core/scripts/ensure-locales"
|
|
4
|
+
import ensureShipping from "@hszrdm/core/scripts/ensure-shipping"
|
|
3
5
|
import { normalizeMedusaExecArgs } from "@hszrdm/core/scripts/exec-args"
|
|
4
6
|
|
|
5
7
|
export default async function runCoreInit(params: ExecArgs) {
|
|
6
|
-
|
|
8
|
+
await coreInit({
|
|
7
9
|
...params,
|
|
8
10
|
args: normalizeMedusaExecArgs(params.args || [], {
|
|
9
11
|
boolean: ["yes", "force"],
|
|
@@ -18,4 +20,14 @@ export default async function runCoreInit(params: ExecArgs) {
|
|
|
18
20
|
],
|
|
19
21
|
}),
|
|
20
22
|
})
|
|
23
|
+
|
|
24
|
+
await ensureLocales({
|
|
25
|
+
...params,
|
|
26
|
+
args: [],
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
await ensureShipping({
|
|
30
|
+
...params,
|
|
31
|
+
args: [],
|
|
32
|
+
})
|
|
21
33
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="next" />
|
|
2
2
|
/// <reference types="next/image-types/global" />
|
|
3
|
+
import "./.next/types/routes.d.ts";
|
|
4
|
+
import "./.next/types/root-params.d.ts";
|
|
3
5
|
|
|
4
|
-
// This file
|
|
6
|
+
// NOTE: This file should not be edited
|
|
7
|
+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
@@ -5,6 +5,8 @@ import { checkoutApi } from "@/lib/core/checkout"
|
|
|
5
5
|
import { getCategoryByHandle, listProducts } from "@/lib/core/catalog"
|
|
6
6
|
import { stringValue } from "@/lib/core/commerce"
|
|
7
7
|
import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
|
|
8
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
9
|
+
import { medusaLocale, storefrontLocale } from "@/lib/storefront-routes"
|
|
8
10
|
|
|
9
11
|
export async function generateMetadata({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
|
|
10
12
|
const { handle, countryCode } = await params
|
|
@@ -14,8 +16,11 @@ export async function generateMetadata({ params }: { params: Promise<{ countryCo
|
|
|
14
16
|
|
|
15
17
|
export default async function CategoryPage({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
|
|
16
18
|
const { handle, countryCode } = await params
|
|
19
|
+
const locale = storefrontLocale(countryCode)
|
|
20
|
+
const copy = storefrontCopy(locale)
|
|
21
|
+
const apiLocale = medusaLocale(locale)
|
|
17
22
|
const config = await getCoreConfig()
|
|
18
|
-
const category = await getCategoryByHandle(handle).then((result) => result.product_categories[0]).catch(() => null)
|
|
23
|
+
const category = await getCategoryByHandle(handle, apiLocale).then((result) => result.product_categories[0]).catch(() => null)
|
|
19
24
|
if (!category) notFound()
|
|
20
25
|
const [jsonLd, region] = await Promise.all([
|
|
21
26
|
structuredDataForEntity(config, { type: "category", handle, countryCode }).catch(() => null),
|
|
@@ -25,14 +30,15 @@ export default async function CategoryPage({ params }: { params: Promise<{ count
|
|
|
25
30
|
categoryId: stringValue(category.id),
|
|
26
31
|
order: "-created_at",
|
|
27
32
|
regionId: region ? stringValue(region.id) : undefined,
|
|
33
|
+
locale: apiLocale,
|
|
28
34
|
limit: 48,
|
|
29
35
|
}).then((result) => result.products).catch(() => [])
|
|
30
36
|
|
|
31
37
|
return (
|
|
32
38
|
<div className="stack page-section">
|
|
33
39
|
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
|
|
34
|
-
<div className="page-heading"><div><p className="eyebrow">
|
|
35
|
-
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard config={config} product={product} key={stringValue(product.id)} />)}</div> : <div className="empty-state">
|
|
40
|
+
<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
|
+
{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>}
|
|
36
42
|
</div>
|
|
37
43
|
)
|
|
38
44
|
}
|
|
@@ -7,6 +7,8 @@ import { getProductByHandle } from "@/lib/core/catalog"
|
|
|
7
7
|
import { asRecords, formatMoney, productVariantCurrency, productVariantPrice, stringValue } from "@/lib/core/commerce"
|
|
8
8
|
import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
|
|
9
9
|
import { ecommerceItemFromProduct } from "@/lib/core/tracking"
|
|
10
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
11
|
+
import { medusaLocale, storefrontLocale } from "@/lib/storefront-routes"
|
|
10
12
|
|
|
11
13
|
export async function generateMetadata({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
|
|
12
14
|
const { handle, countryCode } = await params
|
|
@@ -16,9 +18,11 @@ export async function generateMetadata({ params }: { params: Promise<{ countryCo
|
|
|
16
18
|
|
|
17
19
|
export default async function ProductPage({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
|
|
18
20
|
const { handle, countryCode } = await params
|
|
21
|
+
const locale = storefrontLocale(countryCode)
|
|
22
|
+
const copy = storefrontCopy(locale)
|
|
19
23
|
const config = await getCoreConfig()
|
|
20
24
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
21
|
-
const product = await getProductByHandle(handle, region ? stringValue(region.id) : undefined).then((result) => result.products[0]).catch(() => null)
|
|
25
|
+
const product = await getProductByHandle(handle, region ? stringValue(region.id) : undefined, medusaLocale(locale)).then((result) => result.products[0]).catch(() => null)
|
|
22
26
|
if (!product) notFound()
|
|
23
27
|
const jsonLd = await structuredDataForEntity(config, { type: "product", handle, countryCode }).catch(() => null)
|
|
24
28
|
const variants = asRecords(product.variants)
|
|
@@ -35,15 +39,15 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
35
39
|
<ProductViewTracker analytics={config.analytics} item={tracking.item} currency={tracking.currency} value={tracking.value} />
|
|
36
40
|
<div className="product-detail">
|
|
37
41
|
<div className="product-gallery">
|
|
38
|
-
<div className="product-main-image">{thumbnail ? <img src={thumbnail} alt={stringValue(product.title)} /> : <span className="media-placeholder">
|
|
42
|
+
<div className="product-main-image">{thumbnail ? <img src={thumbnail} alt={stringValue(product.title)} /> : <span className="media-placeholder">{copy.noImage}</span>}</div>
|
|
39
43
|
{images.length > 1 ? <div className="thumbnail-row">{images.slice(0, 6).map((image, index) => <img key={`${stringValue(image.id)}:${index}`} src={stringValue(image.url)} alt="" />)}</div> : null}
|
|
40
44
|
</div>
|
|
41
45
|
<section className="product-copy stack">
|
|
42
|
-
<div><p className="eyebrow">
|
|
43
|
-
{Number.isFinite(price) ? <div className="product-price">{formatMoney(price, currency,
|
|
46
|
+
<div><p className="eyebrow">{copy.product}</p><h1>{stringValue(product.title)}</h1></div>
|
|
47
|
+
{Number.isFinite(price) ? <div className="product-price">{formatMoney(price, currency, locale === "en" ? "en-US" : "hu-HU")}</div> : null}
|
|
44
48
|
{product.description ? <p className="product-description">{stringValue(product.description)}</p> : null}
|
|
45
49
|
<AddToCart product={product} config={config} />
|
|
46
|
-
<div className="product-meta">{product.subtitle ? <span>{stringValue(product.subtitle)}</span> : null}{product.material ? <span>
|
|
50
|
+
<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>
|
|
47
51
|
</section>
|
|
48
52
|
</div>
|
|
49
53
|
</div>
|
|
@@ -4,35 +4,42 @@ import { getCoreConfig } from "@/lib/core/client"
|
|
|
4
4
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
5
5
|
import { listCategories, listProducts } from "@/lib/core/catalog"
|
|
6
6
|
import { stringValue } from "@/lib/core/commerce"
|
|
7
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
8
|
+
import { medusaLocale, storefrontLocale } from "@/lib/storefront-routes"
|
|
7
9
|
|
|
8
10
|
type SearchParams = Promise<{ q?: string; category?: string; sort?: string; page?: string }>
|
|
11
|
+
type Params = Promise<{ countryCode: string }>
|
|
9
12
|
const sortMap: Record<string, string> = { newest: "-created_at", oldest: "created_at", name: "title" }
|
|
10
13
|
|
|
11
|
-
export default async function ProductsPage({ searchParams }: { searchParams: SearchParams }) {
|
|
14
|
+
export default async function ProductsPage({ params, searchParams }: { params: Params; searchParams: SearchParams }) {
|
|
12
15
|
const config = await getCoreConfig()
|
|
16
|
+
const { countryCode } = await params
|
|
17
|
+
const locale = storefrontLocale(countryCode)
|
|
18
|
+
const copy = storefrontCopy(locale)
|
|
19
|
+
const apiLocale = medusaLocale(locale)
|
|
13
20
|
const query = await searchParams
|
|
14
21
|
const page = Math.max(1, Number(query.page) || 1)
|
|
15
22
|
const limit = 24
|
|
16
23
|
const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
|
|
17
24
|
const regionId = region ? stringValue(region.id) : undefined
|
|
18
25
|
const [{ products, count = 0 }, categoryResult] = await Promise.all([
|
|
19
|
-
listProducts({ q: query.q, categoryId: query.category, order: sortMap[query.sort || "newest"] || sortMap.newest, regionId, limit, offset: (page - 1) * limit }),
|
|
20
|
-
listCategories().catch(() => ({ product_categories: [] })),
|
|
26
|
+
listProducts({ q: query.q, categoryId: query.category, order: sortMap[query.sort || "newest"] || sortMap.newest, regionId, locale: apiLocale, limit, offset: (page - 1) * limit }),
|
|
27
|
+
listCategories(apiLocale).catch(() => ({ product_categories: [] })),
|
|
21
28
|
])
|
|
22
29
|
const categories = categoryResult.product_categories
|
|
23
30
|
const totalPages = Math.max(1, Math.ceil(count / limit))
|
|
24
31
|
|
|
25
32
|
return (
|
|
26
33
|
<div className="stack page-section">
|
|
27
|
-
<div className="page-heading"><div><p className="eyebrow">
|
|
34
|
+
<div className="page-heading"><div><p className="eyebrow">{copy.catalog}</p><h1>{copy.productsTitle}</h1><p className="muted">{copy.catalogDescription}</p></div></div>
|
|
28
35
|
<form className="catalog-toolbar" method="get">
|
|
29
|
-
<label className="catalog-search">
|
|
30
|
-
<label>
|
|
31
|
-
<label>
|
|
32
|
-
<button className="button" type="submit">
|
|
36
|
+
<label className="catalog-search">{copy.search}<input name="q" defaultValue={query.q || ""} placeholder={copy.searchPlaceholder} /></label>
|
|
37
|
+
<label>{copy.category}<select name="category" defaultValue={query.category || ""}><option value="">{copy.allCategories}</option>{categories.map((category) => <option value={stringValue(category.id)} key={stringValue(category.id)}>{stringValue(category.name)}</option>)}</select></label>
|
|
38
|
+
<label>{copy.sort}<select name="sort" defaultValue={query.sort || "newest"}><option value="newest">{copy.newest}</option><option value="oldest">{copy.oldest}</option><option value="name">{copy.nameAZ}</option></select></label>
|
|
39
|
+
<button className="button" type="submit">{copy.filter}</button>
|
|
33
40
|
</form>
|
|
34
|
-
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard product={product} config={config} key={stringValue(product.id)} />)}</div> : <div className="empty-state"><strong>
|
|
35
|
-
{totalPages > 1 ? <nav className="pagination" aria-label="Oldalak">{page > 1 ? <Link href={pageHref(query, page - 1)}
|
|
41
|
+
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard product={product} config={config} locale={locale} key={stringValue(product.id)} />)}</div> : <div className="empty-state"><strong>{copy.noResults}</strong><span className="muted">{copy.modifySearch}</span></div>}
|
|
42
|
+
{totalPages > 1 ? <nav className="pagination" aria-label={locale === "en" ? "Pages" : "Oldalak"}>{page > 1 ? <Link href={pageHref(query, page - 1)}>{copy.previous}</Link> : <span />}<span>{page} / {totalPages}</span>{page < totalPages ? <Link href={pageHref(query, page + 1)}>{copy.next}</Link> : <span />}</nav> : null}
|
|
36
43
|
</div>
|
|
37
44
|
)
|
|
38
45
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { Suspense } from "react"
|
|
2
|
+
import { CheckoutAnalytics } from "@/components/checkout-analytics"
|
|
2
3
|
import { CheckoutFlow } from "@/components/checkout-flow"
|
|
3
4
|
import { getCoreConfig } from "@/lib/core/client"
|
|
5
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
6
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
7
|
|
|
5
8
|
export default async function CheckoutPage() {
|
|
6
|
-
const config = await
|
|
9
|
+
const [config, locale] = await Promise.all([
|
|
10
|
+
getCoreConfig(),
|
|
11
|
+
requestStorefrontLocale(),
|
|
12
|
+
])
|
|
13
|
+
const copy = storefrontCopy(locale)
|
|
14
|
+
|
|
7
15
|
return (
|
|
8
16
|
<div className="stack page-section">
|
|
9
|
-
<div className="page-heading"><div><p className="eyebrow">
|
|
10
|
-
<Suspense fallback={<div className="empty-state">
|
|
17
|
+
<div className="page-heading"><div><p className="eyebrow">{copy.checkoutEyebrow}</p><h1>{copy.checkoutTitle}</h1><p className="muted">{copy.checkoutDescription}</p></div></div>
|
|
18
|
+
<Suspense fallback={<div className="empty-state">{copy.checkoutLoading}</div>}>
|
|
19
|
+
<CheckoutAnalytics config={config} />
|
|
11
20
|
<CheckoutFlow config={config} />
|
|
12
21
|
</Suspense>
|
|
13
22
|
</div>
|
|
@@ -3,6 +3,9 @@ import { notFound } from "next/navigation"
|
|
|
3
3
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
4
4
|
import { endpoint, getCoreConfig, medusaFetch } from "@/lib/core/client"
|
|
5
5
|
import { asRecords, formatMoney, isRecord, stringValue, type JsonRecord } from "@/lib/core/commerce"
|
|
6
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
7
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
8
|
+
import { medusaLocale, orderPath, STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
6
9
|
|
|
7
10
|
type SearchParams = Promise<{ order_id?: string }>
|
|
8
11
|
|
|
@@ -11,9 +14,13 @@ export default async function CheckoutSuccessPage({ searchParams }: { searchPara
|
|
|
11
14
|
const orderId = query.order_id?.trim()
|
|
12
15
|
if (!orderId) notFound()
|
|
13
16
|
const config = await getCoreConfig()
|
|
14
|
-
const
|
|
17
|
+
const locale = await requestStorefrontLocale()
|
|
18
|
+
const copy = storefrontCopy(locale)
|
|
19
|
+
const routes = STOREFRONT_ROUTES[locale]
|
|
20
|
+
const numberLocale = medusaLocale(locale)
|
|
21
|
+
const orderEndpoint = endpoint(config.account.endpoints.order, { id: orderId })
|
|
15
22
|
const { order } = await medusaFetch<{ order: JsonRecord }>(
|
|
16
|
-
`${
|
|
23
|
+
`${orderEndpoint}?fields=+items,+shipping_methods,+metadata`,
|
|
17
24
|
{ cache: "no-store" },
|
|
18
25
|
).catch(() => ({ order: null as unknown as JsonRecord }))
|
|
19
26
|
if (!order) notFound()
|
|
@@ -32,36 +39,69 @@ export default async function CheckoutSuccessPage({ searchParams }: { searchPara
|
|
|
32
39
|
<div className="stack page-section narrow-page">
|
|
33
40
|
<section className="success-hero panel stack">
|
|
34
41
|
<div className="success-icon">✓</div>
|
|
35
|
-
<div
|
|
36
|
-
|
|
42
|
+
<div>
|
|
43
|
+
<p className="eyebrow">{copy.orderRecorded}</p>
|
|
44
|
+
<h1>{copy.thankYou}</h1>
|
|
45
|
+
<p className="muted">{copy.orderNumber}: <strong>#{stringValue(order.display_id || order.id)}</strong></p>
|
|
46
|
+
</div>
|
|
47
|
+
<div className="button-row">
|
|
48
|
+
<Link className="button" href={routes.products}>{copy.continueShopping}</Link>
|
|
49
|
+
{order.customer_id ? <Link className="button secondary" href={orderPath(locale, orderId)}>{copy.orderDetails}</Link> : null}
|
|
50
|
+
</div>
|
|
37
51
|
</section>
|
|
38
52
|
|
|
39
53
|
<section className="panel stack">
|
|
40
|
-
<h2
|
|
41
|
-
{asRecords(order.items).map((item) =>
|
|
42
|
-
|
|
54
|
+
<h2>{copy.summary}</h2>
|
|
55
|
+
{asRecords(order.items).map((item) => (
|
|
56
|
+
<div className="summary-line" key={stringValue(item.id)}>
|
|
57
|
+
<span>{stringValue(item.product_title || item.title)} × {stringValue(item.quantity)}</span>
|
|
58
|
+
<strong>{typeof item.total === "number" ? formatMoney(item.total, currency, numberLocale) : ""}</strong>
|
|
59
|
+
</div>
|
|
60
|
+
))}
|
|
61
|
+
{typeof order.total === "number" ? (
|
|
62
|
+
<div className="summary-total"><span>{copy.total}</span><strong>{formatMoney(order.total, currency, numberLocale)}</strong></div>
|
|
63
|
+
) : null}
|
|
43
64
|
</section>
|
|
44
65
|
|
|
45
|
-
{cod ? <div className="notice"><strong>
|
|
66
|
+
{cod ? <div className="notice"><strong>{copy.codOrder}</strong> {copy.codText}</div> : null}
|
|
46
67
|
|
|
47
68
|
{bank ? (
|
|
48
69
|
<section className="panel stack-sm">
|
|
49
|
-
<div><p className="eyebrow">
|
|
50
|
-
{bank.name ? <Info label=
|
|
51
|
-
<Info label=
|
|
52
|
-
{bank.account_number ? <Info label=
|
|
70
|
+
<div><p className="eyebrow">{copy.bankTransfer}</p><h2>{copy.transferDetails}</h2></div>
|
|
71
|
+
{bank.name ? <Info label={copy.bank} value={stringValue(bank.name)} /> : null}
|
|
72
|
+
<Info label={copy.beneficiary} value={stringValue(bank.account_holder)} />
|
|
73
|
+
{bank.account_number ? <Info label={copy.bankAccount} value={stringValue(bank.account_number)} /> : null}
|
|
53
74
|
{bank.iban ? <Info label="IBAN" value={stringValue(bank.iban)} /> : null}
|
|
54
75
|
{bank.bic ? <Info label="BIC / SWIFT" value={stringValue(bank.bic)} /> : null}
|
|
55
|
-
{transferSnapshot?.reference ? <Info label=
|
|
56
|
-
{transferSnapshot?.dueDate
|
|
57
|
-
|
|
76
|
+
{transferSnapshot?.reference ? <Info label={copy.reference} value={stringValue(transferSnapshot.reference)} /> : null}
|
|
77
|
+
{transferSnapshot?.dueDate
|
|
78
|
+
? <Info label={copy.paymentDeadline} value={stringValue(transferSnapshot.dueDate)} />
|
|
79
|
+
: bankTransfer?.due_days
|
|
80
|
+
? <Info label={copy.paymentDeadline} value={`${stringValue(bankTransfer.due_days)} ${copy.days}`} />
|
|
81
|
+
: null}
|
|
82
|
+
<p className="muted small">{copy.referenceHint}</p>
|
|
58
83
|
</section>
|
|
59
84
|
) : null}
|
|
60
85
|
|
|
61
86
|
<section className="panel stack-sm">
|
|
62
|
-
<h2>
|
|
63
|
-
{shippingMethods.map((method) =>
|
|
64
|
-
|
|
87
|
+
<h2>{copy.shipping}</h2>
|
|
88
|
+
{shippingMethods.map((method) => (
|
|
89
|
+
<Info
|
|
90
|
+
key={stringValue(method.id)}
|
|
91
|
+
label={stringValue(method.name || copy.shipping)}
|
|
92
|
+
value={typeof method.amount === "number" ? formatMoney(method.amount, currency, numberLocale) : copy.selected}
|
|
93
|
+
/>
|
|
94
|
+
))}
|
|
95
|
+
{isRecord(order.shipping_address) ? (
|
|
96
|
+
<p className="muted">{[
|
|
97
|
+
stringValue(order.shipping_address.first_name),
|
|
98
|
+
stringValue(order.shipping_address.last_name),
|
|
99
|
+
stringValue(order.shipping_address.postal_code),
|
|
100
|
+
stringValue(order.shipping_address.city),
|
|
101
|
+
stringValue(order.shipping_address.address_1),
|
|
102
|
+
stringValue(order.shipping_address.address_2),
|
|
103
|
+
].filter(Boolean).join(" ")}</p>
|
|
104
|
+
) : null}
|
|
65
105
|
</section>
|
|
66
106
|
</div>
|
|
67
107
|
)
|
|
@@ -6,6 +6,8 @@ import { CartProvider } from "@/components/cart-provider"
|
|
|
6
6
|
import { ConsentBanner } from "@/components/consent-banner"
|
|
7
7
|
import { StorefrontHeader } from "@/components/storefront-header"
|
|
8
8
|
import { getCoreConfig } from "@/lib/core/client"
|
|
9
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
10
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
9
11
|
|
|
10
12
|
const consentDefaultScript = `
|
|
11
13
|
window.dataLayer = window.dataLayer || [];
|
|
@@ -36,9 +38,14 @@ export async function generateMetadata(): Promise<Metadata> {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
39
|
-
const config = await
|
|
41
|
+
const [config, locale] = await Promise.all([
|
|
42
|
+
getCoreConfig(),
|
|
43
|
+
requestStorefrontLocale(),
|
|
44
|
+
])
|
|
45
|
+
const routes = STOREFRONT_ROUTES[locale]
|
|
46
|
+
|
|
40
47
|
return (
|
|
41
|
-
<html lang={
|
|
48
|
+
<html lang={locale}>
|
|
42
49
|
<head><script dangerouslySetInnerHTML={{ __html: consentDefaultScript }} /></head>
|
|
43
50
|
<body>
|
|
44
51
|
<CartProvider config={config}>
|
|
@@ -47,7 +54,7 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
47
54
|
<footer className="footer">
|
|
48
55
|
<div className="shell footer-inner">
|
|
49
56
|
<div><strong>{config.store.name}</strong><p className="muted small">Powered by HSZRDM Commerce</p></div>
|
|
50
|
-
<nav className="footer-nav"><Link href=
|
|
57
|
+
<nav className="footer-nav"><Link href={routes.legal}>Jogi dokumentumok</Link><Link href={routes.account}>Fiókom</Link><Link href={routes.products}>Termékek</Link></nav>
|
|
51
58
|
</div>
|
|
52
59
|
</footer>
|
|
53
60
|
<AnalyticsGate analytics={config.analytics} />
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { getCoreConfig } from "@/lib/core/client"
|
|
2
2
|
import { listLegalDocuments } from "@/lib/core/legal"
|
|
3
|
+
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
4
|
+
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
3
5
|
|
|
4
6
|
export default async function LegalPage() {
|
|
5
|
-
const config = await
|
|
7
|
+
const [config, locale] = await Promise.all([
|
|
8
|
+
getCoreConfig(),
|
|
9
|
+
requestStorefrontLocale(),
|
|
10
|
+
])
|
|
11
|
+
const copy = storefrontCopy(locale)
|
|
6
12
|
const { documents } = await listLegalDocuments(config)
|
|
7
13
|
|
|
8
14
|
return (
|
|
9
15
|
<div className="stack page-section">
|
|
10
16
|
<div className="page-heading">
|
|
11
|
-
<div><p className="eyebrow">
|
|
17
|
+
<div><p className="eyebrow">{copy.legalEyebrow}</p><h1>{copy.legalTitle}</h1><p className="muted">{copy.legalDescription}</p></div>
|
|
12
18
|
</div>
|
|
13
19
|
{documents.length ? (
|
|
14
20
|
<div className="product-grid">
|
|
15
21
|
{documents.map((document) => (
|
|
16
22
|
<article className="card stack-sm" key={document.key}>
|
|
17
23
|
<h2>{document.title || document.key}</h2>
|
|
18
|
-
<p className="muted">{(document.requiredAtCheckout ?? document.required_at_checkout) ?
|
|
19
|
-
{document.pdfEndpoint ? <a className="button secondary" href={document.pdfEndpoint} target="_blank" rel="noreferrer">
|
|
24
|
+
<p className="muted">{(document.requiredAtCheckout ?? document.required_at_checkout) ? copy.requiredAtCheckout : copy.infoDocument}</p>
|
|
25
|
+
{document.pdfEndpoint ? <a className="button secondary" href={document.pdfEndpoint} target="_blank" rel="noreferrer">{copy.openPdf}</a> : null}
|
|
20
26
|
</article>
|
|
21
27
|
))}
|
|
22
28
|
</div>
|
|
23
|
-
) : <div className="empty-state">
|
|
29
|
+
) : <div className="empty-state">{copy.noLegalDocuments}</div>}
|
|
24
30
|
</div>
|
|
25
31
|
)
|
|
26
32
|
}
|