@akinon/next 1.13.1 → 1.14.1
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/.editorconfig +7 -0
- package/CHANGELOG.md +19 -0
- package/assets/styles/index.scss +28 -28
- package/bin/pz-install-plugins.js +0 -0
- package/bin/pz-install-theme.js +0 -0
- package/bin/pz-postbuild.js +0 -0
- package/bin/pz-postdev.js +0 -0
- package/bin/pz-postinstall.js +0 -0
- package/bin/pz-poststart.js +0 -0
- package/bin/pz-prebuild.js +0 -0
- package/bin/pz-predev.js +0 -0
- package/bin/pz-prestart.js +0 -0
- package/components/accordion.tsx +52 -0
- package/components/button.tsx +46 -0
- package/components/index.ts +17 -1
- package/components/input.tsx +110 -0
- package/components/plugin-module.tsx +11 -8
- package/components/price.tsx +55 -0
- package/components/selected-payment-option-view.tsx +7 -0
- package/data/client/address.ts +107 -107
- package/data/client/api.ts +2 -1
- package/data/client/b2b.ts +106 -106
- package/data/client/checkout.ts +516 -479
- package/data/client/wishlist.ts +31 -1
- package/data/server/category.ts +6 -2
- package/data/server/form.ts +4 -4
- package/data/server/list.ts +6 -1
- package/data/urls.ts +13 -2
- package/hooks/use-payment-options.ts +2 -1
- package/package.json +2 -2
- package/plugins.js +2 -1
- package/redux/middlewares/checkout.ts +265 -260
- package/redux/reducers/checkout.ts +13 -0
- package/redux/reducers/index.ts +14 -14
- package/types/commerce/b2b.ts +117 -117
- package/types/commerce/checkout.ts +7 -0
- package/types/index.ts +37 -0
- package/utils/generate-commerce-search-params.ts +22 -22
- package/utils/get-currency.ts +29 -29
package/types/commerce/b2b.ts
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import { Product } from './product';
|
|
2
|
-
|
|
3
|
-
export type Division = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
division_type: string;
|
|
7
|
-
parent: number;
|
|
8
|
-
erp_code: string;
|
|
9
|
-
country_id: number;
|
|
10
|
-
city_id: number;
|
|
11
|
-
township_id: number;
|
|
12
|
-
district_id: number;
|
|
13
|
-
address: string;
|
|
14
|
-
phone_number: string;
|
|
15
|
-
fax_number: string;
|
|
16
|
-
is_active: true;
|
|
17
|
-
latitude: null;
|
|
18
|
-
longitude: null;
|
|
19
|
-
monthly_order_limit: string;
|
|
20
|
-
current_balance: string;
|
|
21
|
-
current_balance_last_update: null | string;
|
|
22
|
-
extra_data: object;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export interface ProductB2b extends Product {
|
|
26
|
-
sku: string;
|
|
27
|
-
name: string;
|
|
28
|
-
price: string;
|
|
29
|
-
base_code: string;
|
|
30
|
-
asorti: string;
|
|
31
|
-
category: string;
|
|
32
|
-
currency: string;
|
|
33
|
-
variants: {
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
};
|
|
36
|
-
product_image: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type BasketResponse = {
|
|
40
|
-
id: number;
|
|
41
|
-
total_amount: string;
|
|
42
|
-
total_quantity: number;
|
|
43
|
-
basket_items: [
|
|
44
|
-
{
|
|
45
|
-
total_amount: string;
|
|
46
|
-
price: string;
|
|
47
|
-
quantity: number;
|
|
48
|
-
divisions: BasketItemDivision[];
|
|
49
|
-
product: ProductB2b;
|
|
50
|
-
product_remote_id: number;
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export interface QuotationErrorType {
|
|
56
|
-
data: {
|
|
57
|
-
non_field_errors: string[];
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface BasketItemDivision {
|
|
62
|
-
id: number;
|
|
63
|
-
name: string;
|
|
64
|
-
erp_code: string;
|
|
65
|
-
quantity: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type BasketItemType = {
|
|
69
|
-
total_amount: string;
|
|
70
|
-
price: string;
|
|
71
|
-
quantity: number;
|
|
72
|
-
divisions: BasketItemDivision[];
|
|
73
|
-
product: ProductB2b;
|
|
74
|
-
product_remote_id: number;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type BasketParams = {
|
|
78
|
-
division: string;
|
|
79
|
-
product_remote_id: string;
|
|
80
|
-
quantity: string;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export type SaveBasketParams = {
|
|
84
|
-
name: string;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export type CreateQuotationParams = {
|
|
88
|
-
name: string;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type UpdateProductParams = {
|
|
92
|
-
product_remote_id: number;
|
|
93
|
-
division: number;
|
|
94
|
-
quantity: number
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export type DeleteProductParams = {
|
|
98
|
-
product_remote_id: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export type LoadBasketParams = {
|
|
102
|
-
id: number;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export interface GetResponse<T> {
|
|
106
|
-
count: number;
|
|
107
|
-
next: null;
|
|
108
|
-
previous: null;
|
|
109
|
-
results: T[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type DraftResponse = {
|
|
113
|
-
id: number;
|
|
114
|
-
name: string;
|
|
115
|
-
total_amount: number;
|
|
116
|
-
total_quantity: number;
|
|
117
|
-
};
|
|
1
|
+
import { Product } from './product';
|
|
2
|
+
|
|
3
|
+
export type Division = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
division_type: string;
|
|
7
|
+
parent: number;
|
|
8
|
+
erp_code: string;
|
|
9
|
+
country_id: number;
|
|
10
|
+
city_id: number;
|
|
11
|
+
township_id: number;
|
|
12
|
+
district_id: number;
|
|
13
|
+
address: string;
|
|
14
|
+
phone_number: string;
|
|
15
|
+
fax_number: string;
|
|
16
|
+
is_active: true;
|
|
17
|
+
latitude: null;
|
|
18
|
+
longitude: null;
|
|
19
|
+
monthly_order_limit: string;
|
|
20
|
+
current_balance: string;
|
|
21
|
+
current_balance_last_update: null | string;
|
|
22
|
+
extra_data: object;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface ProductB2b extends Product {
|
|
26
|
+
sku: string;
|
|
27
|
+
name: string;
|
|
28
|
+
price: string;
|
|
29
|
+
base_code: string;
|
|
30
|
+
asorti: string;
|
|
31
|
+
category: string;
|
|
32
|
+
currency: string;
|
|
33
|
+
variants: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
product_image: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type BasketResponse = {
|
|
40
|
+
id: number;
|
|
41
|
+
total_amount: string;
|
|
42
|
+
total_quantity: number;
|
|
43
|
+
basket_items: [
|
|
44
|
+
{
|
|
45
|
+
total_amount: string;
|
|
46
|
+
price: string;
|
|
47
|
+
quantity: number;
|
|
48
|
+
divisions: BasketItemDivision[];
|
|
49
|
+
product: ProductB2b;
|
|
50
|
+
product_remote_id: number;
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export interface QuotationErrorType {
|
|
56
|
+
data: {
|
|
57
|
+
non_field_errors: string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface BasketItemDivision {
|
|
62
|
+
id: number;
|
|
63
|
+
name: string;
|
|
64
|
+
erp_code: string;
|
|
65
|
+
quantity: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type BasketItemType = {
|
|
69
|
+
total_amount: string;
|
|
70
|
+
price: string;
|
|
71
|
+
quantity: number;
|
|
72
|
+
divisions: BasketItemDivision[];
|
|
73
|
+
product: ProductB2b;
|
|
74
|
+
product_remote_id: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type BasketParams = {
|
|
78
|
+
division: string;
|
|
79
|
+
product_remote_id: string;
|
|
80
|
+
quantity: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type SaveBasketParams = {
|
|
84
|
+
name: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type CreateQuotationParams = {
|
|
88
|
+
name: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type UpdateProductParams = {
|
|
92
|
+
product_remote_id: number;
|
|
93
|
+
division: number;
|
|
94
|
+
quantity: number
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type DeleteProductParams = {
|
|
98
|
+
product_remote_id: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type LoadBasketParams = {
|
|
102
|
+
id: number;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export interface GetResponse<T> {
|
|
106
|
+
count: number;
|
|
107
|
+
next: null;
|
|
108
|
+
previous: null;
|
|
109
|
+
results: T[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type DraftResponse = {
|
|
113
|
+
id: number;
|
|
114
|
+
name: string;
|
|
115
|
+
total_amount: number;
|
|
116
|
+
total_quantity: number;
|
|
117
|
+
};
|
|
@@ -77,6 +77,7 @@ export interface PreOrder {
|
|
|
77
77
|
installment: InstallmentOption;
|
|
78
78
|
retail_store?: RetailStore;
|
|
79
79
|
gift_box?: GiftBox;
|
|
80
|
+
credit_payment_option?: CheckoutCreditPaymentOption;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export interface GuestLoginFormParams {
|
|
@@ -92,6 +93,11 @@ export interface PaymentChoice {
|
|
|
92
93
|
value: string;
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
export interface CheckoutCreditPaymentOption {
|
|
97
|
+
name: string;
|
|
98
|
+
pk: number;
|
|
99
|
+
slug: string;
|
|
100
|
+
}
|
|
95
101
|
export interface CheckoutContext {
|
|
96
102
|
page_name: string;
|
|
97
103
|
page_slug: string;
|
|
@@ -102,6 +108,7 @@ export interface CheckoutContext {
|
|
|
102
108
|
addresses?: Address[];
|
|
103
109
|
shipping_options?: ShippingOption[];
|
|
104
110
|
payment_options?: PaymentOption[];
|
|
111
|
+
credit_payment_options?: CheckoutCreditPaymentOption[];
|
|
105
112
|
payment_choices?: PaymentChoice[];
|
|
106
113
|
card_type: CreditCardType;
|
|
107
114
|
installments?: InstallmentOption[];
|
package/types/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LocaleUrlStrategy } from '../localization';
|
|
2
2
|
import { PzNextRequest } from '../middlewares';
|
|
3
|
+
import { Control, FieldError } from 'react-hook-form';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
3
5
|
|
|
4
6
|
declare global {
|
|
5
7
|
export interface Window {
|
|
@@ -235,3 +237,38 @@ export interface IconProps extends React.ComponentPropsWithRef<'i'> {
|
|
|
235
237
|
size?: number;
|
|
236
238
|
className?: string;
|
|
237
239
|
}
|
|
240
|
+
|
|
241
|
+
export interface ButtonProps
|
|
242
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
243
|
+
appearance?: 'filled' | 'outlined' | 'ghost';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface PriceProps {
|
|
247
|
+
currencyCode?: string;
|
|
248
|
+
useCurrencySymbol?: boolean;
|
|
249
|
+
useCurrencyAfterPrice?: boolean;
|
|
250
|
+
useCurrencySpace?: boolean;
|
|
251
|
+
useNegative?: boolean;
|
|
252
|
+
useNegativeSpace?: boolean;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface InputProps extends React.HTMLProps<HTMLInputElement> {
|
|
256
|
+
label?: string;
|
|
257
|
+
labelStyle?: 'default' | 'floating';
|
|
258
|
+
error?: FieldError | undefined;
|
|
259
|
+
control?: Control<any, any>;
|
|
260
|
+
required?: boolean;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface AccordionProps {
|
|
264
|
+
isCollapse?: boolean;
|
|
265
|
+
title?: string;
|
|
266
|
+
subTitle?: string;
|
|
267
|
+
icons?: string[];
|
|
268
|
+
iconSize?: number;
|
|
269
|
+
iconColor?: string;
|
|
270
|
+
children?: ReactNode;
|
|
271
|
+
className?: string;
|
|
272
|
+
titleClassName?: string;
|
|
273
|
+
dataTestId?: string;
|
|
274
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import logger from './log';
|
|
2
|
-
|
|
3
|
-
export const generateCommerceSearchParams = (searchParams?: URLSearchParams) => {
|
|
4
|
-
if (!searchParams) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const urlSerchParams = new URLSearchParams(searchParams);
|
|
9
|
-
|
|
10
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
11
|
-
if (typeof value === 'object') {
|
|
12
|
-
urlSerchParams.delete(key);
|
|
13
|
-
value.forEach((val) => {
|
|
14
|
-
urlSerchParams.append(key, val);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
logger.debug(`generateCommerceSearchParams: ${urlSerchParams.toString()}`);
|
|
20
|
-
|
|
21
|
-
return `?${urlSerchParams.toString()}`;
|
|
22
|
-
};
|
|
1
|
+
import logger from './log';
|
|
2
|
+
|
|
3
|
+
export const generateCommerceSearchParams = (searchParams?: URLSearchParams) => {
|
|
4
|
+
if (!searchParams) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const urlSerchParams = new URLSearchParams(searchParams);
|
|
9
|
+
|
|
10
|
+
Object.entries(searchParams).forEach(([key, value]) => {
|
|
11
|
+
if (typeof value === 'object') {
|
|
12
|
+
urlSerchParams.delete(key);
|
|
13
|
+
value.forEach((val) => {
|
|
14
|
+
urlSerchParams.append(key, val);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
logger.debug(`generateCommerceSearchParams: ${urlSerchParams.toString()}`);
|
|
20
|
+
|
|
21
|
+
return `?${urlSerchParams.toString()}`;
|
|
22
|
+
};
|
package/utils/get-currency.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import getSymbolFromCurrency from 'currency-symbol-map';
|
|
4
|
-
|
|
5
|
-
type GetCurrencyType = {
|
|
6
|
-
currencyCode: string;
|
|
7
|
-
useCurrencySymbol?: boolean;
|
|
8
|
-
useCurrencyAfterPrice?: boolean;
|
|
9
|
-
useCurrencySpace?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const getCurrency = (args: GetCurrencyType) => {
|
|
13
|
-
const {
|
|
14
|
-
currencyCode,
|
|
15
|
-
useCurrencySymbol = true,
|
|
16
|
-
useCurrencyAfterPrice = true,
|
|
17
|
-
useCurrencySpace = true
|
|
18
|
-
} = args;
|
|
19
|
-
|
|
20
|
-
const currencySpace = useCurrencySpace ? ' ' : '';
|
|
21
|
-
const currency = useCurrencySymbol
|
|
22
|
-
? `${getSymbolFromCurrency(currencyCode)}`
|
|
23
|
-
: currencyCode;
|
|
24
|
-
const currencyAfterPrice = useCurrencyAfterPrice
|
|
25
|
-
? `${currencySpace}${currency}`
|
|
26
|
-
: `${currency}${currencySpace}`;
|
|
27
|
-
|
|
28
|
-
return currencyAfterPrice;
|
|
29
|
-
};
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import getSymbolFromCurrency from 'currency-symbol-map';
|
|
4
|
+
|
|
5
|
+
type GetCurrencyType = {
|
|
6
|
+
currencyCode: string;
|
|
7
|
+
useCurrencySymbol?: boolean;
|
|
8
|
+
useCurrencyAfterPrice?: boolean;
|
|
9
|
+
useCurrencySpace?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getCurrency = (args: GetCurrencyType) => {
|
|
13
|
+
const {
|
|
14
|
+
currencyCode,
|
|
15
|
+
useCurrencySymbol = true,
|
|
16
|
+
useCurrencyAfterPrice = true,
|
|
17
|
+
useCurrencySpace = true
|
|
18
|
+
} = args;
|
|
19
|
+
|
|
20
|
+
const currencySpace = useCurrencySpace ? ' ' : '';
|
|
21
|
+
const currency = useCurrencySymbol
|
|
22
|
+
? `${getSymbolFromCurrency(currencyCode)}`
|
|
23
|
+
: currencyCode;
|
|
24
|
+
const currencyAfterPrice = useCurrencyAfterPrice
|
|
25
|
+
? `${currencySpace}${currency}`
|
|
26
|
+
: `${currency}${currencySpace}`;
|
|
27
|
+
|
|
28
|
+
return currencyAfterPrice;
|
|
29
|
+
};
|