@akinon/projectzero 1.99.0-snapshot-ZERO-3640-20250919140935 → 1.100.0-rc.71

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 (65) hide show
  1. package/CHANGELOG.md +238 -5
  2. package/app-template/.env.example +1 -0
  3. package/app-template/.github/instructions/account.instructions.md +749 -0
  4. package/app-template/.github/instructions/edge-cases.instructions.md +73 -0
  5. package/app-template/.gitignore +3 -0
  6. package/app-template/CHANGELOG.md +5004 -312
  7. package/app-template/README.md +25 -1
  8. package/app-template/package.json +19 -19
  9. package/app-template/public/locales/en/common.json +48 -1
  10. package/app-template/public/locales/tr/common.json +48 -1
  11. package/app-template/src/app/[commerce]/[locale]/[currency]/basket/page.tsx +9 -82
  12. package/app-template/src/app/[commerce]/[locale]/[currency]/category/[pk]/page.tsx +17 -4
  13. package/app-template/src/app/[commerce]/[locale]/[currency]/flat-page/[pk]/page.tsx +12 -1
  14. package/app-template/src/app/[commerce]/[locale]/[currency]/group-product/[pk]/page.tsx +29 -11
  15. package/app-template/src/app/[commerce]/[locale]/[currency]/landing-page/[pk]/page.tsx +12 -1
  16. package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/loading.tsx +67 -0
  17. package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/page.tsx +28 -10
  18. package/app-template/src/app/[commerce]/[locale]/[currency]/special-page/[pk]/page.tsx +12 -1
  19. package/app-template/src/app/api/form/[...id]/route.ts +1 -7
  20. package/app-template/src/app/api/image-proxy/route.ts +1 -0
  21. package/app-template/src/app/api/similar-product-list/route.ts +1 -0
  22. package/app-template/src/app/api/similar-products/route.ts +1 -0
  23. package/app-template/src/assets/fonts/pz-icon.css +3 -0
  24. package/app-template/src/components/__tests__/link.test.tsx +2 -0
  25. package/app-template/src/components/accordion.tsx +22 -19
  26. package/app-template/src/components/currency-select.tsx +1 -0
  27. package/app-template/src/components/file-input.tsx +27 -7
  28. package/app-template/src/components/generate-form-fields.tsx +43 -4
  29. package/app-template/src/components/input.tsx +9 -2
  30. package/app-template/src/components/modal.tsx +32 -16
  31. package/app-template/src/components/pagination.tsx +1 -0
  32. package/app-template/src/components/select.tsx +38 -26
  33. package/app-template/src/components/types/index.ts +25 -1
  34. package/app-template/src/hooks/index.ts +2 -0
  35. package/app-template/src/hooks/use-product-cart.ts +77 -0
  36. package/app-template/src/hooks/use-stock-alert.ts +74 -0
  37. package/app-template/src/plugins.js +3 -1
  38. package/app-template/src/settings.js +8 -2
  39. package/app-template/src/types/index.ts +74 -3
  40. package/app-template/src/utils/variant-validation.ts +41 -0
  41. package/app-template/src/views/account/address-form.tsx +8 -4
  42. package/app-template/src/views/account/contact-form.tsx +1 -1
  43. package/app-template/src/views/account/content-header.tsx +2 -2
  44. package/app-template/src/views/account/faq/faq-tabs.tsx +8 -2
  45. package/app-template/src/views/basket/basket-content.tsx +106 -0
  46. package/app-template/src/views/basket/basket-item.tsx +22 -14
  47. package/app-template/src/views/basket/summary.tsx +10 -7
  48. package/app-template/src/views/breadcrumb.tsx +2 -2
  49. package/app-template/src/views/category/category-info.tsx +1 -0
  50. package/app-template/src/views/category/filters/index.tsx +1 -1
  51. package/app-template/src/views/guest-login/index.tsx +6 -1
  52. package/app-template/src/views/header/action-menu.tsx +1 -1
  53. package/app-template/src/views/header/search/index.tsx +17 -5
  54. package/app-template/src/views/login/index.tsx +11 -10
  55. package/app-template/src/views/otp-login/index.tsx +11 -6
  56. package/app-template/src/views/product/product-actions.tsx +165 -0
  57. package/app-template/src/views/product/product-info.tsx +62 -263
  58. package/app-template/src/views/product/product-share.tsx +56 -0
  59. package/app-template/src/views/product/product-variants.tsx +26 -0
  60. package/app-template/src/views/product/slider.tsx +86 -73
  61. package/app-template/src/views/register/index.tsx +15 -11
  62. package/app-template/src/widgets/footer-menu.tsx +6 -2
  63. package/commands/plugins.ts +63 -16
  64. package/dist/commands/plugins.js +57 -16
  65. package/package.json +1 -1
