@akinon/projectzero 1.99.0-rc.70 → 1.99.0-snapshot-ZERO-3640-20250919140314

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 (64) hide show
  1. package/CHANGELOG.md +5 -240
  2. package/app-template/.env.example +0 -1
  3. package/app-template/CHANGELOG.md +300 -5065
  4. package/app-template/README.md +1 -25
  5. package/app-template/package.json +19 -21
  6. package/app-template/public/locales/en/common.json +1 -48
  7. package/app-template/public/locales/tr/common.json +1 -48
  8. package/app-template/src/app/[commerce]/[locale]/[currency]/basket/page.tsx +82 -9
  9. package/app-template/src/app/[commerce]/[locale]/[currency]/category/[pk]/page.tsx +4 -17
  10. package/app-template/src/app/[commerce]/[locale]/[currency]/flat-page/[pk]/page.tsx +1 -12
  11. package/app-template/src/app/[commerce]/[locale]/[currency]/group-product/[pk]/page.tsx +11 -29
  12. package/app-template/src/app/[commerce]/[locale]/[currency]/landing-page/[pk]/page.tsx +1 -12
  13. package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/page.tsx +10 -28
  14. package/app-template/src/app/[commerce]/[locale]/[currency]/special-page/[pk]/page.tsx +1 -12
  15. package/app-template/src/app/api/form/[...id]/route.ts +7 -1
  16. package/app-template/src/assets/fonts/pz-icon.css +0 -3
  17. package/app-template/src/components/__tests__/link.test.tsx +0 -2
  18. package/app-template/src/components/accordion.tsx +19 -22
  19. package/app-template/src/components/currency-select.tsx +0 -1
  20. package/app-template/src/components/file-input.tsx +7 -27
  21. package/app-template/src/components/generate-form-fields.tsx +4 -43
  22. package/app-template/src/components/input.tsx +2 -9
  23. package/app-template/src/components/modal.tsx +16 -32
  24. package/app-template/src/components/pagination.tsx +0 -1
  25. package/app-template/src/components/select.tsx +26 -38
  26. package/app-template/src/components/types/index.ts +1 -25
  27. package/app-template/src/hooks/index.ts +0 -2
  28. package/app-template/src/plugins.js +1 -3
  29. package/app-template/src/settings.js +2 -8
  30. package/app-template/src/types/index.ts +3 -74
  31. package/app-template/src/views/account/address-form.tsx +4 -8
  32. package/app-template/src/views/account/contact-form.tsx +1 -1
  33. package/app-template/src/views/account/content-header.tsx +2 -2
  34. package/app-template/src/views/account/faq/faq-tabs.tsx +2 -8
  35. package/app-template/src/views/basket/basket-item.tsx +14 -22
  36. package/app-template/src/views/basket/summary.tsx +7 -10
  37. package/app-template/src/views/breadcrumb.tsx +2 -2
  38. package/app-template/src/views/category/category-info.tsx +0 -1
  39. package/app-template/src/views/category/filters/index.tsx +1 -1
  40. package/app-template/src/views/guest-login/index.tsx +1 -6
  41. package/app-template/src/views/header/action-menu.tsx +1 -1
  42. package/app-template/src/views/header/search/index.tsx +5 -17
  43. package/app-template/src/views/login/index.tsx +10 -11
  44. package/app-template/src/views/otp-login/index.tsx +6 -11
  45. package/app-template/src/views/product/product-info.tsx +263 -62
  46. package/app-template/src/views/product/slider.tsx +73 -86
  47. package/app-template/src/views/register/index.tsx +11 -15
  48. package/app-template/src/widgets/footer-menu.tsx +2 -6
  49. package/commands/plugins.ts +16 -63
  50. package/dist/commands/plugins.js +16 -57
  51. package/package.json +1 -1
  52. package/app-template/.github/instructions/account.instructions.md +0 -749
  53. package/app-template/.github/instructions/edge-cases.instructions.md +0 -73
  54. package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/loading.tsx +0 -67
  55. package/app-template/src/app/api/image-proxy/route.ts +0 -1
  56. package/app-template/src/app/api/similar-product-list/route.ts +0 -1
  57. package/app-template/src/app/api/similar-products/route.ts +0 -1
  58. package/app-template/src/hooks/use-product-cart.ts +0 -77
  59. package/app-template/src/hooks/use-stock-alert.ts +0 -74
  60. package/app-template/src/utils/variant-validation.ts +0 -41
  61. package/app-template/src/views/basket/basket-content.tsx +0 -106
  62. package/app-template/src/views/product/product-actions.tsx +0 -165
  63. package/app-template/src/views/product/product-share.tsx +0 -56
  64. package/app-template/src/views/product/product-variants.tsx +0 -26
@@ -3,7 +3,6 @@
3
3
  import { Accordion, LoaderSpinner, TabPanel, Tabs } from '@theme/components';
4
4
  import React from 'react';
5
5
  import { useGetWidgetQuery } from '@akinon/next/data/client/misc';
