@hszrdm/create-commerce 0.0.0-stage → 1.0.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.
Files changed (68) hide show
  1. package/README.md +50 -2
  2. package/bin/create-commerce.mjs +51 -0
  3. package/package.json +23 -4
  4. package/src/cli.mjs +585 -0
  5. package/templates/backend/.env.example +113 -0
  6. package/templates/backend/README.md +7 -0
  7. package/templates/backend/instrumentation.ts +24 -0
  8. package/templates/backend/medusa-config.ts +11 -0
  9. package/templates/backend/package.json +42 -0
  10. package/templates/backend/scripts/prepare-project.mjs +49 -0
  11. package/templates/backend/src/project/README.md +13 -0
  12. package/templates/backend/src/project/api/.gitkeep +0 -0
  13. package/templates/backend/src/project/jobs/.gitkeep +0 -0
  14. package/templates/backend/src/project/modules/.gitkeep +0 -0
  15. package/templates/backend/src/project/subscribers/.gitkeep +0 -0
  16. package/templates/backend/src/project/workflows/.gitkeep +0 -0
  17. package/templates/backend/src/scripts/core-init.ts +21 -0
  18. package/templates/backend/src/scripts/create-storefront-key.ts +12 -0
  19. package/templates/backend/src/scripts/verify-bootstrap.ts +1 -0
  20. package/templates/backend/tsconfig.json +33 -0
  21. package/templates/storefront/.env.example +5 -0
  22. package/templates/storefront/README.md +108 -0
  23. package/templates/storefront/next-env.d.ts +4 -0
  24. package/templates/storefront/next.config.ts +8 -0
  25. package/templates/storefront/package.json +24 -0
  26. package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +38 -0
  27. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +51 -0
  28. package/templates/storefront/src/app/[countryCode]/products/page.tsx +47 -0
  29. package/templates/storefront/src/app/account/orders/[id]/page.tsx +8 -0
  30. package/templates/storefront/src/app/account/page.tsx +11 -0
  31. package/templates/storefront/src/app/cart/page.tsx +12 -0
  32. package/templates/storefront/src/app/checkout/page.tsx +15 -0
  33. package/templates/storefront/src/app/checkout/success/page.tsx +72 -0
  34. package/templates/storefront/src/app/error.tsx +14 -0
  35. package/templates/storefront/src/app/globals.css +250 -0
  36. package/templates/storefront/src/app/layout.tsx +59 -0
  37. package/templates/storefront/src/app/legal/page.tsx +26 -0
  38. package/templates/storefront/src/app/loading.tsx +3 -0
  39. package/templates/storefront/src/app/not-found.tsx +14 -0
  40. package/templates/storefront/src/app/page.tsx +47 -0
  41. package/templates/storefront/src/app/reset-password/page.tsx +14 -0
  42. package/templates/storefront/src/app/robots.txt/route.ts +13 -0
  43. package/templates/storefront/src/app/sitemap.xml/route.ts +13 -0
  44. package/templates/storefront/src/components/account-dashboard.tsx +325 -0
  45. package/templates/storefront/src/components/add-to-cart.tsx +71 -0
  46. package/templates/storefront/src/components/analytics.tsx +90 -0
  47. package/templates/storefront/src/components/cart-provider.tsx +236 -0
  48. package/templates/storefront/src/components/cart-view.tsx +135 -0
  49. package/templates/storefront/src/components/checkout-flow.tsx +534 -0
  50. package/templates/storefront/src/components/consent-banner.tsx +131 -0
  51. package/templates/storefront/src/components/order-detail.tsx +273 -0
  52. package/templates/storefront/src/components/product-card.tsx +38 -0
  53. package/templates/storefront/src/components/product-view-tracker.tsx +37 -0
  54. package/templates/storefront/src/components/reset-password-form.tsx +65 -0
  55. package/templates/storefront/src/components/storefront-header.tsx +42 -0
  56. package/templates/storefront/src/components/stripe-payment.tsx +90 -0
  57. package/templates/storefront/src/lib/core/account.ts +170 -0
  58. package/templates/storefront/src/lib/core/after-sales.ts +50 -0
  59. package/templates/storefront/src/lib/core/catalog.ts +56 -0
  60. package/templates/storefront/src/lib/core/checkout.ts +330 -0
  61. package/templates/storefront/src/lib/core/client.ts +107 -0
  62. package/templates/storefront/src/lib/core/commerce.ts +148 -0
  63. package/templates/storefront/src/lib/core/consent.ts +111 -0
  64. package/templates/storefront/src/lib/core/legal.ts +33 -0
  65. package/templates/storefront/src/lib/core/seo.ts +88 -0
  66. package/templates/storefront/src/lib/core/tracking.ts +584 -0
  67. package/templates/storefront/src/lib/core/types.ts +123 -0
  68. package/templates/storefront/tsconfig.json +23 -0
