@akinon/projectzero 1.45.0-rc.5 → 1.46.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 +2 -55
- package/README.md +2 -3
- package/app-template/.lintstagedrc.js +4 -5
- package/app-template/CHANGELOG.md +48 -1131
- package/app-template/docs/basic-setup.md +1 -1
- package/app-template/docs/plugins.md +7 -7
- package/app-template/package.json +21 -23
- package/app-template/public/locales/en/account.json +4 -4
- package/app-template/public/locales/tr/account.json +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/account/address/page.tsx +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/account/coupons/page.tsx +4 -4
- package/app-template/src/app/[commerce]/[locale]/[currency]/account/profile/page.tsx +0 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/category/[pk]/page.tsx +2 -5
- package/app-template/src/app/[commerce]/[locale]/[currency]/orders/completed/[token]/page.tsx +8 -12
- package/app-template/src/components/checkbox.tsx +2 -2
- package/app-template/src/components/input.tsx +7 -19
- package/app-template/src/components/price.tsx +4 -9
- package/app-template/src/redux/reducers/category.ts +1 -7
- package/app-template/src/settings.js +1 -6
- package/app-template/src/views/account/address-card.tsx +2 -2
- package/app-template/src/views/account/address-form.tsx +7 -22
- package/app-template/src/views/account/contact-form.tsx +6 -23
- package/app-template/src/views/account/favorite-item.tsx +2 -2
- package/app-template/src/views/account/favourite-products/favourite-products-list.tsx +1 -5
- package/app-template/src/views/breadcrumb.tsx +1 -4
- package/app-template/src/views/category/category-info.tsx +17 -31
- package/app-template/src/views/category/filters/index.tsx +105 -5
- package/app-template/src/views/category/layout.tsx +3 -5
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +4 -33
- package/app-template/src/views/checkout/steps/payment/options/redirection.tsx +37 -43
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +3 -19
- package/app-template/src/views/checkout/steps/shipping/address-box.tsx +2 -2
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +1 -1
- package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +37 -230
- package/app-template/src/views/find-in-store/index.tsx +3 -2
- package/app-template/src/views/header/mobile-menu.tsx +8 -25
- package/app-template/tsconfig.json +4 -14
- package/app-template/yarn.lock +1953 -1824
- package/commands/create.ts +5 -29
- package/dist/commands/create.js +2 -25
- package/package.json +2 -2
- package/app-template/package-lock.json +0 -29303
- package/app-template/src/app/[commerce]/[locale]/[currency]/[...prettyurl]/page.tsx +0 -8
- package/app-template/src/views/category/filters/filter-item.tsx +0 -131
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
3
|
-
import { Facet, FacetChoice } from '@akinon/next/types';
|
|
4
|
-
import { Accordion, Radio, Checkbox } from '../../../components';
|
|
5
|
-
import { WIDGET_TYPE } from '../../../types';
|
|
6
|
-
import { SizeFilter } from './size-filter';
|
|
7
|
-
import { toggleFacet } from '@theme/redux/reducers/category';
|
|
8
|
-
import { commonProductAttributes } from '@theme/settings';
|
|
9
|
-
import { useRouter } from '@akinon/next/hooks';
|
|
10
|
-
|
|
11
|
-
const COMPONENT_TYPES = {
|
|
12
|
-
[WIDGET_TYPE.category]: Radio,
|
|
13
|
-
[WIDGET_TYPE.multiselect]: Checkbox
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const sizeKey = commonProductAttributes.find(
|
|
17
|
-
(item) => item.translationKey === 'size'
|
|
18
|
-
).key;
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
facet: Facet;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const sortByPredefinedOrder = (
|
|
25
|
-
aLabel: string,
|
|
26
|
-
bLabel: string,
|
|
27
|
-
order: string[]
|
|
28
|
-
) => {
|
|
29
|
-
const aIndex = order.indexOf(aLabel);
|
|
30
|
-
const bIndex = order.indexOf(bLabel);
|
|
31
|
-
|
|
32
|
-
if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex;
|
|
33
|
-
if (aIndex !== -1) return -1;
|
|
34
|
-
if (bIndex !== -1) return 1;
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const sortByNumericValue = (aLabel: string, bLabel: string) => {
|
|
40
|
-
const aNum = parseInt(aLabel, 10);
|
|
41
|
-
const bNum = parseInt(bLabel, 10);
|
|
42
|
-
|
|
43
|
-
if (!isNaN(aNum) && !isNaN(bNum)) return aNum - bNum;
|
|
44
|
-
if (!isNaN(aNum)) return -1;
|
|
45
|
-
if (!isNaN(bNum)) return 1;
|
|
46
|
-
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const sortChoices = (
|
|
51
|
-
facetKey: string,
|
|
52
|
-
choices: FacetChoice[]
|
|
53
|
-
): FacetChoice[] => {
|
|
54
|
-
if (facetKey === sizeKey) {
|
|
55
|
-
const order = ['xs', 's', 'm', 'l', 'xl'];
|
|
56
|
-
|
|
57
|
-
return choices.sort((a, b) => {
|
|
58
|
-
const aLabel = a.label.toLowerCase();
|
|
59
|
-
const bLabel = b.label.toLowerCase();
|
|
60
|
-
|
|
61
|
-
const orderComparison = sortByPredefinedOrder(aLabel, bLabel, order);
|
|
62
|
-
if (orderComparison !== null) return orderComparison;
|
|
63
|
-
|
|
64
|
-
const numericComparison = sortByNumericValue(aLabel, bLabel);
|
|
65
|
-
if (numericComparison !== null) return numericComparison;
|
|
66
|
-
|
|
67
|
-
return aLabel.localeCompare(bLabel);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return choices;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const getComponentByWidgetType = (widgetType: string, facetKey: string) => {
|
|
75
|
-
if (facetKey === sizeKey) {
|
|
76
|
-
return SizeFilter;
|
|
77
|
-
}
|
|
78
|
-
return COMPONENT_TYPES[widgetType] || COMPONENT_TYPES[WIDGET_TYPE.category];
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const FilterItem = ({ facet }: Props) => {
|
|
82
|
-
const dispatch = useAppDispatch();
|
|
83
|
-
const router = useRouter();
|
|
84
|
-
|
|
85
|
-
const handleSelectFilter = (choice: FacetChoice) => {
|
|
86
|
-
if (facet.key === 'category_ids') {
|
|
87
|
-
router.push(choice.url);
|
|
88
|
-
} else {
|
|
89
|
-
dispatch(toggleFacet({ facet, choice }));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const Component = getComponentByWidgetType(facet.widget_type, facet.key);
|
|
94
|
-
const choices = sortChoices(facet.key, [...facet.data.choices]);
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<Accordion
|
|
98
|
-
key={facet.key}
|
|
99
|
-
title={facet.name}
|
|
100
|
-
isCollapse={choices.some((choice) => choice.is_selected)}
|
|
101
|
-
dataTestId={`filter-${facet.name}`}
|
|
102
|
-
>
|
|
103
|
-
<div
|
|
104
|
-
className={clsx('flex gap-4', {
|
|
105
|
-
'flex-wrap flex-row': facet.key === sizeKey,
|
|
106
|
-
'flex-col': facet.key !== sizeKey
|
|
107
|
-
})}
|
|
108
|
-
>
|
|
109
|
-
{choices.map((choice, index) => (
|
|
110
|
-
<Component
|
|
111
|
-
key={choice.label}
|
|
112
|
-
data={choice}
|
|
113
|
-
name={facet.key}
|
|
114
|
-
onChange={() => facet.key !== sizeKey && handleSelectFilter(choice)}
|
|
115
|
-
onClick={() => facet.key === sizeKey && handleSelectFilter(choice)}
|
|
116
|
-
checked={choice.is_selected}
|
|
117
|
-
data-testid={`${choice.label.trim()}`}
|
|
118
|
-
>
|
|
119
|
-
{choice.label} (
|
|
120
|
-
<span
|
|
121
|
-
data-testid={`filter-count-${facet.name.toLowerCase()}-${index}`}
|
|
122
|
-
>
|
|
123
|
-
{choice.quantity}
|
|
124
|
-
</span>
|
|
125
|
-
)
|
|
126
|
-
</Component>
|
|
127
|
-
))}
|
|
128
|
-
</div>
|
|
129
|
-
</Accordion>
|
|
130
|
-
);
|
|
131
|
-
};
|