@akinon/projectzero 1.126.20-v1-rc.17 → 1.126.20

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 (80) hide show
  1. package/CHANGELOG.md +1 -5
  2. package/app-template/.env.example +6 -0
  3. package/app-template/CHANGELOG.md +39 -35
  4. package/app-template/package.json +29 -28
  5. package/app-template/public/locales/en/checkout.json +50 -0
  6. package/app-template/public/locales/tr/checkout.json +50 -0
  7. package/app-template/src/app/[pz]/account/(dashboard)/layout.tsx +20 -0
  8. package/app-template/src/app/[pz]/account/account-page-slot.tsx +35 -0
  9. package/app-template/src/app/[pz]/account/address/layout.tsx +18 -0
  10. package/app-template/src/app/[pz]/account/change-email/layout.tsx +18 -0
  11. package/app-template/src/app/[pz]/account/change-password/layout.tsx +18 -0
  12. package/app-template/src/app/[pz]/account/contact/layout.tsx +18 -0
  13. package/app-template/src/app/[pz]/account/coupons/layout.tsx +18 -0
  14. package/app-template/src/app/[pz]/account/faq/layout.tsx +14 -0
  15. package/app-template/src/app/[pz]/account/favourite-products/layout.tsx +21 -0
  16. package/app-template/src/app/[pz]/account/layout.tsx +36 -3
  17. package/app-template/src/app/[pz]/account/orders/(list)/layout.tsx +20 -0
  18. package/app-template/src/app/[pz]/account/orders/[id]/(detail)/layout.tsx +40 -0
  19. package/app-template/src/app/[pz]/account/profile/layout.tsx +18 -0
  20. package/app-template/src/app/[pz]/auth/(login)/layout.tsx +37 -0
  21. package/app-template/src/app/[pz]/basket/layout.tsx +25 -0
  22. package/app-template/src/app/[pz]/client-root.tsx +2 -0
  23. package/app-template/src/app/[pz]/configure-page-context.ts +17 -0
  24. package/app-template/src/app/[pz]/layout.tsx +22 -3
  25. package/app-template/src/app/[pz]/orders/checkout/layout.tsx +47 -0
  26. package/app-template/src/app/[pz]/orders/checkout/page.tsx +75 -97
  27. package/app-template/src/app/[pz]/orders/completed/[token]/layout.tsx +24 -2
  28. package/app-template/src/app/[pz]/users/password/reset/layout.tsx +21 -0
  29. package/app-template/src/app/[pz]/users/reset/[[...id]]/layout.tsx +30 -0
  30. package/app-template/src/components/checkbox.tsx +22 -3
  31. package/app-template/src/components/route-handler.tsx +48 -0
  32. package/app-template/src/routes/index.ts +6 -6
  33. package/app-template/src/views/checkout/__tests__/part-style-reachability.test.ts +119 -0
  34. package/app-template/src/views/checkout/step-button.tsx +13 -2
  35. package/app-template/src/views/checkout/step-list.tsx +5 -1
  36. package/app-template/src/views/checkout/steps/payment/agreements.tsx +9 -1
  37. package/app-template/src/views/checkout/steps/payment/index.tsx +10 -2
  38. package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +2 -0
  39. package/app-template/src/views/checkout/steps/payment/options/funds-transfer.tsx +2 -0
  40. package/app-template/src/views/checkout/steps/payment/payment-header.tsx +5 -1
  41. package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +16 -4
  42. package/app-template/src/views/checkout/steps/shipping/addresses.tsx +2 -1
  43. package/app-template/src/views/checkout/steps/shipping/index.tsx +2 -0
  44. package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +2 -0
  45. package/app-template/src/views/checkout/summary.tsx +56 -18
  46. package/app-template/src/views/checkout/variants/__tests__/registry.test.tsx +82 -0
  47. package/app-template/src/views/checkout/variants/__tests__/use-resolved-config.test.tsx +208 -0
  48. package/app-template/src/views/checkout/variants/basket-and-checkout/basket-section.tsx +150 -0
  49. package/app-template/src/views/checkout/variants/basket-and-checkout/index.tsx +135 -0
  50. package/app-template/src/views/checkout/variants/multi-step/index.tsx +78 -0
  51. package/app-template/src/views/checkout/variants/one-page/accordion-section.tsx +165 -0
  52. package/app-template/src/views/checkout/variants/one-page/hooks/use-checkout-funnel-gtm.ts +60 -0
  53. package/app-template/src/views/checkout/variants/one-page/hooks/use-section-state.ts +103 -0
  54. package/app-template/src/views/checkout/variants/one-page/index.tsx +125 -0
  55. package/app-template/src/views/checkout/variants/one-page/mobile-summary-sheet.tsx +109 -0
  56. package/app-template/src/views/checkout/variants/one-page/one-page-summary.tsx +301 -0
  57. package/app-template/src/views/checkout/variants/one-page/payment-options-grid.tsx +220 -0
  58. package/app-template/src/views/checkout/variants/one-page/sections/address-section.tsx +320 -0
  59. package/app-template/src/views/checkout/variants/one-page/sections/contact-section.tsx +62 -0
  60. package/app-template/src/views/checkout/variants/one-page/sections/payment-section.tsx +73 -0
  61. package/app-template/src/views/checkout/variants/one-page/sections/shipping-section.tsx +328 -0
  62. package/app-template/src/views/checkout/variants/one-page/skeletons/address-skeleton.tsx +25 -0
  63. package/app-template/src/views/checkout/variants/one-page/skeletons/checkout-skeleton.tsx +27 -0
  64. package/app-template/src/views/checkout/variants/one-page/skeletons/index.ts +6 -0
  65. package/app-template/src/views/checkout/variants/one-page/skeletons/payment-skeleton.tsx +23 -0
  66. package/app-template/src/views/checkout/variants/one-page/skeletons/section-skeleton.tsx +47 -0
  67. package/app-template/src/views/checkout/variants/one-page/skeletons/shipping-skeleton.tsx +20 -0
  68. package/app-template/src/views/checkout/variants/one-page/skeletons/summary-skeleton.tsx +38 -0
  69. package/app-template/src/views/checkout/variants/one-page/trust-badges.tsx +35 -0
  70. package/app-template/src/views/checkout/variants/registry.ts +43 -0
  71. package/app-template/src/views/checkout/variants/types.ts +30 -0
  72. package/app-template/src/views/checkout/variants/use-resolved-config.ts +168 -0
  73. package/app-template/tailwind.config.js +3 -1
  74. package/dist/commands/plugins.js +23 -2
  75. package/package.json +1 -1
  76. package/app-template/src/app/[pz]/account/orders/[id]/layout.tsx +0 -5
  77. /package/app-template/src/app/[pz]/account/{page.tsx → (dashboard)/page.tsx} +0 -0
  78. /package/app-template/src/app/[pz]/account/orders/{page.tsx → (list)/page.tsx} +0 -0
  79. /package/app-template/src/app/[pz]/account/orders/[id]/{page.tsx → (detail)/page.tsx} +0 -0
  80. /package/app-template/src/app/[pz]/auth/{page.tsx → (login)/page.tsx} +0 -0
