@akinon/projectzero 1.126.19 → 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.
- package/CHANGELOG.md +2 -0
- package/app-template/.env.example +6 -0
- package/app-template/CHANGELOG.md +40 -0
- package/app-template/package.json +29 -28
- package/app-template/public/locales/en/checkout.json +50 -0
- package/app-template/public/locales/tr/checkout.json +50 -0
- package/app-template/src/app/[pz]/account/(dashboard)/layout.tsx +20 -0
- package/app-template/src/app/[pz]/account/account-page-slot.tsx +35 -0
- package/app-template/src/app/[pz]/account/address/layout.tsx +18 -0
- package/app-template/src/app/[pz]/account/change-email/layout.tsx +18 -0
- package/app-template/src/app/[pz]/account/change-password/layout.tsx +18 -0
- package/app-template/src/app/[pz]/account/contact/layout.tsx +18 -0
- package/app-template/src/app/[pz]/account/coupons/layout.tsx +18 -0
- package/app-template/src/app/[pz]/account/faq/layout.tsx +14 -0
- package/app-template/src/app/[pz]/account/favourite-products/layout.tsx +21 -0
- package/app-template/src/app/[pz]/account/layout.tsx +36 -3
- package/app-template/src/app/[pz]/account/orders/(list)/layout.tsx +20 -0
- package/app-template/src/app/[pz]/account/orders/[id]/(detail)/layout.tsx +40 -0
- package/app-template/src/app/[pz]/account/profile/layout.tsx +18 -0
- package/app-template/src/app/[pz]/auth/(login)/layout.tsx +37 -0
- package/app-template/src/app/[pz]/basket/layout.tsx +25 -0
- package/app-template/src/app/[pz]/client-root.tsx +2 -0
- package/app-template/src/app/[pz]/configure-page-context.ts +17 -0
- package/app-template/src/app/[pz]/layout.tsx +22 -3
- package/app-template/src/app/[pz]/orders/checkout/layout.tsx +47 -0
- package/app-template/src/app/[pz]/orders/checkout/page.tsx +75 -97
- package/app-template/src/app/[pz]/orders/completed/[token]/layout.tsx +24 -2
- package/app-template/src/app/[pz]/users/password/reset/layout.tsx +21 -0
- package/app-template/src/app/[pz]/users/reset/[[...id]]/layout.tsx +30 -0
- package/app-template/src/components/checkbox.tsx +22 -3
- package/app-template/src/components/route-handler.tsx +48 -0
- package/app-template/src/routes/index.ts +6 -6
- package/app-template/src/views/checkout/__tests__/part-style-reachability.test.ts +119 -0
- package/app-template/src/views/checkout/step-button.tsx +13 -2
- package/app-template/src/views/checkout/step-list.tsx +5 -1
- package/app-template/src/views/checkout/steps/payment/agreements.tsx +9 -1
- package/app-template/src/views/checkout/steps/payment/index.tsx +10 -2
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +2 -0
- package/app-template/src/views/checkout/steps/payment/options/funds-transfer.tsx +2 -0
- package/app-template/src/views/checkout/steps/payment/payment-header.tsx +5 -1
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +16 -4
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +2 -1
- package/app-template/src/views/checkout/steps/shipping/index.tsx +2 -0
- package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +2 -0
- package/app-template/src/views/checkout/summary.tsx +56 -18
- package/app-template/src/views/checkout/variants/__tests__/registry.test.tsx +82 -0
- package/app-template/src/views/checkout/variants/__tests__/use-resolved-config.test.tsx +208 -0
- package/app-template/src/views/checkout/variants/basket-and-checkout/basket-section.tsx +150 -0
- package/app-template/src/views/checkout/variants/basket-and-checkout/index.tsx +135 -0
- package/app-template/src/views/checkout/variants/multi-step/index.tsx +78 -0
- package/app-template/src/views/checkout/variants/one-page/accordion-section.tsx +165 -0
- package/app-template/src/views/checkout/variants/one-page/hooks/use-checkout-funnel-gtm.ts +60 -0
- package/app-template/src/views/checkout/variants/one-page/hooks/use-section-state.ts +103 -0
- package/app-template/src/views/checkout/variants/one-page/index.tsx +125 -0
- package/app-template/src/views/checkout/variants/one-page/mobile-summary-sheet.tsx +109 -0
- package/app-template/src/views/checkout/variants/one-page/one-page-summary.tsx +301 -0
- package/app-template/src/views/checkout/variants/one-page/payment-options-grid.tsx +220 -0
- package/app-template/src/views/checkout/variants/one-page/sections/address-section.tsx +320 -0
- package/app-template/src/views/checkout/variants/one-page/sections/contact-section.tsx +62 -0
- package/app-template/src/views/checkout/variants/one-page/sections/payment-section.tsx +73 -0
- package/app-template/src/views/checkout/variants/one-page/sections/shipping-section.tsx +328 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/address-skeleton.tsx +25 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/checkout-skeleton.tsx +27 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/index.ts +6 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/payment-skeleton.tsx +23 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/section-skeleton.tsx +47 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/shipping-skeleton.tsx +20 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/summary-skeleton.tsx +38 -0
- package/app-template/src/views/checkout/variants/one-page/trust-badges.tsx +35 -0
- package/app-template/src/views/checkout/variants/registry.ts +43 -0
- package/app-template/src/views/checkout/variants/types.ts +30 -0
- package/app-template/src/views/checkout/variants/use-resolved-config.ts +168 -0
- package/app-template/tailwind.config.js +3 -1
- package/dist/commands/plugins.js +23 -2
- package/package.json +1 -1
- package/app-template/src/app/[pz]/account/orders/[id]/layout.tsx +0 -5
- /package/app-template/src/app/[pz]/account/{page.tsx → (dashboard)/page.tsx} +0 -0
- /package/app-template/src/app/[pz]/account/orders/{page.tsx → (list)/page.tsx} +0 -0
- /package/app-template/src/app/[pz]/account/orders/[id]/{page.tsx → (detail)/page.tsx} +0 -0
- /package/app-template/src/app/[pz]/auth/{page.tsx → (login)/page.tsx} +0 -0
|
@@ -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-
|
|
84
|
+
<div className="overflow-x-clip">
|
|
79
85
|
<MobileAppToggler>
|
|
80
|
-
<
|
|
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
|
-
<
|
|
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 {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { useAppDispatch
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
} from '@akinon/next/
|
|
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
|
|
20
|
-
import
|
|
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
|
|
25
|
-
|
|
26
|
-
);
|
|
26
|
+
const router = useRouter();
|
|
27
|
+
const dispatch = useAppDispatch();
|
|
27
28
|
|
|
28
|
-
const { data: indexData, isLoading: isResetStateLoading } =
|
|
29
|
+
const { data: indexData, isLoading: isResetStateLoading } =
|
|
30
|
+
useResetCheckoutStateQuery(null);
|
|
29
31
|
|
|
30
32
|
const {
|
|
31
33
|
data: checkoutData,
|
|
32
|
-
|
|
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
|
-
|
|
41
|
-
const
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Part styling only works by INHERITANCE, and inheritance loses to any
|
|
6
|
+
* declaration on the element itself.
|
|
7
|
+
*
|
|
8
|
+
* A checkout part rule lands on the element the part is stamped on:
|
|
9
|
+
*
|
|
10
|
+
* [data-block-id="…"] [data-part="payment-option"] { color: #fff !important }
|
|
11
|
+
*
|
|
12
|
+
* If the text inside that element sits in a child that declares its own
|
|
13
|
+
* `text-…` colour, size or weight, the inherited value never reaches it —
|
|
14
|
+
* `!important` does not help, because the child is not competing for the same
|
|
15
|
+
* declaration, it simply has one of its own. Every typography control the
|
|
16
|
+
* panel offers for that part is then a silent no-op: the designer sets Text
|
|
17
|
+
* Color to white, nothing moves, and there is no error to explain it.
|
|
18
|
+
*
|
|
19
|
+
* That is exactly how a starter template painted a near-black selected
|
|
20
|
+
* payment card behind a near-black method name (contrast ≈ 1:1), and how
|
|
21
|
+
* "Font Weight" on the grand total row did nothing.
|
|
22
|
+
*
|
|
23
|
+
* The rule this file locks: on these elements the typography lives on the
|
|
24
|
+
* STAMPED element, and a child either carries none of its own or is a part in
|
|
25
|
+
* its own right. Where two children genuinely differ (a totals row's label and
|
|
26
|
+
* its amount), each gets its own part instead of the row pretending to control
|
|
27
|
+
* both.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const checkoutDir = path.resolve(__dirname, '..');
|
|
31
|
+
|
|
32
|
+
const read = (relative: string): string =>
|
|
33
|
+
fs.readFileSync(path.join(checkoutDir, relative), 'utf8');
|
|
34
|
+
|
|
35
|
+
/** Utilities that would out-declare an inherited part rule. */
|
|
36
|
+
const TYPOGRAPHY_UTILITY =
|
|
37
|
+
/\btext-(?:xs|sm|base|lg|xl|\d?xl|black-\d+|gray-\d+|primary-\d+|secondary)\b|\bfont-(?:light|normal|medium|semibold|bold)\b/;
|
|
38
|
+
|
|
39
|
+
describe('one-page payment cards keep their typography on the stamped button', () => {
|
|
40
|
+
const source = read('variants/one-page/payment-options-grid.tsx');
|
|
41
|
+
|
|
42
|
+
it('declares the text styles on the button that carries the part', () => {
|
|
43
|
+
const button = source.slice(
|
|
44
|
+
source.indexOf('<button'),
|
|
45
|
+
source.indexOf('<Icon')
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(button).toContain("partAttrs('payment-option'");
|
|
49
|
+
expect(button).toMatch(/text-sm font-medium leading-tight/);
|
|
50
|
+
expect(button).toMatch(/text-black-800/);
|
|
51
|
+
expect(button).toMatch(/text-gray-700/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('leaves the method name span with layout classes only', () => {
|
|
55
|
+
expect(source).toContain('<span className="flex-1">{option.name}</span>');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('never re-colours the icon with fill utilities', () => {
|
|
59
|
+
// `Icon` renders an icon FONT, so `fill-*` coloured nothing at all; the
|
|
60
|
+
// glyph follows `color`, which now comes from the button.
|
|
61
|
+
expect(source).not.toMatch(/\bfill-(?:black|gray)-\d+\b/);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('multi-step payment options keep their typography on the stamped element', () => {
|
|
66
|
+
const source = read('steps/payment/payment-option-buttons.tsx');
|
|
67
|
+
|
|
68
|
+
it('puts the mobile row styles on the label that carries the part', () => {
|
|
69
|
+
const label = source.slice(
|
|
70
|
+
source.indexOf('<label'),
|
|
71
|
+
source.indexOf('</label>')
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(label).toContain("partAttrs('payment-option'");
|
|
75
|
+
expect(label).toMatch(/text-primary-800 font-light text-lg/);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('leaves the method name span with layout classes only', () => {
|
|
79
|
+
expect(source).toContain('<span className="flex">{option.name}</span>');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('summary rows expose their label and amount as parts', () => {
|
|
84
|
+
it.each([['variants/one-page/one-page-summary.tsx'], ['summary.tsx']])(
|
|
85
|
+
'%s stamps both cells of every totals row and the grand total',
|
|
86
|
+
(file) => {
|
|
87
|
+
const source = read(file);
|
|
88
|
+
|
|
89
|
+
for (const part of [
|
|
90
|
+
'summary-row-label',
|
|
91
|
+
'summary-row-value',
|
|
92
|
+
'summary-total-label',
|
|
93
|
+
'summary-total-value'
|
|
94
|
+
]) {
|
|
95
|
+
expect(source).toContain(`partAttrs('${part}')`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
it('gives the one-page grand total row a baseline its label can inherit', () => {
|
|
101
|
+
const source = read('variants/one-page/one-page-summary.tsx');
|
|
102
|
+
const total = source.slice(
|
|
103
|
+
source.indexOf("partAttrs('summary-total')") - 400,
|
|
104
|
+
source.indexOf("partAttrs('summary-total-value')")
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// The row owns the label's treatment; the label span declares nothing.
|
|
108
|
+
expect(total).toMatch(/text-sm font-medium uppercase/);
|
|
109
|
+
expect(total).toContain("<span {...partAttrs('summary-total-label')}>");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('keeps a stamped cell free to declare its own look', () => {
|
|
113
|
+
// The amount is allowed to differ — it answers to summary-*-value.
|
|
114
|
+
const source = read('variants/one-page/one-page-summary.tsx');
|
|
115
|
+
|
|
116
|
+
expect(source).toMatch(TYPOGRAPHY_UTILITY);
|
|
117
|
+
expect(source).toContain("partAttrs('summary-total-value')");
|
|
118
|
+
});
|
|
119
|
+
});
|