@@ -12,6 +12,30 @@ Run `cp .env.example .env && yarn` command at project root and all dependencies
12
12
 
13
13
  - `SITEMAP_S3_BUCKET_NAME`: S3 bucket name for XML sitemaps (e.g., "0fb534"). This is required for the sitemap route to function correctly.
14
14
 
15
+ ### Optional Environment Variables
16
+
17
+ - `NEXT_PUBLIC_ENABLE_IMAGE_SEARCH`: Set to `true` to enable image search feature for all users. If not set or `false`, the feature will only be visible to users who have enabled it via localStorage.
18
+
19
+ ## Image Search Feature
20
+
21
+ The image search functionality allows users to search for similar products by uploading images or cropping existing product images.
22
+
23
+ ### Feature Visibility Control
24
+
25
+ The image search feature can be controlled in two ways:
26
+
27
+ 1. **Environment Variable (Global)**: Set `NEXT_PUBLIC_ENABLE_IMAGE_SEARCH=true` to enable for all users
28
+ 2. **localStorage (Individual Users)**: Users can enable it locally using browser developer tools
29
+
30
+ ````
31
+
32
+ ### Feature Locations
33
+
34
+ When enabled, the image search feature appears in:
35
+
36
+ - **Header Search**: Camera icon next to the search input
37
+ - **Product Detail Page**: "View Similar Styles" button on product images
38
+
15
39
  ### Build
16
40
 
17
41
  To build the app, run the following command:
@@ -19,7 +43,7 @@ To build the app, run the following command:
19
43
  ```bash
20
44
  cd projectzeronext # Project root
21
45
  yarn build
22
- ```
46
+ ````
23
47
 
24
48
  ### Develop
25
49
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "1.98.0",
3
+ "version": "1.100.0-rc.71",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -24,22 +24,22 @@
24
24
  "test:middleware": "jest middleware-matcher.test.ts --bail"
25
25
  },
26
26
  "dependencies": {
27
- "@akinon/next": "1.98.0",
28
- "@akinon/pz-akifast": "1.98.0",
29
- "@akinon/pz-b2b": "1.98.0",
30
- "@akinon/pz-basket-gift-pack": "1.98.0",
31
- "@akinon/pz-bkm": "1.98.0",
32
- "@akinon/pz-checkout-gift-pack": "1.98.0",
33
- "@akinon/pz-click-collect": "1.98.0",
34
- "@akinon/pz-credit-payment": "1.98.0",
35
- "@akinon/pz-gpay": "1.98.0",
36
- "@akinon/pz-masterpass": "1.98.0",
37
- "@akinon/pz-one-click-checkout": "1.98.0",
38
- "@akinon/pz-otp": "1.98.0",
39
- "@akinon/pz-pay-on-delivery": "1.98.0",
40
- "@akinon/pz-saved-card": "1.98.0",
41
- "@akinon/pz-tabby-extension": "1.98.0",
42
- "@akinon/pz-tamara-extension": "1.98.0",
27
+ "@akinon/next": "1.100.0-rc.71",
28
+ "@akinon/pz-akifast": "1.100.0-rc.71",
29
+ "@akinon/pz-b2b": "1.100.0-rc.71",
30
+ "@akinon/pz-basket-gift-pack": "1.100.0-rc.71",
31
+ "@akinon/pz-bkm": "1.100.0-rc.71",
32
+ "@akinon/pz-checkout-gift-pack": "1.100.0-rc.71",
33
+ "@akinon/pz-click-collect": "1.100.0-rc.71",
34
+ "@akinon/pz-credit-payment": "1.100.0-rc.71",
35
+ "@akinon/pz-gpay": "1.100.0-rc.71",
36
+ "@akinon/pz-masterpass": "1.100.0-rc.71",
37
+ "@akinon/pz-one-click-checkout": "1.100.0-rc.71",
38
+ "@akinon/pz-otp": "1.100.0-rc.71",
39
+ "@akinon/pz-pay-on-delivery": "1.100.0-rc.71",
40
+ "@akinon/pz-saved-card": "1.100.0-rc.71",
41
+ "@akinon/pz-tabby-extension": "1.100.0-rc.71",
42
+ "@akinon/pz-tamara-extension": "1.100.0-rc.71",
43
43
  "@hookform/resolvers": "2.9.0",
44
44
  "@next/third-parties": "14.1.0",
45
45
  "@react-google-maps/api": "2.17.1",
@@ -62,7 +62,7 @@
62
62
  "yup": "0.32.11"
63
63
  },
