@akinon/projectzero 2.0.39-rc.0 → 2.0.39

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 (35) hide show
  1. package/CHANGELOG.md +1 -7
  2. package/app-template/.env.example +0 -1
  3. package/app-template/AGENTS.md +0 -8
  4. package/app-template/CHANGELOG.md +32 -78
  5. package/app-template/README.md +1 -25
  6. package/app-template/next.config.mjs +1 -7
  7. package/app-template/package.json +41 -41
  8. package/app-template/src/app/[pz]/account/layout.tsx +13 -2
  9. package/app-template/src/app/[pz]/account/orders/[id]/layout.tsx +26 -2
  10. package/app-template/src/app/[pz]/basket/layout.tsx +25 -0
  11. package/app-template/src/app/[pz]/category/[pk]/page.tsx +1 -1
  12. package/app-template/src/app/[pz]/client-root.tsx +2 -0
  13. package/app-template/src/app/[pz]/configure-page-context.ts +17 -0
  14. package/app-template/src/app/[pz]/flat-page/[pk]/page.tsx +14 -3
  15. package/app-template/src/app/[pz]/layout.tsx +1 -0
  16. package/app-template/src/app/[pz]/list/page.tsx +1 -1
  17. package/app-template/src/app/[pz]/orders/checkout/layout.tsx +23 -0
  18. package/app-template/src/app/[pz]/orders/completed/[token]/layout.tsx +24 -2
  19. package/app-template/src/app/[pz]/page.tsx +1 -1
  20. package/app-template/src/app/[pz]/pages/[slug]/page.tsx +1 -1
  21. package/app-template/src/app/[pz]/special-page/[pk]/page.tsx +10 -1
  22. package/app-template/src/hooks/index.ts +0 -2
  23. package/app-template/src/plugins.js +0 -1
  24. package/app-template/src/proxy.ts +1 -2
  25. package/app-template/src/views/category/layout.tsx +12 -2
  26. package/app-template/src/views/header/search/index.tsx +5 -13
  27. package/app-template/src/views/product/layout.tsx +8 -5
  28. package/app-template/src/views/product/slider.tsx +38 -85
  29. package/commands/plugins.ts +0 -4
  30. package/dist/commands/plugins.js +0 -4
  31. package/package.json +1 -1
  32. package/app-template/src/app/api/client-env/route.ts +0 -5
  33. package/app-template/src/app/global-error.tsx +0 -22
  34. package/app-template/src/utils/__tests__/theme-page-context.test.ts +0 -148
  35. package/app-template/src/utils/theme-page-context.ts +0 -309
@@ -3,11 +3,14 @@ import { BreadcrumbResultType, GetCategoryResponse } from '@akinon/next/types';
3
3
  import Breadcrumb from '@theme/views/breadcrumb';
4
4
  import { CategoryBanner } from '@theme/views/category/category-banner';
5
5
  import ListPage from '@theme/views/category/category-info';
6
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
7
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
6
8
 
7
9
  export default async function Layout({
8
10
  data,
9
11
  children,
10
- breadcrumbData
12
+ breadcrumbData,
13
+ pageContext
11
14
  }: {
12
15
  data: GetCategoryResponse;
13
16
  children?: React.ReactNode;
@@ -35,7 +38,14 @@ export default async function Layout({
35
38
  </div>
36
39
  <CategoryBanner {...data?.category?.attributes?.category_banner} />
37
40
  </div>
38
- <ListPage data={data} />
41
+ {/* The listing context was built on every request and thrown away: the
42
+ prop was declared and never read, so no listing binding has ever
43
+ resolved on any brand. */}
44
+ <ChromeSlot
45
+ slug={PLACEHOLDER_SLUGS.productListing}
46
+ fallback={<ListPage data={data} />}
47
+ pageContext={pageContext}
48
+ />
39
49
  </>
40
50
  );
41
51
  }
@@ -4,7 +4,8 @@ import { useEffect, useRef, useState } from 'react';
4
4
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
5
5
  import { closeSearch } from '@akinon/next/redux/reducers/header';
6
6
  import clsx from 'clsx';
7
- import { Icon, Input } from '@theme/components';
7
+
8
+ import { Icon } from '@theme/components';
8
9
  import Results from './results';
9
10
  import { ROUTES } from '@theme/routes';
10
11
  import { useLocalization, useRouter } from '@akinon/next/hooks';
@@ -41,14 +42,6 @@ export default function Search() {
41
42
  };
42
43
  }, [isSearchOpen, dispatch]);
