@akinon/next 1.23.0-rc.3 → 1.23.0-rc.4
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 +10 -0
- package/data/client/address.ts +8 -6
- package/data/client/wishlist.ts +2 -2
- package/package.json +2 -2
- package/utils/app-fetch.ts +1 -12
package/CHANGELOG.md
CHANGED
package/data/client/address.ts
CHANGED
|
@@ -32,10 +32,12 @@ const addressApi = api.injectEndpoints({
|
|
|
32
32
|
query: () => buildClientRequestUrl(address.getRetailStore)
|
|
33
33
|
}),
|
|
34
34
|
getRetailStoreCities: builder.query<GetResponse<any>, string>({
|
|
35
|
-
query: (country) =>
|
|
35
|
+
query: (country) =>
|
|
36
|
+
buildClientRequestUrl(address.getRetailStoreCities(country))
|
|
36
37
|
}),
|
|
37
38
|
getRetailStoreTownships: builder.query<GetResponse<any>, string>({
|
|
38
|
-
query: (city) =>
|
|
39
|
+
query: (city) =>
|
|
40
|
+
buildClientRequestUrl(address.getRetailStoreTownships(city))
|
|
39
41
|
}),
|
|
40
42
|
addAddress: builder.mutation<Address, Partial<Address>>({
|
|
41
43
|
query: (body) => ({
|
|
@@ -48,7 +50,7 @@ const addressApi = api.injectEndpoints({
|
|
|
48
50
|
type: body.is_corporate === 'true' ? 'corporate' : 'personal'
|
|
49
51
|
}
|
|
50
52
|
}),
|
|
51
|
-
invalidatesTags:
|
|
53
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout'])
|
|
52
54
|
}),
|
|
53
55
|
editAddress: builder.mutation<Address, Partial<Address>>({
|
|
54
56
|
query: ({ pk, ...body }) => ({
|
|
@@ -62,14 +64,14 @@ const addressApi = api.injectEndpoints({
|
|
|
62
64
|
type: body.is_corporate === 'true' ? 'corporate' : 'personal'
|
|
63
65
|
}
|
|
64
66
|
}),
|
|
65
|
-
invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
67
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
66
68
|
}),
|
|
67
69
|
removeAddress: builder.mutation<void, number>({
|
|
68
70
|
query: (id) => ({
|
|
69
71
|
url: buildClientRequestUrl(address.removeAddress(id)),
|
|
70
72
|
method: 'DELETE'
|
|
71
73
|
}),
|
|
72
|
-
invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
74
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
73
75
|
}),
|
|
74
76
|
setDefaultAddress: builder.mutation<Address, Partial<Address>>({
|
|
75
77
|
query: ({ pk, primary }) => ({
|
|
@@ -79,7 +81,7 @@ const addressApi = api.injectEndpoints({
|
|
|
79
81
|
method: 'PATCH',
|
|
80
82
|
body: { primary }
|
|
81
83
|
}),
|
|
82
|
-
invalidatesTags: ['Addresses']
|
|
84
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses'])
|
|
83
85
|
}),
|
|
84
86
|
getStores: builder.query<GetResponse<Address>, void>({
|
|
85
87
|
query: () => ({
|
package/data/client/wishlist.ts
CHANGED
|
@@ -73,14 +73,14 @@ export const wishlistApi = api.injectEndpoints({
|
|
|
73
73
|
product: productPk
|
|
74
74
|
}
|
|
75
75
|
}),
|
|
76
|
-
invalidatesTags: ['Favorite']
|
|
76
|
+
invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
|
|
77
77
|
}),
|
|
78
78
|
removeFavorite: build.mutation<RemoteFavoriteResponse, number>({
|
|
79
79
|
query: (favPk: number) => ({
|
|
80
80
|
url: buildClientRequestUrl(wishlist.removeFavorite(favPk)),
|
|
81
81
|
method: 'DELETE'
|
|
82
82
|
}),
|
|
83
|
-
invalidatesTags: ['Favorite']
|
|
83
|
+
invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
|
|
84
84
|
}),
|
|
85
85
|
addStockAlert: build.mutation<AddStockAlertResponse, AddStockAlertRequest>({
|
|
86
86
|
query: ({ productPk, email }) => ({
|
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.23.0-rc.
|
|
4
|
+
"version": "1.23.0-rc.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
33
33
|
"@typescript-eslint/parser": "6.7.4",
|
|
34
34
|
"eslint": "^8.14.0",
|
|
35
|
-
"@akinon/eslint-plugin-projectzero": "1.23.0-rc.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.23.0-rc.4",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/utils/app-fetch.ts
CHANGED
|
@@ -28,7 +28,7 @@ const appFetch = async <T>(
|
|
|
28
28
|
|
|
29
29
|
if (commerceUrl === 'default') {
|
|
30
30
|
logger.error('Commerce URL is not set. Current value is "default"');
|
|
31
|
-
|
|
31
|
+
return undefined;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
|
|
@@ -48,10 +48,6 @@ const appFetch = async <T>(
|
|
|
48
48
|
status = req.status;
|
|
49
49
|
logger.debug(`FETCH END ${url}`, { status: req.status, ip });
|
|
50
50
|
|
|
51
|
-
if (!req.ok) {
|
|
52
|
-
throw new Error(`Request failed with status ${status}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
if (responseType === FetchResponseType.JSON) {
|
|
56
52
|
response = (await req.json()) as T;
|
|
57
53
|
} else {
|
|
@@ -65,13 +61,6 @@ const appFetch = async <T>(
|
|
|
65
61
|
if (!url.toString().includes('/cms/seo/')) {
|
|
66
62
|
logger[logType](`FETCH FAILED`, { url, status, error, ip });
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
// throw the error if it's fatal, so it can be caught and handled at higher levels
|
|
70
|
-
if (logType === 'fatal') {
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return Promise.reject(error);
|
|
75
64
|
}
|
|
76
65
|
|
|
77
66
|
return response;
|