buymeua-api-fe 0.14.0 → 0.15.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 +21 -0
- package/README.md +6 -3
- package/dist/entities/ad/api/adApi.js +1 -1
- package/dist/entities/ad/api/adApi.js.map +1 -1
- package/dist/entities/cart/api/cartApi.js +2 -2
- package/dist/entities/cart/api/cartApi.js.map +1 -1
- package/dist/entities/category/api/categoryApi.js +1 -1
- package/dist/entities/category/api/categoryApi.js.map +1 -1
- package/dist/entities/chat/api/chatApi.js +1 -1
- package/dist/entities/chat/api/chatApi.js.map +1 -1
- package/dist/entities/country/api/countryApi.js +1 -1
- package/dist/entities/country/api/countryApi.js.map +1 -1
- package/dist/entities/favorite/api/favoriteApi.d.ts +40 -41
- package/dist/entities/favorite/api/favoriteApi.d.ts.map +1 -1
- package/dist/entities/favorite/api/favoriteApi.js +287 -269
- package/dist/entities/favorite/api/favoriteApi.js.map +1 -1
- package/dist/entities/favorite/model/types.d.ts +5 -16
- package/dist/entities/favorite/model/types.d.ts.map +1 -1
- package/dist/entities/notification/api/notificationApi.js +1 -1
- package/dist/entities/notification/api/notificationApi.js.map +1 -1
- package/dist/entities/novaposhta/api/novaposhtaApi.js +3 -3
- package/dist/entities/novaposhta/api/novaposhtaApi.js.map +1 -1
- package/dist/entities/product/api/productApi.d.ts +132 -317
- package/dist/entities/product/api/productApi.d.ts.map +1 -1
- package/dist/entities/product/api/productApi.js +54 -13
- package/dist/entities/product/api/productApi.js.map +1 -1
- package/dist/entities/product/model/types.d.ts +0 -6
- package/dist/entities/product/model/types.d.ts.map +1 -1
- package/dist/entities/referral/api/referralApi.js +2 -2
- package/dist/entities/referral/api/referralApi.js.map +1 -1
- package/dist/entities/stories/api/storiesApi.js +1 -1
- package/dist/entities/stories/api/storiesApi.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { productApi } from '../../product';
|
|
2
2
|
import { getNextPageParam } from '../../../shared/lib';
|
|
3
|
-
// TODO: optimistic
|
|
4
3
|
export const favoriteApi = productApi
|
|
5
4
|
.injectEndpoints({
|
|
6
5
|
endpoints: (build) => ({
|
|
@@ -17,8 +16,8 @@ export const favoriteApi = productApi
|
|
|
17
16
|
query: (arg) => ({
|
|
18
17
|
url: 'v1/favorite/merchants',
|
|
19
18
|
params: {
|
|
20
|
-
page: arg.pageParam,
|
|
21
19
|
...arg.queryArg,
|
|
20
|
+
page: arg.pageParam,
|
|
22
21
|
},
|
|
23
22
|
}),
|
|
24
23
|
}),
|
|
@@ -30,8 +29,8 @@ export const favoriteApi = productApi
|
|
|
30
29
|
query: (arg) => ({
|
|
31
30
|
url: 'v1/favorite/merchant-items',
|
|
32
31
|
params: {
|
|
33
|
-
page: arg.pageParam,
|
|
34
32
|
...arg.queryArg,
|
|
33
|
+
page: arg.pageParam,
|
|
35
34
|
},
|
|
36
35
|
}),
|
|
37
36
|
}),
|
|
@@ -39,269 +38,264 @@ export const favoriteApi = productApi
|
|
|
39
38
|
query: (arg) => ({
|
|
40
39
|
url: 'v1/favorite',
|
|
41
40
|
method: 'POST',
|
|
42
|
-
body:
|
|
41
|
+
body: arg,
|
|
43
42
|
}),
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
43
|
+
// TODO: Review, refactor, standalone func to this and deleteFavoriteMerchantItem
|
|
44
|
+
onQueryStarted: async (queryArgument, mutationLifeCycleApi) => {
|
|
45
|
+
if (!queryArgument.optimisticUpdate)
|
|
46
|
+
return;
|
|
47
|
+
const patchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteMerchantItems', {
|
|
48
|
+
merchant_id: queryArgument.optimisticUpdate.product.merchant_id,
|
|
49
|
+
}, (draft) => {
|
|
50
|
+
const firstPage = draft.pages[0];
|
|
51
|
+
if (!firstPage || !queryArgument.optimisticUpdate?.product)
|
|
52
|
+
return;
|
|
53
|
+
const favoriteItem = {
|
|
54
|
+
...queryArgument.optimisticUpdate.product,
|
|
55
|
+
favorite_item_id: performance.now() + Math.random() * 1000,
|
|
56
|
+
};
|
|
57
|
+
firstPage.data.push(favoriteItem);
|
|
58
|
+
}));
|
|
59
|
+
const favoriteCountPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteCount', undefined, (draft) => {
|
|
60
|
+
draft.total_quantity += 1;
|
|
61
|
+
}));
|
|
62
|
+
let productPatchResult;
|
|
63
|
+
let bestsellerProductPatchResult;
|
|
64
|
+
let supplierProductPatchResult;
|
|
65
|
+
let productDetailsPatchResult;
|
|
66
|
+
let supplierProductDetailsPatchResult;
|
|
67
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
68
|
+
{
|
|
69
|
+
type: 'Product',
|
|
70
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
71
|
+
},
|
|
72
|
+
])) {
|
|
73
|
+
if (endpointName !== 'getProducts')
|
|
74
|
+
continue;
|
|
75
|
+
productPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProducts', originalArgs, (draft) => {
|
|
76
|
+
draft.pages.forEach((page) => {
|
|
77
|
+
page.data.forEach((product) => {
|
|
78
|
+
if (product.id ===
|
|
79
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
80
|
+
product.in_favorite = true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
87
|
+
{
|
|
88
|
+
type: 'BestsellerProduct',
|
|
89
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
90
|
+
},
|
|
91
|
+
])) {
|
|
92
|
+
if (endpointName !== 'getBestSellers')
|
|
93
|
+
continue;
|
|
94
|
+
bestsellerProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getBestSellers', originalArgs, (draft) => {
|
|
95
|
+
draft.data.forEach((bestsellerProduct) => {
|
|
96
|
+
if (bestsellerProduct.id ===
|
|
97
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
98
|
+
bestsellerProduct.in_favorite = true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
104
|
+
{
|
|
105
|
+
type: 'SupplierProduct',
|
|
106
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
107
|
+
},
|
|
108
|
+
])) {
|
|
109
|
+
if (endpointName !== 'getSupplierProducts')
|
|
110
|
+
continue;
|
|
111
|
+
supplierProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProducts', originalArgs, (draft) => {
|
|
112
|
+
draft.pages.forEach((page) => {
|
|
113
|
+
page.data.forEach((product) => {
|
|
114
|
+
if (product.id ===
|
|
115
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
116
|
+
product.in_favorite = true;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
123
|
+
{
|
|
124
|
+
type: 'ProductDetails',
|
|
125
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
126
|
+
},
|
|
127
|
+
])) {
|
|
128
|
+
if (endpointName !== 'getProductDetails')
|
|
129
|
+
continue;
|
|
130
|
+
productDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProductDetails', originalArgs, (draft) => {
|
|
131
|
+
draft.data.in_favorite = true;
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
135
|
+
{
|
|
136
|
+
type: 'SupplierProductDetails',
|
|
137
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
138
|
+
},
|
|
139
|
+
])) {
|
|
140
|
+
if (endpointName !== 'getSupplierProductDetails')
|
|
141
|
+
continue;
|
|
142
|
+
supplierProductDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProductDetails', originalArgs, (draft) => {
|
|
143
|
+
draft.data.in_favorite = true;
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
await mutationLifeCycleApi.queryFulfilled;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
patchResult.undo();
|
|
151
|
+
favoriteCountPatchResult.undo();
|
|
152
|
+
if (productPatchResult)
|
|
153
|
+
productPatchResult.undo();
|
|
154
|
+
if (bestsellerProductPatchResult)
|
|
155
|
+
bestsellerProductPatchResult.undo();
|
|
156
|
+
if (supplierProductPatchResult)
|
|
157
|
+
supplierProductPatchResult.undo();
|
|
158
|
+
if (productDetailsPatchResult)
|
|
159
|
+
productDetailsPatchResult.undo();
|
|
160
|
+
if (supplierProductDetailsPatchResult)
|
|
161
|
+
supplierProductDetailsPatchResult.undo();
|
|
162
|
+
}
|
|
163
|
+
},
|
|
163
164
|
}),
|
|
164
165
|
deleteFavoriteMerchantItem: build.mutation({
|
|
165
166
|
query: (arg) => ({
|
|
166
167
|
url: 'v1/favorite',
|
|
167
168
|
method: 'DELETE',
|
|
168
|
-
body:
|
|
169
|
+
body: arg,
|
|
169
170
|
}),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// if (productPatchResult) productPatchResult.undo();
|
|
299
|
-
// if (supplierProductPatchResult) supplierProductPatchResult.undo();
|
|
300
|
-
// if (productDetailsPatchResult) productDetailsPatchResult.undo();
|
|
301
|
-
// if (supplierProductDetailsPatchResult)
|
|
302
|
-
// supplierProductDetailsPatchResult.undo();
|
|
303
|
-
// }
|
|
304
|
-
// },
|
|
171
|
+
onQueryStarted: async (queryArgument, mutationLifeCycleApi) => {
|
|
172
|
+
if (!queryArgument.optimisticUpdate)
|
|
173
|
+
return;
|
|
174
|
+
let patchResult;
|
|
175
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
176
|
+
{
|
|
177
|
+
type: 'FavoriteMerchantItem',
|
|
178
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
179
|
+
},
|
|
180
|
+
])) {
|
|
181
|
+
if (endpointName !== 'getFavoriteMerchantItems')
|
|
182
|
+
continue;
|
|
183
|
+
patchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteMerchantItems', originalArgs, (draft) => {
|
|
184
|
+
draft.pages.forEach((favoriteMerchantItems) => {
|
|
185
|
+
favoriteMerchantItems.data.forEach((item, index) => {
|
|
186
|
+
if (item.id === queryArgument.optimisticUpdate?.product.id) {
|
|
187
|
+
favoriteMerchantItems.data.splice(index, 1);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
const favoriteCountPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteCount', undefined, (draft) => {
|
|
194
|
+
draft.total_quantity -= 1;
|
|
195
|
+
}));
|
|
196
|
+
let productPatchResult;
|
|
197
|
+
let bestsellerProductPatchResult;
|
|
198
|
+
let supplierProductPatchResult;
|
|
199
|
+
let productDetailsPatchResult;
|
|
200
|
+
let supplierProductDetailsPatchResult;
|
|
201
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
202
|
+
{
|
|
203
|
+
type: 'Product',
|
|
204
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
205
|
+
},
|
|
206
|
+
])) {
|
|
207
|
+
if (endpointName !== 'getProducts')
|
|
208
|
+
continue;
|
|
209
|
+
productPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProducts', originalArgs, (draft) => {
|
|
210
|
+
draft.pages.forEach((page) => {
|
|
211
|
+
page.data.forEach((product) => {
|
|
212
|
+
if (product.id ===
|
|
213
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
214
|
+
product.in_favorite = false;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
221
|
+
{
|
|
222
|
+
type: 'BestsellerProduct',
|
|
223
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
224
|
+
},
|
|
225
|
+
])) {
|
|
226
|
+
if (endpointName !== 'getBestSellers')
|
|
227
|
+
continue;
|
|
228
|
+
bestsellerProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getBestSellers', originalArgs, (draft) => {
|
|
229
|
+
draft.data.forEach((bestsellerProduct) => {
|
|
230
|
+
if (bestsellerProduct.id ===
|
|
231
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
232
|
+
bestsellerProduct.in_favorite = false;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
238
|
+
{
|
|
239
|
+
type: 'SupplierProduct',
|
|
240
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
241
|
+
},
|
|
242
|
+
])) {
|
|
243
|
+
if (endpointName !== 'getSupplierProducts')
|
|
244
|
+
continue;
|
|
245
|
+
supplierProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProducts', originalArgs, (draft) => {
|
|
246
|
+
draft.pages.forEach((page) => {
|
|
247
|
+
page.data.forEach((product) => {
|
|
248
|
+
if (product.id ===
|
|
249
|
+
queryArgument.optimisticUpdate?.product.id) {
|
|
250
|
+
product.in_favorite = false;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
257
|
+
{
|
|
258
|
+
type: 'ProductDetails',
|
|
259
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
260
|
+
},
|
|
261
|
+
])) {
|
|
262
|
+
if (endpointName !== 'getProductDetails')
|
|
263
|
+
continue;
|
|
264
|
+
productDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProductDetails', originalArgs, (draft) => {
|
|
265
|
+
draft.data.in_favorite = false;
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
|
|
269
|
+
{
|
|
270
|
+
type: 'SupplierProductDetails',
|
|
271
|
+
id: queryArgument.optimisticUpdate.product.id,
|
|
272
|
+
},
|
|
273
|
+
])) {
|
|
274
|
+
if (endpointName !== 'getSupplierProductDetails')
|
|
275
|
+
continue;
|
|
276
|
+
supplierProductDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProductDetails', originalArgs, (draft) => {
|
|
277
|
+
draft.data.in_favorite = false;
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
await mutationLifeCycleApi.queryFulfilled;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
if (patchResult)
|
|
285
|
+
patchResult.undo();
|
|
286
|
+
favoriteCountPatchResult.undo();
|
|
287
|
+
if (productPatchResult)
|
|
288
|
+
productPatchResult.undo();
|
|
289
|
+
if (bestsellerProductPatchResult)
|
|
290
|
+
bestsellerProductPatchResult.undo();
|
|
291
|
+
if (supplierProductPatchResult)
|
|
292
|
+
supplierProductPatchResult.undo();
|
|
293
|
+
if (productDetailsPatchResult)
|
|
294
|
+
productDetailsPatchResult.undo();
|
|
295
|
+
if (supplierProductDetailsPatchResult)
|
|
296
|
+
supplierProductDetailsPatchResult.undo();
|
|
297
|
+
}
|
|
298
|
+
},
|
|
305
299
|
}),
|
|
306
300
|
}),
|
|
307
301
|
overrideExisting: false,
|
|
@@ -345,18 +339,42 @@ export const favoriteApi = productApi
|
|
|
345
339
|
},
|
|
346
340
|
},
|
|
347
341
|
addFavoriteMerchantItem: {
|
|
348
|
-
invalidatesTags:
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
invalidatesTags: (_result, _error, arg, _meta) => {
|
|
343
|
+
return arg.optimisticUpdate
|
|
344
|
+
? [
|
|
345
|
+
{ type: 'FavoriteMerchant', id: 'LIST' },
|
|
346
|
+
{ type: 'FavoriteMerchantItem', id: 'LIST' },
|
|
347
|
+
]
|
|
348
|
+
: [
|
|
349
|
+
{ type: 'FavoriteMerchant', id: 'LIST' },
|
|
350
|
+
{ type: 'FavoriteMerchantItem', id: 'LIST' },
|
|
351
|
+
{ type: 'FavoriteCount', id: 'LIST' },
|
|
352
|
+
{ type: 'Product', id: arg.product_id },
|
|
353
|
+
{ type: 'BestsellerProduct', id: arg.product_id },
|
|
354
|
+
{ type: 'ProductDetails', id: arg.product_id },
|
|
355
|
+
{ type: 'SupplierProduct', id: arg.product_id },
|
|
356
|
+
{ type: 'SupplierProductDetails', id: arg.product_id },
|
|
357
|
+
];
|
|
358
|
+
},
|
|
353
359
|
},
|
|
354
360
|
deleteFavoriteMerchantItem: {
|
|
355
|
-
invalidatesTags:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
361
|
+
invalidatesTags: (_result, _error, arg, _meta) => {
|
|
362
|
+
return arg.optimisticUpdate
|
|
363
|
+
? [
|
|
364
|
+
{ type: 'FavoriteMerchant', id: 'LIST' },
|
|
365
|
+
{ type: 'FavoriteMerchantItem', id: 'LIST' },
|
|
366
|
+
]
|
|
367
|
+
: [
|
|
368
|
+
{ type: 'FavoriteMerchant', id: 'LIST' },
|
|
369
|
+
{ type: 'FavoriteMerchantItem', id: 'LIST' },
|
|
370
|
+
{ type: 'FavoriteCount', id: 'LIST' },
|
|
371
|
+
{ type: 'Product', id: arg.product_id },
|
|
372
|
+
{ type: 'BestsellerProduct', id: arg.product_id },
|
|
373
|
+
{ type: 'ProductDetails', id: arg.product_id },
|
|
374
|
+
{ type: 'SupplierProduct', id: arg.product_id },
|
|
375
|
+
{ type: 'SupplierProductDetails', id: arg.product_id },
|
|
376
|
+
];
|
|
377
|
+
},
|
|
360
378
|
},
|
|
361
379
|
},
|
|
362
380
|
});
|