@hszrdm/create-commerce 1.4.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.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/templates/backend/.env.example +13 -0
  3. package/templates/backend/README.md +4 -0
  4. package/templates/backend/package.json +3 -1
  5. package/templates/backend/scripts/core-backup.mjs +281 -0
  6. package/templates/backend/scripts/core-restore.mjs +179 -0
  7. package/templates/backend/scripts/lib/core-backup-common.mjs +237 -0
  8. package/templates/backend/scripts/production-assets/deploy.sh +2 -1
  9. package/templates/backend/scripts/production-assets/install.sh +2 -1
  10. package/templates/backend/scripts/production-assets/restore.sh +4 -1
  11. package/templates/backend/src/scripts/core-init.ts +3 -1
  12. package/templates/storefront/README.md +35 -12
  13. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +3 -2
  14. package/templates/storefront/src/app/blog/page.tsx +46 -8
  15. package/templates/storefront/src/app/cart/page.tsx +2 -0
  16. package/templates/storefront/src/app/cart/shared/[token]/page.tsx +25 -0
  17. package/templates/storefront/src/app/cart-recovery/page.tsx +35 -0
  18. package/templates/storefront/src/app/ertekeles/page.tsx +25 -0
  19. package/templates/storefront/src/app/fiok-aktivalas/page.tsx +35 -0
  20. package/templates/storefront/src/app/knowledge-base/page.tsx +46 -8
  21. package/templates/storefront/src/app/layout.tsx +5 -2
  22. package/templates/storefront/src/app/legal/page.tsx +18 -2
  23. package/templates/storefront/src/app/page.tsx +33 -4
  24. package/templates/storefront/src/app/pages/page.tsx +43 -0
  25. package/templates/storefront/src/components/abandoned-cart-recovery.tsx +139 -0
  26. package/templates/storefront/src/components/account-activation-form.tsx +333 -0
  27. package/templates/storefront/src/components/add-to-cart.tsx +132 -2
  28. package/templates/storefront/src/components/analytics.tsx +52 -19
  29. package/templates/storefront/src/components/cart-provider.tsx +40 -3
  30. package/templates/storefront/src/components/cart-share-button.tsx +93 -0
  31. package/templates/storefront/src/components/cms-taxonomy-filters.tsx +86 -0
  32. package/templates/storefront/src/components/customer-cart-resume-gate.tsx +112 -0
  33. package/templates/storefront/src/components/fogyasztobarat-embed.tsx +32 -0
  34. package/templates/storefront/src/components/review-request-form.tsx +419 -0
  35. package/templates/storefront/src/components/shared-cart-view.tsx +257 -0
  36. package/templates/storefront/src/lib/core/abandoned-cart.ts +47 -0
  37. package/templates/storefront/src/lib/core/account-activation.ts +75 -0
  38. package/templates/storefront/src/lib/core/back-in-stock.ts +25 -0
  39. package/templates/storefront/src/lib/core/catalog.ts +12 -0
  40. package/templates/storefront/src/lib/core/checkout.ts +86 -4
  41. package/templates/storefront/src/lib/core/customer-cart-resume.ts +51 -0
  42. package/templates/storefront/src/lib/core/google-ads.ts +58 -0
  43. package/templates/storefront/src/lib/core/legal.ts +14 -0
  44. package/templates/storefront/src/lib/core/reviews.ts +37 -5
  45. package/templates/storefront/src/lib/core/shared-cart.ts +37 -0
  46. package/templates/storefront/src/lib/core/types.ts +18 -0
  47. package/templates/storefront/src/lib/storefront-routes.ts +12 -0
  48. package/templates/storefront/src/proxy.ts +11 -0