64
64
  "devDependencies": {
65
- "@akinon/eslint-plugin-projectzero": "1.98.0",
65
+ "@akinon/eslint-plugin-projectzero": "1.100.0-rc.71",
66
66
  "@semantic-release/changelog": "6.0.2",
67
67
  "@semantic-release/exec": "6.0.3",
68
68
  "@semantic-release/git": "10.0.1",
@@ -90,7 +90,7 @@
90
90
  "jest-environment-jsdom": "29.7.0",
91
91
  "lint-staged": "13.1.0",
92
92
  "prettier": "2.6.2",
93
- "react-number-format": "5.3.4",
93
+ "react-number-format": "5.4.3",
94
94
  "sass": "1.49.9",
95
95
  "semantic-release": "19.0.5",
96
96
  "server-only": "0.0.1",
@@ -27,7 +27,25 @@
27
27
  "clean": "clean",
28
28
  "categories": "CATEGORIES",
29
29
  "view_all": "VIEW ALL",
30
- "not_found": "Search Results Not Found"
30
+ "not_found": "Search Results Not Found",
31
+ "image_search": {
32
+ "title": "Search by Image",
33
+ "upload_image": "Upload an image to find similar products",
34
+ "select_image": "Select Image",
35
+ "crop_image": "Crop Image",
36
+ "cancel_crop": "Cancel Crop",
37
+ "apply_crop": "Apply Crop",
38
+ "try_another": "Try Another Image",
39
+ "search_image": "Search Image",
40
+ "similar_products": "Similar Products",
41
+ "loading_cropper": "Loading cropper...",
42
+ "no_products": "No similar products found",
43
+ "best_results": "For best results:",
44
+ "tip_1": "Upload clear images of products",
45
+ "tip_2": "Use images with simple backgrounds",
46
+ "tip_3": "Focus on the main product",
47
+ "tip_4": "Use the crop tool to focus on specific details"
48
+ }
31
49
  },
32
50
  "page_404": {
33
51
  "title": "Page not found.",
@@ -71,5 +89,34 @@
71
89
  "file_input": {
72
90
  "select_file": "Select File",
73
91
  "no_file": "No file selected"
92
+ },
93
+ "product": {
94
+ "no_products": "No products found",
95
+ "new_image": "New Image",
96
+ "view_similar_styles": "View Similar Styles",
97
+ "clear_all_filters": "Clear All Filters",
98
+ "reset_to_original": "Reset to Original",
99
+ "similar_styles": "Similar Styles",
100
+ "filters": "Filters",
101
+ "active_filters": "Active Filters"
102
+ },
103
+ "similar_products": {
104
+ "errors": {
105
+ "file_size_too_large": "Image size should be less than 5MB",
106
+ "invalid_image_file": "The selected file is not a valid image",
107
+ "invalid_image_format": "Invalid image format detected",
108
+ "search_failed": "Search failed. Please try again later",
109
+ "connection_failed": "Image search failed. Please check your connection and try again",
110
+ "invalid_image_properties": "Invalid image properties detected",
111
+ "file_read_error": "Error reading the file",
112
+ "processing_error": "Error processing image",
113
+ "crop_processing_error": "Error processing cropped image"
114
+ }
115
+ },
116
+ "forms": {
117
+ "sending": "Sending...",
118
+ "success": "Form submitted successfully!",
119
+ "error": "An error occurred while submitting the form. Please try again.",
120
+ "submit_error": "Form submit error:"
74
121
  }
75
122
  }
