@akinon/projectzero 1.107.0-rc.86 → 1.107.0
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 +5 -232
- package/app-template/.env.example +0 -1
- package/app-template/CHANGELOG.md +318 -4926
- package/app-template/README.md +1 -25
- package/app-template/package.json +20 -20
- package/app-template/public/locales/en/common.json +1 -42
- package/app-template/public/locales/tr/common.json +1 -42
- package/app-template/src/app/[commerce]/[locale]/[currency]/basket/page.tsx +82 -9
- package/app-template/src/app/[commerce]/[locale]/[currency]/landing-page/[pk]/page.tsx +1 -12
- package/app-template/src/assets/fonts/pz-icon.css +0 -3
- package/app-template/src/components/input.tsx +1 -2
- package/app-template/src/hooks/index.ts +0 -2
- package/app-template/src/plugins.js +2 -2
- package/app-template/src/settings.js +1 -6
- package/app-template/src/views/basket/basket-item.tsx +13 -16
- package/app-template/src/views/basket/summary.tsx +7 -10
- package/app-template/src/views/guest-login/index.tsx +1 -6
- package/app-template/src/views/header/search/index.tsx +5 -17
- package/app-template/src/views/product/slider.tsx +73 -86
- package/commands/plugins.ts +2 -29
- package/dist/commands/plugins.js +2 -23
- package/package.json +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/loading.tsx +0 -67
- package/app-template/src/app/api/image-proxy/route.ts +0 -1
- package/app-template/src/app/api/similar-product-list/route.ts +0 -1
- package/app-template/src/app/api/similar-products/route.ts +0 -1
- package/app-template/src/views/basket/basket-content.tsx +0 -106
package/app-template/README.md
CHANGED
|
@@ -12,30 +12,6 @@ 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
|
-
|
|
39
15
|
### Build
|
|
40
16
|
|
|
41
17
|
To build the app, run the following command:
|
|
@@ -43,7 +19,7 @@ To build the app, run the following command:
|
|
|
43
19
|
```bash
|
|
44
20
|
cd projectzeronext # Project root
|
|
45
21
|
yarn build
|
|
46
|
-
|
|
22
|
+
```
|
|
47
23
|
|
|
48
24
|
### Develop
|
|
49
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "projectzeronext",
|
|
3
|
-
"version": "1.107.0
|
|
3
|
+
"version": "1.107.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -24,23 +24,23 @@
|
|
|
24
24
|
"test:middleware": "jest middleware-matcher.test.ts --bail"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@akinon/next": "1.107.0
|
|
28
|
-
"@akinon/pz-akifast": "1.107.0
|
|
29
|
-
"@akinon/pz-b2b": "1.107.0
|
|
30
|
-
"@akinon/pz-basket-gift-pack": "1.107.0
|
|
31
|
-
"@akinon/pz-bkm": "1.107.0
|
|
32
|
-
"@akinon/pz-checkout-gift-pack": "1.107.0
|
|
33
|
-
"@akinon/pz-click-collect": "1.107.0
|
|
34
|
-
"@akinon/pz-credit-payment": "1.107.0
|
|
35
|
-
"@akinon/pz-gpay": "1.107.0
|
|
36
|
-
"@akinon/pz-hepsipay": "1.107.0
|
|
37
|
-
"@akinon/pz-masterpass": "1.107.0
|
|
38
|
-
"@akinon/pz-one-click-checkout": "1.107.0
|
|
39
|
-
"@akinon/pz-otp": "1.107.0
|
|
40
|
-
"@akinon/pz-pay-on-delivery": "1.107.0
|
|
41
|
-
"@akinon/pz-saved-card": "1.107.0
|
|
42
|
-
"@akinon/pz-tabby-extension": "1.107.0
|
|
43
|
-
"@akinon/pz-tamara-extension": "1.107.0
|
|
27
|
+
"@akinon/next": "1.107.0",
|
|
28
|
+
"@akinon/pz-akifast": "1.107.0",
|
|
29
|
+
"@akinon/pz-b2b": "1.107.0",
|
|
30
|
+
"@akinon/pz-basket-gift-pack": "1.107.0",
|
|
31
|
+
"@akinon/pz-bkm": "1.107.0",
|
|
32
|
+
"@akinon/pz-checkout-gift-pack": "1.107.0",
|
|
33
|
+
"@akinon/pz-click-collect": "1.107.0",
|
|
34
|
+
"@akinon/pz-credit-payment": "1.107.0",
|
|
35
|
+
"@akinon/pz-gpay": "1.107.0",
|
|
36
|
+
"@akinon/pz-hepsipay": "1.107.0",
|
|
37
|
+
"@akinon/pz-masterpass": "1.107.0",
|
|
38
|
+
"@akinon/pz-one-click-checkout": "1.107.0",
|
|
39
|
+
"@akinon/pz-otp": "1.107.0",
|
|
40
|
+
"@akinon/pz-pay-on-delivery": "1.107.0",
|
|
41
|
+
"@akinon/pz-saved-card": "1.107.0",
|
|
42
|
+
"@akinon/pz-tabby-extension": "1.107.0",
|
|
43
|
+
"@akinon/pz-tamara-extension": "1.107.0",
|
|
44
44
|
"@hookform/resolvers": "2.9.0",
|
|
45
45
|
"@next/third-parties": "14.1.0",
|
|
46
46
|
"@react-google-maps/api": "2.17.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"yup": "0.32.11"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@akinon/eslint-plugin-projectzero": "1.107.0
|
|
66
|
+
"@akinon/eslint-plugin-projectzero": "1.107.0",
|
|
67
67
|
"@semantic-release/changelog": "6.0.2",
|
|
68
68
|
"@semantic-release/exec": "6.0.3",
|
|
69
69
|
"@semantic-release/git": "10.0.1",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"jest-environment-jsdom": "29.7.0",
|
|
92
92
|
"lint-staged": "13.1.0",
|
|
93
93
|
"prettier": "2.6.2",
|
|
94
|
-
"react-number-format": "5.4
|
|
94
|
+
"react-number-format": "5.3.4",
|
|
95
95
|
"sass": "1.49.9",
|
|
96
96
|
"semantic-release": "19.0.5",
|
|
97
97
|
"server-only": "0.0.1",
|
|
@@ -27,25 +27,7 @@
|
|
|
27
27
|
"clean": "clean",
|
|
28
28
|
"categories": "CATEGORIES",
|
|
29
29
|
"view_all": "VIEW ALL",
|
|
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
|
-
}
|
|
30
|
+
"not_found": "Search Results Not Found"
|
|
49
31
|
},
|
|
50
32
|
"page_404": {
|
|
51
33
|
"title": "Page not found.",
|
|
@@ -90,29 +72,6 @@
|
|
|
90
72
|
"select_file": "Select File",
|
|
91
73
|
"no_file": "No file selected"
|
|
92
74
|
},
|
|
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
75
|
"forms": {
|
|
117
76
|
"sending": "Sending...",
|
|
118
77
|
"success": "Form submitted successfully!",
|
|
@@ -27,25 +27,7 @@
|
|
|
27
27
|
"clean": "temizle",
|
|
28
28
|
"categories": "KATEGORİLER",
|
|
29
29
|
"view_all": "HEPSİNİ GÖSTER",
|
|
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
|
-
}
|
|
30
|
+
"not_found": "Arama Sonuçları Bulunamadı"
|
|
49
31
|
},
|
|
50
32
|
"page_404": {
|
|
51
33
|
"title": "Sayfa bulunamadı.",
|
|
@@ -90,29 +72,6 @@
|
|
|
90
72
|
"select_file": "Dosya Seç",
|
|
91
73
|
"no_file": "Dosya seçilmedi"
|
|
92
74
|
},
|
|
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
75
|
"forms": {
|
|
117
76
|
"sending": "Gönderiliyor...",
|
|
118
77
|
"success": "Form başarıyla gönderildi!",
|
|
@@ -1,14 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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';
|
|
3
11
|
import settings from '@theme/settings';
|
|
4
12
|
|
|
5
|
-
export default
|
|
6
|
-
const { basket } =
|
|
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>
|
|
7
72
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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>
|
|
12
77
|
|
|
13
|
-
|
|
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
|
+
);
|
|
14
87
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
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';
|
|
5
4
|
|
|
6
5
|
async function Page({ params }: PageProps<{ pk: number }>) {
|
|
7
|
-
|
|
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
|
-
}
|
|
6
|
+
const data = await getLandingPageData({ pk: params.pk });
|
|
18
7
|
|
|
19
8
|
const content = data.landing_page;
|
|
20
9
|
|
|
@@ -78,8 +78,7 @@ 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 &&
|
|
82
|
-
(focused || hasValue || props.value || props.format)
|
|
81
|
+
hasFloatingLabel && (focused || hasValue)
|
|
83
82
|
})
|
|
84
83
|
)}
|
|
85
84
|
>
|
|
@@ -1,10 +1,6 @@
|
|
|
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
|
-
|
|
8
4
|
const commerceUrl = encodeURI(process.env.SERVICE_BACKEND_URL ?? 'default');
|
|
9
5
|
|
|
10
6
|
/** @type {import('@akinon/next/types').Settings} */
|
|
@@ -18,7 +14,6 @@ module.exports = {
|
|
|
18
14
|
{ translationKey: 'size', key: 'size' }
|
|
19
15
|
],
|
|
20
16
|
localization: {
|
|
21
|
-
// If there is one locale in the locales array, the default locale will be hidden in the URL.
|
|
22
17
|
locales: [
|
|
23
18
|
{
|
|
24
19
|
label: 'EN',
|
|
@@ -46,7 +41,7 @@ module.exports = {
|
|
|
46
41
|
}
|
|
47
42
|
],
|
|
48
43
|
defaultLocaleValue: 'en',
|
|
49
|
-
localeUrlStrategy: LocaleUrlStrategy.HideDefaultLocale,
|
|
44
|
+
localeUrlStrategy: LocaleUrlStrategy.HideDefaultLocale,
|
|
50
45
|
redirectToDefaultLocale: true,
|
|
51
46
|
defaultCurrencyCode: 'usd'
|
|
52
47
|
},
|
|
@@ -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 {
|
|
6
|
+
import { 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,12 +19,11 @@ import { pushRemoveFromCart } from '@theme/utils/gtm';
|
|
|
19
19
|
interface Props {
|
|
20
20
|
basketItem?: BasketItemType;
|
|
21
21
|
namespace?: string;
|
|
22
|
-
onBasketUpdate?: (basket: Basket) => void;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export const BasketItem = (props: Props) => {
|
|
26
25
|
const { t } = useLocalization();
|
|
27
|
-
const { basketItem, namespace
|
|
26
|
+
const { basketItem, namespace } = props;
|
|
28
27
|
const [updateQuantityMutation] = useUpdateQuantityMutation();
|
|
29
28
|
const dispatch = useAppDispatch();
|
|
30
29
|
const [isRemoveBasketModalOpen, setRemoveBasketModalOpen] = useState(false);
|
|
@@ -55,21 +54,19 @@ export const BasketItem = (props: Props) => {
|
|
|
55
54
|
requestParams.namespace = namespace;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
await updateQuantityMutation(requestParams)
|
|
58
|
+
.unwrap()
|
|
59
|
+
.then((data) =>
|
|
60
|
+
dispatch(
|
|
61
|
+
basketApi.util.updateQueryData(
|
|
62
|
+
'getBasket',
|
|
63
|
+
undefined,
|
|
64
|
+
(draftBasket) => {
|
|
65
|
+
Object.assign(draftBasket, data.basket);
|
|
66
|
+
}
|
|
67
|
+
)
|
|
67
68
|
)
|
|
68
69
|
);
|
|
69
|
-
onBasketUpdate?.(response.basket);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.error('Error updating quantity:', error);
|
|
72
|
-
}
|
|
73
70
|
};
|
|
74
71
|
|
|
75
72
|
const deleteProduct = async (productPk?: number) => {
|
|
@@ -18,7 +18,6 @@ import clsx from 'clsx';
|
|
|
18
18
|
|
|
19
19
|
interface Props {
|
|
20
20
|
basket: Basket;
|
|
21
|
-
onBasketUpdate?: (basket: Basket) => void;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
const voucherCodeFormSchema = (t) =>
|
|
@@ -28,7 +27,7 @@ const voucherCodeFormSchema = (t) =>
|
|
|
28
27
|
|
|
29
28
|
export const Summary = (props: Props) => {
|
|
30
29
|
const { t } = useLocalization();
|
|
31
|
-
const { basket
|
|
30
|
+
const { basket } = props;
|
|
32
31
|
const router = useRouter();
|
|
33
32
|
const {
|
|
34
33
|
register,
|
|
@@ -54,7 +53,7 @@ export const Summary = (props: Props) => {
|
|
|
54
53
|
const removeVoucherCode = () => {
|
|
55
54
|
removeVoucherCodeMutation()
|
|
56
55
|
.unwrap()
|
|
57
|
-
.then((basket) =>
|
|
56
|
+
.then((basket) =>
|
|
58
57
|
dispatch(
|
|
59
58
|
basketApi.util.updateQueryData(
|
|
60
59
|
'getBasket',
|
|
@@ -63,9 +62,8 @@ export const Summary = (props: Props) => {
|
|
|
63
62
|
Object.assign(draftBasket, basket);
|
|
64
63
|
}
|
|
65
64
|
)
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
})
|
|
65
|
+
)
|
|
66
|
+
)
|
|
69
67
|
.catch((error: Error) => {
|
|
70
68
|
setError('voucherCode', { message: error.data.non_field_errors });
|
|
71
69
|
});
|
|
@@ -76,7 +74,7 @@ export const Summary = (props: Props) => {
|
|
|
76
74
|
voucher_code: data.voucherCode
|
|
77
75
|
})
|
|
78
76
|
.unwrap()
|
|
79
|
-
.then((basket) =>
|
|
77
|
+
.then((basket) =>
|
|
80
78
|
dispatch(
|
|
81
79
|
basketApi.util.updateQueryData(
|
|
82
80
|
'getBasket',
|
|
@@ -85,9 +83,8 @@ export const Summary = (props: Props) => {
|
|
|
85
83
|
Object.assign(draftBasket, basket);
|
|
86
84
|
}
|
|
87
85
|
)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
})
|
|
86
|
+
)
|
|
87
|
+
)
|
|
91
88
|
.catch((error: Error) => {
|
|
92
89
|
setError('voucherCode', { message: error.data.non_field_errors });
|
|
93
90
|
});
|
|
@@ -51,14 +51,9 @@ const GuestLogin = () => {
|
|
|
51
51
|
).unwrap();
|
|
52
52
|
|
|
53
53
|
Object.keys(response?.errors || {}).forEach((key) => {
|
|
54
|
-
const errorValue = response?.errors[key];
|
|
55
|
-
const message = Array.isArray(errorValue)
|
|
56
|
-
? errorValue.join(', ')
|
|
57
|
-
: errorValue || '';
|
|
58
|
-
|
|
59
54
|
setError(key as keyof GuestLoginFormParams, {
|
|
60
55
|
type: 'custom',
|
|
61
|
-
message
|
|
56
|
+
message: response?.errors[key]?.join(', ')
|
|
62
57
|
});
|
|
63
58
|
});
|
|
64
59
|
} catch (error) {
|
|
@@ -4,11 +4,11 @@ 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
|
-
|
|
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';
|
|
11
|
-
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
12
12
|
|
|
13
13
|
export default function Search() {
|
|
14
14
|
const { t } = useLocalization();
|
|
@@ -41,14 +41,6 @@ export default function Search() {
|
|
|
41
41
|
};
|
|
42
42
|
}, [isSearchOpen, dispatch]);
|
|
43
43
|
|
|
44
|
-
const handleSearchTextChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
45
|
-
setSearchText(e.target.value);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const handleCloseSearch = () => {
|
|
49
|
-
dispatch(closeSearch());
|
|
50
|
-
};
|
|
51
|
-
|
|
52
44
|
return (
|
|
53
45
|
<>
|
|
54
46
|
<div
|
|
@@ -74,9 +66,9 @@ export default function Search() {
|
|
|
74
66
|
{t('common.search.results_for')}
|
|
75
67
|
</span>
|
|
76
68
|
<div className="flex items-center">
|
|
77
|
-
<
|
|
69
|
+
<input
|
|
78
70
|
value={searchText}
|
|
79
|
-
onChange={
|
|
71
|
+
onChange={(e) => setSearchText(e.target.value)}
|
|
80
72
|
onKeyDown={(e) => {
|
|
81
73
|
if (e.key === 'Enter' && searchText.trim() !== '') {
|
|
82
74
|
router.push(`${ROUTES.LIST}/?search_text=${searchText}`);
|
|
@@ -86,18 +78,14 @@ export default function Search() {
|
|
|
86
78
|
placeholder={t('common.search.placeholder')}
|
|
87
79
|
ref={inputRef}
|
|
88
80
|
/>
|
|
89
|
-
|
|
90
|
-
<PluginModule component={Component.HeaderImageSearchFeature} />
|
|
91
|
-
|
|
92
81
|
<Icon
|
|
93
82
|
name="close"
|
|
94
83
|
size={14}
|
|
95
|
-
onClick={
|
|
84
|
+
onClick={() => dispatch(closeSearch())}
|
|
96
85
|
className="cursor-pointer"
|
|
97
86
|
/>
|
|
98
87
|
</div>
|
|
99
88
|
</div>
|
|
100
|
-
|
|
101
89
|
<Results searchText={searchText} />
|
|
102
90
|
</div>
|
|
103
91
|
</div>
|