@akinon/projectzero 1.41.0-rc.0 ā 1.41.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 +1 -36
- package/app-template/CHANGELOG.md +23 -330
- package/app-template/package.json +16 -15
- package/app-template/public/locales/en/account.json +4 -4
- package/app-template/public/locales/en/auth.json +1 -2
- package/app-template/public/locales/tr/account.json +1 -1
- package/app-template/public/locales/tr/auth.json +1 -2
- 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]/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 +3 -3
- package/app-template/src/plugins.js +2 -1
- package/app-template/src/views/account/address-form.tsx +7 -22
- package/app-template/src/views/account/contact-form.tsx +6 -22
- package/app-template/src/views/account/favourite-products/favourite-products-list.tsx +1 -5
- package/app-template/src/views/basket/summary.tsx +35 -26
- package/app-template/src/views/category/filters/index.tsx +105 -5
- package/app-template/src/views/login/index.tsx +20 -9
- package/app-template/src/views/product/product-info.tsx +42 -32
- package/app-template/tsconfig.json +4 -14
- package/commands/create.ts +5 -29
- package/dist/commands/create.js +2 -25
- package/package.json +1 -1
- 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
package/dist/commands/create.js
CHANGED
|
@@ -39,7 +39,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const readline = __importStar(require("readline"));
|
|
41
41
|
const utils_1 = require("../utils");
|
|
42
|
-
const { execSync } = require('child_process');
|
|
43
42
|
const loadingSpinner = require('loading-spinner');
|
|
44
43
|
const workingDir = path_1.default.resolve(process.cwd());
|
|
45
44
|
const rl = readline.createInterface({
|
|
@@ -132,8 +131,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
132
131
|
}
|
|
133
132
|
const answers = yield getAnswers();
|
|
134
133
|
const brandName = answers.brandName === '.' ? path_1.default.basename(workingDir) : answers.brandName;
|
|
135
|
-
const projectDir =
|
|
136
|
-
const relativeProjectDir = answers.brandName === '.' ? '.' : (0, utils_1.slugify)(brandName);
|
|
134
|
+
const projectDir = path_1.default.resolve(workingDir, (0, utils_1.slugify)(brandName));
|
|
137
135
|
if (!fs.existsSync(projectDir)) {
|
|
138
136
|
fs.mkdirSync(projectDir, { recursive: true });
|
|
139
137
|
}
|
|
@@ -155,28 +153,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
155
153
|
updateFileContents(path_1.default.join(projectDir, 'package.json'), {
|
|
156
154
|
name: (0, utils_1.slugify)(brandName)
|
|
157
155
|
});
|
|
158
|
-
console.log('\x1b[34m%s\x1b[0m', '\nš Installing packages...\n');
|
|
159
|
-
execSync(`cd ${relativeProjectDir} && yarn install`, { stdio: 'ignore' });
|
|
160
156
|
loadingSpinner.stop();
|
|
161
|
-
|
|
162
|
-
⨠${brandName} project is ready at \x1b[4m${projectDir}\x1b[0m
|
|
163
|
-
|
|
164
|
-
Within the directory, the following commands are available:
|
|
165
|
-
|
|
166
|
-
\x1b[35m$ yarn dev\x1b[0m
|
|
167
|
-
\x1b[32mLaunches the development server.\x1b[0m
|
|
168
|
-
|
|
169
|
-
\x1b[35m$ yarn build\x1b[0m
|
|
170
|
-
\x1b[32mCompiles the app into static files for production.\x1b[0m
|
|
171
|
-
|
|
172
|
-
\x1b[35m$ yarn start\x1b[0m
|
|
173
|
-
\x1b[32mRuns the production server.\x1b[0m
|
|
174
|
-
`;
|
|
175
|
-
const getStartedMessage = answers.brandName === '.'
|
|
176
|
-
? 'To get started, you can type:\n\n \x1b[35m$ yarn dev\x1b[0m\n'
|
|
177
|
-
: `To get started, you can type:\n\n \x1b[35m$ cd ${relativeProjectDir}\x1b[0m\n \x1b[35m$ yarn dev\x1b[0m\n`;
|
|
178
|
-
console.log('\x1b[32m%s\x1b[0m', successMessage);
|
|
179
|
-
console.log('\x1b[36m%s\x1b[0m', getStartedMessage);
|
|
180
|
-
console.log('\x1b[33m%s\x1b[0m', 'Project setup is complete\n');
|
|
157
|
+
console.log('\x1b[32m%s\x1b[0m', `\n ā ${answers.brandName} project is ready.\n`);
|
|
181
158
|
console.log('\x1b[33m%s\x1b[0m', 'Project Zero - Akinon\n');
|
|
182
159
|
});
|
package/package.json
CHANGED
|
@@ -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
|
-
};
|