@@ -0,0 +1,47 @@
1
+ import { CoreApiError, medusaFetch } from "./client"
2
+ import type { CoreConfig } from "./types"
3
+
4
+ export type AbandonedCartRecoveryResult = {
5
+ valid: boolean
6
+ reason?: string
7
+ cart_id?: string
8
+ locale?: "hu-HU" | "en-US" | string
9
+ coupon_code?: string | null
10
+ }
11
+
12
+ export function abandonedCartApi(config: CoreConfig) {
13
+ const recoveryEndpoint =
14
+ config.checkout.endpoints.abandoned_cart_recovery ||
15
+ "/store/abandoned-cart/recover"
16
+
17
+ return {
18
+ recover: async (token: string) => {
19
+ const query = new URLSearchParams({ token })
20
+ try {
21
+ return await medusaFetch<AbandonedCartRecoveryResult>(
22
+ `${recoveryEndpoint}?${query.toString()}`,
23
+ { cache: "no-store" },
24
+ )
25
+ } catch (cause) {
26
+ if (
27
+ cause instanceof CoreApiError &&
28
+ (cause.status === 400 || cause.status === 410) &&
29
+ isRecord(cause.payload)
30
+ ) {
31
+ return {
32
+ valid: false,
33
+ reason:
34
+ typeof cause.payload.reason === "string"
35
+ ? cause.payload.reason
36
+ : "invalid",
37
+ } satisfies AbandonedCartRecoveryResult
38
+ }
39
+ throw cause
40
+ }
41
+ },
42
+ }
43
+ }
44
+
45
+ function isRecord(value: unknown): value is Record<string, unknown> {
46
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value)
47
+ }
@@ -0,0 +1,75 @@
1
+ import { CoreApiError, medusaFetch } from "./client"
2
+ import type { CoreConfig } from "./types"
3
+
4
+ export type CustomerActivationReward = {
5
+ enabled?: boolean
6
+ type?: "percentage" | "fixed"
7
+ value?: number
8
+ currency_code?: string
9
+ }
10
+
11
+ export type CustomerActivationValidation = {
12
+ valid: boolean
13
+ reason?: "missing" | "expired" | "used" | "invalid" | string | null
14
+ customer_id?: string
15
+ masked_email?: string
16
+ first_name?: string | null
17
+ expires_at?: string | null
18
+ reward?: CustomerActivationReward | null
19
+ }
20
+
21
+ export type CustomerActivationResult = {
22
+ activated: true
23
+ customer_id: string
24
+ coupon_code: string | null
25
+ reward: CustomerActivationReward | null
26
+ }
27
+
28
+ export function customerActivationApi(config: CoreConfig) {
29
+ const validationEndpoint =
30
+ config.account.endpoints.customer_activation || "/store/customer-activation"
31
+ const completionEndpoint =
32
+ config.account.endpoints.customer_activation_complete ||
33
+ "/store/customer-activation/complete"
34
+
35
+ return {
36
+ validate: async (customerId: string, token: string) => {
37
+ const query = new URLSearchParams({ customer: customerId, token })
38
+ try {
39
+ return await medusaFetch<CustomerActivationValidation>(
40
+ `${validationEndpoint}?${query.toString()}`,
41
+ { cache: "no-store" },
42
+ )
43
+ } catch (cause) {
44
+ if (
45
+ cause instanceof CoreApiError &&
46
+ (cause.status === 400 || cause.status === 410) &&
47
+ isRecord(cause.payload)
48
+ ) {
49
+ return {
50
+ valid: false,
51
+ reason:
52
+ typeof cause.payload.reason === "string"
53
+ ? cause.payload.reason
54
+ : "invalid",
55
+ } satisfies CustomerActivationValidation
56
+ }
57
+ throw cause
58
+ }
59
+ },
60
+
61
+ complete: (customerId: string, token: string, password: string) =>
62
+ medusaFetch<CustomerActivationResult>(completionEndpoint, {
63
+ method: "POST",
64
+ body: JSON.stringify({
65
+ customer_id: customerId,
66
+ token,
67
+ password,
68
+ }),
69
+ }),
70
+ }
71
+ }
72
+
73
+ function isRecord(value: unknown): value is Record<string, unknown> {
74
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value)
75
+ }
@@ -0,0 +1,25 @@
1
+ import { medusaFetch } from "./client"
2
+
3
+ export type BackInStockResponse = {
4
+ subscribed: boolean
5
+ already_available?: boolean
6
+ already_subscribed?: boolean
7
+ reactivated?: boolean
8
+ subscription_id?: string
9
+ availability?: number | null
10
+ }
11
+
12
+ export async function subscribeBackInStock(input: {
13
+ email: string
14
+ variantId: string
15
+ locale: string
16
+ }) {
17
+ return medusaFetch<BackInStockResponse>("/store/back-in-stock", {
18
+ method: "POST",
19
+ body: JSON.stringify({
20
+ email: input.email,
21
+ variant_id: input.variantId,
22
+ locale: input.locale,
23
+ }),
24
+ })
25
+ }
@@ -86,3 +86,15 @@ export function getProductByHandle(handle: string, regionId?: string, locale?: s
86
86
  { next: { revalidate: 60 } },
87
87
  )