@@ -0,0 +1,37 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
3
+
4
+ /**
5
+ * The login screen is handed to the theme editor here rather than in page.tsx,
6
+ * because the slot is an async server component and the page is a client one.
7
+ * With no composition published the slot renders the page untouched.
8
+ *
9
+ * The slot lives in a `(login)` route group so the composition covers exactly
10
+ * this screen: `auth/oauth-login` is a provider callback, and a login body
11
+ * mounted one level up would replace it too.
12
+ *
13
+ * No `pageContext`: an auth screen fetches no commerce data, and the blocks a
14
+ * designer rebuilds it from (`auth-form`, `register-form`, `oauth-buttons`)
15
+ * read the session client-side.
16
+ *
17
+ * Login and register stay on this ONE screen. Whether they read as tabs or as
18
+ * two forms side by side is composed here (the starter templates ship both
19
+ * shapes), so no second route is involved.
20
+ */
21
+ export default function LoginLayout({
22
+ children
23
+ }: {
24
+ children: React.ReactNode;
25
+ }) {
26
+ return (
27
+ // `contents` on both wrappers keeps the slot chain layout-transparent, so
28
+ // an uncomposed login page keeps its own box model even where a brand's
29
+ // <main> is a flex or grid container.
30
+ <ChromeSlot
31
+ slug={PLACEHOLDER_SLUGS.auth}
32
+ fallback={children}
33
+ className="contents"
34
+ fallbackClassName="contents"
35
+ />
36
+ );
37
+ }
@@ -0,0 +1,25 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { LiveBasketPageContext } from '@akinon/pz-theme/src/chrome/live-basket-page-context';
3
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
4
+ import { ROUTES } from '@theme/routes';
5
+
6
+ /**
7
+ * The basket body is handed to the theme editor here rather than in page.tsx,
8
+ * because the slot is an async server component and the page is a client one.
9
+ * With no composition published the slot renders the page untouched.
10
+ *
11
+ * The provider sits above the slot so the composition binds the shopper's live
12
+ * basket: the basket is session-scoped and has no server data module, so a
13
+ * server-built context would be a snapshot that never moves.
14
+ */
15
+ export default function BasketLayout({
16
+ children
17
+ }: {
18
+ children: React.ReactNode;
19
+ }) {
20
+ return (
21
+ <LiveBasketPageContext path={ROUTES.BASKET}>
22
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.basket} fallback={children} />
23
+ </LiveBasketPageContext>
24
+ );
25
+ }
@@ -1,5 +1,7 @@
1
1
  'use client';