@@ -27,7 +27,25 @@
27
27
  "clean": "temizle",
28
28
  "categories": "KATEGORİLER",
29
29
  "view_all": "HEPSİNİ GÖSTER",
30
- "not_found": "Arama Sonuçları Bulunamadı"
30
+ "not_found": "Arama Sonuçları Bulunamadı",
31
+ "image_search": {
32
+ "title": "Görsel ile Ara",
33
+ "upload_image": "Benzer ürünleri bulmak için bir görsel yükleyin",
34
+ "select_image": "Görsel Seç",
35
+ "crop_image": "Görsel Kırp",
36
+ "cancel_crop": "Kırpmayı İptal Et",
37
+ "apply_crop": "Kırpmayı Uygula",
38
+ "try_another": "Başka Görsel Dene",
39
+ "search_image": "Arama Görseli",
40
+ "similar_products": "Benzer Ürünler",
41
+ "loading_cropper": "Kırpıcı yükleniyor...",
42
+ "no_products": "Benzer ürün bulunamadı",
43
+ "best_results": "En iyi sonuçlar için:",
44
+ "tip_1": "Net ürün görselleri yükleyin",
45
+ "tip_2": "Basit arka planlı görseller kullanın",
46
+ "tip_3": "Ana ürüne odaklanın",
47
+ "tip_4": "Belirli detaylara odaklanmak için kırpma aracını kullanın"
48
+ }
31
49
  },
32
50
  "page_404": {
33
51
  "title": "Sayfa bulunamadı.",
@@ -71,5 +89,34 @@
71
89
  "file_input": {
72
90
  "select_file": "Dosya Seç",
73
91
  "no_file": "Dosya seçilmedi"
92
+ },
93
+ "product": {
94
+ "no_products": "Ürün bulunamadı",
95
+ "new_image": "Yeni Görsel",
96
+ "view_similar_styles": "Benzer Stillere Göz At",
97
+ "clear_all_filters": "Tüm Filtreleri Temizle",
98
+ "reset_to_original": "Orjinale Dön",
99
+ "similar_styles": "Benzer Stillere Göz At",
100
+ "filters": "Filtreler",
101
+ "active_filters": "Aktif Filtreler"
102
+ },
103
+ "similar_products": {
104
+ "errors": {
105
+ "file_size_too_large": "Görsel boyutu 5MB'dan küçük olmalıdır",
106
+ "invalid_image_file": "Seçilen dosya geçerli bir görsel değil",
107
+ "invalid_image_format": "Geçersiz görsel formatı tespit edildi",
108
+ "search_failed": "Arama başarısız oldu. Lütfen daha sonra tekrar deneyin",
109
+ "connection_failed": "Görsel arama başarısız oldu. Lütfen bağlantınızı kontrol edip tekrar deneyin",
110
+ "invalid_image_properties": "Geçersiz görsel özellikleri tespit edildi",
111
+ "file_read_error": "Dosya okuma hatası",
112
+ "processing_error": "Görsel işleme hatası",
113
+ "crop_processing_error": "Kırpılan görsel işleme hatası"
114
+ }
115
+ },
116
+ "forms": {
117
+ "sending": "Gönderiliyor...",
118
+ "success": "Form başarıyla gönderildi!",
119
+ "error": "Form gönderilirken bir hata oluştu. Lütfen tekrar deneyin.",
120
+ "submit_error": "Form gönderme hatası:"
74
121
  }
75
122
  }
