@akinon/next 1.45.0-rc.2 → 1.45.0-rc.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.45.0-rc.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 948eb42: ZERO-2852: Add out of stock endpoints
8
+
3
9
  ## 1.45.0-rc.2
4
10
 
5
11
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { FavoriteItem } from '../../types';
1
+ import { FavoriteItem, Product } from '../../types';
2
2
  import { buildClientRequestUrl } from '../../utils';
3
3
  import { api } from './api';
4
4
  import { wishlist } from '../urls';
@@ -55,6 +55,25 @@ interface GetStockAlertsResponse {
55
55
  interface DeleteStockAlertResponse {
56
56
  success: boolean;
57
57
  }
58
+ interface GetCollectionOOSResponse {
59
+ count: number;
60
+ results: CollectionItem[];
61
+ next?: string | null;
62
+ previous?: string | null;
63
+ }
64
+
65
+ export interface CollectionItem {
66
+ pk: number;
67
+ status: string;
68
+ name: string;
69
+ slug: string;
70
+ items: Product[];
71
+ }
72
+
73
+ export interface CollectionItemsResponse {
74
+ pk: number;
75
+ product: Product;
76
+ }
58
77
 
59
78
  export const wishlistApi = api.injectEndpoints({
60
79
  endpoints: (build) => ({
@@ -105,6 +124,50 @@ export const wishlistApi = api.injectEndpoints({
105
124
  method: 'DELETE'
106
125
  }),
107
126
  invalidatesTags: ['StockAlert']
127
+ }),
128
+ setCollectionOOS: build.mutation<
129
+ CollectionItem,
130
+ { name: string; status: string }
131
+ >({
132
+ query: ({ name, status = 'private' }) => ({
133
+ url: buildClientRequestUrl(wishlist.setCollection(), {
134
+ contentType: 'application/json'
135
+ }),
136
+ method: 'POST',
137
+ body: {
138
+ name,
139
+ status
140
+ }
141
+ })
142
+ }),
143
+ setCollectionItems: build.mutation<
144
+ CollectionItemsResponse,
145
+ { usercollection_id: number; product_id: number | number[] }
146
+ >({
147
+ query: ({ usercollection_id, product_id }) => ({
148
+ url: buildClientRequestUrl(wishlist.setCollectionItems, {
149
+ contentType: 'application/json'
150
+ }),
151
+ method: 'POST',
152
+ body: {
153
+ usercollection_id,
154
+ product_id
155
+ }
156
+ })
157
+ }),
158
+ getCollectionsOOS: build.query<
159
+ GetCollectionOOSResponse,
160
+ { search?: string; product_id?: number }
161
+ >({
162
+ query: ({ search, product_id }) => ({
163
+ url: buildClientRequestUrl(wishlist.getCollections(search, product_id))
164
+ })
165
+ }),
166
+ deleteCollection: build.query<void, number>({
167
+ query: (pk: number) => ({
168
+ url: buildClientRequestUrl(wishlist.deleteCollection(pk)),
169
+ method: 'DELETE'
170
+ })
108
171
  })
109
172
  }),
110
173
  overrideExisting: true
@@ -116,5 +179,10 @@ export const {
116
179
  useRemoveFavoriteMutation,
117
180
  useAddStockAlertMutation,
118
181
  useGetStockAlertsQuery,
119
- useDeleteStockAlertMutation
182
+ useDeleteStockAlertMutation,
183
+ useSetCollectionOOSMutation,
184
+ useSetCollectionItemsMutation,
185
+ useGetCollectionsOOSQuery,
186
+ useLazyGetCollectionsOOSQuery,
187
+ useLazyDeleteCollectionQuery
120
188
  } = wishlistApi;
package/data/urls.ts CHANGED
@@ -165,7 +165,14 @@ export const wishlist = {
165
165
  page?: number;
166
166
  limit?: number;
167
167
  }) => `/wishlists/product-alerts/?limit=${limit}&page=${page}`,
168
- deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`
168
+ deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`,
169
+ setCollection: () => '/wishlists/user-collections/',
170
+ setCollectionItems: '/wishlists/user-collection-items/',
171
+ getCollections: (search?: string, product_id?: number) =>
172
+ `/wishlists/user-collections/?search=${search ? search : ''}&product_id=${
173
+ product_id ? product_id : ''
174
+ }`,
175
+ deleteCollection: (pk: number) => `/wishlists/user-collections/${pk}/`
169
176
  };
170
177
 
171
178
  export const user = {
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.45.0-rc.2",
4
+ "version": "1.45.0-rc.3",
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.45.0-rc.2",
33
+ "@akinon/eslint-plugin-projectzero": "1.45.0-rc.3",
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",