@teamnovu/kit-shopware-composables 0.0.31 → 0.0.32
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/dist/index.mjs
CHANGED
|
@@ -13,11 +13,11 @@ const A = {
|
|
|
13
13
|
all: () => ["context"]
|
|
14
14
|
}, ee = {
|
|
15
15
|
all: () => ["language"]
|
|
16
|
-
},
|
|
16
|
+
}, N = {
|
|
17
17
|
all: () => ["category"],
|
|
18
|
-
lists: () => [...
|
|
18
|
+
lists: () => [...N.all(), "list"],
|
|
19
19
|
list: (e) => [
|
|
20
|
-
...
|
|
20
|
+
...N.all(),
|
|
21
21
|
"list",
|
|
22
22
|
{
|
|
23
23
|
body: e
|
|
@@ -43,20 +43,20 @@ const A = {
|
|
|
43
43
|
body: t
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
|
-
},
|
|
46
|
+
}, O = {
|
|
47
47
|
all: () => ["product"],
|
|
48
|
-
lists: () => [...
|
|
48
|
+
lists: () => [...O.all(), "list"],
|
|
49
49
|
list: (e, s) => [
|
|
50
|
-
...
|
|
50
|
+
...O.all(),
|
|
51
51
|
"list",
|
|
52
52
|
{
|
|
53
53
|
url: e,
|
|
54
54
|
body: s
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
|
-
details: () => [...
|
|
57
|
+
details: () => [...O.all(), "detail"],
|
|
58
58
|
customDetail: (e, s) => [
|
|
59
|
-
...
|
|
59
|
+
...O.details(),
|
|
60
60
|
"custom",
|
|
61
61
|
{
|
|
62
62
|
url: e,
|
|
@@ -64,27 +64,27 @@ const A = {
|
|
|
64
64
|
}
|
|
65
65
|
],
|
|
66
66
|
headlessDetail: (e) => [
|
|
67
|
-
...
|
|
67
|
+
...O.details(),
|
|
68
68
|
{
|
|
69
69
|
body: e
|
|
70
70
|
}
|
|
71
71
|
],
|
|
72
72
|
detail: (e, s) => [
|
|
73
|
-
...
|
|
73
|
+
...O.details(),
|
|
74
74
|
e,
|
|
75
75
|
{
|
|
76
76
|
body: s
|
|
77
77
|
}
|
|
78
78
|
],
|
|
79
79
|
search: (e) => [
|
|
80
|
-
...
|
|
80
|
+
...O.all(),
|
|
81
81
|
"search",
|
|
82
82
|
{
|
|
83
83
|
body: e
|
|
84
84
|
}
|
|
85
85
|
],
|
|
86
86
|
searchSuggest: (e) => [
|
|
87
|
-
...
|
|
87
|
+
...O.all(),
|
|
88
88
|
"searchSuggest",
|
|
89
89
|
{
|
|
90
90
|
body: e
|
|
@@ -108,21 +108,21 @@ const A = {
|
|
|
108
108
|
],
|
|
109
109
|
details: () => [...F.all(), "detail"],
|
|
110
110
|
detail: (e, s) => [...F.details(), e, ...s ? [{ body: s }] : []]
|
|
111
|
-
},
|
|
111
|
+
}, b = {
|
|
112
112
|
all: () => ["shippingMethod"],
|
|
113
|
-
lists: () => [...
|
|
113
|
+
lists: () => [...b.all(), "list"],
|
|
114
114
|
list: (e) => [
|
|
115
|
-
...
|
|
115
|
+
...b.all(),
|
|
116
116
|
"list",
|
|
117
117
|
{
|
|
118
118
|
body: e
|
|
119
119
|
}
|
|
120
120
|
]
|
|
121
|
-
},
|
|
121
|
+
}, k = {
|
|
122
122
|
all: () => ["paymentMethod"],
|
|
123
|
-
lists: () => [...
|
|
123
|
+
lists: () => [...k.all(), "list"],
|
|
124
124
|
list: (e) => [
|
|
125
|
-
...
|
|
125
|
+
...k.lists(),
|
|
126
126
|
{
|
|
127
127
|
body: e
|
|
128
128
|
}
|
|
@@ -235,7 +235,7 @@ function ae(e) {
|
|
|
235
235
|
})
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function B(e) {
|
|
239
239
|
return q(ae(e));
|
|
240
240
|
}
|
|
241
241
|
const ue = "updateContext patch /context";
|
|
@@ -256,7 +256,7 @@ function $(e) {
|
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
function Qt() {
|
|
259
|
-
const e = $(), s =
|
|
259
|
+
const e = $(), s = B(), t = se(), n = c(() => s.isFetching.value || e.isPending.value), r = async (d) => {
|
|
260
260
|
await e.mutateAsync({
|
|
261
261
|
billingAddressId: d.id
|
|
262
262
|
}), await J(n).toBe(!1);
|
|
@@ -274,16 +274,16 @@ function Qt() {
|
|
|
274
274
|
var d;
|
|
275
275
|
return ((d = t.data.value) == null ? void 0 : d.elements.filter(
|
|
276
276
|
(M) => {
|
|
277
|
-
var
|
|
278
|
-
return M.id !== ((
|
|
277
|
+
var K;
|
|
278
|
+
return M.id !== ((K = u.value) == null ? void 0 : K.id);
|
|
279
279
|
}
|
|
280
280
|
)) ?? [];
|
|
281
281
|
}), P = c(() => {
|
|
282
282
|
var d;
|
|
283
283
|
return ((d = t.data.value) == null ? void 0 : d.elements.filter(
|
|
284
284
|
(M) => {
|
|
285
|
-
var
|
|
286
|
-
return M.id !== ((
|
|
285
|
+
var K;
|
|
286
|
+
return M.id !== ((K = i.value) == null ? void 0 : K.id);
|
|
287
287
|
}
|
|
288
288
|
)) ?? [];
|
|
289
289
|
});
|
|
@@ -362,7 +362,7 @@ function Pt(e, s) {
|
|
|
362
362
|
firstName: (x = (C = r.value) == null ? void 0 : C.orderCustomer) == null ? void 0 : x.firstName,
|
|
363
363
|
lastName: (G = (z = r.value) == null ? void 0 : z.orderCustomer) == null ? void 0 : G.lastName
|
|
364
364
|
};
|
|
365
|
-
}),
|
|
365
|
+
}), K = c(() => {
|
|
366
366
|
var l, m;
|
|
367
367
|
return (m = (l = r.value) == null ? void 0 : l.addresses) == null ? void 0 : m.find(
|
|
368
368
|
({ id: C }) => {
|
|
@@ -398,7 +398,7 @@ function Pt(e, s) {
|
|
|
398
398
|
subtotal: P,
|
|
399
399
|
shippingCosts: d,
|
|
400
400
|
shippingAddress: p,
|
|
401
|
-
billingAddress:
|
|
401
|
+
billingAddress: K,
|
|
402
402
|
personalDetails: M,
|
|
403
403
|
shippingMethod: w,
|
|
404
404
|
paymentMethod: S,
|
|
@@ -427,7 +427,7 @@ function Mt(e) {
|
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
429
|
const le = "createCustomerAddress post /account/address";
|
|
430
|
-
function
|
|
430
|
+
function Kt(e) {
|
|
431
431
|
const s = g(), t = Q();
|
|
432
432
|
return h({
|
|
433
433
|
...e,
|
|
@@ -439,7 +439,7 @@ function Ot(e) {
|
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
const de = "deleteCustomerAddress delete /account/address/{addressId}";
|
|
442
|
-
function
|
|
442
|
+
function Ot(e) {
|
|
443
443
|
const s = g(), t = Q();
|
|
444
444
|
return h({
|
|
445
445
|
...e,
|
|
@@ -479,7 +479,14 @@ function At(e) {
|
|
|
479
479
|
}),
|
|
480
480
|
onSuccess: async (n, r, a) => {
|
|
481
481
|
var u, i;
|
|
482
|
-
t.setQueryData(L.get(), n), await
|
|
482
|
+
t.setQueryData(L.get(), n), await Promise.all([
|
|
483
|
+
t.invalidateQueries({ queryKey: k.lists() }),
|
|
484
|
+
t.invalidateQueries({ queryKey: b.lists() })
|
|
485
|
+
]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
|
|
486
|
+
n,
|
|
487
|
+
r,
|
|
488
|
+
a
|
|
489
|
+
));
|
|
483
490
|
}
|
|
484
491
|
});
|
|
485
492
|
}
|
|
@@ -507,7 +514,14 @@ function Ft(e) {
|
|
|
507
514
|
}),
|
|
508
515
|
onSuccess: async (n, r, a) => {
|
|
509
516
|
var u, i;
|
|
510
|
-
t.setQueryData(L.get(), n), await
|
|
517
|
+
t.setQueryData(L.get(), n), await Promise.all([
|
|
518
|
+
t.invalidateQueries({ queryKey: k.lists() }),
|
|
519
|
+
t.invalidateQueries({ queryKey: b.lists() })
|
|
520
|
+
]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
|
|
521
|
+
n,
|
|
522
|
+
r,
|
|
523
|
+
a
|
|
524
|
+
));
|
|
511
525
|
}
|
|
512
526
|
});
|
|
513
527
|
}
|
|
@@ -599,13 +613,13 @@ function bt(e) {
|
|
|
599
613
|
}
|
|
600
614
|
});
|
|
601
615
|
}
|
|
602
|
-
const
|
|
616
|
+
const Ke = "loginCustomer post /account/login";
|
|
603
617
|
function kt(e) {
|
|
604
618
|
const s = g(), t = Q();
|
|
605
619
|
return h({
|
|
606
620
|
...e,
|
|
607
621
|
mutationFn: async (n) => {
|
|
608
|
-
const r = await s.queryRaw(
|
|
622
|
+
const r = await s.queryRaw(Ke, {
|
|
609
623
|
body: n
|
|
610
624
|
}), a = r.headers.get("sw-context-token");
|
|
611
625
|
return a && (s.contextToken = a), r.json();
|
|
@@ -620,12 +634,12 @@ function kt(e) {
|
|
|
620
634
|
}
|
|
621
635
|
});
|
|
622
636
|
}
|
|
623
|
-
const
|
|
637
|
+
const Oe = "logoutCustomer post /account/logout";
|
|
624
638
|
function Bt(e) {
|
|
625
639
|
const s = g(), t = Q();
|
|
626
640
|
return h({
|
|
627
641
|
...e,
|
|
628
|
-
mutationFn: async (n) => s.query(
|
|
642
|
+
mutationFn: async (n) => s.query(Oe, y(n)),
|
|
629
643
|
onSuccess: async (n, r, a) => {
|
|
630
644
|
var u, i;
|
|
631
645
|
await Promise.all([
|
|
@@ -794,7 +808,7 @@ function Wt(e, s, t) {
|
|
|
794
808
|
}
|
|
795
809
|
const je = "readPaymentMethod post /payment-method";
|
|
796
810
|
function Ve(e) {
|
|
797
|
-
const s = g(), t =
|
|
811
|
+
const s = g(), t = k.list(c(() => {
|
|
798
812
|
var n;
|
|
799
813
|
return (n = y(e)) == null ? void 0 : n.body;
|
|
800
814
|
}));
|
|
@@ -834,7 +848,7 @@ function Xt(e) {
|
|
|
834
848
|
});
|
|
835
849
|
}
|
|
836
850
|
const He = "readCategoryList post /category", We = function(s) {
|
|
837
|
-
const t = g(), n =
|
|
851
|
+
const t = g(), n = N.list(s);
|
|
838
852
|
return v({
|
|
839
853
|
queryKey: n,
|
|
840
854
|
queryFn: async ({ signal: r }) => t.query(He, {
|
|
@@ -848,7 +862,7 @@ function Yt(e) {
|
|
|
848
862
|
}
|
|
849
863
|
const Je = "readCompactProductListing post /novu/headless/product-listing/{seoUrl}";
|
|
850
864
|
function Xe(e, s) {
|
|
851
|
-
const t = g(), n =
|
|
865
|
+
const t = g(), n = O.list(e, s);
|
|
852
866
|
return v({
|
|
853
867
|
queryKey: n,
|
|
854
868
|
queryFn: async ({ signal: r }) => {
|
|
@@ -869,7 +883,7 @@ function Zt(e, s) {
|
|
|
869
883
|
}
|
|
870
884
|
const Ye = "readCustomProductDetail post /novu/headless/product/{seoUrl}";
|
|
871
885
|
function Ze(e, s) {
|
|
872
|
-
const t = g(), n =
|
|
886
|
+
const t = g(), n = O.customDetail(e, s);
|
|
873
887
|
return v({
|
|
874
888
|
queryKey: n,
|
|
875
889
|
queryFn: async ({ signal: r }) => {
|
|
@@ -890,7 +904,7 @@ function _t(e, s) {
|
|
|
890
904
|
}
|
|
891
905
|
const _e = "searchPage post /search";
|
|
892
906
|
function et(e) {
|
|
893
|
-
const s = g(), t =
|
|
907
|
+
const s = g(), t = O.search(e);
|
|
894
908
|
return v({
|
|
895
909
|
queryKey: t,
|
|
896
910
|
queryFn: async ({ signal: n }) => {
|
|
@@ -907,7 +921,7 @@ function en(e) {
|
|
|
907
921
|
}
|
|
908
922
|
const tt = "searchSuggest post /search-suggest";
|
|
909
923
|
function nt(e) {
|
|
910
|
-
const s = g(), t =
|
|
924
|
+
const s = g(), t = O.searchSuggest(e);
|
|
911
925
|
return v({
|
|
912
926
|
queryKey: t,
|
|
913
927
|
queryFn: async ({ signal: n }) => {
|
|
@@ -924,7 +938,7 @@ function tn(e) {
|
|
|
924
938
|
}
|
|
925
939
|
const st = "readProduct post /product";
|
|
926
940
|
function rt(e) {
|
|
927
|
-
const s = g(), t =
|
|
941
|
+
const s = g(), t = O.headlessDetail(e);
|
|
928
942
|
return v({
|
|
929
943
|
queryKey: t,
|
|
930
944
|
queryFn: async ({ signal: n }) => {
|
|
@@ -941,7 +955,7 @@ function nn(e) {
|
|
|
941
955
|
}
|
|
942
956
|
const at = "readProductDetail post /product/{productId}";
|
|
943
957
|
function ut(e, s) {
|
|
944
|
-
const t = g(), n =
|
|
958
|
+
const t = g(), n = O.detail(e, s);
|
|
945
959
|
return v({
|
|
946
960
|
queryKey: n,
|
|
947
961
|
queryFn: async ({ signal: r }) => {
|
|
@@ -994,7 +1008,7 @@ function an(e) {
|
|
|
994
1008
|
}
|
|
995
1009
|
const dt = "readShippingMethod post /shipping-method";
|
|
996
1010
|
function yt(e) {
|
|
997
|
-
const s = g(), t =
|
|
1011
|
+
const s = g(), t = b.list(c(() => {
|
|
998
1012
|
var n;
|
|
999
1013
|
return (n = y(e)) == null ? void 0 : n.body;
|
|
1000
1014
|
}));
|
|
@@ -1010,7 +1024,7 @@ function pt(e) {
|
|
|
1010
1024
|
return q(yt(e));
|
|
1011
1025
|
}
|
|
1012
1026
|
function un() {
|
|
1013
|
-
const e =
|
|
1027
|
+
const e = B(), s = $(), t = $e({
|
|
1014
1028
|
query: {
|
|
1015
1029
|
onlyAvailable: !0
|
|
1016
1030
|
}
|
|
@@ -1034,7 +1048,7 @@ function un() {
|
|
|
1034
1048
|
};
|
|
1035
1049
|
}
|
|
1036
1050
|
function on() {
|
|
1037
|
-
const e =
|
|
1051
|
+
const e = B(), s = $(), t = pt({
|
|
1038
1052
|
query: {
|
|
1039
1053
|
onlyAvailable: !0
|
|
1040
1054
|
}
|
|
@@ -1066,7 +1080,7 @@ const gt = (e, s) => {
|
|
|
1066
1080
|
}
|
|
1067
1081
|
return (t == null ? void 0 : t[s]) ?? "";
|
|
1068
1082
|
}, cn = () => {
|
|
1069
|
-
const e =
|
|
1083
|
+
const e = B(), s = c(() => {
|
|
1070
1084
|
var t, n, r;
|
|
1071
1085
|
return ((r = (n = (t = e.data) == null ? void 0 : t.value) == null ? void 0 : n.context) == null ? void 0 : r.languageIdChain) ?? [];
|
|
1072
1086
|
});
|
|
@@ -1085,22 +1099,22 @@ function ln(e) {
|
|
|
1085
1099
|
get() {
|
|
1086
1100
|
return a.page;
|
|
1087
1101
|
},
|
|
1088
|
-
set(
|
|
1089
|
-
a.page = Math.max(1, Math.min(o(u),
|
|
1102
|
+
set(K) {
|
|
1103
|
+
a.page = Math.max(1, Math.min(o(u), K));
|
|
1090
1104
|
}
|
|
1091
1105
|
});
|
|
1092
1106
|
H(
|
|
1093
1107
|
[() => o(u), () => a],
|
|
1094
|
-
([
|
|
1095
|
-
a.page = Math.min(
|
|
1108
|
+
([K, p]) => {
|
|
1109
|
+
a.page = Math.min(K, a.page), a.total = p.total ?? 0, a.limit = p.limit;
|
|
1096
1110
|
}
|
|
1097
1111
|
);
|
|
1098
1112
|
const f = c(() => a.page === o(u)), P = c(() => a.page === 1), d = c(() => ({
|
|
1099
1113
|
p: a.page,
|
|
1100
1114
|
limit: a.limit,
|
|
1101
1115
|
"total-count-mode": a.totalCountMode ?? "none"
|
|
1102
|
-
})), M = (
|
|
1103
|
-
H(() => o(
|
|
1116
|
+
})), M = (K) => {
|
|
1117
|
+
H(() => o(K), (p) => {
|
|
1104
1118
|
p && (a.total = (p == null ? void 0 : p.total) ?? 0, a.limit = (p == null ? void 0 : p.limit) ?? 0);
|
|
1105
1119
|
});
|
|
1106
1120
|
};
|
|
@@ -1172,14 +1186,14 @@ function dn(e) {
|
|
|
1172
1186
|
var p, S, w;
|
|
1173
1187
|
return (w = (S = (p = e.value) == null ? void 0 : p.calculatedPrice) == null ? void 0 : S.regulationPrice) == null ? void 0 : w.price;
|
|
1174
1188
|
}
|
|
1175
|
-
),
|
|
1189
|
+
), K = c(() => X(e.value));
|
|
1176
1190
|
return {
|
|
1177
1191
|
price: P,
|
|
1178
1192
|
totalPrice: f,
|
|
1179
1193
|
unitPrice: i,
|
|
1180
1194
|
displayFromVariants: a,
|
|
1181
1195
|
displayFrom: r,
|
|
1182
|
-
tierPrices:
|
|
1196
|
+
tierPrices: K,
|
|
1183
1197
|
referencePrice: n,
|
|
1184
1198
|
isListPrice: d,
|
|
1185
1199
|
regulationPrice: M
|
|
@@ -1261,7 +1275,7 @@ export {
|
|
|
1261
1275
|
St as absolutizeSeoUrl,
|
|
1262
1276
|
F as addressKeys,
|
|
1263
1277
|
L as cartKeys,
|
|
1264
|
-
|
|
1278
|
+
N as categoryKeys,
|
|
1265
1279
|
A as contextKeys,
|
|
1266
1280
|
j as countryKeys,
|
|
1267
1281
|
I as customerKeys,
|
|
@@ -1269,14 +1283,14 @@ export {
|
|
|
1269
1283
|
ee as languageKey,
|
|
1270
1284
|
D as navigationKeys,
|
|
1271
1285
|
U as orderKeys,
|
|
1272
|
-
|
|
1273
|
-
|
|
1286
|
+
k as paymentKeys,
|
|
1287
|
+
O as productKeys,
|
|
1274
1288
|
je as readPaymentMethodOperation,
|
|
1275
1289
|
dt as readShippingMethodOperation,
|
|
1276
1290
|
V as relativizeSeoUrl,
|
|
1277
1291
|
E as salutationKeys,
|
|
1278
1292
|
T as seoUrlKeys,
|
|
1279
|
-
|
|
1293
|
+
b as shippingKeys,
|
|
1280
1294
|
_ as shopwareClientKey,
|
|
1281
1295
|
y as unrefOptions,
|
|
1282
1296
|
At as useAddLineItemMutation,
|
|
@@ -1284,11 +1298,11 @@ export {
|
|
|
1284
1298
|
zt as useChangePasswordMutation,
|
|
1285
1299
|
bt as useChangeProfileMutation,
|
|
1286
1300
|
Qt as useCheckoutAddresses,
|
|
1287
|
-
|
|
1301
|
+
Kt as useCreateCustomerAddressMutation,
|
|
1288
1302
|
It as useCreateOrderMutation,
|
|
1289
1303
|
Tt as useDefaultBillingAddressMutation,
|
|
1290
1304
|
Et as useDefaultShippingAddressMutation,
|
|
1291
|
-
|
|
1305
|
+
Ot as useDeleteCustomerAddressMutation,
|
|
1292
1306
|
jt as useDeleteCustomerMutation,
|
|
1293
1307
|
Jt as useHandlePaymentMutation,
|
|
1294
1308
|
Gt as useImitateCustomerLoginQuery,
|
|
@@ -1312,7 +1326,7 @@ export {
|
|
|
1312
1326
|
We as useReadCategoryListQueryOptions,
|
|
1313
1327
|
Zt as useReadCompactProductListingQuery,
|
|
1314
1328
|
Xe as useReadCompactProductListingQueryOptions,
|
|
1315
|
-
|
|
1329
|
+
B as useReadContextQuery,
|
|
1316
1330
|
ae as useReadContextQueryOptions,
|
|
1317
1331
|
Ut as useReadCountryQuery,
|
|
1318
1332
|
Qe as useReadCountryQueryOptions,
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useMutation,
|
|
3
|
+
type UseMutationOptions,
|
|
4
|
+
useQueryClient,
|
|
5
|
+
} from '@tanstack/vue-query'
|
|
2
6
|
import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
|
|
3
7
|
import { unref } from 'vue'
|
|
4
8
|
import { useShopwareQueryClient } from '../../inject'
|
|
5
|
-
import { cartKeys, paymentKeys } from '../../keys'
|
|
6
|
-
import type {
|
|
9
|
+
import { cartKeys, paymentKeys, shippingKeys } from '../../keys'
|
|
10
|
+
import type {
|
|
11
|
+
OperationBody,
|
|
12
|
+
OperationKey,
|
|
13
|
+
OperationResponse,
|
|
14
|
+
} from '../types/query'
|
|
7
15
|
|
|
8
16
|
const addCartItemOperation = 'addLineItem post /checkout/cart/line-item' satisfies OperationKey
|
|
9
17
|
|
|
10
18
|
type LineItem = OperationBody<typeof addCartItemOperation>['items'][number]
|
|
11
19
|
|
|
12
|
-
type LineItemPayload =
|
|
13
|
-
Partial<Omit<LineItem, 'id' | 'quantity' | 'type'>> &
|
|
20
|
+
type LineItemPayload = Partial<Omit<LineItem, 'id' | 'quantity' | 'type'>> &
|
|
14
21
|
Required<Pick<LineItem, 'id' | 'quantity' | 'type'>>
|
|
15
22
|
|
|
16
|
-
type Body = Omit<
|
|
17
|
-
OperationBody<typeof addCartItemOperation>,
|
|
18
|
-
'items'
|
|
19
|
-
> & {
|
|
23
|
+
type Body = Omit<OperationBody<typeof addCartItemOperation>, 'items'> & {
|
|
20
24
|
items: LineItemPayload[]
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -39,9 +43,16 @@ export function useAddLineItemMutation(
|
|
|
39
43
|
},
|
|
40
44
|
onSuccess: async (newCart, variables, context) => {
|
|
41
45
|
queryClient.setQueryData(cartKeys.get(), newCart)
|
|
42
|
-
await
|
|
46
|
+
await Promise.all([
|
|
47
|
+
queryClient.invalidateQueries({ queryKey: paymentKeys.lists() }),
|
|
48
|
+
queryClient.invalidateQueries({ queryKey: shippingKeys.lists() }),
|
|
49
|
+
])
|
|
43
50
|
// queryClient.invalidateQueries({ queryKey: cartKeys.get() })
|
|
44
|
-
await unref(unref(mutationOptions)?.onSuccess)?.(
|
|
51
|
+
await unref(unref(mutationOptions)?.onSuccess)?.(
|
|
52
|
+
newCart,
|
|
53
|
+
variables,
|
|
54
|
+
context,
|
|
55
|
+
)
|
|
45
56
|
},
|
|
46
57
|
})
|
|
47
58
|
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useMutation,
|
|
3
|
+
type UseMutationOptions,
|
|
4
|
+
useQueryClient,
|
|
5
|
+
} from '@tanstack/vue-query'
|
|
2
6
|
import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
|
|
3
7
|
import { unref } from 'vue'
|
|
4
8
|
import { useShopwareQueryClient } from '../../inject'
|
|
5
|
-
import { cartKeys, paymentKeys } from '../../keys'
|
|
6
|
-
import type {
|
|
9
|
+
import { cartKeys, paymentKeys, shippingKeys } from '../../keys'
|
|
10
|
+
import type {
|
|
11
|
+
OperationBody,
|
|
12
|
+
OperationKey,
|
|
13
|
+
OperationResponse,
|
|
14
|
+
} from '../types/query'
|
|
7
15
|
|
|
8
16
|
const removeCartItemOperation = 'removeLineItem post /checkout/cart/line-item/delete' satisfies OperationKey
|
|
9
17
|
|
|
@@ -26,9 +34,16 @@ export function useRemoveLineItemMutation(
|
|
|
26
34
|
},
|
|
27
35
|
onSuccess: async (newCart, variables, context) => {
|
|
28
36
|
queryClient.setQueryData(cartKeys.get(), newCart)
|
|
29
|
-
await
|
|
37
|
+
await Promise.all([
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: paymentKeys.lists() }),
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: shippingKeys.lists() }),
|
|
40
|
+
])
|
|
30
41
|
// queryClient.invalidateQueries({ queryKey: cartKeys.get() })
|
|
31
|
-
await unref(unref(mutationOptions)?.onSuccess)?.(
|
|
42
|
+
await unref(unref(mutationOptions)?.onSuccess)?.(
|
|
43
|
+
newCart,
|
|
44
|
+
variables,
|
|
45
|
+
context,
|
|
46
|
+
)
|
|
32
47
|
},
|
|
33
48
|
})
|
|
34
49
|
}
|