@@ -1,87 +1,14 @@
1
- 'use client';
2
-
3
- import { useEffect } from 'react';
4
- import { ROUTES } from '@theme/routes';
5
- import { useGetBasketQuery } from '@akinon/next/data/client/basket';
6
- import { pushCartView } from '@theme/utils/gtm';
7
- import { Button, LoaderSpinner, Link } from '@theme/components';
8
- import { BasketItem, Summary } from '@theme/views/basket';
9
- import { useLocalization } from '@akinon/next/hooks';
10
- import PluginModule, { Component } from '@akinon/next/components/plugin-module';
1
+ import { BasketContent } from '@theme/views/basket/basket-content';
2
+ import { getBasketData } from '@akinon/next/data/server/basket';
11
3
  import settings from '@theme/settings';
12
4
 
13
- export default function Page() {
14
- const { data: basket, isLoading, isSuccess } = useGetBasketQuery();
15
- const { t } = useLocalization();
16
- const multiBasket = settings.plugins?.multiBasket ?? false;
17
-
18
- useEffect(() => {
19
- if (isSuccess) {
20
- const products = basket.basketitem_set.map((basketItem) => ({
21
- ...basketItem.product
22
- }));
23
- pushCartView(products);
24
- }
25
- }, [basket, isSuccess]);
26
-
27
- return (
28
- <div className="max-w-screen-xl p-4 flex flex-col text-primary-800 lg:p-8 xl:flex-row xl:mx-auto">
29
- {isLoading && (
30
- <div className="flex justify-center w-full">
31
- <LoaderSpinner />
32
- </div>
33
- )}
34
- {isSuccess &&
35
- (basket && basket.basketitem_set && basket.basketitem_set.length > 0 ? (
36
- <>
37
- <div className="flex-1 xl:mr-16">
38
- <div className="flex items-center justify-between py-2 border-b border-gray-200 lg:py-3">
39
- <h2 className="text-xl lg:text-2xl font-light">
40
- {t('basket.my_cart')}
41
- </h2>
42
- <Link
43
- href={ROUTES.HOME}
44
- className="text-xs hover:text-secondary-500"
45
- >
46
- {t('basket.back_to_shopping')}
47
- </Link>
48
- </div>
49
- <ul>
50
- {multiBasket ? (
51
- <PluginModule
52
- component={Component.MultiBasket}
53
- props={{ BasketItem }}
54
- />
55
- ) : (
56
- basket.basketitem_set.map((basketItem, index) => (
57
- <BasketItem basketItem={basketItem} key={index} />
58
- ))
59
- )}
60
- </ul>
61
- </div>
62
- <Summary basket={basket} />
63
- </>
64
- ) : (
65
- <div className="flex flex-col items-center container max-w-screen-sm py-4 px-4 xs:py-6 xs:px-6 sm:py-8 sm:px-8 lg:max-w-screen-xl">
66
- <h1
67
- className="w-full text-xl font-light text-secondary text-center sm:text-2xl"
68
- data-testid="basket-empty"
69
- >
70
- {t('basket.empty.title')}
71
- </h1>
5
+ export default async function Page() {
6
+ const { basket } = await getBasketData();
72
7
 
73
- <div className="w-full text-sm text-black-800 text-center my-4 mb-2 sm:text-base">
74
- <p>{t('basket.empty.content_first')}</p>
75
- <p>{t('basket.empty.content_second')}.</p>
76
- </div>
8
+ const multiBasket: boolean =
9
+ typeof settings.plugins?.multiBasket === 'boolean'
10
+ ? settings.plugins.multiBasket
11
+ : false;
77
12
 
78
- <Link href={ROUTES.HOME} passHref>
79
- <Button className="px-10 mt-2" appearance="filled">
80
- {t('basket.empty.button')}
81
- </Button>
82
- </Link>
83
- </div>
84
- ))}
85
- </div>
86
- );
13
+ return <BasketContent initialBasket={basket} multiBasket={multiBasket} />;
87
14
  }
@@ -2,12 +2,25 @@ import { getCategoryData } from '@akinon/next/data/server';
2
2
  import { withSegmentDefaults } from '@akinon/next/hocs/server';
3
3
  import { PageProps } from '@akinon/next/types';
4
4
  import CategoryLayout from '@theme/views/category/layout';
5
+ import { notFound } from 'next/navigation';
5
6
 
6
7
  async function Page({ params, searchParams }: PageProps<{ pk: number }>) {
7
- const { data, breadcrumbData } = await getCategoryData({
8
- pk: params.pk,
9
- searchParams
10
- });
8
+ let categoryData;
9
+
10
+ try {
11
+ categoryData = await getCategoryData({
12
+ pk: params.pk,
13
+ searchParams
14
+ });
15
+ } catch (error) {
16
+ return notFound();
17
+ }
18
+
19
+ if (!categoryData || !categoryData.data) {
20
+ return notFound();
21
+ }
22
+
23
+ const { data, breadcrumbData } = categoryData;
11
24
 
12
25
  return (
13
26
  <>
@@ -1,9 +1,20 @@
1
1
  import { getFlatPageData } from '@akinon/next/data/server';
2
2
  import { withSegmentDefaults } from '@akinon/next/hocs/server';
3
3
  import { PageProps } from '@akinon/next/types';
4
+ import { notFound } from 'next/navigation';
4
5
 
5
6
  async function Page({ params }: PageProps<{ pk: number }>) {
6
- const data = await getFlatPageData({ pk: params.pk });
7
+ let data;
8
+
9
+ try {
10
+ data = await getFlatPageData({ pk: params.pk });
11
+ } catch (error) {
12
+ return notFound();
13
+ }
14
+
15
+ if (!data || !data.flat_page) {
16
+ return notFound();
17
+ }
7
18
 
8
19
  return (
9
20
  <div className="container mx-auto py-6">
@@ -4,6 +4,7 @@ import { getProductData, getWidgetData } from '@akinon/next/data/server';
4
4
  import { withSegmentDefaults } from '@akinon/next/hocs/server';
5
5
  import { PageProps, Metadata } from '@akinon/next/types';
6
6
  import { generateJsonLd } from '@theme/utils/generate-jsonld';
7
+ import { notFound } from 'next/navigation';
7
8
 
8
9
  export async function generateMetadata({
9
10
  params,
@@ -12,14 +13,19 @@ export async function generateMetadata({
12
13
  let result: Metadata = {};
13
14
 
14
15
  try {
15
- const {
16
- data: { product }
17
- } = await getProductData({
16
+ const productData = await getProductData({
18
17
  pk: params.pk,
19
18
  searchParams,
20
19
  groupProduct: true
21
20
  });
22
21
 
22
+ // If product data is not found, return empty metadata
23
+ if (!productData || !productData.data || !productData.data.product) {
24
+ return result;
25
+ }
26
+
27
+ const { product } = productData.data;
28
+
23
29
  result = {
24
30
  title: product.name,
25
31
  description: String(product.attributes.description),
@@ -42,15 +48,27 @@ export async function generateMetadata({
42
48
  }
43
49
 
44
50
  async function Page({ params, searchParams }: PageProps<{ pk: number }>) {
45
- const [{ data, breadcrumbData }, deliveryReturn] = await Promise.all([
46
- getProductData({
47
- pk: params.pk,
48
- searchParams,
49
- groupProduct: true
50
- }),
51
- getWidgetData({ slug: 'product-delivery-returns' })
52
- ]);
51
+ let productData;
52
+ let deliveryReturn;
53
+
54
+ try {
55
+ [productData, deliveryReturn] = await Promise.all([
56
+ getProductData({
57
+ pk: params.pk,
58
+ searchParams,
59
+ groupProduct: true
60
+ }),
61
+ getWidgetData({ slug: 'product-delivery-returns' })
62
+ ]);
63
+ } catch (error) {
64
+ return notFound();
65
+ }
66
+
67
+ if (!productData || !productData.data || !productData.data.product) {
68
+ return notFound();
69
+ }
53
70
 
71
+ const { data, breadcrumbData } = productData;
54
72
  const jsonLd = generateJsonLd(data.product);
55
73
 
56
74
  return (
@@ -1,9 +1,20 @@
1
1
  import { getLandingPageData } from '@akinon/next/data/server';
2
2
  import { withSegmentDefaults } from '@akinon/next/hocs/server';
3
3
  import { PageProps } from '@akinon/next/types';
4
+ import { notFound } from 'next/navigation';
4
5
 
5
6
  async function Page({ params }: PageProps<{ pk: number }>) {
6
- const data = await getLandingPageData({ pk: params.pk });
7
+ let data;
8
+
9
+ try {
10
+ data = await getLandingPageData({ pk: params.pk });
11
+ } catch (error) {
12
+ return notFound();
13
+ }
14
+
15
+ if (!data || !data.landing_page) {
16
+ return notFound();
17
+ }
7
18
 
8
19
  const content = data.landing_page;
9
20
 
@@ -0,0 +1,67 @@
1
+ import { Skeleton, SkeletonWrapper } from 'components';
2
+
3
+ export default function Loading() {
4
+ return (
5
+ <div className="container mx-auto">
6
+ <div className="max-w-5xl mx-auto my-5 px-7">
7
+ <SkeletonWrapper className="md:mb-7">
8
+ <Skeleton className="w-[17.25rem] h-4 lg:w-64" />
9
+ </SkeletonWrapper>
10
+ </div>
11
+ <div className="grid max-w-5xl grid-cols-2 lg:gap-8 mx-auto px-7">
12
+ <div className="col-span-2 mb-7 md:mb-0 lg:col-span-1">
13
+ <div className="flex gap-1">
14
+ <SkeletonWrapper className="hidden md:block md:mb-7">
15
+ {Array(5)
16
+ .fill(null)
17
+ .map((_, index) => (
18
+ <Skeleton key={index} className="w-20 h-24 mb-2" />
19
+ ))}
20
+ </SkeletonWrapper>
21
+
22
+ <div className="flex-1">
23
+ <SkeletonWrapper className="md:mb-7">
24
+ <Skeleton className="w-full h-[30.375rem] md:h-[36.375rem]" />
25
+ </SkeletonWrapper>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ <div className="flex flex-col items-center col-span-2 lg:col-span-1">
30
+ <div className="w-full">
31
+ <SkeletonWrapper className="w-full md:mb-7 flex justify-center items-center">
32
+ <Skeleton className="w-96 h-16 mb-9" />
33
+ <Skeleton className="hidden w-36 h-14 mb-9 md:block" />
34
+
35
+ <div className="flex flex-col justify-center items-center mb-9">
36
+ <Skeleton className="w-36 h-4 mb-2" />
37
+ <div className="flex items-center gap-2">
38
+ {Array(3)
39
+ .fill(null)
40
+ .map((_, index) => (
41
+ <Skeleton key={index} className="w-24 h-10" />
42
+ ))}
43
+ </div>
44
+ </div>
45
+
46
+ <div className="flex flex-col justify-center items-center mb-4">
47
+ <Skeleton className="w-36 h-4 mb-2" />
48
+ <div className="flex items-center gap-2">
49
+ {Array(5)
50
+ .fill(null)
51
+ .map((_, index) => (
52
+ <Skeleton key={index} className="w-11 h-11" />
53
+ ))}
54
+ </div>
55
+ </div>
56
+
57
+ <Skeleton className="hidden w-full h-14 mb-6 md:block" />
58
+ <Skeleton className="w-40 h-10 mb-9 md:w-72" />
59
+ <Skeleton className="w-24 h-10 mb-7" />
60
+ <Skeleton className="w-full h-36" />
61
+ </SkeletonWrapper>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ );
67
+ }
@@ -4,6 +4,7 @@ import { PageProps, Metadata } from '@akinon/next/types';
4
4
  import { generateJsonLd } from '@theme/utils/generate-jsonld';
5
5
  import { AccordionWrapper, ProductInfo } from '@theme/views/product';
6
6
  import ProductLayout from '@theme/views/product/layout';
7
+ import { notFound } from 'next/navigation';
7
8
 
8
9
  export async function generateMetadata({
9
10
  params,
@@ -12,13 +13,17 @@ export async function generateMetadata({
12
13
  let result: Metadata = {};
13
14
 
14
15
  try {
15
- const {
16
- data: { product }
17
- } = await getProductData({
16
+ const productData = await getProductData({
18
17
  pk: params.pk,
19
18
  searchParams
20
19
  });
21
20
 
21
+ if (!productData || !productData.data || !productData.data.product) {
22
+ return result;
23
+ }
24
+
25
+ const { product } = productData.data;
26
+
22
27
  result = {
23
28
  title: product.name,
24
29
  description: String(product.attributes.description),
@@ -41,14 +46,27 @@ export async function generateMetadata({
41
46
  }
42
47
 
43
48
  async function Page({ params, searchParams }: PageProps<{ pk: number }>) {
44
- const [{ data, breadcrumbData }, deliveryReturn] = await Promise.all([
45
- getProductData({
46
- pk: params.pk,
47
- searchParams
48
- }),
49
- getWidgetData({ slug: 'product-delivery-returns' })
50
- ]);
49
+ let productData;
50
+ let deliveryReturn;
51
+
52
+ try {
53
+ [productData, deliveryReturn] = await Promise.all([
54
+ getProductData({
55
+ pk: params.pk,
56
+ searchParams
57
+ }),
58
+ getWidgetData({ slug: 'product-delivery-returns' })
59
+ ]);
60
+ } catch (error) {
61
+ return notFound();
62
+ }
63
+
64
+ // If product data is not found, return 404
65
+ if (!productData || !productData.data || !productData.data.product) {
66
+ return notFound();
67
+ }
51
68
 
69
+ const { data, breadcrumbData } = productData;
52
70
  const jsonLd = generateJsonLd(data.product);
53
71
 
54
72
  return (
@@ -4,9 +4,20 @@ import { PageProps } from '@akinon/next/types';
4
4
  import CategoryLayout from '@theme/views/category/layout';
5
5
  import SpecialPageBanner from '@theme/widgets/special-page-banner';
6
6
  import SpecialPageCarousel from '@theme/widgets/special-page-carousel';
7
+ import { notFound } from 'next/navigation';
7
8
 
8
9
  async function Page({ params, searchParams }: PageProps<{ pk: number }>) {
9
- const data = await getSpecialPageData({ pk: params.pk, searchParams });
10
+ let data;
11
+
12
+ try {
13
+ data = await getSpecialPageData({ pk: params.pk, searchParams });
14
+ } catch (error) {
15
+ return notFound();
16
+ }
17
+
18
+ if (!data) {
19
+ return notFound();
20
+ }
10
21
 
11
22
  return (
12
23
  <>
@@ -1,7 +1 @@
1
- import { NextResponse } from 'next/server';
2
-
3
- export async function POST() {
4
- // TODO: Handle Form Data
5
-
6
- return NextResponse.json({ message: 'ok' });
7
- }
1
+ export * from '@akinon/next/api/form';
@@ -0,0 +1 @@
1
+ export * from '@akinon/next/api/image-proxy';
@@ -0,0 +1 @@
1
+ export * from '@akinon/next/api/similar-product-list';
@@ -0,0 +1 @@
1
+ export * from '@akinon/next/api/similar-products';
@@ -152,3 +152,6 @@ url("./pz-icon.svg?db4ba799c4ca72f4bb855458e0cd19ee#pz-icon") format("svg");
152
152
  .pz-icon-whatsapp:before {
153
153
  content: "\f12c";
154
154
  }
155
+ .pz-icon-camera:before {
156
+ content: "\f12d";
157
+ }
@@ -30,6 +30,8 @@ describe('Link Component', () => {
30
30
  wrapper = container;
31
31
  });
32
32
 
33
+ wrapper;
34
+
33
35
  it('should render without error', () => {
34
36
  const link = screen.getByRole('link');
35
37