@@ -0,0 +1,7 @@
1
+ # HSZRDM Commerce backend starter
2
+
3
+ Minimal Medusa v2 host application for `@hszrdm/core`.
4
+
5
+ Shared commerce functionality comes from `@hszrdm/core`. Webshop-specific backend code belongs in `src/project/` only. `medusa-config.ts` deliberately stays thin and delegates shared configuration to `createHszrdmCommerceConfig()`.
6
+
7
+ Generated projects should create `.env` from `.env.example`, install dependencies, run `npm run db:migrate`, then `npm run core:init -- --yes`.
@@ -0,0 +1,24 @@
1
+ // Uncomment this file to enable instrumentation and observability using OpenTelemetry
2
+ // Refer to the docs for installation instructions: https://docs.medusajs.com/learn/debugging-and-testing/instrumentation
3
+
4
+ // import { registerOtel } from "@medusajs/medusa"
5
+ // // If using an exporter other than Zipkin, require it here.
6
+ // import { ZipkinExporter } from "@opentelemetry/exporter-zipkin"
7
+
8
+ // // If using an exporter other than Zipkin, initialize it here.
9
+ // const exporter = new ZipkinExporter({
10
+ // serviceName: 'my-medusa-project',
11
+ // })
12
+
13
+ // export function register() {
14
+ // registerOtel({
15
+ // serviceName: 'medusajs',
16
+ // // pass exporter
17
+ // exporter,
18
+ // instrument: {
19
+ // http: true,
20
+ // workflows: true,
21
+ // query: true
22
+ // },
23
+ // })
24
+ // }
@@ -0,0 +1,11 @@
1
+ import { loadEnv } from "@medusajs/framework/utils"
2
+ import { createHszrdmCommerceConfig } from "@hszrdm/core/config"
3
+
4
+ const envFile =
5
+ process.env.APP_ENV === "test"
6
+ ? "test"
7
+ : process.env.NODE_ENV || "development"
8
+
9
+ loadEnv(envFile, process.cwd())
10
+
11
+ module.exports = createHszrdmCommerceConfig()
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "hszrdm-commerce-backend-starter",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "prepare:project": "node ./scripts/prepare-project.mjs",
7
+ "dev": "npm run prepare:project && medusa develop",
8
+ "build": "npm run prepare:project && NODE_ENV=production medusa build",
9
+ "verify:build": "APP_ENV=test npm run build",
10
+ "start": "medusa start",
11
+ "typecheck": "npm run prepare:project && tsc --noEmit",
12
+ "core:init": "npm run prepare:project && medusa exec ./src/scripts/core-init.ts",
13
+ "storefront:key": "npm run prepare:project && medusa exec ./src/scripts/create-storefront-key.ts",
14
+ "bootstrap:assert": "npm run prepare:project && medusa exec ./src/scripts/verify-bootstrap.ts",
15
+ "db:migrate": "npm run prepare:project && medusa db:migrate",
16
+ "db:generate": "npm run prepare:project && medusa db:generate",
17
+ "start:prod": "cd .medusa/server && medusa start"
18
+ },
19
+ "dependencies": {
20
+ "@hszrdm/core": "1.0.0",
21
+ "@medusajs/admin-sdk": "2.21.2",
22
+ "@medusajs/cli": "2.21.2",
23
+ "@medusajs/framework": "2.21.2",
24
+ "@medusajs/medusa": "2.21.2",
25
+ "@medusajs/ui": "4.2.6",
26
+ "react": "^18.3.1",
27
+ "react-dom": "^18.3.1",
28
+ "react-router-dom": "7.18.4"
29
+ },
30
+ "devDependencies": {
31
+ "@swc/core": "1.16.13",
32
+ "@types/node": "22.20.4",
33
+ "@types/react": "18.3.31",
34
+ "@types/react-dom": "18.3.7",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "5.9.3"
37
+ },
38
+ "engines": {
39
+ "node": "22.x"
40
+ },
41
+ "packageManager": "npm@10.9.4"
42
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ existsSync,
5
+ lstatSync,
6
+ mkdirSync,
7
+ readlinkSync,
8
+ rmSync,
9
+ symlinkSync,
10
+ } from "node:fs"
11
+ import { dirname, join, relative, resolve } from "node:path"
12
+ import { fileURLToPath } from "node:url"
13
+
14
+ const backendRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
15
+ const srcRoot = join(backendRoot, "src")
16
+ const projectRoot = join(srcRoot, "project")
17
+ const extensionRoots = ["api", "modules", "workflows", "subscribers", "jobs"]
18
+
19
+ mkdirSync(projectRoot, { recursive: true })
20
+
21
+ for (const name of extensionRoots) {
22
+ const target = join(projectRoot, name)
23
+ const bridge = join(srcRoot, name)
24
+ mkdirSync(target, { recursive: true })
25
+
26
+ const expectedTarget = relative(dirname(bridge), target)
27
+ if (existsSync(bridge)) {
28
+ const stat = lstatSync(bridge)
29
+ if (stat.isSymbolicLink() && readlinkSync(bridge) === expectedTarget) {
30
+ continue
31
+ }
32
+ if (stat.isSymbolicLink()) {
33
+ rmSync(bridge, { force: true })
34
+ } else {
35
+ throw new Error(
36
+ `Managed HSZRDM project bridge already exists as a real path: ${bridge}. ` +
37
+ `Move project-specific code to src/project/${name}.`,
38
+ )
39
+ }
40
+ }
41
+
42
+ symlinkSync(
43
+ expectedTarget,
44
+ bridge,
45
+ process.platform === "win32" ? "junction" : "dir",
46
+ )
47
+ }
48
+
49
+ console.log("✅ HSZRDM project extension bridge ready.")
@@ -0,0 +1,13 @@
1
+ # Project-specific extensions
2
+
3
+ This directory is the only intended home for webshop-specific backend behavior.
4
+
5
+ - `modules/` – project-only Medusa modules
6
+ - `api/` – project-only API routes
7
+ - `workflows/` – project-only workflows and hooks
8
+ - `subscribers/` – project-only subscribers
9
+ - `jobs/` – project-only scheduled jobs
10
+
11
+ If functionality becomes useful for multiple shops, generalize it and move it to `@hszrdm/core` instead of copying it between projects.
12
+
13
+ The backend `prepare:project` script exposes these folders through the conventional Medusa `src/*` extension paths without duplicating source files.
File without changes
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ import type { ExecArgs } from "@medusajs/framework/types"
2
+ import coreInit from "@hszrdm/core/scripts/core-init"
3
+ import { normalizeMedusaExecArgs } from "@hszrdm/core/scripts/exec-args"
4
+
5
+ export default async function runCoreInit(params: ExecArgs) {
6
+ return coreInit({
7
+ ...params,
8
+ args: normalizeMedusaExecArgs(params.args || [], {
9
+ boolean: ["yes", "force"],
10
+ value: [
11
+ "store-name",
12
+ "currency",
13
+ "country",
14
+ "locale",
15
+ "region-name",
16
+ "sales-channel-name",
17
+ "stock-location-name",
18
+ ],
19
+ }),
20
+ })
21
+ }
@@ -0,0 +1,12 @@
1
+ import type { ExecArgs } from "@medusajs/framework/types"
2
+ import createStorefrontKey from "@hszrdm/core/scripts/create-storefront-key"
3
+ import { normalizeMedusaExecArgs } from "@hszrdm/core/scripts/exec-args"
4
+
5
+ export default async function runCreateStorefrontKey(params: ExecArgs) {
6
+ return createStorefrontKey({
7
+ ...params,
8
+ args: normalizeMedusaExecArgs(params.args || [], {
9
+ value: ["title", "created-by", "sales-channel-id"],
10
+ }),
11
+ })
12
+ }
@@ -0,0 +1 @@
1
+ export { default } from "@hszrdm/core/scripts/verify-bootstrap"
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2021",
4
+ "esModuleInterop": true,
5
+ "module": "Node16",
6
+ "moduleResolution": "Node16",
7
+ "emitDecoratorMetadata": true,
8
+ "experimentalDecorators": true,
9
+ "skipLibCheck": true,
10
+ "skipDefaultLibCheck": true,
11
+ "declaration": false,
12
+ "sourceMap": false,
13
+ "inlineSourceMap": true,
14
+ "outDir": "./.medusa/server",
15
+ "rootDir": "./",
16
+ "jsx": "react-jsx",
17
+ "forceConsistentCasingInFileNames": true,
18
+ "resolveJsonModule": true,
19
+ "checkJs": false,
20
+ "strictNullChecks": true,
21
+ "types": ["node"]
22
+ },
23
+ "ts-node": {
24
+ "swc": true
25
+ },
26
+ "include": ["**/*", ".medusa/types/*"],
27
+ "exclude": [
28
+ "node_modules",
29
+ ".medusa/server",
30
+ ".medusa/admin",
31
+ ".cache"
32
+ ]
33
+ }
@@ -0,0 +1,5 @@
1
+ # Only two bootstrap values are required. Everything else comes from
2
+ # GET /store/core-config and the Medusa Store API.
3
+ MEDUSA_BACKEND_URL=http://localhost:9000
4
+ NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000
5
+ NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=
@@ -0,0 +1,108 @@
1
+ # Core Storefront Starter (Next.js)
2
+
3
+ Újrahasznosítható, teljes referencia-storefront a MEDUSA WEBSHOP CORE backendhez.
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 másold ki saját frontend repóba, majd cseréld a design réteget; a `src/lib/core` integrációs contractot és a commerce flow komponenseket érdemes megtartani.
6
+
7
+ ## Indítás
8
+
9
+ ```bash
10
+ cp .env.example .env.local
11
+ npm install
12
+ npm run dev
13
+ ```
14
+
15
+ A bootstraphoz csak:
16
+
17
+ ```env
18
+ MEDUSA_BACKEND_URL=http://localhost:9000
19
+ NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000
20
+ NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=
21
+ ```
22
+
23
+ szükséges. A payment/shipping/legal/SEO/analytics capability-k a `GET /store/core-config` contractból érkeznek.
24
+
25
+ ## Beépített storefront flow
26
+
27
+ - store identity és capability bootstrap;
28
+ - teljes terméklista: keresés, kategóriaszűrés, rendezés, lapozás;
29
+ - kategória- és termékoldal Core SEO/JSON-LD contracttal;
30
+ - variáns- és mennyiségválasztás, Add to Cart;
31
+ - közös cart state, cart drawer és teljes kosároldal;
32
+ - kupon hozzáadás/eltávolítás;
33
+ - region automatikus feloldása a Core alapértelmezett országa alapján;
34
+ - checkout contact + shipping/billing cím;
35
+ - Medusa shipping option választás;
36
+ - FOXPOST, GLS, DPD és MPL Core pickup-point listák;
37
+ - Packeta point ID adapter az official widget bekötéséhez, secret kiexponálása nélkül;
38
+ - Stripe Payment Element;
39
+ - OTP SimplePay redirect + BACK return folytatás;
40
+ - banki átutalás / COD system-provider megkülönböztetés Core metadata markerrel;
41
+ - dinamikus legal dokumentumok kötelező elfogadása;
42
+ - order completion és rendelés-visszaigazolás;
43
+ - banki átutalási adatok a sikeroldalon;
44
+ - login, regisztráció, guest cart customerhez kapcsolása;
45
+ - profil, e-mail verification/change, jelszócsere/reset és fióktörlés;
46
+ - címjegyzék CRUD;
47
+ - rendelési előzmények és rendelésrészlet;
48
+ - return / exchange / claim self-service;
49
+ - globális loading/error/404/empty state-ek;
50
+ - Consent Mode v2, GA4/GTM és e-commerce tracking;
51
+ - robots.txt / sitemap.xml proxy és Search Console verification.
52
+
53
+ ## Authority boundary
54
+
55
+ A starter **nem** számol újra:
56
+
57
+ - árat;
58
+ - kosár végösszeget;
59
+ - adót;
60
+ - promóciót;
61
+ - shipping availability-t vagy árat;
62
+ - payment provider availability-t;
63
+ - after-sales jogosultságot;
64
+ - legal checkout-követelményt.
65
+
66
+ 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.
67
+
68
+ ## Fizetés
69
+
70
+ ### Stripe
71
+
72
+ A Core publikus `NEXT_PUBLIC_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.
73
+
74
+ ### SimplePay
75
+
76
+ A Medusa payment sessionből kapott `paymentUrl` nyílik meg. A Core BACK route a `/checkout?cart_id=...&simplepay_return=...` oldalra tér vissza, ahol a starter újraellenőrzi és lezárja a rendelést.
77
+
78
+ ### Banki átutalás és utánvét
79
+
80
+ Mindkettő Medusa system payment provider. A starter nem vezeti be saját payment providerként őket:
81
+
82
+ - COD: a kiválasztott shipping method `data.cod` markeréből következik;
83
+ - banki átutalás: a Core bank-transfer endpoint `cart_metadata` markerét menti a cartba.
84
+
85
+ ## Pickup pontok
86
+
87
+ A Core publikus, secret-safe list endpointjait használjuk:
88
+
89
+ ```text
90
+ /store/foxpost/lockers
91
+ /store/gls/delivery-points
92
+ /store/dpd/pickup-points
93
+ /store/mpl/delivery-places
94
+ ```
95
+
96
+ 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.
97
+
98
+ ## Build ellenőrzés
99
+
100
+ A starter önálló app, ezért külön futtasd:
101
+
102
+ ```bash
103
+ npm install
104
+ npm run typecheck
105
+ npm run build
106
+ ```
107
+
108
+ A backend unit suite statikus regressziós tesztje azt is ellenőrzi, hogy a kötelező starter route-ok és Core contractok megmaradjanak.
@@ -0,0 +1,4 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // This file is managed by Next.js.
@@ -0,0 +1,8 @@
1
+ import type { NextConfig } from "next"
2
+
3
+ const nextConfig: NextConfig = {
4
+ output: "standalone",
5
+ reactStrictMode: true,
6
+ }
7
+
8
+ export default nextConfig
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@hszrdm/core-storefront-starter",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "typecheck": "tsc --noEmit"
10
+ },
11
+ "dependencies": {
12
+ "@stripe/react-stripe-js": "7.0.0",
13
+ "@stripe/stripe-js": "10.2.0",
14
+ "next": "16.4.3",
15
+ "react": "19.3.1",
16
+ "react-dom": "19.3.1"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "26.6.5",
20
+ "@types/react": "19.3.0",
21
+ "@types/react-dom": "19.3.0",
22
+ "typescript": "7.0.2"
23
+ }
24
+ }
@@ -0,0 +1,38 @@
1
+ import { notFound } from "next/navigation"
2
+ import { ProductCard } from "@/components/product-card"
3
+ import { getCoreConfig } from "@/lib/core/client"
4
+ import { checkoutApi } from "@/lib/core/checkout"
5
+ import { getCategoryByHandle, listProducts } from "@/lib/core/catalog"
6
+ import { stringValue } from "@/lib/core/commerce"
7
+ import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
8
+
9
+ export async function generateMetadata({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
10
+ const { handle, countryCode } = await params
11
+ const config = await getCoreConfig()
12
+ return metadataFromCore(config, { type: "category", handle, countryCode })
13
+ }
14
+
15
+ export default async function CategoryPage({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
16
+ const { handle, countryCode } = await params
17
+ const config = await getCoreConfig()
18
+ const category = await getCategoryByHandle(handle).then((result) => result.product_categories[0]).catch(() => null)
19
+ if (!category) notFound()
20
+ const [jsonLd, region] = await Promise.all([
21
+ structuredDataForEntity(config, { type: "category", handle, countryCode }).catch(() => null),
22
+ checkoutApi(config).resolveDefaultRegion().catch(() => null),
23
+ ])
24
+ const products = await listProducts({
25
+ categoryId: stringValue(category.id),
26
+ order: "-created_at",
27
+ regionId: region ? stringValue(region.id) : undefined,
28
+ limit: 48,
29
+ }).then((result) => result.products).catch(() => [])
30
+
31
+ return (
32
+ <div className="stack page-section">
33
+ {jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
34
+ <div className="page-heading"><div><p className="eyebrow">Kategória</p><h1>{stringValue(category.name)}</h1>{category.description ? <p className="muted">{stringValue(category.description)}</p> : null}</div></div>
35
+ {products.length ? <div className="product-grid">{products.map((product) => <ProductCard config={config} product={product} key={stringValue(product.id)} />)}</div> : <div className="empty-state">Ebben a kategóriában még nincs publikált termék.</div>}
36
+ </div>
37
+ )
38
+ }
@@ -0,0 +1,51 @@
1
+ import { notFound } from "next/navigation"
2
+ import { AddToCart } from "@/components/add-to-cart"
3
+ import { ProductViewTracker } from "@/components/product-view-tracker"
4
+ import { getCoreConfig } from "@/lib/core/client"
5
+ import { checkoutApi } from "@/lib/core/checkout"
6
+ import { getProductByHandle } from "@/lib/core/catalog"
7
+ import { asRecords, formatMoney, productVariantCurrency, productVariantPrice, stringValue } from "@/lib/core/commerce"
8
+ import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
9
+ import { ecommerceItemFromProduct } from "@/lib/core/tracking"
10
+
11
+ export async function generateMetadata({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
12
+ const { handle, countryCode } = await params
13
+ const config = await getCoreConfig()
14
+ return metadataFromCore(config, { type: "product", handle, countryCode })
15
+ }
16
+
17
+ export default async function ProductPage({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
18
+ const { handle, countryCode } = await params
19
+ const config = await getCoreConfig()
20
+ 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)
22
+ if (!product) notFound()
23
+ const jsonLd = await structuredDataForEntity(config, { type: "product", handle, countryCode }).catch(() => null)
24
+ const variants = asRecords(product.variants)
25
+ const first = variants[0]
26
+ const price = productVariantPrice(first)
27
+ const currency = productVariantCurrency(first, config.store.default_currency)
28
+ const tracking = ecommerceItemFromProduct({ product, variant: first, currency })
29
+ const images = asRecords(product.images)
30
+ const thumbnail = stringValue(product.thumbnail || images[0]?.url)
31
+
32
+ return (
33
+ <div className="stack page-section">
34
+ {jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
35
+ <ProductViewTracker analytics={config.analytics} item={tracking.item} currency={tracking.currency} value={tracking.value} />
36
+ <div className="product-detail">
37
+ <div className="product-gallery">
38
+ <div className="product-main-image">{thumbnail ? <img src={thumbnail} alt={stringValue(product.title)} /> : <span className="media-placeholder">Nincs kép</span>}</div>
39
+ {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
+ </div>
41
+ <section className="product-copy stack">
42
+ <div><p className="eyebrow">Termék</p><h1>{stringValue(product.title)}</h1></div>
43
+ {Number.isFinite(price) ? <div className="product-price">{formatMoney(price, currency, config.store.locale)}</div> : null}
44
+ {product.description ? <p className="product-description">{stringValue(product.description)}</p> : null}
45
+ <AddToCart product={product} config={config} />
46
+ <div className="product-meta">{product.subtitle ? <span>{stringValue(product.subtitle)}</span> : null}{product.material ? <span>Anyag: {stringValue(product.material)}</span> : null}{product.origin_country ? <span>Származás: {stringValue(product.origin_country)}</span> : null}</div>
47
+ </section>
48
+ </div>
49
+ </div>
50
+ )
51
+ }
@@ -0,0 +1,47 @@
1
+ import Link from "next/link"
2
+ import { ProductCard } from "@/components/product-card"
3
+ import { getCoreConfig } from "@/lib/core/client"
4
+ import { checkoutApi } from "@/lib/core/checkout"
5
+ import { listCategories, listProducts } from "@/lib/core/catalog"
6
+ import { stringValue } from "@/lib/core/commerce"
7
+
8
+ type SearchParams = Promise<{ q?: string; category?: string; sort?: string; page?: string }>
9
+ const sortMap: Record<string, string> = { newest: "-created_at", oldest: "created_at", name: "title" }
10
+
11
+ export default async function ProductsPage({ searchParams }: { searchParams: SearchParams }) {
12
+ const config = await getCoreConfig()
13
+ const query = await searchParams
14
+ const page = Math.max(1, Number(query.page) || 1)
15
+ const limit = 24
16
+ const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
17
+ const regionId = region ? stringValue(region.id) : undefined
18
+ 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: [] })),
21
+ ])
22
+ const categories = categoryResult.product_categories
23
+ const totalPages = Math.max(1, Math.ceil(count / limit))
24
+
25
+ return (
26
+ <div className="stack page-section">
27
+ <div className="page-heading"><div><p className="eyebrow">Katalógus</p><h1>Termékek</h1><p className="muted">Keresés, kategória és rendezés közvetlenül a Medusa Store API alapján.</p></div></div>
28
+ <form className="catalog-toolbar" method="get">
29
+ <label className="catalog-search">Keresés<input name="q" defaultValue={query.q || ""} placeholder="Terméknév, leírás…" /></label>
30
+ <label>Kategória<select name="category" defaultValue={query.category || ""}><option value="">Összes kategória</option>{categories.map((category) => <option value={stringValue(category.id)} key={stringValue(category.id)}>{stringValue(category.name)}</option>)}</select></label>
31
+ <label>Rendezés<select name="sort" defaultValue={query.sort || "newest"}><option value="newest">Legújabb</option><option value="oldest">Legrégebbi</option><option value="name">Név A–Z</option></select></label>
32
+ <button className="button" type="submit">Szűrés</button>
33
+ </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>Nincs találat.</strong><span className="muted">Módosítsd a keresést vagy a kategóriaszűrőt.</span></div>}
35
+ {totalPages > 1 ? <nav className="pagination" aria-label="Oldalak">{page > 1 ? <Link href={pageHref(query, page - 1)}>← Előző</Link> : <span />}<span>{page} / {totalPages}</span>{page < totalPages ? <Link href={pageHref(query, page + 1)}>Következő →</Link> : <span />}</nav> : null}
36
+ </div>
37
+ )
38
+ }
39
+
40
+ function pageHref(query: Awaited<SearchParams>, page: number) {
41
+ const params = new URLSearchParams()
42
+ if (query.q) params.set("q", query.q)
43
+ if (query.category) params.set("category", query.category)
44
+ if (query.sort) params.set("sort", query.sort)
45
+ params.set("page", String(page))
46
+ return `?${params.toString()}`
47
+ }
@@ -0,0 +1,8 @@
1
+ import { OrderDetail } from "@/components/order-detail"
2
+ import { getCoreConfig } from "@/lib/core/client"
3
+
4
+ export default async function AccountOrderPage({ params }: { params: Promise<{ id: string }> }) {
5
+ const { id } = await params
6
+ const config = await getCoreConfig()
7
+ return <div className="page-section"><OrderDetail config={config} orderId={id} /></div>
8
+ }
@@ -0,0 +1,11 @@
1
+ import { AccountDashboard } from "@/components/account-dashboard"
2
+ import { getCoreConfig } from "@/lib/core/client"
3
+
4
+ export default async function AccountPage() {
5
+ const config = await getCoreConfig()
6
+ return (
7
+ <div className="stack page-section">
8
+ <AccountDashboard config={config} />
9
+ </div>
10
+ )
11
+ }
@@ -0,0 +1,12 @@
1
+ import { CartView } from "@/components/cart-view"
2
+ import { getCoreConfig } from "@/lib/core/client"
3
+
4
+ export default async function CartPage() {
5
+ const config = await getCoreConfig()
6
+ return (
7
+ <div className="stack page-section narrow-page">
8
+ <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
+ <section className="panel"><CartView config={config} /></section>
10
+ </div>
11
+ )
12
+ }
@@ -0,0 +1,15 @@
1
+ import { Suspense } from "react"
2
+ import { CheckoutFlow } from "@/components/checkout-flow"
3
+ import { getCoreConfig } from "@/lib/core/client"
4
+
5
+ export default async function CheckoutPage() {
6
+ const config = await getCoreConfig()
7
+ return (
8
+ <div className="stack page-section">
9
+ <div className="page-heading"><div><p className="eyebrow">Checkout</p><h1>Pénztár</h1><p className="muted">A szállítás, fizetés, végösszeg és jogi követelmények a Core/Medusa aktuális állapotából jönnek.</p></div></div>
10
+ <Suspense fallback={<div className="empty-state">Pénztár betöltése…</div>}>
11
+ <CheckoutFlow config={config} />
12
+ </Suspense>
13
+ </div>
14
+ )
15
+ }