43
44
 
44
- const handleSearchTextChange = (e: React.ChangeEvent<HTMLInputElement>) => {
45
- setSearchText(e.target.value);
46
- };
47
-
48
- const handleCloseSearch = () => {
49
- dispatch(closeSearch());
50
- };
51
-
52
45
  return (
53
46
  <>
54
47
  <div
@@ -74,9 +67,9 @@ export default function Search() {
74
67
  {t('common.search.results_for')}
75
68
  </span>
76
69
  <div className="flex items-center">
77
- <Input
70
+ <input
78
71
  value={searchText}
79
- onChange={handleSearchTextChange}
72
+ onChange={(e) => setSearchText(e.target.value)}
80
73
  onKeyDown={(e) => {
81
74
  if (e.key === 'Enter' && searchText.trim() !== '') {
82
75
  router.push(`${ROUTES.LIST}/?search_text=${searchText}`);
@@ -98,12 +91,11 @@ export default function Search() {
98
91
  <Icon
99
92
  name="close"
100
93
  size={14}
101
- onClick={handleCloseSearch}
94
+ onClick={() => dispatch(closeSearch())}
102
95
  className="cursor-pointer"
103
96
  />
104
97
  </div>
105
98
  </div>
106
-
107
99
  <Results searchText={searchText} />
108
100
  </div>
109
101
  </div>
@@ -1,8 +1,9 @@
1
1
  import Breadcrumb from '@theme/views/breadcrumb';
2
2
  import { ProductInfoSlider } from '@theme/views/product';
3
- import ThemePlaceholder from '@akinon/pz-theme/src/theme-placeholder';
3
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
4
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
4
5
  import { BreadcrumbResultType, ProductResult } from '@akinon/next/types';
5
- import { buildProductPageContext } from '@theme/utils/theme-page-context';
6
+ import { buildProductPageContext } from '@akinon/pz-theme/src/chrome/page-context';
6
7
 
7
8
  interface DeliveryReturnItem {
8
9
  product_delivery_returns?: {
@@ -23,7 +24,9 @@ export default async function ProductLayout({
23
24
  breadcrumbData,
24
25
  children
25
26
  }: ProductPageProps) {
26
- const productPageContext = buildProductPageContext(data);
27
+ // Breadcrumbs travel with the product context so the PDP is not the one
28
+ // page type whose composition cannot build a trail.
29
+ const productPageContext = buildProductPageContext(data, breadcrumbData);
27
30
  const categoryIds = breadcrumbData
28
31
  ?.map((item) => item.extra_context?.attributes?.category_id)
29
32
  .filter(Boolean)
@@ -51,8 +54,8 @@ export default async function ProductLayout({
51
54
  <div className="w-full">{children}</div>
52
55
  </div>
53
56
  </div>
54
- <ThemePlaceholder
55
- slug="product-page-new"
57
+ <ChromeSlot
58
+ slug={PLACEHOLDER_SLUGS.productDetail}
56
59
  pageContext={productPageContext}
57
60
  />
58
61
  </div>
@@ -36,100 +36,53 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
36
36
  carouselRef.current?.next();
37
37
  };
38
38
 
39
- const handleThumbnailClick = (index: number) => {
39
+ const handleThumbnailClick = (index) => {
40
40
  setActiveIndex(index);
41
41
  carouselRef.current?.goToSlide(index);
42
42
  };
43
43
 
44
44
  return (
45
- <>
46
- <div className="lg:grid lg:grid-cols-6">
47
- <div className="lg:col-span-1">
48
- <div className="flex flex-col items-center justify-center md:mr-[6px]">
49
- <button
50
- onClick={goToPrev}
51
- className={twMerge(
52
- 'hidden justify-center p-2 mb-3 border border-gray-100 rounded-full cursor-pointer lg:block',
53
- [activeIndex === 0 && 'cursor-not-allowed opacity-45']
54
- )}
55
- disabled={activeIndex === 0}
56
- >
57
- <Icon name="chevron-up" size={15} className="fill-[#000000]" />
58
- </button>
59
- <div className="hidden flex-col items-center overflow-scroll w-[80px] max-h-[620px] lg:block">
60
- {product?.productimage_set?.map((item, index) => (
61
- <Image
62
- key={index}
63
- src={item.image}
64
- alt={`Thumbnail ${index}`}
65
- width={80}
66
- height={128}
67
- aspectRatio={80 / 128}
68
- className={twMerge('cursor-pointer', [
69
- activeIndex === index && 'border-2 border-primary'
70
- ])}
71
- onClick={() => handleThumbnailClick(index)}
72
- />
73
- ))}
74
- </div>
75
- <button
76
- onClick={goToNext}
77
- className={twMerge(
78
- 'hidden justify-center p-2 mt-3 border border-gray-100 rounded-full cursor-pointer lg:block',
79
- [
80
- activeIndex === product.productimage_set.length - 1 &&
81
- 'cursor-not-allowed opacity-45'
82
- ]
83
- )}
84
- disabled={activeIndex === product.productimage_set.length - 1}
85
- >
86
- <Icon name="chevron-down" size={15} className="fill-[#000000]" />
87
- </button>
88
- </div>
89
- </div>
90
-
91
- <div className="relative lg:col-span-5">
92
- <FavButton className="absolute right-8 top-6 z-[20] sm:hidden" />
93
-
94
- <PluginModule
95
- component={Component.ProductImageSearchFeature}
96
- props={{
97
- product,
98
- activeIndex,
99
- showResetButton: true
100
- }}
101
- />
102
-
103
- <CarouselCore
104
- responsive={{
105
- all: {
106
- breakpoint: { max: 5000, min: 0 },
107
- items: 1
108
- }
109
- }}
110
- arrows={false}
111
- swipeable={true}
112
- ref={carouselRef}
113
- afterChange={(previousSlide, { currentSlide }) => {
114
- setActiveIndex(currentSlide);
115
- }}
116
- containerAspectRatio={{ mobile: 520 / 798, desktop: 484 / 726 }}
45
+ <div className="lg:grid lg:grid-cols-6">
46
+ <div className="lg:col-span-1">
47
+ <div className="flex flex-col items-center justify-center md:mr-[6px]">
48
+ <button
49
+ onClick={goToPrev}
50
+ className={twMerge(
51
+ 'hidden justify-center p-2 mb-3 border border-gray-100 rounded-full cursor-pointer lg:block',
52
+ [activeIndex === 0 && 'cursor-not-allowed opacity-45']
53
+ )}
54
+ disabled={activeIndex === 0}
117
55
  >
118
- {product?.productimage_set?.map((item, i) => (
56
+ <Icon name="chevron-up" size={15} className="fill-[#000000]" />
57
+ </button>
58
+ <div className="hidden flex-col items-center overflow-scroll w-[80px] max-h-[620px] lg:block">
59
+ {product?.productimage_set?.map((item, index) => (
119
60
  <Image
120
- key={i}
61
+ key={index}
121
62
  src={item.image}
122
- alt={product?.name || 'Product image'}
123
- draggable={false}
124
- aspectRatio={484 / 726}
125
- sizes="(min-width: 425px) 512px,
126
- (min-width: 601px) 576px,
127
- (min-width: 768px) 336px,
128
- (min-width: 1024px) 484px, 368px"
129
- fill
63
+ alt={`Thumbnail ${index}`}
64
+ width={80}
65
+ height={128}
66
+ className={twMerge('cursor-pointer', [
67
+ activeIndex === index && 'border-2 border-primary'
68
+ ])}
69
+ onClick={() => handleThumbnailClick(index)}
130
70
  />
131
71
  ))}
132
- </CarouselCore>
72
+ </div>
73
+ <button
74
+ onClick={goToNext}
75
+ className={twMerge(
76
+ 'hidden justify-center p-2 mt-3 border border-gray-100 rounded-full cursor-pointer lg:block',
77
+ [
78
+ activeIndex === product.productimage_set.length - 1 &&
79
+ 'cursor-not-allowed opacity-45'
80
+ ]
81
+ )}
82
+ disabled={activeIndex === product.productimage_set.length - 1}
83
+ >
84
+ <Icon name="chevron-down" size={15} className="fill-[#000000]" />
85
+ </button>
133
86
  </div>
134
87
  </div>
135
88
 
@@ -187,6 +140,6 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
187
140
  ))}
188
141
  </CarouselCore>
189
142
  </div>
190
- </>
143
+ </div>
191
144
  );
192
145
  }
@@ -164,10 +164,6 @@ export default async () => {
164
164
  name: 'Tamara Payment Extension',
165
165
  value: 'pz-tamara-extension'
166
166
  },
167
- {
168
- name: 'Similar Products',
169
- value: 'pz-similar-products'
170
- },
171
167
  {
172
168
  name: 'Hepsipay',
173
169
  value: 'pz-hepsipay'
@@ -183,10 +183,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
183
183
  name: 'Tamara Payment Extension',
184
184
  value: 'pz-tamara-extension'
185
185
  },
186
- {
187
- name: 'Similar Products',
188
- value: 'pz-similar-products'
189
- },
190
186
  {
191
187
  name: 'Hepsipay',
192
188
  value: 'pz-hepsipay'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "2.0.39-rc.0",
3
+ "version": "2.0.39",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {
@@ -1,5 +0,0 @@
1
- export { GET } from '@akinon/next/api/client-env';
2
-
3
- // NEXT_PUBLIC_* values are read from the server runtime, not the build. Force
4
- // dynamic so Next never statically caches an (empty) build-time response.
5
- export const dynamic = 'force-dynamic';
@@ -1,22 +0,0 @@
1
- 'use client';
2
-
3
- import { useSentryUncaughtErrors } from '@akinon/next/hooks';
4
-
5
- export default function GlobalError({
6
- error,
7
- reset
8
- }: {
9
- error: Error & { digest?: string };
10
- reset: () => void;
11
- }) {
12
- useSentryUncaughtErrors(error);
13
-
14
- return (
15
- <html>
16
- <body>
17
- <h2>Something went wrong!</h2>
18
- <button onClick={() => reset()}>Try again</button>
19
- </body>
20
- </html>
21
- );
22
- }
@@ -1,148 +0,0 @@
1
- import {
2
- buildAccountPageContext,
3
- buildBasketPageContext,
4
- buildCustomPageContext,
5
- buildHomepagePageContext,
6
- buildListingPageContext,
7
- buildProductPageContext
8
- } from '../theme-page-context';
9
-
10
- describe('theme-page-context utils', () => {
11
- it('builds homepage and custom page contexts', () => {
12
- const homepage = buildHomepagePageContext();
13
- const customPage = buildCustomPageContext('summer-campaign');
14
-
15
- expect(homepage.homepage.slug).toBe('homepage');
16
- expect(customPage.customPage.slug).toBe('summer-campaign');
17
- expect(customPage.customPage.title).toBe('Summer Campaign');
18
- });
19
-
20
- it('builds product page context with normalized product aliases', () => {
21
- const productPageContext = buildProductPageContext({
22
- product: {
23
- pk: 1,
24
- name: 'Spring Sneaker',
25
- absolute_url: '/products/spring-sneaker',
26
- productimage_set: [{ image: 'https://cdn.example.com/image.jpg' }],
27
- price: '199.90',
28
- retail_price: '249.90',
29
- currency_type: 'TRY',
30
- attributes_kwargs: {}
31
- },
32
- selected_variant: null,
33
- variants: []
34
- } as never);
35
-
36
- // The normalized aliases (title/url/images) are added dynamically and
37
- // are not part of the declared product type.
38
- const product = productPageContext.product as Record<string, any>;
39
- expect(product.title).toBe('Spring Sneaker');
40
- expect(product.url).toBe('/products/spring-sneaker');
41
- expect(product.images[0].url).toBe('https://cdn.example.com/image.jpg');
42
- });
43
-
44
- it('builds listing context aliases for category/search/plp style pages', () => {
45
- const listingContext = buildListingPageContext({
46
- data: {
47
- category: {
48
- name: 'Sneakers',
49
- absolute_url: '/category/sneakers',
50
- attributes: {
51
- category_seo_title: {
52
- value: {
53
- text: 'Sneaker landing'
54
- }
55
- }
56
- }
57
- },
58
- products: [
59
- {
60
- pk: 1,
61
- name: 'Spring Sneaker',
62
- absolute_url: '/products/spring-sneaker',
63
- productimage_set: [{ image: 'https://cdn.example.com/image.jpg' }],
64
- price: '199.90',
65
- retail_price: '249.90',
66
- currency_type: 'TRY',
67
- attributes_kwargs: {}
68
- }
69
- ],
70
- facets: [{ key: 'color', name: 'Color' }],
71
- pagination: { count: 12 },
72
- sorters: [{ label: 'Newest', value: 'newest' }],
73
- search_text: 'sneaker'
74
- } as never,
75
- breadcrumbData: [
76
- { label: 'Sneakers', path: '/category/sneakers' }
77
- ] as never,
78
- pageType: 'search',
79
- path: '/list'
80
- });
81
-
82
- expect(listingContext.page.type).toBe('search');
83
- expect(listingContext.category.name).toBe('Sneakers');
84
- expect(listingContext.search.query).toBe('sneaker');
85
- expect(listingContext.plp.products).toHaveLength(1);
86
- expect(listingContext.listing.totalProducts).toBe(12);
87
- });
88
-
89
- it('builds basket and account contexts from live data', () => {
90
- const basketContext = buildBasketPageContext({
91
- basket: {
92
- pk: 10,
93
- total_quantity: 3,
94
- total_amount: '799.90',
95
- total_product_amount: '899.90',
96
- total_discount_amount: '100.00',
97
- voucher_code: 'SPRING',
98
- discounts: [],
99
- basketitem_set: [
100
- {
101
- id: 1,
102
- quantity: 2,
103
- price: '399.95',
104
- retail_price: '449.95',
105
- total_amount: '799.90',
106
- unit_price: '399.95',
107
- currency_type: 'TRY',
108
- image: 'https://cdn.example.com/image.jpg',
109
- attributes_kwargs: {
110
- color: { label: 'Color', value: 'Black' }
111
- },
112
- product: {
113
- pk: 1,
114
- name: 'Spring Sneaker',
115
- absolute_url: '/products/spring-sneaker',
116
- productimage_set: [
117
- { image: 'https://cdn.example.com/image.jpg' }
118
- ],
119
- price: '399.95',
120
- retail_price: '449.95',
121
- currency_type: 'TRY',
122
- attributes_kwargs: {}
123
- }
124
- }
125
- ]
126
- } as never,
127
- path: '/baskets/basket'
128
- });
129
-
130
- const accountContext = buildAccountPageContext({
131
- path: '/account/profile',
132
- profileInfo: {
133
- first_name: 'Ada',
134
- last_name: 'Lovelace',
135
- email: 'ada@example.com'
136
- },
137
- sessionUser: {
138
- name: 'Ada Lovelace',
139
- email: 'ada@example.com'
140
- }
141
- });
142
-
143
- expect(basketContext.basket.totalQuantity).toBe(3);
144
- expect(basketContext.basket.items[0].title).toBe('Spring Sneaker');
145
- expect(accountContext.account.user.fullName).toBe('Ada Lovelace');
146
- expect(accountContext.account.route).toBe('/account/profile');
147
- });
148
- });