2
2
 
3
+ import './configure-page-context';
4
+
3
5
  export default function ClientRoot({
4
6
  children
5
7
  }: {
@@ -0,0 +1,17 @@
1
+ import { configurePageContextRoutes } from '@akinon/pz-theme/src/chrome/page-context';
2
+ import { ROUTES, ORDER_ROUTES, ACCOUNT_ROUTES } from '@theme/routes';
3
+
4
+ /**
5
+ * The packaged page-context builders default to `/basket`; this storefront
6
+ * routes it at `/baskets/basket`. Without this the published context would
7
+ * carry a basket path no link block could follow.
8
+ *
9
+ * Imported from BOTH the server layout and the client root: the routes live in
10
+ * module state, and the client bundle gets its own copy of that module.
11
+ */
12
+ configurePageContextRoutes({
13
+ home: ROUTES.HOME,
14
+ basket: ROUTES.BASKET,
15
+ checkout: ORDER_ROUTES.CHECKOUT,
16
+ account: ACCOUNT_ROUTES.ACCOUNT
17
+ });
@@ -16,6 +16,12 @@ import { PREVIEW_PZ_SEGMENT } from '@akinon/next/utils/preview';
16
16
  import { isDraftRender } from '@akinon/next/utils/preview-render';
17
17
  import { parsePzParams } from '@akinon/next/utils/pz-segments';
18
18
  import settings from '@theme/settings';
19
+ import RouteHandler from '@theme/components/route-handler';
20
+ import { PreviewAuthStateReporter } from '@akinon/pz-theme/src/chrome/preview-auth-state';
21
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
22
+ import ThemeModals from '@akinon/pz-theme/src/overlays/theme-modals';
23
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
24
+ import './configure-page-context';
19
25
 
20
26
  export const viewport: Viewport = {
21
27
  width: 'device-width',
@@ -75,18 +81,31 @@ async function RootLayout({
75
81
  )}
76
82
  <PzRoot translations={translations} locale={locale.value}>
77
83
  <ClientRoot>
78
- <div className="overflow-x-hidden">
84
+ <div className="overflow-x-clip">
79
85
  <MobileAppToggler>
80
- <Header />
86
+ <ChromeSlot
87
+ slug={PLACEHOLDER_SLUGS.header}
88
+ fallback={<Header />}
89
+ />
81
90
  </MobileAppToggler>
82
91
  <main>
83
92
  {children}
93
+ <RouteHandler />
94
+ <PreviewAuthStateReporter />
84
95
  <RootModal />
85
96
  </main>
86
97
  <MobileAppToggler>
87
- <Footer />
98
+ <ChromeSlot
99
+ slug={PLACEHOLDER_SLUGS.footer}
100
+ fallback={<Footer />}
101
+ />
88
102
  </MobileAppToggler>
89
103
  </div>
104
+ {/* Outside the clipping wrapper above: a composed modal is a fixed
105
+ layer over the whole page, and it belongs to the layout rather
106
+ than to any one route because its trigger may be in the header
107
+ on a page it never appears on. */}
108
+ <ThemeModals />
90
109
  </ClientRoot>
91
110
  </PzRoot>
92
111
  </body>
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
3
+ import ComposableRegion from '@akinon/pz-theme/src/chrome/composable-region';
4
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
5
+ import { LiveCheckoutPageContext } from '@akinon/pz-theme/src/chrome/live-checkout-page-context';
6
+ import { CheckoutPiecesProvider } from '@akinon/pz-theme/src/chrome/checkout-pieces-provider';
7
+
8
+ /**
9
+ * Checkout internals are sealed, checkout placement is composable. The body
10
+ * slot's composition positions the real flow, steps and summary through
11
+ * checkout outlet blocks; the flow itself always renders — in an outlet when
12
+ * one claims it, in its default place below otherwise. No slot takes the
13
+ * flow as its fallback: a composition may move the payment steps, never
14
+ * replace them. Ordering is load-bearing: the body slot mounts BEFORE
15
+ * `children`, so outlet targets register before the flow's first paint.
16
+ *
17
+ * The body's takeover is offered on the flow itself, by the region wrapping
18
+ * it: the designer hovers the real checkout content and gets the same
19
+ * affordance every other page has, instead of a dashed band above content
20
+ * that answers a hover with nothing. Starting a composition that way is why
21
+ * the body slot's own band is suppressed — one slug, one CTA.
22
+ */
23
+ export default function CheckoutLayout({
24
+ children
25
+ }: {
26
+ children: React.ReactNode;
27
+ }) {
28
+ return (
29
+ <LiveCheckoutPageContext>
30
+ <CheckoutPiecesProvider>
31
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.checkoutTop} />
32
+ <ChromeSlot
33
+ slug={PLACEHOLDER_SLUGS.checkoutBody}
34
+ emptyZoneBand={false}
35
+ />
36
+ <ComposableRegion
37
+ slug={PLACEHOLDER_SLUGS.checkoutBody}
38
+ label="The checkout flow stays code-owned — take this area over to arrange where the flow, steps and summary render"
39
+ composedNote="The checkout flow renders here until a checkout flow outlet places it — it stays code-owned and inert on the canvas"
40
+ >
41
+ {children}
42
+ </ComposableRegion>
43
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.checkoutBottom} />
44
+ </CheckoutPiecesProvider>
45
+ </LiveCheckoutPageContext>
46
+ );
47
+ }
@@ -1,66 +1,55 @@
1
1
  'use client';
2
2
 
3
- import { CheckoutStepList, Summary } from '@theme/views/checkout';
4
- import PaymentStep from '@theme/views/checkout/steps/payment';
5
- import ShippingStep from '@theme/views/checkout/steps/shipping';
6
- import { useEffect, useMemo, useRef } from 'react';
7
- import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
3
+ import { useEffect, useMemo, type ReactNode } from 'react';
4
+ import dynamic from 'next/dynamic';
5
+ import { CheckoutPiece } from '@akinon/pz-theme/src/chrome/checkout-piece';
6
+ import { isThemeEditorDesigner } from '@akinon/pz-theme/src/chrome/checkout-pieces';
7
+ import { useAppDispatch } from '@akinon/next/redux/hooks';
8
+ import { resetCheckoutState } from '@akinon/next/redux/reducers/checkout';
8
9
  import {
9
- resetCheckoutState,
10
- setCurrentStep
11
- } from '@akinon/next/redux/reducers/checkout';
12
- import { RootState } from '@theme/redux/store';
13
- import { ROUTES } from '@theme/routes';
14
- import { useFetchCheckoutQuery, useResetCheckoutStateQuery } from '@akinon/next/data/client/checkout';
15
- import { Button, LoaderSpinner } from '@theme/components';
16
- import { pushAddPaymentInfo, pushAddShippingInfo } from '@theme/utils/gtm';
17
- import { CheckoutStep } from '@akinon/next/types';
10
+ useFetchCheckoutQuery,
11
+ useResetCheckoutStateQuery
12
+ } from '@akinon/next/data/client/checkout';
18
13
  import { useRouter, useLocalization } from '@akinon/next/hooks';