88
88
  }
89
+
90
+ export function getProductById(productId: string, regionId?: string, locale?: string) {
91
+ const params = new URLSearchParams({
92
+ fields: "+variants.calculated_price,+categories,+images",
93
+ })
94
+ if (regionId) params.set("region_id", regionId)
95
+ if (locale?.trim()) params.set("locale", locale.trim())
96
+ return medusaFetch<{ product: Record<string, unknown> }>(
97
+ `/store/products/${encodeURIComponent(productId)}?${params.toString()}`,
98
+ { cache: "no-store" },
99
+ )
100
+ }
@@ -1,4 +1,5 @@
1
1
  import { endpoint, medusaFetch } from "./client"
2
+ import { trackGoogleAdsPurchase } from "./google-ads"
2
3
  import {
3
4
  trackCartEvent,
4
5
  trackCartLineChange,
@@ -86,6 +87,59 @@ export function checkoutApi(config: CoreConfig) {
86
87
  })
87
88
  }
88
89
 
90
+ const saveFoxpostSelection = (
91
+ cartId: string,
92
+ deliveryType: "LOCKER" | "HOME",
93
+ locker: Record<string, unknown> | null = null,
94
+ ) =>
95
+ medusaFetch<{ foxpost: Record<string, unknown> }>(
96
+ endpoint(paths.foxpost_selection, { id: cartId }),
97
+ {
98
+ method: "POST",
99
+ body: JSON.stringify({ deliveryType, locker }),
100
+ },
101
+ )
102
+
103
+ const saveGlsSelection = (
104
+ cartId: string,
105
+ deliveryType: "POINT" | "HOME",
106
+ deliveryPoint: Record<string, unknown> | null = null,
107
+ ) =>
108
+ medusaFetch<{ gls: Record<string, unknown> }>(
109
+ endpoint(paths.gls_selection, { id: cartId }),
110
+ {
111
+ method: "POST",
112
+ body: JSON.stringify({ deliveryType, deliveryPoint }),
113
+ },
114
+ )
115
+
116
+ const persistCarrierSelection = async (
117
+ cartId: string,
118
+ optionId: string,
119
+ data: Record<string, unknown> | undefined,
120
+ cart: Record<string, unknown>,
121
+ ) => {
122
+ const selected = selectedShippingMethod(cart, optionId)
123
+ const carrierText = shippingMethodDescriptor(selected, optionId)
124
+ const foxpostData = isRecord(data?.foxpost) ? data.foxpost : null
125
+ const glsData = isRecord(data?.gls) ? data.gls : null
126
+
127
+ if (foxpostData || carrierText.includes("foxpost")) {
128
+ const locker = foxpostData && isRecord(foxpostData.locker)
129
+ ? foxpostData.locker
130
+ : null
131
+ await saveFoxpostSelection(cartId, locker ? "LOCKER" : "HOME", locker)
132
+ return
133
+ }
134
+
135
+ if (glsData || carrierText.includes("gls")) {
136
+ const deliveryPoint = glsData && isRecord(glsData.deliveryPoint)
137
+ ? glsData.deliveryPoint
138
+ : null
139
+ await saveGlsSelection(cartId, deliveryPoint ? "POINT" : "HOME", deliveryPoint)
140
+ }
141
+ }
142
+
89
143
  return {
90
144
  regions,
91
145
  resolveDefaultRegion,
@@ -225,10 +279,14 @@ export function checkoutApi(config: CoreConfig) {
225
279
  body: JSON.stringify({ option_id: optionId, ...(data ? { data } : {}) }),
226
280
  },
227
281
  )
