@akinon/next 1.89.0-rc.6 → 1.89.0-rc.8
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 +14 -0
- package/__tests__/tsconfig.json +2 -1
- package/bin/pz-run-tests.js +60 -25
- package/components/price.tsx +2 -2
- package/hooks/use-loyalty-availability.ts +21 -0
- package/jest.config.js +1 -1
- package/package.json +2 -2
- package/redux/middlewares/checkout.ts +10 -1
- package/redux/reducers/checkout.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.89.0-rc.8
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d8fad39: ZERO-3370: include plugins test to build stage
|
|
8
|
+
- 943a239: ZERO-3370: add allowJs in akinon-next test tsconfig
|
|
9
|
+
- 0cabbda: ZERO-3370: replace inline monorepo check with reusable utility
|
|
10
|
+
|
|
11
|
+
## 1.89.0-rc.7
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- dfaceff: ZERO-3356: Add useLoyaltyAvailability hook and update checkout state management
|
|
16
|
+
|
|
3
17
|
## 1.89.0-rc.6
|
|
4
18
|
|
|
5
19
|
## 1.89.0-rc.5
|
package/__tests__/tsconfig.json
CHANGED
package/bin/pz-run-tests.js
CHANGED
|
@@ -5,60 +5,95 @@ const path = require('path');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const glob = require('glob');
|
|
7
7
|
const findBaseDir = require('../utils/find-base-dir');
|
|
8
|
+
const checkMonorepo = require('../utils/check-monorepo');
|
|
8
9
|
|
|
10
|
+
const IS_MONOREPO = checkMonorepo() !== null;
|
|
9
11
|
const BASE_DIR = findBaseDir();
|
|
12
|
+
const PLUGINS = require(path.join(BASE_DIR, 'src', 'plugins.js'));
|
|
10
13
|
|
|
11
|
-
function
|
|
14
|
+
function findPluginTestFiles(akinonNextPackagePath) {
|
|
15
|
+
const pluginsRootPath = path.join(
|
|
16
|
+
akinonNextPackagePath,
|
|
17
|
+
'..',
|
|
18
|
+
'..',
|
|
19
|
+
IS_MONOREPO ? 'packages' : '@akinon'
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (!fs.existsSync(pluginsRootPath)) {
|
|
23
|
+
console.log('Plugins directory not found:', pluginsRootPath);
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return PLUGINS.reduce((testFiles, pluginName) => {
|
|
28
|
+
const pluginDirectoryPath = path.join(pluginsRootPath, pluginName);
|
|
29
|
+
if (fs.existsSync(pluginDirectoryPath)) {
|
|
30
|
+
const pluginTestFiles = glob.sync('**/*.test.ts', {
|
|
31
|
+
cwd: pluginDirectoryPath,
|
|
32
|
+
absolute: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return testFiles.concat(pluginTestFiles);
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`Plugin directory not found: ${pluginName}`);
|
|
38
|
+
}
|
|
39
|
+
return testFiles;
|
|
40
|
+
}, []);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isJestInstalled() {
|
|
12
44
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
45
|
+
const jestExecutablePath = path.join(
|
|
46
|
+
BASE_DIR,
|
|
47
|
+
'node_modules',
|
|
48
|
+
'.bin',
|
|
49
|
+
'jest'
|
|
50
|
+
);
|
|
51
|
+
return fs.existsSync(jestExecutablePath);
|
|
15
52
|
} catch (error) {
|
|
16
53
|
return false;
|
|
17
54
|
}
|
|
18
55
|
}
|
|
19
56
|
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (insideNodeModules) {
|
|
57
|
+
function getAkinonNextPackagePath() {
|
|
58
|
+
if (!IS_MONOREPO) {
|
|
24
59
|
return path.resolve(__dirname, '..');
|
|
25
60
|
}
|
|
26
61
|
|
|
27
62
|
return path.resolve(__dirname, '../../../packages/akinon-next');
|
|
28
63
|
}
|
|
29
64
|
|
|
30
|
-
if (!
|
|
31
|
-
console.error('\x1b[31mError: Jest is not
|
|
65
|
+
if (!isJestInstalled()) {
|
|
66
|
+
console.error('\x1b[31mError: Jest is not installed in the project!\x1b[0m');
|
|
32
67
|
console.error(
|
|
33
|
-
'Please
|
|
68
|
+
'Please install all dependencies by running one of the following commands:'
|
|
34
69
|
);
|
|
35
70
|
console.error(' npm install');
|
|
36
|
-
console.error('or');
|
|
37
71
|
console.error(' yarn install');
|
|
38
72
|
process.exit(1);
|
|
39
73
|
}
|
|
40
74
|
|
|
41
|
-
const
|
|
42
|
-
const
|
|
75
|
+
const jestExecutablePath = path.join(BASE_DIR, 'node_modules', '.bin', 'jest');
|
|
76
|
+
const akinonNextPackagePath = getAkinonNextPackagePath();
|
|
43
77
|
|
|
44
|
-
const testFiles =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
const testFiles = [
|
|
79
|
+
...glob.sync('__tests__/**/*.test.ts', {
|
|
80
|
+
cwd: akinonNextPackagePath,
|
|
81
|
+
absolute: true
|
|
82
|
+
}),
|
|
83
|
+
...findPluginTestFiles(akinonNextPackagePath)
|
|
84
|
+
];
|
|
48
85
|
|
|
49
|
-
|
|
86
|
+
console.log(`Found ${testFiles.length} test files to run`);
|
|
87
|
+
|
|
88
|
+
const jestArguments = [
|
|
50
89
|
...testFiles,
|
|
51
|
-
`--config ${path.join(
|
|
90
|
+
`--config ${path.join(akinonNextPackagePath, 'jest.config.js')}`,
|
|
52
91
|
'--runTestsByPath',
|
|
53
92
|
'--passWithNoTests'
|
|
54
93
|
];
|
|
55
94
|
|
|
56
|
-
|
|
57
|
-
cwd:
|
|
95
|
+
spawn(jestExecutablePath, jestArguments, {
|
|
96
|
+
cwd: akinonNextPackagePath,
|
|
58
97
|
stdio: 'inherit',
|
|
59
98
|
shell: true
|
|
60
99
|
});
|
|
61
|
-
|
|
62
|
-
jestProcess.on('close', (code) => {
|
|
63
|
-
process.exit(code);
|
|
64
|
-
});
|
package/components/price.tsx
CHANGED
|
@@ -55,8 +55,8 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
|
55
55
|
: formattedValue;
|
|
56
56
|
|
|
57
57
|
const currentCurrencyDecimalScale = Settings.localization.currencies.find(
|
|
58
|
-
(currency) => currency
|
|
59
|
-
)
|
|
58
|
+
(currency) => currency?.code === currencyCode_
|
|
59
|
+
)?.decimalScale;
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
62
|
<NumericFormat
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useAppSelector } from '../redux/hooks';
|
|
2
|
+
|
|
3
|
+
export const useLoyaltyAvailability = () => {
|
|
4
|
+
const { paymentOptions, unavailablePaymentOptions } = useAppSelector(
|
|
5
|
+
(state) => state.checkout
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
const hasLoyaltyInAvailable = paymentOptions.some(
|
|
9
|
+
(option) =>
|
|
10
|
+
option.payment_type === 'loyalty_money' ||
|
|
11
|
+
option.payment_type === 'loyalty'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const hasLoyaltyInUnavailable = unavailablePaymentOptions.some(
|
|
15
|
+
(option) =>
|
|
16
|
+
option.payment_type === 'loyalty_money' ||
|
|
17
|
+
option.payment_type === 'loyalty'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return hasLoyaltyInAvailable || hasLoyaltyInUnavailable;
|
|
21
|
+
};
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.89.0-rc.
|
|
4
|
+
"version": "1.89.0-rc.8",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"set-cookie-parser": "2.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@akinon/eslint-plugin-projectzero": "1.89.0-rc.
|
|
37
|
+
"@akinon/eslint-plugin-projectzero": "1.89.0-rc.8",
|
|
38
38
|
"@babel/core": "7.26.10",
|
|
39
39
|
"@babel/preset-env": "7.26.9",
|
|
40
40
|
"@babel/preset-typescript": "7.27.0",
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
setShippingOptions,
|
|
21
21
|
setHepsipayAvailability,
|
|
22
22
|
setWalletPaymentData,
|
|
23
|
-
setPayOnDeliveryOtpModalActive
|
|
23
|
+
setPayOnDeliveryOtpModalActive,
|
|
24
|
+
setUnavailablePaymentOptions
|
|
24
25
|
} from '../../redux/reducers/checkout';
|
|
25
26
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
26
27
|
import { checkoutApi } from '../../data/client/checkout';
|
|
@@ -148,6 +149,14 @@ export const contextListMiddleware: Middleware = ({
|
|
|
148
149
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
if (context.page_context.unavailable_options) {
|
|
153
|
+
dispatch(
|
|
154
|
+
setUnavailablePaymentOptions(
|
|
155
|
+
context.page_context.unavailable_options
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
151
160
|
if (context.page_context.credit_payment_options) {
|
|
152
161
|
dispatch(
|
|
153
162
|
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
@@ -40,6 +40,7 @@ export interface CheckoutState {
|
|
|
40
40
|
shippingOptions: ShippingOption[];
|
|
41
41
|
dataSourceShippingOptions: DataSource[];
|
|
42
42
|
paymentOptions: PaymentOption[];
|
|
43
|
+
unavailablePaymentOptions: PaymentOption[];
|
|
43
44
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
44
45
|
selectedCreditPaymentPk: number;
|
|
45
46
|
paymentChoices: PaymentChoice[];
|
|
@@ -94,6 +95,7 @@ const initialState: CheckoutState = {
|
|
|
94
95
|
shippingOptions: [],
|
|
95
96
|
dataSourceShippingOptions: [],
|
|
96
97
|
paymentOptions: [],
|
|
98
|
+
unavailablePaymentOptions: [],
|
|
97
99
|
creditPaymentOptions: [],
|
|
98
100
|
selectedCreditPaymentPk: null,
|
|
99
101
|
paymentChoices: [],
|
|
@@ -157,6 +159,9 @@ const checkoutSlice = createSlice({
|
|
|
157
159
|
setPaymentOptions(state, { payload }) {
|
|
158
160
|
state.paymentOptions = payload;
|
|
159
161
|
},
|
|
162
|
+
setUnavailablePaymentOptions(state, { payload }) {
|
|
163
|
+
state.unavailablePaymentOptions = payload;
|
|
164
|
+
},
|
|
160
165
|
setPaymentChoices(state, { payload }) {
|
|
161
166
|
state.paymentChoices = payload;
|
|
162
167
|
},
|
|
@@ -218,9 +223,10 @@ export const {
|
|
|
218
223
|
setShippingOptions,
|
|
219
224
|
setDataSourceShippingOptions,
|
|
220
225
|
setPaymentOptions,
|
|
226
|
+
setUnavailablePaymentOptions,
|
|
227
|
+
setPaymentChoices,
|
|
221
228
|
setCreditPaymentOptions,
|
|
222
229
|
setSelectedCreditPaymentPk,
|
|
223
|
-
setPaymentChoices,
|
|
224
230
|
setCardType,
|
|
225
231
|
setInstallmentOptions,
|
|
226
232
|
setBankAccounts,
|