19
- import dynamic from 'next/dynamic';
20
- import PluginModule, { Component } from '@akinon/next/components/plugin-module';
14
+ import { Button, LoaderSpinner } from '@theme/components';
15
+ import { ROUTES } from '@theme/routes';
16
+ import settings from '@theme/settings';
17
+ import {
18
+ getCheckoutVariant,
19
+ UNIFIED_VARIANTS
20
+ } from '@theme/views/checkout/variants/registry';
21
+ import { CheckoutOnePageSkeleton } from '@theme/views/checkout/variants/one-page/skeletons';
22
+ import { useResolvedCheckoutConfig } from '@theme/views/checkout/variants/use-resolved-config';
21
23
 
22
24
  const Checkout = () => {
23
25
  const { t } = useLocalization();
24
- const { steps, preOrder } = useAppSelector(
25
- (state: RootState) => state.checkout
26
- );
26
+ const router = useRouter();
27
+ const dispatch = useAppDispatch();
27
28
 
28
- const { data: indexData, isLoading: isResetStateLoading } = useResetCheckoutStateQuery(null);
29
+ const { data: indexData, isLoading: isResetStateLoading } =
30
+ useResetCheckoutStateQuery(null);
29
31
 
30
32
  const {
31
33
  data: checkoutData,
32
- isFetching,
34
+ isLoading: isCheckoutLoading,
33
35
  isError,
34
- isSuccess,
35
36
  refetch: refetchCheckout
36
37
  } = useFetchCheckoutQuery(null, {
37
38
  refetchOnMountOrArgChange: true,
38
39
  skip: isResetStateLoading || !indexData
39
40
  });
40
- const initialStepChanged = useRef<boolean>(false);
41
- const router = useRouter();
42
- const dispatch = useAppDispatch();
41
+
42
+ const { variantId, options: variantOptions } = useResolvedCheckoutConfig();
43
43
 
44
44
  const CheckoutAuth = useMemo(
45
- () =>
46
- dynamic(() => {
47
- return import('@theme/views/checkout/auth');
48
- }),
45
+ () => dynamic(() => import('@theme/views/checkout/auth')),
49
46
  []
50
47
  );
51
48
 
52
- useEffect(() => {
53
- if (steps.shipping.completed && !initialStepChanged.current) {
54
- dispatch(setCurrentStep(CheckoutStep.Payment));
55
- initialStepChanged.current = true;
56
- }
57
- }, [steps.shipping.completed]); // eslint-disable-line react-hooks/exhaustive-deps
58
-
59
- useEffect(() => {
60
- if (preOrder && !preOrder.shipping_option) {
61
- initialStepChanged.current = true;
62
- }
63
- }, [preOrder]);
49
+ const CheckoutVariant = useMemo(
50
+ () => getCheckoutVariant(variantId),
51
+ [variantId]
52
+ );
64
53
 
65
54
  useEffect(() => {
66
55
  return () => {
@@ -68,76 +57,65 @@ const Checkout = () => {
68
57
  };
69
58
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
70
59
 
71
- useEffect(() => {
72
- if (isSuccess) {
73
- const products = checkoutData?.pre_order?.basket?.basketitem_set.map(
74
- (basketItem) => ({
75
- ...basketItem.product
76
- })
77
- );
78
- if (steps.current === 'shipping') {
79
- pushAddShippingInfo(products);
80
- }
81
- if (steps.current === 'payment') {
82
- pushAddPaymentInfo(products, String(preOrder?.payment_option?.name));
83
- }
84
- }
85
- }, [isSuccess, steps, checkoutData, preOrder?.payment_option?.name]);
86
-
87
- if (checkoutData?.redirect_url?.includes('basket')) {
60
+ // In unified mode the basket lives inside the checkout page and the basket
61
+ // page auto-redirects here while it has items — following the backend's
62
+ // basket redirect would bounce between the two pages forever. Check the
63
+ // settings.js baseline as well, since the basket page redirects based on it
64
+ // even when the async theme-settings override resolves to another variant.
65
+ const baselineVariant = (settings as { checkout?: { variant?: string } })
66
+ ?.checkout?.variant;
67
+ const isUnifiedCheckout =
68
+ UNIFIED_VARIANTS.has(variantId) ||
69
+ UNIFIED_VARIANTS.has(baselineVariant ?? '');
70
+
71
+ // The designer canvas edits the checkout page itself — an empty test basket
72
+ // must never navigate the iframe to the basket page, or the composition
73
+ // being authored disappears mid-edit. Live keeps the redirect untouched.
74
+ if (
75
+ !isUnifiedCheckout &&
76
+ checkoutData?.redirect_url?.includes('basket') &&
77
+ !isThemeEditorDesigner()
78
+ ) {
88
79
  router.push(ROUTES.BASKET);
89
80
  return null;
90
81
  }
91
82
 
83
+ // One stable CheckoutPiece instance hosts every gate below: the latch runs
84
+ // once, and the loading-to-variant transition is a child swap under the same
85
+ // (possibly portaled) position — no remounts mid-session.
86
+ let body: ReactNode;
87
+
92
88
  if (checkoutData?.template_name === 'orders/index.html') {
93
- return (
89
+ body = (
94
90
  <section className="container px-4 my-7 md:mt-20 lg:px-0 lg:mx-auto">
95
91
  <CheckoutAuth />
96
92
  </section>
97
93
  );
98
- }
99
-
100
- if (isResetStateLoading || isFetching || isError) {
101
- return (
94
+ } else if (isError) {
95
+ body = (
102
96
  <div className="flex flex-col items-center justify-center h-80">
103
- {isResetStateLoading || isFetching ? (
104
- <LoaderSpinner />
105
- ) : (
106
- <>
107
- <div>{t('checkout.error.title')}</div>
108
- <div className="mt-5">
109
- <Button onClick={refetchCheckout}>
110
- {t('checkout.error.button')}
111
- </Button>
112
- </div>
113
- </>
114
- )}
97
+ <div>{t('checkout.error.title')}</div>
98
+ <div className="mt-5">
99
+ <Button onClick={refetchCheckout}>
100
+ {t('checkout.error.button')}
101
+ </Button>
102
+ </div>
115
103
  </div>
116
104
  );
105
+ } else if (isResetStateLoading || isCheckoutLoading) {
106
+ body =
107
+ variantId === 'multi-step' ? (
108
+ <div className="flex flex-col items-center justify-center h-80">
109
+ <LoaderSpinner />
110
+ </div>
111
+ ) : (
112
+ <CheckoutOnePageSkeleton />
113
+ );
114
+ } else {
115
+ body = <CheckoutVariant options={variantOptions} />;
117
116
  }
118
117
 
119
- return (
120
- <PluginModule component={Component.MasterpassProvider}>
121
- <PluginModule component={Component.MasterpassDeleteConfirmationModal} />
122
- <PluginModule component={Component.MasterpassOtpModal} />
123
- <PluginModule component={Component.MasterpassLinkModal} />
124
-
125
- <div className="container flex flex-col flex-wrap w-full px-4 md:px-0">
126
- <CheckoutStepList />
127
-
128
- <div className="w-full flex flex-wrap">
129
- <div className="w-full h-fit-content lg:w-2/3">
130
- {steps.current === CheckoutStep.Shipping && <ShippingStep />}
131
- {steps.current === CheckoutStep.Payment && <PaymentStep />}
132
- </div>
133
-
134
- <div className="w-full h-fit-content mt-6 lg:w-1/3 lg:pl-8 lg:mt-0">
135
- <Summary />
136
- </div>
137
- </div>
138
- </div>
139
- </PluginModule>
140
- );
118
+ return <CheckoutPiece piece="flow">{body}</CheckoutPiece>;
141
119
  };
142
120
 
143
121
  export default Checkout;
@@ -1,5 +1,27 @@
1
1
  import React from 'react';
2
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
3
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
4
+ import { LiveOrderSuccessPageContext } from '@akinon/pz-theme/src/chrome/live-order-page-context';
2
5
 
3
- export default function Layout({ children }: { children: React.ReactNode }) {
4
- return <div>{children}</div>;
6
+ /**
7
+ * The order-success body is composable and binds the shopper's own order.
8
+ * There is no server order fetcher, so the context comes from the client
9
+ * provider — which also keeps the order out of any cached shell.
10
+ */
11
+ export default function Layout({
12
+ children,
13
+ params
14
+ }: {
15
+ children: React.ReactNode;
16
+ params: { token: string };
17
+ }) {
18
+ const { token } = params;
19
+
20
+ return (
21
+ <div>
22
+ <LiveOrderSuccessPageContext token={token}>
23
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.orderSuccess} fallback={children} />
24
+ </LiveOrderSuccessPageContext>
25
+ </div>
26
+ );
5
27
  }
@@ -0,0 +1,21 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
3
+
4
+ /**
5
+ * The forgot-password body, handed over the same way as the login screen: the
6
+ * slot is an async server component and the page is a client one. This route
7
+ * holds a single page, so it needs no route group to keep the composition off
8
+ * a sibling screen.
9
+ *
10
+ * Brands that route it at `/auth/forgot-password` instead resolve to the same
11
+ * placeholder, so one composition serves both spellings.
12
+ */
13
+ export default function ForgotPasswordLayout({
14
+ children
15
+ }: {
16
+ children: React.ReactNode;
17
+ }) {
18
+ return (
19
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.forgotPassword} fallback={children} />
20
+ );
21
+ }
@@ -0,0 +1,30 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
3
+
4
+ /**
5
+ * The screen the reset MAIL lands on, handed to the editor the same way its
6
+ * two neighbours already are: the slot is an async server component and the
7
+ * page is a client one, so the handover lives in the layout.
8
+ *
9
+ * A different page from the one that ASKS for the mail — that is
10
+ * `users/password/reset` — and the last auth screen a brand could not compose:
11
+ * `reset-password-body` was a slug the editor offered and nothing mounted, so a
12
+ * designer could build the screen, publish it, and the shopper coming out of
13
+ * their inbox still met the hand-written page.
14
+ *
15
+ * The token stays in the URL either way: this route's catch-all carries it, and
16
+ * `reset-password-block` reads it back out of the segments (a token containing
17
+ * slashes is joined, which a single segment would get wrong).
18
+ *
19
+ * With no composition published the slot renders the page untouched, so this
20
+ * changes nothing until a brand composes the screen.
21
+ */
22
+ export default function ResetPasswordLayout({
23
+ children
24
+ }: {
25
+ children: React.ReactNode;
26
+ }) {
27
+ return (
28
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.resetPassword} fallback={children} />
29
+ );
30
+ }
@@ -3,10 +3,29 @@ import { CheckboxProps } from '@theme/components/types';
3
3
  import { twMerge } from 'tailwind-merge';
4
4
 
5
5
  const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
6
- const { children, checked = false, error, ...rest } = props;
6
+ // Part styling names the ROW, not the native box: when a caller stamps a
7
+ // checkbox (see `partAttrs`), the attributes ride the label wrapper so the
8
+ // whole line — box, text, links, spacing — is restylable, and the input
9
+ // keeps every other prop it has today. No caller that omits them is
10
+ // affected: both values are simply undefined and React drops them.
11
+ const {
12
+ children,
13
+ checked = false,
14
+ error,
15
+ 'data-part': partName,
16
+ 'data-state': partState,
17
+ ...rest
18
+ } = props as CheckboxProps & {
19
+ 'data-part'?: string;
20
+ 'data-state'?: string;
21
+ };
7
22
 
8
23
  return (
9
- <label className={twMerge('flex flex-col text-xs', props.className)}>
24
+ <label
25
+ className={twMerge('flex flex-col text-xs', props.className)}
26
+ data-part={partName}
27
+ data-state={partState}
28
+ >
10
29
  <div className="flex items-center">
11
30
  <input
12
31
  data-testid="checkbox"
@@ -19,7 +38,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
19
38
  {children && <span className="ml-2">{children}</span>}
20
39
  </div>
21
40
  {error && (
22
- <span className="mt-1 text-sm text-error">{error.message}</span>
41
+ <span className="mt-1 text-sm text-error">{String(error.message)}</span>
23
42
  )}
24
43
  </label>
25
44
  );
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+
3
+ import { useEffect } from 'react';
4
+ import {
5
+ usePathname,
6
+ useSearchParams,
7
+ useSelectedLayoutSegment
8
+ } from 'next/navigation';
9
+
10
+ import { postToEditor } from '@akinon/pz-theme/src/editor-bridge';
11
+ const RouteHandler = () => {
12
+ const pathname = usePathname();
13
+ const searchParams = useSearchParams();
14
+ const layoutSegment = useSelectedLayoutSegment();
15
+
16
+ useEffect(() => {
17
+ postToEditor({
18
+ type: 'ROUTE_CHANGE_COMPLETE',
19
+ url: `${pathname}?${searchParams}`,
20
+ layoutSegment: layoutSegment === null ? 'home' : layoutSegment
21
+ });
22
+ }, [pathname, searchParams]);
23
+
24
+ useEffect(() => {
25
+ const handleClick = (e: MouseEvent) => {
26
+ const target = e.target as HTMLElement;
27
+ const anchor = target.closest('a[href]');
28
+
29
+ if (anchor) {
30
+ const isMenuToggle =
31
+ anchor.getAttribute('data-is-menu-toggle') === 'true';
32
+ if (!isMenuToggle) {
33
+ postToEditor({
34
+ type: 'ROUTE_CHANGE_START',
35
+ url: anchor.getAttribute('href')
36
+ });
37
+ }
38
+ }
39
+ };
40
+
41
+ document.addEventListener('click', handleClick);
42
+ return () => document.removeEventListener('click', handleClick);
43
+ }, []);
44
+
45
+ return null;
46
+ };
47
+
48
+ export default RouteHandler;
@@ -1,17 +1,17 @@
1
- enum GENERAL_ROUTES {
1
+ export enum GENERAL_ROUTES {
2
2
  HOME = '/',
3
3
  BASKET = '/baskets/basket',
4
4
  LIST = '/list'
5
5
  }
6
6
 
7
- enum AUTH_ROUTES {
7
+ export enum AUTH_ROUTES {
8
8
  AUTH = '/users/auth',
9
9
  FORGOT_PASSWORD = '/users/password/reset',
10
10
  EMAIL_SET_PRIMARY = '/users/email-set-primary/.+',
11
11
  CONFIRM_EMAIL = '/users/registration/account-confirm-email/.+'
12
12
  }
13
13
 
14
- enum ACCOUNT_ROUTES {
14
+ export enum ACCOUNT_ROUTES {
15
15
  ACCOUNT = '/account',
16
16
  ACCOUNT_ADDRESS = '/account/address',
17
17
  ACCOUNT_CHANGE_EMAIL = '/account/change-email',
@@ -25,17 +25,17 @@ enum ACCOUNT_ROUTES {
25
25
  ANONYMOUS_TRACKING = '/anonymous-tracking'
26
26
  }
27
27
 
28
- enum ORDER_ROUTES {
28
+ export enum ORDER_ROUTES {
29
29
  CHECKOUT = '/orders/checkout',
30
30
  CHECKOUT_COMPLETED = '/orders/completed',
31
31
  PAYMENT_GATEWAY_HASO = '/payment-gateway/haso'
32
32
  }
33
33
 
34
- enum FLATPAGE_ROUTES {
34
+ export enum FLATPAGE_ROUTES {
35
35
  CONTACT_US = '/contact-us'
36
36
  }
37
37
 
38
- enum PRODUCT_ROUTES {}
38
+ export enum PRODUCT_ROUTES {}
39
39
 
40
40
  export const ROUTES = {
41
41
  ...GENERAL_ROUTES,