@akinon/next 1.56.0 → 1.58.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 +13 -0
- package/api/client.ts +18 -9
- package/components/selected-payment-option-view.tsx +26 -37
- package/data/client/account.ts +10 -9
- package/hooks/use-payment-options.ts +2 -1
- package/package.json +2 -2
- package/plugins.js +2 -1
- package/types/commerce/account.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.58.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f3d076b: ZERO-2864: create tabby extension plugin
|
|
8
|
+
|
|
9
|
+
## 1.57.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- fad2768: ZERO-2739: add gpay to payment plugin map
|
|
14
|
+
- dff0d59: ZERO-2659: add formData support to proxy api requests
|
|
15
|
+
|
|
3
16
|
## 1.56.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/api/client.ts
CHANGED
|
@@ -84,12 +84,13 @@ async function proxyRequest(...args) {
|
|
|
84
84
|
fetchOptions.headers['Content-Type'] = options.contentType;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
const isMultipartFormData = req.headers.get('content-type')?.includes('multipart/form-data;');
|
|
88
|
+
|
|
87
89
|
if (req.method !== 'GET') {
|
|
88
|
-
|
|
89
|
-
let body = {};
|
|
90
|
+
let body: Record<string, any> | FormData = {};
|
|
90
91
|
|
|
91
92
|
try {
|
|
92
|
-
body = await req.json();
|
|
93
|
+
body = isMultipartFormData ? await req.formData() : await req.json();
|
|
93
94
|
} catch (error) {
|
|
94
95
|
logger.error(
|
|
95
96
|
`Client Proxy Request - Error while parsing request body to JSON`,
|
|
@@ -100,13 +101,21 @@ async function proxyRequest(...args) {
|
|
|
100
101
|
);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
104
|
+
if (isMultipartFormData) {
|
|
105
|
+
fetchOptions.body = body as FormData;
|
|
106
|
+
} else {
|
|
107
|
+
const formData = new FormData();
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
Object.keys(body ?? {}).forEach((key) => {
|
|
110
|
+
if (body[key]) {
|
|
111
|
+
formData.append(key, body[key]);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
fetchOptions.body = !options.useFormData
|
|
116
|
+
? JSON.stringify(body)
|
|
117
|
+
: formData;
|
|
118
|
+
}
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
let url = `${commerceUrl}/${slug.replace(/,/g, '/')}`;
|
|
@@ -6,6 +6,21 @@ import dynamic from 'next/dynamic';
|
|
|
6
6
|
import { PaymentOptionViews } from 'views/checkout/steps/payment';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
+
const fallbackView = () => <div />;
|
|
10
|
+
|
|
11
|
+
const paymentTypeToView = {
|
|
12
|
+
bkm_express: 'bkm',
|
|
13
|
+
credit_card: 'credit-card',
|
|
14
|
+
credit_payment: 'credit-payment',
|
|
15
|
+
funds_transfer: 'funds-transfer',
|
|
16
|
+
gpay: 'gpay',
|
|
17
|
+
loyalty_money: 'loyalty',
|
|
18
|
+
masterpass: 'credit-card',
|
|
19
|
+
pay_on_delivery: 'pay-on-delivery',
|
|
20
|
+
redirection: 'redirection'
|
|
21
|
+
// Add other mappings as needed
|
|
22
|
+
};
|
|
23
|
+
|
|
9
24
|
export default function SelectedPaymentOptionView() {
|
|
10
25
|
const { payment_option } = useAppSelector(
|
|
11
26
|
(state: RootState) => state.checkout.preOrder
|
|
@@ -14,7 +29,7 @@ export default function SelectedPaymentOptionView() {
|
|
|
14
29
|
const Component = useMemo(
|
|
15
30
|
() =>
|
|
16
31
|
dynamic(
|
|
17
|
-
() => {
|
|
32
|
+
async () => {
|
|
18
33
|
const customOption = PaymentOptionViews.find(
|
|
19
34
|
(opt) => opt.slug === payment_option?.slug
|
|
20
35
|
);
|
|
@@ -29,46 +44,20 @@ export default function SelectedPaymentOptionView() {
|
|
|
29
44
|
});
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
|
|
47
|
+
const view = paymentTypeToView[payment_option?.payment_type] || null;
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`views/checkout/steps/payment/options
|
|
38
|
-
);
|
|
39
|
-
} else if (payment_option?.payment_type === 'funds_transfer') {
|
|
40
|
-
promise = import(
|
|
41
|
-
`views/checkout/steps/payment/options/funds-transfer`
|
|
42
|
-
);
|
|
43
|
-
} else if (payment_option?.payment_type === 'redirection') {
|
|
44
|
-
promise = import(
|
|
45
|
-
`views/checkout/steps/payment/options/redirection`
|
|
46
|
-
);
|
|
47
|
-
} else if (payment_option?.payment_type === 'pay_on_delivery') {
|
|
48
|
-
promise = import(
|
|
49
|
-
`views/checkout/steps/payment/options/pay-on-delivery`
|
|
50
|
-
);
|
|
51
|
-
} else if (payment_option?.payment_type === 'loyalty_money') {
|
|
52
|
-
promise = import(`views/checkout/steps/payment/options/loyalty`);
|
|
53
|
-
} else if (payment_option?.payment_type === 'masterpass') {
|
|
54
|
-
promise = import(
|
|
55
|
-
`views/checkout/steps/payment/options/credit-card`
|
|
49
|
+
if (view) {
|
|
50
|
+
try {
|
|
51
|
+
const mod = await import(
|
|
52
|
+
`views/checkout/steps/payment/options/${view}`
|
|
56
53
|
);
|
|
54
|
+
return mod.default || fallbackView;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return fallbackView;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
// promise = import(`views/checkout/steps/payment/options/credit-payment`);
|
|
60
|
-
// }
|
|
61
|
-
// else if (payment_option.payment_type === 'gpay') {
|
|
62
|
-
// promise = import(`views/checkout/steps/payment/options/gpay`);
|
|
63
|
-
// }
|
|
64
|
-
// else if (payment_option.payment_type === 'bkm_express') {
|
|
65
|
-
// promise = import(`views/checkout/steps/payment/options/bkm`);
|
|
66
|
-
// }
|
|
67
|
-
} catch (error) {}
|
|
58
|
+
}
|
|
68
59
|
|
|
69
|
-
return
|
|
70
|
-
? promise.then((mod) => mod.default).catch(() => () => null)
|
|
71
|
-
: new Promise<any>((resolve) => resolve(() => null));
|
|
60
|
+
return fallbackView;
|
|
72
61
|
},
|
|
73
62
|
{ ssr: false }
|
|
74
63
|
),
|
package/data/client/account.ts
CHANGED
|
@@ -123,15 +123,16 @@ const accountApi = api.injectEndpoints({
|
|
|
123
123
|
query: ({ page, status, limit }) =>
|
|
124
124
|
buildClientRequestUrl(account.getQuotations(page, status, limit))
|
|
125
125
|
}),
|
|
126
|
-
sendContact: builder.mutation<void,
|
|
127
|
-
query: (body) =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
sendContact: builder.mutation<void, FormData>({
|
|
127
|
+
query: (body) => {
|
|
128
|
+
return {
|
|
129
|
+
url: buildClientRequestUrl(account.sendContact, {
|
|
130
|
+
useFormData: true
|
|
131
|
+
}),
|
|
132
|
+
method: 'POST',
|
|
133
|
+
body
|
|
134
|
+
};
|
|
135
|
+
}
|
|
135
136
|
}),
|
|
136
137
|
cancelOrder: builder.mutation<void, AccountOrderCancellation>({
|
|
137
138
|
query: ({ id, ...body }) => ({
|
|
@@ -18,7 +18,8 @@ export const usePaymentOptions = () => {
|
|
|
18
18
|
pay_on_delivery: 'pz-pay-on-delivery',
|
|
19
19
|
bkm_express: 'pz-bkm',
|
|
20
20
|
credit_payment: 'pz-credit-payment',
|
|
21
|
-
masterpass: 'pz-masterpass'
|
|
21
|
+
masterpass: 'pz-masterpass',
|
|
22
|
+
gpay: 'pz-gpay'
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const isInitialTypeIncluded = (type: string) => initialTypes.has(type);
|
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.
|
|
4
|
+
"version": "1.58.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"set-cookie-parser": "2.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
32
|
+
"@akinon/eslint-plugin-projectzero": "1.58.0",
|
|
33
33
|
"@types/react-redux": "7.1.30",
|
|
34
34
|
"@types/set-cookie-parser": "2.4.7",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/plugins.js
CHANGED