282
+ await persistCarrierSelection(cartId, optionId, data, result.cart)
228
283
  trackShippingInfo(config.analytics, result.cart, shippingTier(result.cart, optionId))
229
284
  return result
230
285
  },
231
286
 
287
+ saveFoxpostSelection,
288
+ saveGlsSelection,
289
+
232
290
  foxpostLockers: () =>
233
291
  medusaFetch<{ lockers: Array<Record<string, unknown>> }>(paths.foxpost_lockers, {
234
292
  cache: "no-store",
@@ -295,6 +353,7 @@ export function checkoutApi(config: CoreConfig) {
295
353
  )
296
354
  if (result.type === "order" && isRecord(result.order)) {
297
355
  trackPurchase(config.analytics, result.order)
356
+ trackGoogleAdsPurchase(config.marketing.google_ads, result.order)
298
357
  }
299
358
  return result
300
359
  },
@@ -309,11 +368,34 @@ function findLine(
309
368
  return cart.items.filter(isRecord).find(predicate) || null
310
369
  }
311
370
 
371
+ function selectedShippingMethod(cart: Record<string, unknown>, optionId: string) {
372
+ return asRecords(cart.shipping_methods).find(
373
+ (method) => stringValue(method.shipping_option_id) === optionId,
374
+ ) || null
375
+ }
376
+
377
+ function shippingMethodDescriptor(
378
+ method: Record<string, unknown> | null,
379
+ optionId: string,
380
+ ) {
381
+ const option = method && isRecord(method.shipping_option)
382
+ ? method.shipping_option
383
+ : {}
384
+ return [
385
+ optionId,
386
+ method?.name,
387
+ method?.provider_id,
388
+ option.id,
389
+ option.name,
390
+ option.provider_id,
391
+ ]
392
+ .map((value) => stringValue(value).toLowerCase())
393
+ .filter(Boolean)
394
+ .join(" ")
395
+ }
396
+
312
397
  function shippingTier(cart: Record<string, unknown>, optionId: string) {
313
- if (!Array.isArray(cart.shipping_methods)) return optionId
314
- const selected = cart.shipping_methods
315
- .filter(isRecord)
316
- .find((method) => method.shipping_option_id === optionId)
398
+ const selected = selectedShippingMethod(cart, optionId)
317
399
  const shippingOption = selected && isRecord(selected.shipping_option)
318
400
  ? selected.shipping_option
319
401
  : null
@@ -0,0 +1,51 @@
1
+ import { CoreApiError, medusaFetch } from "./client"
2
+
3
+ export type CustomerCartResumeAction =
4
+ | "none"
5
+ | "resume"
6
+ | "keep-current"
7
+ | "merge-required"
8
+
9
+ export type CustomerCartResumeSummary = {
10
+ id: string
11
+ customer_id?: string | null
12
+ item_count?: number
13
+ status?: string | null
14
+ }
15
+
16
+ export type CustomerCartResumeDecision = {
17
+ action: CustomerCartResumeAction
18
+ target_cart_id: string | null
19
+ merge_required: boolean
20
+ active_cart: CustomerCartResumeSummary | null
21
+ current_cart: CustomerCartResumeSummary | null
22
+ }
23
+
24
+ export const CUSTOMER_CART_RESUME_CONFLICT_EVENT =
25
+ "hszrdm:customer-cart-resume-conflict"
26
+
27
+ export function resolveCustomerCartResume(currentCartId?: string | null) {
28
+ const params = new URLSearchParams()
29
+ if (currentCartId?.trim()) params.set("current_cart_id", currentCartId.trim())
30
+ const suffix = params.size ? `?${params.toString()}` : ""
31
+ return medusaFetch<CustomerCartResumeDecision>(
32
+ `/store/core-carts/me/active${suffix}`,
33
+ { cache: "no-store" },
34
+ )
35
+ }
36
+
37
+ export function isUnauthenticatedCartResume(error: unknown) {
38
+ return error instanceof CoreApiError && error.status === 401
39
+ }
40
+
41
+ export function announceCustomerCartResumeConflict(
42
+ decision: CustomerCartResumeDecision,
43
+ ) {
44
+ if (typeof window === "undefined") return
45
+ window.dispatchEvent(
46
+ new CustomEvent<CustomerCartResumeDecision>(
47
+ CUSTOMER_CART_RESUME_CONFLICT_EVENT,
48
+ { detail: decision },
49
+ ),
50
+ )
51
+ }
@@ -0,0 +1,58 @@
1
+ import { readConsentPreferences } from "./consent"
2
+ import type { CoreConfig } from "./types"
3
+
4
+ export function trackGoogleAdsPurchase(
5
+ googleAds: CoreConfig["marketing"]["google_ads"],
6
+ order: Record<string, unknown>,
7
+ ) {
8
+ if (typeof window === "undefined") return false
9
+ if (!googleAds.enabled || !googleAds.purchase_send_to) return false
10
+ if (!readConsentPreferences()?.marketing) return false
11
+
12
+ const transactionId = text(order.id) || text(order.display_id)
13
+ if (!transactionId) return false
14
+
15
+ const dedupeKey = `core:google-ads:purchase:${transactionId}`
16
+ if (window.localStorage.getItem(dedupeKey) === "sent") return false
17
+
18
+ const payload = {
19
+ send_to: googleAds.purchase_send_to,
20
+ transaction_id: transactionId,
21
+ value: finite(order.total),
22
+ currency: text(order.currency_code).toUpperCase() || "HUF",
23
+ }
24
+
25
+ const target = window as typeof window & {
26
+ dataLayer?: Array<Record<string, unknown> | unknown[]>
27
+ gtag?: (...args: unknown[]) => void
28
+ }
29
+ target.dataLayer = target.dataLayer || []
30
+
31
+ if (googleAds.google_tag_manager_enabled) {
32
+ target.dataLayer.push({
33
+ event: "google_ads_purchase",
34
+ ...payload,
35
+ })
36
+ window.localStorage.setItem(dedupeKey, "sent")
37
+ return true
38
+ }
39
+
40
+ if (typeof target.gtag === "function") {
41
+ target.gtag("event", "conversion", payload)
42
+ window.localStorage.setItem(dedupeKey, "sent")
43
+ return true
44
+ }
45
+
46
+ return false
47
+ }
48
+
49
+ function text(value: unknown) {
50
+ return typeof value === "string" || typeof value === "number"
51
+ ? String(value).trim()
52
+ : ""
53
+ }
54
+
55
+ function finite(value: unknown) {
56
+ const result = typeof value === "number" ? value : Number(value)
57
+ return Number.isFinite(result) ? result : undefined
58
+ }
@@ -1,6 +1,14 @@
1
1
  import { absoluteBackendUrl, endpoint, medusaFetch } from "./client"
2
2
  import type { CoreConfig, LegalDocument } from "./types"
3
3
 
4
+ export type LegalEmbedConfig = {
5
+ enabled: boolean
6
+ provider?: string
7
+ scriptUrl?: string
8
+ dataId?: string
9
+ dataType?: string
10
+ }
11
+
4
12
  export async function listLegalDocuments(config: CoreConfig) {
5
13
  const result = await medusaFetch<{ documents: LegalDocument[] }>(
6
14
  config.legal.documents_endpoint,
@@ -17,6 +25,12 @@ export async function listLegalDocuments(config: CoreConfig) {
17
25
  }
18
26
  }
19
27
 
28
+ export function getLegalEmbed() {
29
+ return medusaFetch<LegalEmbedConfig>("/store/legal/embed", {
30
+ cache: "no-store",
31
+ })
32
+ }
33
+
20
34
  export function acceptLegalDocument(
21
35
  config: CoreConfig,
22
36
  key: string,
@@ -7,7 +7,7 @@ export type ProductReview = {
7
7
  rating: number
8
8
  body: string
9
9
  verified_purchase: boolean
10
- status?: "pending" | "approved" | "rejected"
10
+ status?: "pending" | "published" | "rejected"
11
11
  created_at?: string
12
12
  updated_at?: string
13
13
  }
@@ -17,6 +17,25 @@ export type ProductReviewSummary = {
17
17
  count: number
18
18
  }
19
19
 
20
+ export type ReviewRequestProduct = {
21
+ product_id: string
22
+ title: string
23
+ handle: string | null
24
+ thumbnail: string | null
25
+ reviewed: boolean
26
+ }
27
+
28
+ export type ReviewRequest = {
29
+ order: {
30
+ id: string
31
+ display_id: string | number | null
32
+ }
33
+ products: ReviewRequestProduct[]
34
+ reward: {
35
+ available_after_publish: boolean
36
+ }
37
+ }
38
+
20
39
  export function listProductReviews(productId: string, options: { limit?: number; offset?: number } = {}) {
21
40
  const params = new URLSearchParams()
22
41
  if (options.limit != null) params.set("limit", String(options.limit))
@@ -32,9 +51,22 @@ export function listProductReviews(productId: string, options: { limit?: number;
32
51
  })
33
52
  }
34
53
 
35
- export function submitProductReview(productId: string, input: { rating: number; body: string }) {
36
- return medusaFetch<{ review: ProductReview }>(`/store/products/${encodeURIComponent(productId)}/reviews`, {
37
- method: "POST",
38
- body: JSON.stringify(input),
54
+ export function loadReviewRequest(token: string) {
55
+ const params = new URLSearchParams({ token })
56
+ return medusaFetch<ReviewRequest>(`/store/review-request?${params.toString()}`, {
57
+ cache: "no-store",
39
58
  })
40
59
  }
60
+
61
+ export function submitProductReview(
62
+ productId: string,
63
+ input: { rating: number; body: string; review_request_token?: string },
64
+ ) {
65
+ return medusaFetch<{ review: ProductReview; reward_error?: string | null }>(
66
+ `/store/products/${encodeURIComponent(productId)}/reviews`,
67
+ {
68
+ method: "POST",
69
+ body: JSON.stringify(input),
70
+ },
71
+ )
72
+ }
@@ -0,0 +1,37 @@
1
+ import { medusaFetch } from "./client"
2
+
3
+ export type SharedCartSnapshotItem = {
4
+ product_id: string | null
5
+ variant_id: string
6
+ quantity: number
7
+ availability?: number | null
8
+ }
9
+
10
+ export type SharedCartPayload = {
11
+ items: SharedCartSnapshotItem[]
12
+ region_id: string | null
13
+ currency_code: string | null
14
+ expires_at: string
15
+ use_count: number
16
+ }
17
+
18
+ export function createSharedCart(input: {
19
+ items: SharedCartSnapshotItem[]
20
+ region_id?: string | null
21
+ currency_code?: string | null
22
+ }) {
23
+ return medusaFetch<{ token: string; expires_at: string; use_count: number }>(
24
+ "/store/shared-carts",
25
+ {
26
+ method: "POST",
27
+ body: JSON.stringify(input),
28
+ },
29
+ )
30
+ }
31
+
32
+ export function getSharedCart(token: string) {
33
+ return medusaFetch<{ shared_cart: SharedCartPayload }>(
34
+ `/store/shared-carts/${encodeURIComponent(token)}`,
35
+ { cache: "no-store" },
36
+ )
37
+ }
@@ -19,9 +19,18 @@ export type CoreConfig = {
19
19
  seo: boolean
20
20
  analytics: boolean
21
21
  merchant_feed: boolean
22
+ google_ads: boolean
22
23
  }
23
24
  account: {
24
25
  enabled: boolean
26
+ profile: boolean
27
+ addresses: boolean
28
+ order_history: boolean
29
+ email_verification: boolean
30
+ email_change: boolean
31
+ password_reset: boolean
32
+ password_change: boolean
33
+ delete_account: boolean
25
34
  managed_by: Record<string, string>
26
35
  endpoints: EndpointMap
27
36
  }
@@ -81,6 +90,15 @@ export type CoreConfig = {
81
90
  }
82
91
  marketing: {
83
92
  google_merchant: { enabled: boolean; feed_endpoint: string }
93
+ google_ads: {
94
+ enabled: boolean
95
+ consent_required: true
96
+ conversion_id: string | null
97
+ purchase_conversion_label: string | null
98
+ purchase_send_to: string | null
99
+ remarketing_enabled: boolean
100
+ google_tag_manager_enabled: boolean
101
+ }
84
102
  }
85
103
  checkout: {
86
104
  payment_availability: "medusa_region"
@@ -5,6 +5,8 @@ export const STOREFRONT_ROUTES = {
5
5
  products: "/hu/termekek",
6
6
  categories: "/hu/kategoriak",
7
7
  cart: "/hu/kosar",
8
+ sharedCart: "/hu/kosar/megosztas",
9
+ cartRecovery: "/hu/kosar-visszaallitas",
8
10
  checkout: "/hu/penztar",
9
11
  checkoutSuccess: "/hu/penztar/sikeres-rendeles",
10
12
  account: "/hu/fiokom",
@@ -24,6 +26,8 @@ export const STOREFRONT_ROUTES = {
24
26
  products: "/en/products",
25
27
  categories: "/en/categories",
26
28
  cart: "/en/cart",
29
+ sharedCart: "/en/cart/shared",
30
+ cartRecovery: "/en/cart-recovery",
27
31
  checkout: "/en/checkout",
28
32
  checkoutSuccess: "/en/checkout/success",
29
33
  account: "/en/account",
@@ -69,6 +73,10 @@ export function orderPath(locale: StorefrontLocale, orderId: string) {
69
73
  return `${STOREFRONT_ROUTES[locale].orders}/${encodeURIComponent(orderId)}`
70
74
  }
71
75
 
76
+ export function sharedCartPath(locale: StorefrontLocale, token: string) {
77
+ return `${STOREFRONT_ROUTES[locale].sharedCart}/${encodeURIComponent(token)}`
78
+ }
79
+
72
80
  export function blogPostPath(locale: StorefrontLocale, slug: string) {
73
81
  return `${STOREFRONT_ROUTES[locale].blog}/${encodeURIComponent(slug)}`
74
82
  }
@@ -101,6 +109,10 @@ export function equivalentLocalePath(
101
109
  return `${target.categories}/${pathname.slice(source.categories.length + 1)}`
102
110
  }
103
111
  if (pathname === source.cart) return target.cart
112
+ if (pathname.startsWith(`${source.sharedCart}/`)) {
113
+ return `${target.sharedCart}/${pathname.slice(source.sharedCart.length + 1)}`
114
+ }
115
+ if (pathname === source.cartRecovery) return target.cartRecovery
104
116
  if (pathname === source.checkout) return target.checkout
105
117
  if (pathname === source.checkoutSuccess) return target.checkoutSuccess
106
118
  if (pathname === source.account) return target.account
@@ -52,6 +52,10 @@ function legacyRedirect(pathname: string, locale: StorefrontLocale) {
52
52
  if (pathname === "/") return STOREFRONT_ROUTES[locale].home
53
53
 
54
54
  if (pathname === "/cart") return STOREFRONT_ROUTES[locale].cart
55
+ if (pathname.startsWith("/cart/shared/")) {
56
+ return `${STOREFRONT_ROUTES[locale].sharedCart}/${pathname.slice("/cart/shared/".length)}`
57
+ }
58
+ if (pathname === "/cart-recovery" || pathname === "/kosar-visszaallitas") return STOREFRONT_ROUTES[locale].cartRecovery
55
59
  if (pathname === "/checkout") return STOREFRONT_ROUTES[locale].checkout
56
60
  if (pathname === "/checkout/success") return STOREFRONT_ROUTES[locale].checkoutSuccess
57
61
  if (pathname === "/account") return STOREFRONT_ROUTES[locale].account
@@ -72,6 +76,8 @@ function legacyRedirect(pathname: string, locale: StorefrontLocale) {
72
76
  if (pathname === "/hu/categories") return STOREFRONT_ROUTES.hu.categories
73
77
  if (pathname.startsWith("/hu/categories/")) return `${STOREFRONT_ROUTES.hu.categories}/${pathname.slice("/hu/categories/".length)}`
74
78
  if (pathname === "/hu/cart") return STOREFRONT_ROUTES.hu.cart
79
+ if (pathname.startsWith("/hu/cart/shared/")) return `${STOREFRONT_ROUTES.hu.sharedCart}/${pathname.slice("/hu/cart/shared/".length)}`
80
+ if (pathname === "/hu/cart-recovery") return STOREFRONT_ROUTES.hu.cartRecovery
75
81
  if (pathname === "/hu/checkout") return STOREFRONT_ROUTES.hu.checkout
76
82
  if (pathname === "/hu/checkout/success") return STOREFRONT_ROUTES.hu.checkoutSuccess
77
83
  if (pathname === "/hu/account") return STOREFRONT_ROUTES.hu.account
@@ -79,6 +85,7 @@ function legacyRedirect(pathname: string, locale: StorefrontLocale) {
79
85
  if (pathname.startsWith("/hu/account/orders/")) return `${STOREFRONT_ROUTES.hu.orders}/${pathname.slice("/hu/account/orders/".length)}`
80
86
  if (pathname === "/hu/reset-password") return STOREFRONT_ROUTES.hu.resetPassword
81
87
  if (pathname === "/hu/legal") return STOREFRONT_ROUTES.hu.legal
88
+ if (pathname === "/en/kosar-visszaallitas") return STOREFRONT_ROUTES.en.cartRecovery
82
89
 
83
90
  return null
84
91
  }
@@ -96,6 +103,10 @@ function internalRewrite(pathname: string, locale: StorefrontLocale) {
96
103
  }
97
104
 
98
105
  if (pathname === routes.cart) return "/cart"
106
+ if (pathname.startsWith(`${routes.sharedCart}/`)) {
107
+ return `/cart/shared/${pathname.slice(routes.sharedCart.length + 1)}`
108
+ }
109
+ if (pathname === routes.cartRecovery) return "/cart-recovery"
99
110
  if (pathname === routes.checkout) return "/checkout"
100
111
  if (pathname === routes.checkoutSuccess) return "/checkout/success"
101
112
  if (pathname === routes.account) return "/account"