@akinon/projectzero 1.107.0 → 1.108.0-rc.87
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 +233 -4
- package/app-template/.env.example +1 -0
- package/app-template/CHANGELOG.md +5697 -1063
- package/app-template/README.md +25 -1
- package/app-template/package.json +21 -20
- package/app-template/public/locales/en/common.json +42 -1
- package/app-template/public/locales/tr/common.json +42 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/basket/page.tsx +9 -82
- package/app-template/src/app/[commerce]/[locale]/[currency]/landing-page/[pk]/page.tsx +12 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/loading.tsx +67 -0
- package/app-template/src/app/api/image-proxy/route.ts +1 -0
- package/app-template/src/app/api/similar-product-list/route.ts +1 -0
- package/app-template/src/app/api/similar-products/route.ts +1 -0
- package/app-template/src/assets/fonts/pz-icon.css +3 -0
- package/app-template/src/components/input.tsx +2 -1
- package/app-template/src/hooks/index.ts +2 -0
- package/app-template/src/settings.js +6 -1
- package/app-template/src/views/basket/basket-content.tsx +106 -0
- package/app-template/src/views/basket/basket-item.tsx +16 -13
- package/app-template/src/views/basket/summary.tsx +10 -7
- package/app-template/src/views/guest-login/index.tsx +6 -1
- package/app-template/src/views/header/search/index.tsx +17 -5
- package/app-template/src/views/product/slider.tsx +86 -73
- package/commands/plugins.ts +29 -2
- package/dist/commands/plugins.js +23 -2
- package/package.json +1 -1
package/app-template/README.md
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.108.0-rc.87",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -24,23 +24,24 @@
|
|
|
24
24
|
"test:middleware": "jest middleware-matcher.test.ts --bail"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@akinon/next": "1.
|
|
28
|
-
"@akinon/pz-akifast": "1.
|
|
29
|
-
"@akinon/pz-b2b": "1.
|
|
30
|
-
"@akinon/pz-basket-gift-pack": "1.
|
|
31
|
-
"@akinon/pz-bkm": "1.
|
|
32
|
-
"@akinon/pz-checkout-gift-pack": "1.
|
|
33
|
-
"@akinon/pz-click-collect": "1.
|
|
34
|
-
"@akinon/pz-credit-payment": "1.
|
|
35
|
-
"@akinon/pz-
|
|
36
|
-
"@akinon/pz-
|
|
37
|
-
"@akinon/pz-
|
|
38
|
-
"@akinon/pz-
|
|
39
|
-
"@akinon/pz-
|
|
40
|
-
"@akinon/pz-
|
|
41
|
-
"@akinon/pz-
|
|
42
|
-
"@akinon/pz-
|
|
43
|
-
"@akinon/pz-
|
|
27
|
+
"@akinon/next": "1.108.0-rc.87",
|
|
28
|
+
"@akinon/pz-akifast": "1.108.0-rc.87",
|
|
29
|
+
"@akinon/pz-b2b": "1.108.0-rc.87",
|
|
30
|
+
"@akinon/pz-basket-gift-pack": "1.108.0-rc.87",
|
|
31
|
+
"@akinon/pz-bkm": "1.108.0-rc.87",
|
|
32
|
+
"@akinon/pz-checkout-gift-pack": "1.108.0-rc.87",
|
|
33
|
+
"@akinon/pz-click-collect": "1.108.0-rc.87",
|
|
34
|
+
"@akinon/pz-credit-payment": "1.108.0-rc.87",
|
|
35
|
+
"@akinon/pz-cybersource-uc": "1.108.0-rc.87",
|
|
36
|
+
"@akinon/pz-gpay": "1.108.0-rc.87",
|
|
37
|
+
"@akinon/pz-hepsipay": "1.108.0-rc.87",
|
|
38
|
+
"@akinon/pz-masterpass": "1.108.0-rc.87",
|
|
39
|
+
"@akinon/pz-one-click-checkout": "1.108.0-rc.87",
|
|
40
|
+
"@akinon/pz-otp": "1.108.0-rc.87",
|
|
41
|
+
"@akinon/pz-pay-on-delivery": "1.108.0-rc.87",
|
|
42
|
+
"@akinon/pz-saved-card": "1.108.0-rc.87",
|
|
43
|
+
"@akinon/pz-tabby-extension": "1.108.0-rc.87",
|
|
44
|
+
"@akinon/pz-tamara-extension": "1.108.0-rc.87",
|
|
44
45
|
"@hookform/resolvers": "2.9.0",
|
|
45
46
|
"@next/third-parties": "14.1.0",
|
|
46
47
|
"@react-google-maps/api": "2.17.1",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"yup": "0.32.11"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
67
|
+
"@akinon/eslint-plugin-projectzero": "1.108.0-rc.87",
|
|
67
68
|
"@semantic-release/changelog": "6.0.2",
|
|
68
69
|
"@semantic-release/exec": "6.0.3",
|
|
69
70
|
"@semantic-release/git": "10.0.1",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"jest-environment-jsdom": "29.7.0",
|
|
92
93
|
"lint-staged": "13.1.0",
|
|
93
94
|
"prettier": "2.6.2",
|
|
94
|
-
"react-number-format": "5.3
|
|
95
|
+
"react-number-format": "5.4.3",
|
|
95
96
|
"sass": "1.49.9",
|
|
96
97
|
"semantic-release": "19.0.5",
|
|
97
98
|
"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.",
|
|
@@ -72,6 +90,29 @@
|
|
|
72
90
|
"select_file": "Select File",
|
|
73
91
|
"no_file": "No file selected"
|
|
74
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
|
+
},
|
|
75
116
|
"forms": {
|
|
76
117
|
"sending": "Sending...",
|
|
77
118
|
"success": "Form submitted successfully!",
|
|
@@ -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ı.",
|
|
@@ -72,6 +90,29 @@
|
|
|
72
90
|
"select_file": "Dosya Seç",
|
|
73
91
|
"no_file": "Dosya seçilmedi"
|
|
74
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
|
+
},
|
|
75
116
|
"forms": {
|
|
76
117
|
"sending": "Gönderiliyor...",
|
|
77
118
|
"success": "Form başarıyla gönderildi!",
|
|
@@ -1,87 +1,14 @@
|
|
|
1
|
-
|
|
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 {
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
8
|
+
const multiBasket: boolean =
|
|
9
|
+
typeof settings.plugins?.multiBasket === 'boolean'
|
|
10
|
+
? settings.plugins.multiBasket
|
|
11
|
+
: false;
|
|
77
12
|
|
|
78
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
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
|
+
}
|
|
@@ -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';
|
|
@@ -78,7 +78,8 @@ export const Input = forwardRef<
|
|
|
78
78
|
hasFloatingLabel,
|
|
79
79
|
'mb-2': !hasFloatingLabel,
|
|
80
80
|
'-translate-y-2 bg-white inline-flex h-auto':
|
|
81
|
-
hasFloatingLabel &&
|
|
81
|
+
hasFloatingLabel &&
|
|
82
|
+
(focused || hasValue || props.value || props.format)
|
|
82
83
|
})
|
|
83
84
|
)}
|
|
84
85
|
>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const { LocaleUrlStrategy } = require('@akinon/next/localization');
|
|
2
2
|
const { ROUTES } = require('@theme/routes');
|
|
3
3
|
|
|
4
|
+
/* IMPORTANT *
|
|
5
|
+
* In order to use one locale in the locales array and hide the default locale in the URL, you need to set the localeUrlStrategy to LocaleUrlStrategy.ShowAllLocales.
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
const commerceUrl = encodeURI(process.env.SERVICE_BACKEND_URL ?? 'default');
|
|
5
9
|
|
|
6
10
|
/** @type {import('@akinon/next/types').Settings} */
|
|
@@ -14,6 +18,7 @@ module.exports = {
|
|
|
14
18
|
{ translationKey: 'size', key: 'size' }
|
|
15
19
|
],
|
|
16
20
|
localization: {
|
|
21
|
+
// If there is one locale in the locales array, the default locale will be hidden in the URL.
|
|
17
22
|
locales: [
|
|
18
23
|
{
|
|
19
24
|
label: 'EN',
|
|
@@ -41,7 +46,7 @@ module.exports = {
|
|
|
41
46
|
}
|
|
42
47
|
],
|
|
43
48
|
defaultLocaleValue: 'en',
|
|
44
|
-
localeUrlStrategy: LocaleUrlStrategy.HideDefaultLocale,
|
|
49
|
+
localeUrlStrategy: LocaleUrlStrategy.HideDefaultLocale, // If there is one locale in the locales array, the default locale will be hidden in the URL and localeUrlStrategy should be set to LocaleUrlStrategy.ShowAllLocales.
|
|
45
50
|
redirectToDefaultLocale: true,
|
|
46
51
|
defaultCurrencyCode: 'usd'
|
|
47
52
|
},
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useLocalization } from '@akinon/next/hooks';
|
|
4
|
+
import { Basket } from '@akinon/next/types';
|
|
5
|
+
import { Button, LoaderSpinner, Link } from '@theme/components';
|
|
6
|
+
import { BasketItem, Summary } from '@theme/views/basket';
|
|
7
|
+
import { ROUTES } from '@theme/routes';
|
|
8
|
+
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
import { pushCartView } from '@theme/utils/gtm';
|
|
11
|
+
|
|
12
|
+
interface BasketContentProps {
|
|
13
|
+
initialBasket: Basket;
|
|
14
|
+
multiBasket: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function BasketContent({
|
|
18
|
+
initialBasket,
|
|
19
|
+
multiBasket
|
|
20
|
+
}: BasketContentProps) {
|
|
21
|
+
const { t } = useLocalization();
|
|
22
|
+
const [basket, setBasket] = useState<Basket>(initialBasket);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (basket) {
|
|
26
|
+
const products = basket.basketitem_set.map((basketItem) => ({
|
|
27
|
+
...basketItem.product
|
|
28
|
+
}));
|
|
29
|
+
pushCartView(products);
|
|
30
|
+
}
|
|
31
|
+
}, [basket]);
|
|
32
|
+
|
|
33
|
+
const handleBasketUpdate = (updatedBasket: Basket) => {
|
|
34
|
+
setBasket(updatedBasket);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (!basket) {
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex justify-center w-full">
|
|
40
|
+
<LoaderSpinner />
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="max-w-screen-xl p-4 flex flex-col text-primary-800 lg:p-8 xl:flex-row xl:mx-auto">
|
|
47
|
+
{basket.basketitem_set && basket.basketitem_set.length > 0 ? (
|
|
48
|
+
<>
|
|
49
|
+
<div className="flex-1 xl:mr-16">
|
|
50
|
+
<div className="flex items-center justify-between py-2 border-b border-gray-200 lg:py-3">
|
|
51
|
+
<h2 className="text-xl lg:text-2xl font-light">
|
|
52
|
+
{t('basket.my_cart')}
|
|
53
|
+
</h2>
|
|
54
|
+
<Link
|
|
55
|
+
href={ROUTES.HOME}
|
|
56
|
+
className="text-xs hover:text-secondary-500"
|
|
57
|
+
>
|
|
58
|
+
{t('basket.back_to_shopping')}
|
|
59
|
+
</Link>
|
|
60
|
+
</div>
|
|
61
|
+
<ul>
|
|
62
|
+
{multiBasket ? (
|
|
63
|
+
<PluginModule
|
|
64
|
+
component={Component.MultiBasket}
|
|
65
|
+
props={{
|
|
66
|
+
BasketItem,
|
|
67
|
+
onBasketUpdate: handleBasketUpdate
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
basket.basketitem_set.map((basketItem, index) => (
|
|
72
|
+
<BasketItem
|
|
73
|
+
key={index}
|
|
74
|
+
basketItem={basketItem}
|
|
75
|
+
onBasketUpdate={handleBasketUpdate}
|
|
76
|
+
/>
|
|
77
|
+
))
|
|
78
|
+
)}
|
|
79
|
+
</ul>
|
|
80
|
+
</div>
|
|
81
|
+
<Summary basket={basket} onBasketUpdate={handleBasketUpdate} />
|
|
82
|
+
</>
|
|
83
|
+
) : (
|
|
84
|
+
<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">
|
|
85
|
+
<h1
|
|
86
|
+
className="w-full text-xl font-light text-secondary text-center sm:text-2xl"
|
|
87
|
+
data-testid="basket-empty"
|
|
88
|
+
>
|
|
89
|
+
{t('basket.empty.title')}
|
|
90
|
+
</h1>
|
|
91
|
+
|
|
92
|
+
<div className="w-full text-sm text-black-800 text-center my-4 mb-2 sm:text-base">
|
|
93
|
+
<p>{t('basket.empty.content_first')}</p>
|
|
94
|
+
<p>{t('basket.empty.content_second')}.</p>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<Link href={ROUTES.HOME} passHref>
|
|
98
|
+
<Button className="px-10 mt-2" appearance="filled">
|
|
99
|
+
{t('basket.empty.button')}
|
|
100
|
+
</Button>
|
|
101
|
+
</Link>
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
useUpdateQuantityMutation
|
|
4
4
|
} from '@akinon/next/data/client/basket';
|
|
5
5
|
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
6
|
-
import { BasketItem as BasketItemType } from '@akinon/next/types';
|
|
6
|
+
import { Basket, BasketItem as BasketItemType } from '@akinon/next/types';
|
|
7
7
|
import { Price, Button, Icon, Modal, Select, Link } from '@theme/components';
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
import { useAddFavoriteMutation } from '@akinon/next/data/client/wishlist';
|
|
@@ -19,11 +19,12 @@ import { pushRemoveFromCart } from '@theme/utils/gtm';
|
|
|
19
19
|
interface Props {
|
|
20
20
|
basketItem?: BasketItemType;
|
|
21
21
|
namespace?: string;
|
|
22
|
+
onBasketUpdate?: (basket: Basket) => void;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export const BasketItem = (props: Props) => {
|
|
25
26
|
const { t } = useLocalization();
|
|
26
|
-
const { basketItem, namespace } = props;
|
|
27
|
+
const { basketItem, namespace, onBasketUpdate } = props;
|
|
27
28
|
const [updateQuantityMutation] = useUpdateQuantityMutation();
|
|
28
29
|
const dispatch = useAppDispatch();
|
|
29
30
|
const [isRemoveBasketModalOpen, setRemoveBasketModalOpen] = useState(false);
|
|
@@ -54,19 +55,21 @@ export const BasketItem = (props: Props) => {
|
|
|
54
55
|
requestParams.namespace = namespace;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
.unwrap()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(draftBasket)
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
)
|
|
58
|
+
try {
|
|
59
|
+
const response = await updateQuantityMutation(requestParams).unwrap();
|
|
60
|
+
dispatch(
|
|
61
|
+
basketApi.util.updateQueryData(
|
|
62
|
+
'getBasket',
|
|
63
|
+
undefined,
|
|
64
|
+
(draftBasket) => {
|
|
65
|
+
Object.assign(draftBasket, response.basket);
|
|
66
|
+
}
|
|
68
67
|
)
|
|
69
68
|
);
|
|
69
|
+
onBasketUpdate?.(response.basket);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error updating quantity:', error);
|
|
72
|
+
}
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
const deleteProduct = async (productPk?: number) => {
|