6
- import { useLocalization } from '@akinon/next/hooks';
7
6
 
8
7
  interface Props {
9
8
  searchKey?: string;
@@ -12,7 +11,6 @@ interface Props {
12
11
  export function FaqTabs(props: Props) {
13
12
  const { searchKey } = props;
14
13
  const { data, isLoading } = useGetWidgetQuery('faq');
15
- const { locale } = useLocalization();
16
14
 
17
15
  if (isLoading) {
18
16
  return <LoaderSpinner className="mt-4" />;
@@ -31,12 +29,8 @@ export function FaqTabs(props: Props) {
31
29
  {data?.attributes?.faq_contents
32
30
  ?.filter(
33
31
  (faq) =>
34
- faq.value.content
35
- .toLocaleLowerCase(locale)
36
- .includes(searchKey) ||
37
- faq.value.title
38
- .toLocaleLowerCase(locale)
39
- .includes(searchKey)
32
+ faq.value.content.toLocaleLowerCase().includes(searchKey) ||
33
+ faq.value.title.toLocaleLowerCase().includes(searchKey)
40
34
  )
41
35
  .map((faq, index) => {
42
36
  if (faq.value.category == item.value.category_id) {
@@ -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 { Basket, BasketItem as BasketItemType } from '@akinon/next/types';
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, onBasketUpdate } = props;
26
+ const { basketItem, namespace } = props;
28
27
  const [updateQuantityMutation] = useUpdateQuantityMutation();
29
28
  const dispatch = useAppDispatch();
30
29
  const [isRemoveBasketModalOpen, setRemoveBasketModalOpen] = useState(false);
@@ -40,12 +39,7 @@ export const BasketItem = (props: Props) => {
40
39
  quantity: number,
41
40
  attributes: object = {}
42
41
  ) => {
43
- const requestParams: {
44
- product: number;
45
- quantity: number;
46
- attributes: object;
47
- namespace?: string;
48
- } = {
42
+ const requestParams: any = {
49
43
  product: productPk,
50
44
  quantity,
51
45
  attributes
@@ -55,21 +49,19 @@ export const BasketItem = (props: Props) => {
55
49
  requestParams.namespace = namespace;
56
50
  }
57
51
 
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
- }
52
+ await updateQuantityMutation(requestParams)
53
+ .unwrap()
54
+ .then((data) =>
55
+ dispatch(
56
+ basketApi.util.updateQueryData(
57
+ 'getBasket',
58
+ undefined,
59
+ (draftBasket) => {
60
+ Object.assign(draftBasket, data.basket);
61
+ }
62
+ )
67
63
  )
68
64
  );
69
- onBasketUpdate?.(response.basket);
70
- } catch (error) {
71
- console.error('Error updating quantity:', error);
72
- }
73
65
  };
74
66
 
75
67
  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, onBasketUpdate } = props;
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
- onBasketUpdate?.(basket);
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
- onBasketUpdate?.(basket);
90
- })
86
+ )
87
+ )
91
88
  .catch((error: Error) => {
92
89
  setError('voucherCode', { message: error.data.non_field_errors });
93
90
  });
@@ -12,7 +12,7 @@ export interface BreadcrumbProps {
12
12
  }
13
13
 
14
14
  export default function Breadcrumb(props: BreadcrumbProps) {
15
- const { t, locale } = useLocalization();
15
+ const { t } = useLocalization();
16
16
  const { breadcrumbList = [] } = props;
17
17
 
18
18
  const list = [
@@ -28,7 +28,7 @@ export default function Breadcrumb(props: BreadcrumbProps) {
28
28
  {list.map((item, index) => (
29
29
  <Fragment key={index}>
30
30
  <Link href={item.url}>
31
- {capitalize(item.text.toLocaleLowerCase(locale))}
31
+ {capitalize(item.text.toLocaleLowerCase())}
32
32
  </Link>
33
33
  {index !== list.length - 1 && <Icon name="chevron-end" size={8} />}
34
34
  </Fragment>
@@ -57,7 +57,6 @@ export default function ListPage(props: ListPageProps) {
57
57
  newUrl.searchParams.delete('page');
58
58
  router.push(newUrl.pathname + newUrl.search, undefined);
59
59
  }
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
61
60
  }, [searchParams, data.products, page]);
62
61
 
63
62
  const { t } = useLocalization();
@@ -6,7 +6,7 @@ import { useLocalization } from '@akinon/next/hooks';
6
6
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
7
7
  import { resetSelectedFacets } from '@theme/redux/reducers/category';
8
8
  import CategoryActiveFilters from '@theme/views/category/category-active-filters';
9
- import { useMemo, useTransition } from 'react';
9
+ import { useMemo, useState, useTransition } from 'react';
10
10
  import { FilterItem } from './filter-item';
11
11
 
12
12
  interface Props {
@@ -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) {
@@ -76,7 +76,7 @@ export default function ActionMenu() {
76
76
  : 'bg-secondary-500 text-white'
77
77
  )}
78
78
  >
79
- <span data-testid="header-basket-count">{totalQuantity}</span>
79
+ {totalQuantity}
80
80
  </Badge>
81
81
  ),
82
82
  miniBasket: <MiniBasket />
@@ -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
- 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';
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
- <Input
69
+ <input
78
70
  value={searchText}
79
- onChange={handleSearchTextChange}
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={handleCloseSearch}
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>
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
- import { signIn } from 'next-auth/react';
3
+ import { signIn, SignInOptions } from 'next-auth/react';
4
4
  import { useSearchParams } from 'next/navigation';
5
5
  import { useState } from 'react';
6
6
  import { ROUTES } from '@theme/routes';
7
- import { LoginFormType, FormType, PzSignInOptions } from '@theme/types';
7
+ import { LoginFormType } from '@theme/types';
8
8
  import { Button, Input, Link } from '@theme/components';
9
9
  import { SubmitHandler, useForm } from 'react-hook-form';
10
10
  import * as yup from 'yup';
@@ -79,9 +79,8 @@ export const Login = () => {
79
79
  redirect: false,
80
80
  callbackUrl: searchParams.get('callbackUrl') ?? '/',
81
81
  captchaValidated,
82
- ...data,
83
- formType: FormType.login
84
- } as PzSignInOptions);
82
+ ...data
83
+ } as SignInOptions);
85
84
 
86
85
  if (loginResponse.error) {
87
86
  const errors: AuthError[] = JSON.parse(loginResponse.error);
@@ -110,25 +109,25 @@ export const Login = () => {
110
109
  try {
111
110
  parsedValue = JSON.parse(item.value);
112
111
  } catch {
113
- parsedValue = [item.value];
112
+ parsedValue = [item.value];
114
113
  }
115
114
  } else {
116
- parsedValue = item.value;
115
+ parsedValue = item.value;
117
116
  }
118
117
 
119
118
  if (Array.isArray(parsedValue)) {
120
119
  setError(item.name as keyof LoginFormType, {
121
120
  type: 'custom',
122
- message: parsedValue.join(', ')
121
+ message: parsedValue.join(', '),
123
122
  });
124
123
  } else {
125
124
  Object.keys(parsedValue).forEach((key) => {
126
125
  const fieldName = key as keyof LoginFormType;
127
126
  const errorMessages = parsedValue[key] as string[];
128
-
127
+
129
128
  setError(fieldName, {
130
129
  type: 'custom',
131
- message: errorMessages.join(', ')
130
+ message: errorMessages.join(', '),
132
131
  });
133
132
  });
134
133
  }
@@ -162,7 +161,7 @@ export const Login = () => {
162
161
  method="post"
163
162
  onSubmit={handleSubmit(onSubmit)}
164
163
  >
165
- <input type="hidden" value={FormType.login} {...register('formType')} />
164
+ <input type="hidden" value="login" {...register('formType')} />
166
165
  <input type="hidden" value={locale} {...register('locale')} />
167
166
 
168
167
  <div className={clsx(errors.email ? 'mb-8' : 'mb-4')}>
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
- import { signIn } from 'next-auth/react';
3
+ import { signIn, SignInOptions } from 'next-auth/react';
4
4
  import { useState } from 'react';
5
- import { OtpLoginFormType, FormType, PzSignInOptions } from '@theme/types';
5
+ import { OtpLoginFormType } from '@theme/types';
6
6
  import { Button, Input } from '@theme/components';
7
7
  import { SubmitHandler, useForm } from 'react-hook-form';
8
8
  import * as yup from 'yup';
@@ -47,9 +47,8 @@ export const OtpLogin = () => {
47
47
  const loginResponse = await signIn('default', {
48
48
  redirect: false,
49
49
  callbackUrl: '/',
50
- ...data,
51
- formType: FormType.otpLogin
52
- } as PzSignInOptions);
50
+ ...data
51
+ } as SignInOptions);
53
52
 
54
53
  if (loginResponse.error) {
55
54
  const errors: AuthError[] = JSON.parse(loginResponse.error);
@@ -101,11 +100,7 @@ export const OtpLogin = () => {
101
100
  {t('auth.login.title_gsm')}
102
101
  </h2>
103
102
  <form onSubmit={handleSubmit(onSubmit)}>
104
- <input
105
- type="hidden"
106
- value={FormType.otpLogin}
107
- {...register('formType')}
108
- />
103
+ <input type="hidden" value="otpLogin" {...register('formType')} />
109
104
  <input type="hidden" value={locale} {...register('locale')} />
110
105
 
111
106
  <div className="mb-4">
@@ -114,7 +109,7 @@ export const OtpLogin = () => {
114
109
  className="h-14"
115
110
  label={t('auth.login.form.phone.placeholder')}
116
111
  type="tel"
117
- format={user_phone_format.replace(/9/g, '#')}
112
+ format={user_phone_format.replace(/\9/g, '#')}
118
113
  mask="_"
119
114
  allowEmptyFormatting={true}
120
115
  control={control}