@akinon/next 1.73.0 → 1.74.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 +14 -0
- package/api/auth.ts +5 -2
- package/api/client.ts +5 -1
- package/components/selected-payment-option-view.tsx +9 -3
- package/data/client/account.ts +3 -2
- package/data/client/checkout.ts +23 -1
- package/data/urls.ts +6 -3
- package/package.json +2 -2
- package/plugins.d.ts +1 -1
- package/redux/middlewares/index.ts +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.74.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5e3333d: ZERO-3078: get saved cards from page context
|
|
8
|
+
- ed55a81: ZERO-3023: fix session cookie persistence after browser restart
|
|
9
|
+
- 3bfa12a: ZERO-3003:Add fetchLoyaltyData and setLoyaltyData requests to RTK
|
|
10
|
+
- 178044e: ZERO-3063: Add support for custom loader in SelectedPaymentOptionView
|
|
11
|
+
- 9a50730: ZERO-3015: Add currency parameter to getOrders query
|
|
12
|
+
- 31d5a71: ZERO-3078: filter valid redux middlewares
|
|
13
|
+
- 56cdddc: ZERO-0000: SHOP-78125: Change unpaid_amount with total_amount_with_interest
|
|
14
|
+
- f0b2f41: ZERO-3062: Update proxyRequest to handle multiple values for search parameters
|
|
15
|
+
- c594b46: ZERO-3078: get saved cards from page context
|
|
16
|
+
|
|
3
17
|
## 1.73.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/api/auth.ts
CHANGED
|
@@ -132,9 +132,12 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
if (sessionId) {
|
|
135
|
+
const maxAge = 30 * 24 * 60 * 60; // 30 days in seconds
|
|
136
|
+
const cookieOptions = `Path=/; HttpOnly; Secure; Max-Age=${maxAge}`;
|
|
137
|
+
|
|
135
138
|
res.setHeader('Set-Cookie', [
|
|
136
|
-
`osessionid=${sessionId};
|
|
137
|
-
`sessionid=${sessionId};
|
|
139
|
+
`osessionid=${sessionId}; ${cookieOptions}`,
|
|
140
|
+
`sessionid=${sessionId}; ${cookieOptions}` // required to get 3D redirection form
|
|
138
141
|
]);
|
|
139
142
|
}
|
|
140
143
|
|
package/api/client.ts
CHANGED
|
@@ -43,7 +43,11 @@ async function proxyRequest(...args) {
|
|
|
43
43
|
Array.from(searchParams.keys())
|
|
44
44
|
.filter((key) => !['slug', 'options'].includes(key))
|
|
45
45
|
.forEach((key) => {
|
|
46
|
-
urlSearchParams.
|
|
46
|
+
urlSearchParams.delete(key);
|
|
47
|
+
|
|
48
|
+
searchParams.getAll(key).forEach((value) => {
|
|
49
|
+
urlSearchParams.append(key, value);
|
|
50
|
+
});
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
const extraHeaders: Record<string, string> = {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { RootState } from 'redux/store';
|
|
4
4
|
import { useAppSelector } from '../redux/hooks';
|
|
5
|
-
import dynamic from 'next/dynamic';
|
|
5
|
+
import dynamic, { DynamicOptionsLoadingProps } from 'next/dynamic';
|
|
6
6
|
import { PaymentOptionViews } from 'views/checkout/steps/payment';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
@@ -22,7 +22,13 @@ const paymentTypeToView = {
|
|
|
22
22
|
// Add other mappings as needed
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
interface SelectedPaymentOptionViewProps {
|
|
26
|
+
loader?: (loadingProps: DynamicOptionsLoadingProps) => JSX.Element;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function SelectedPaymentOptionView({
|
|
30
|
+
loader: Loader
|
|
31
|
+
}: SelectedPaymentOptionViewProps) {
|
|
26
32
|
const { payment_option, wallet_method } = useAppSelector(
|
|
27
33
|
(state: RootState) => state.checkout.preOrder
|
|
28
34
|
);
|
|
@@ -71,7 +77,7 @@ export default function SelectedPaymentOptionView() {
|
|
|
71
77
|
|
|
72
78
|
return fallbackView;
|
|
73
79
|
},
|
|
74
|
-
{ ssr: false }
|
|
80
|
+
{ ssr: false, loading: Loader || undefined }
|
|
75
81
|
),
|
|
76
82
|
[payment_option?.pk]
|
|
77
83
|
);
|
package/data/client/account.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface GetOrdersParams {
|
|
|
21
21
|
page?: number;
|
|
22
22
|
createdDate?: string;
|
|
23
23
|
endDate?: string;
|
|
24
|
+
currency?: string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export interface GetQuotationsResponse {
|
|
@@ -114,9 +115,9 @@ const accountApi = api.injectEndpoints({
|
|
|
114
115
|
query: (id) => buildClientRequestUrl(account.orderId(id))
|
|
115
116
|
}),
|
|
116
117
|
getOrders: builder.query<GetOrdersResponse, GetOrdersParams>({
|
|
117
|
-
query: ({ page, limit, createdDate, endDate } = {}) =>
|
|
118
|
+
query: ({ page, limit, createdDate, endDate, currency } = {}) =>
|
|
118
119
|
buildClientRequestUrl(
|
|
119
|
-
account.getOrders({ page, limit, createdDate, endDate })
|
|
120
|
+
account.getOrders({ page, limit, createdDate, endDate, currency })
|
|
120
121
|
)
|
|
121
122
|
}),
|
|
122
123
|
getOldOrders: builder.query<GetOrdersResponse, GetOrdersParams>({
|
package/data/client/checkout.ts
CHANGED
|
@@ -106,7 +106,7 @@ const completeMasterpassPayment = async (
|
|
|
106
106
|
referenceNo,
|
|
107
107
|
merchantId: credentials?.merchant_id ?? null,
|
|
108
108
|
msisdn,
|
|
109
|
-
amount: preOrder?.
|
|
109
|
+
amount: preOrder?.total_amount_with_interest?.replace('.', '') ?? '',
|
|
110
110
|
additionalParams: additionalParams ?? extras?.additionalParams,
|
|
111
111
|
language,
|
|
112
112
|
installmentCount: preOrder?.installment?.installment_count ?? 1
|
|
@@ -793,6 +793,26 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
793
793
|
extra_field
|
|
794
794
|
}
|
|
795
795
|
})
|
|
796
|
+
}),
|
|
797
|
+
fetchLoyaltyData: build.query<CheckoutResponse, void>({
|
|
798
|
+
query: () => ({
|
|
799
|
+
url: buildClientRequestUrl(checkout.loyaltyCardPage, {
|
|
800
|
+
accept: 'application/json',
|
|
801
|
+
contentType: 'application/json'
|
|
802
|
+
}),
|
|
803
|
+
method: 'GET'
|
|
804
|
+
})
|
|
805
|
+
}),
|
|
806
|
+
setLoyaltyData: build.mutation<CheckoutResponse, number>({
|
|
807
|
+
query: (amount) => ({
|
|
808
|
+
url: buildClientRequestUrl(checkout.loyaltyCardPage, {
|
|
809
|
+
useFormData: true
|
|
810
|
+
}),
|
|
811
|
+
method: 'POST',
|
|
812
|
+
body: {
|
|
813
|
+
selected_loyalty_amount: amount
|
|
814
|
+
}
|
|
815
|
+
})
|
|
796
816
|
})
|
|
797
817
|
}),
|
|
798
818
|
overrideExisting: false
|
|
@@ -832,6 +852,8 @@ export const {
|
|
|
832
852
|
useSetDeliveryBagsMutation,
|
|
833
853
|
useSetAttributeBasedShippingOptionsMutation,
|
|
834
854
|
useSetOrderSelectionPageMutation,
|
|
855
|
+
useFetchLoyaltyDataQuery,
|
|
856
|
+
useSetLoyaltyDataMutation,
|
|
835
857
|
useSetWalletSelectionPageMutation,
|
|
836
858
|
useSetWalletPaymentPageMutation,
|
|
837
859
|
useSetWalletCompletePageMutation
|
package/data/urls.ts
CHANGED
|
@@ -18,13 +18,15 @@ export const account = {
|
|
|
18
18
|
limit,
|
|
19
19
|
createdDate,
|
|
20
20
|
endDate,
|
|
21
|
-
shipping_option_slug
|
|
21
|
+
shipping_option_slug,
|
|
22
|
+
currency
|
|
22
23
|
}: {
|
|
23
24
|
page?: number;
|
|
24
25
|
limit?: number;
|
|
25
26
|
createdDate?: string;
|
|
26
27
|
endDate?: string;
|
|
27
28
|
shipping_option_slug?: string;
|
|
29
|
+
currency?: string;
|
|
28
30
|
}) =>
|
|
29
31
|
`/users/orders/?page=${page || 1}&limit=${limit || 12}${
|
|
30
32
|
createdDate ? `&created_date__gte=${createdDate}` : ''
|
|
@@ -32,7 +34,7 @@ export const account = {
|
|
|
32
34
|
shipping_option_slug
|
|
33
35
|
? `&shipping_option_slug=${shipping_option_slug}`
|
|
34
36
|
: ''
|
|
35
|
-
}`,
|
|
37
|
+
}${currency ? `¤cy=${currency}` : ''}`,
|
|
36
38
|
getOldOrders: ({ page, limit }: { page?: number; limit?: number }) =>
|
|
37
39
|
`/users/old-orders/?page=${page || 1}&limit=${limit || 12}}`,
|
|
38
40
|
getQuotations: (page?: number, status?: string, limit?: number) =>
|
|
@@ -125,7 +127,8 @@ export const checkout = {
|
|
|
125
127
|
setAttributeBasedShippingOption:
|
|
126
128
|
'/orders/checkout/?page=AttributeBasedShippingOptionSelectionPage',
|
|
127
129
|
deliveryBagsPage: '/orders/checkout/?page=DeliveryBagsPage',
|
|
128
|
-
setOrderSelectionPage: '/orders/checkout/?page=OrderSelectionPage'
|
|
130
|
+
setOrderSelectionPage: '/orders/checkout/?page=OrderSelectionPage',
|
|
131
|
+
loyaltyCardPage: '/orders/checkout/?page=LoyaltyCardPage'
|
|
129
132
|
};
|
|
130
133
|
|
|
131
134
|
export const flatpage = {
|
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.74.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.74.0",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/plugins.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ declare module '@akinon/pz-otp/src/redux/reducer' {
|
|
|
26
26
|
|
|
27
27
|
declare module '@akinon/pz-saved-card' {
|
|
28
28
|
export const savedCardReducer: any;
|
|
29
|
+
export const savedCardMiddleware: any;
|
|
29
30
|
export const SavedCardOption: any;
|
|
30
|
-
export const savedCardReducer: any;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
declare module '@akinon/pz-iyzico-saved-card' {
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
import { api } from '../../data/client/api';
|
|
14
14
|
import logger from '@akinon/next/utils/log';
|
|
15
15
|
|
|
16
|
+
// Plugin middlewares
|
|
17
|
+
import { savedCardMiddleware } from '@akinon/pz-saved-card';
|
|
18
|
+
|
|
16
19
|
export const rtkQueryResponseHandler: Middleware =
|
|
17
20
|
({ dispatch }) =>
|
|
18
21
|
(next) =>
|
|
@@ -48,7 +51,12 @@ const middlewares = [
|
|
|
48
51
|
preOrderMiddleware,
|
|
49
52
|
contextListMiddleware,
|
|
50
53
|
hepsiPayMiddleware,
|
|
51
|
-
walletPaymentMiddleware
|
|
54
|
+
walletPaymentMiddleware,
|
|
55
|
+
savedCardMiddleware
|
|
52
56
|
];
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
// Filter out any non-function middleware to ensure all middlewares are valid and executable
|
|
59
|
+
// This prevents runtime errors if any middleware is undefined or not properly initialized
|
|
60
|
+
export default middlewares.filter(
|
|
61
|
+
(middleware) => typeof middleware === 'function'
|
|
62
|
+
);
|