@teamnovu/kit-shopware-composables 0.0.31 → 0.0.33
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,29 +13,29 @@ 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
|
|
24
24
|
}
|
|
25
25
|
]
|
|
26
|
-
},
|
|
26
|
+
}, k = {
|
|
27
27
|
all: () => ["navigation"],
|
|
28
|
-
lists: () => [...
|
|
28
|
+
lists: () => [...k.all(), "list"],
|
|
29
29
|
list: (e) => [
|
|
30
|
-
...
|
|
30
|
+
...k.all(),
|
|
31
31
|
"list",
|
|
32
32
|
{
|
|
33
33
|
body: e
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
|
-
details: () => [...
|
|
36
|
+
details: () => [...k.all(), "detail"],
|
|
37
37
|
detail: (e, s, t) => [
|
|
38
|
-
...
|
|
38
|
+
...k.all(),
|
|
39
39
|
"detail",
|
|
40
40
|
{
|
|
41
41
|
activeId: 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,11 +108,11 @@ const A = {
|
|
|
108
108
|
],
|
|
109
109
|
details: () => [...F.all(), "detail"],
|
|
110
110
|
detail: (e, s) => [...F.details(), e, ...s ? [{ body: s }] : []]
|
|
111
|
-
},
|
|
111
|
+
}, D = {
|
|
112
112
|
all: () => ["shippingMethod"],
|
|
113
|
-
lists: () => [...
|
|
113
|
+
lists: () => [...D.all(), "list"],
|
|
114
114
|
list: (e) => [
|
|
115
|
-
...
|
|
115
|
+
...D.all(),
|
|
116
116
|
"list",
|
|
117
117
|
{
|
|
118
118
|
body: e
|
|
@@ -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";
|
|
@@ -250,13 +250,15 @@ function $(e) {
|
|
|
250
250
|
var u, i;
|
|
251
251
|
await Promise.all([
|
|
252
252
|
t.invalidateQueries({ queryKey: A.all() }),
|
|
253
|
-
t.invalidateQueries({ queryKey: L.get() })
|
|
253
|
+
t.invalidateQueries({ queryKey: L.get() }),
|
|
254
|
+
t.invalidateQueries({ queryKey: b.lists() }),
|
|
255
|
+
t.invalidateQueries({ queryKey: D.lists() })
|
|
254
256
|
]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
|
|
255
257
|
}
|
|
256
258
|
});
|
|
257
259
|
}
|
|
258
260
|
function Qt() {
|
|
259
|
-
const e = $(), s =
|
|
261
|
+
const e = $(), s = B(), t = se(), n = c(() => s.isFetching.value || e.isPending.value), r = async (d) => {
|
|
260
262
|
await e.mutateAsync({
|
|
261
263
|
billingAddressId: d.id
|
|
262
264
|
}), await J(n).toBe(!1);
|
|
@@ -274,16 +276,16 @@ function Qt() {
|
|
|
274
276
|
var d;
|
|
275
277
|
return ((d = t.data.value) == null ? void 0 : d.elements.filter(
|
|
276
278
|
(M) => {
|
|
277
|
-
var
|
|
278
|
-
return M.id !== ((
|
|
279
|
+
var K;
|
|
280
|
+
return M.id !== ((K = u.value) == null ? void 0 : K.id);
|
|
279
281
|
}
|
|
280
282
|
)) ?? [];
|
|
281
283
|
}), P = c(() => {
|
|
282
284
|
var d;
|
|
283
285
|
return ((d = t.data.value) == null ? void 0 : d.elements.filter(
|
|
284
286
|
(M) => {
|
|
285
|
-
var
|
|
286
|
-
return M.id !== ((
|
|
287
|
+
var K;
|
|
288
|
+
return M.id !== ((K = i.value) == null ? void 0 : K.id);
|
|
287
289
|
}
|
|
288
290
|
)) ?? [];
|
|
289
291
|
});
|
|
@@ -362,7 +364,7 @@ function Pt(e, s) {
|
|
|
362
364
|
firstName: (x = (C = r.value) == null ? void 0 : C.orderCustomer) == null ? void 0 : x.firstName,
|
|
363
365
|
lastName: (G = (z = r.value) == null ? void 0 : z.orderCustomer) == null ? void 0 : G.lastName
|
|
364
366
|
};
|
|
365
|
-
}),
|
|
367
|
+
}), K = c(() => {
|
|
366
368
|
var l, m;
|
|
367
369
|
return (m = (l = r.value) == null ? void 0 : l.addresses) == null ? void 0 : m.find(
|
|
368
370
|
({ id: C }) => {
|
|
@@ -398,7 +400,7 @@ function Pt(e, s) {
|
|
|
398
400
|
subtotal: P,
|
|
399
401
|
shippingCosts: d,
|
|
400
402
|
shippingAddress: p,
|
|
401
|
-
billingAddress:
|
|
403
|
+
billingAddress: K,
|
|
402
404
|
personalDetails: M,
|
|
403
405
|
shippingMethod: w,
|
|
404
406
|
paymentMethod: S,
|
|
@@ -427,7 +429,7 @@ function Mt(e) {
|
|
|
427
429
|
};
|
|
428
430
|
}
|
|
429
431
|
const le = "createCustomerAddress post /account/address";
|
|
430
|
-
function
|
|
432
|
+
function Kt(e) {
|
|
431
433
|
const s = g(), t = Q();
|
|
432
434
|
return h({
|
|
433
435
|
...e,
|
|
@@ -439,7 +441,7 @@ function Ot(e) {
|
|
|
439
441
|
});
|
|
440
442
|
}
|
|
441
443
|
const de = "deleteCustomerAddress delete /account/address/{addressId}";
|
|
442
|
-
function
|
|
444
|
+
function Ot(e) {
|
|
443
445
|
const s = g(), t = Q();
|
|
444
446
|
return h({
|
|
445
447
|
...e,
|
|
@@ -479,7 +481,14 @@ function At(e) {
|
|
|
479
481
|
}),
|
|
480
482
|
onSuccess: async (n, r, a) => {
|
|
481
483
|
var u, i;
|
|
482
|
-
t.setQueryData(L.get(), n), await
|
|
484
|
+
t.setQueryData(L.get(), n), await Promise.all([
|
|
485
|
+
t.invalidateQueries({ queryKey: b.lists() }),
|
|
486
|
+
t.invalidateQueries({ queryKey: D.lists() })
|
|
487
|
+
]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
|
|
488
|
+
n,
|
|
489
|
+
r,
|
|
490
|
+
a
|
|
491
|
+
));
|
|
483
492
|
}
|
|
484
493
|
});
|
|
485
494
|
}
|
|
@@ -507,7 +516,14 @@ function Ft(e) {
|
|
|
507
516
|
}),
|
|
508
517
|
onSuccess: async (n, r, a) => {
|
|
509
518
|
var u, i;
|
|
510
|
-
t.setQueryData(L.get(), n), await
|
|
519
|
+
t.setQueryData(L.get(), n), await Promise.all([
|
|
520
|
+
t.invalidateQueries({ queryKey: b.lists() }),
|
|
521
|
+
t.invalidateQueries({ queryKey: D.lists() })
|
|
522
|
+
]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
|
|
523
|
+
n,
|
|
524
|
+
r,
|
|
525
|
+
a
|
|
526
|
+
));
|
|
511
527
|
}
|
|
512
528
|
});
|
|
513
529
|
}
|
|
@@ -599,13 +615,13 @@ function bt(e) {
|
|
|
599
615
|
}
|
|
600
616
|
});
|
|
601
617
|
}
|
|
602
|
-
const
|
|
618
|
+
const Ke = "loginCustomer post /account/login";
|
|
603
619
|
function kt(e) {
|
|
604
620
|
const s = g(), t = Q();
|
|
605
621
|
return h({
|
|
606
622
|
...e,
|
|
607
623
|
mutationFn: async (n) => {
|
|
608
|
-
const r = await s.queryRaw(
|
|
624
|
+
const r = await s.queryRaw(Ke, {
|
|
609
625
|
body: n
|
|
610
626
|
}), a = r.headers.get("sw-context-token");
|
|
611
627
|
return a && (s.contextToken = a), r.json();
|
|
@@ -620,12 +636,12 @@ function kt(e) {
|
|
|
620
636
|
}
|
|
621
637
|
});
|
|
622
638
|
}
|
|
623
|
-
const
|
|
639
|
+
const Oe = "logoutCustomer post /account/logout";
|
|
624
640
|
function Bt(e) {
|
|
625
641
|
const s = g(), t = Q();
|
|
626
642
|
return h({
|
|
627
643
|
...e,
|
|
628
|
-
mutationFn: async (n) => s.query(
|
|
644
|
+
mutationFn: async (n) => s.query(Oe, y(n)),
|
|
629
645
|
onSuccess: async (n, r, a) => {
|
|
630
646
|
var u, i;
|
|
631
647
|
await Promise.all([
|
|
@@ -773,7 +789,7 @@ function Ht(e) {
|
|
|
773
789
|
});
|
|
774
790
|
}
|
|
775
791
|
const Te = "readNavigation post /navigation/{activeId}/{rootId}", Ee = function(s, t, n) {
|
|
776
|
-
const r = g(), a =
|
|
792
|
+
const r = g(), a = k.detail(s, t, n);
|
|
777
793
|
return v({
|
|
778
794
|
queryKey: a,
|
|
779
795
|
queryFn: async ({ signal: u }) => {
|
|
@@ -834,7 +850,7 @@ function Xt(e) {
|
|
|
834
850
|
});
|
|
835
851
|
}
|
|
836
852
|
const He = "readCategoryList post /category", We = function(s) {
|
|
837
|
-
const t = g(), n =
|
|
853
|
+
const t = g(), n = N.list(s);
|
|
838
854
|
return v({
|
|
839
855
|
queryKey: n,
|
|
840
856
|
queryFn: async ({ signal: r }) => t.query(He, {
|
|
@@ -848,7 +864,7 @@ function Yt(e) {
|
|
|
848
864
|
}
|
|
849
865
|
const Je = "readCompactProductListing post /novu/headless/product-listing/{seoUrl}";
|
|
850
866
|
function Xe(e, s) {
|
|
851
|
-
const t = g(), n =
|
|
867
|
+
const t = g(), n = O.list(e, s);
|
|
852
868
|
return v({
|
|
853
869
|
queryKey: n,
|
|
854
870
|
queryFn: async ({ signal: r }) => {
|
|
@@ -869,7 +885,7 @@ function Zt(e, s) {
|
|
|
869
885
|
}
|
|
870
886
|
const Ye = "readCustomProductDetail post /novu/headless/product/{seoUrl}";
|
|
871
887
|
function Ze(e, s) {
|
|
872
|
-
const t = g(), n =
|
|
888
|
+
const t = g(), n = O.customDetail(e, s);
|
|
873
889
|
return v({
|
|
874
890
|
queryKey: n,
|
|
875
891
|
queryFn: async ({ signal: r }) => {
|
|
@@ -890,7 +906,7 @@ function _t(e, s) {
|
|
|
890
906
|
}
|
|
891
907
|
const _e = "searchPage post /search";
|
|
892
908
|
function et(e) {
|
|
893
|
-
const s = g(), t =
|
|
909
|
+
const s = g(), t = O.search(e);
|
|
894
910
|
return v({
|
|
895
911
|
queryKey: t,
|
|
896
912
|
queryFn: async ({ signal: n }) => {
|
|
@@ -907,7 +923,7 @@ function en(e) {
|
|
|
907
923
|
}
|
|
908
924
|
const tt = "searchSuggest post /search-suggest";
|
|
909
925
|
function nt(e) {
|
|
910
|
-
const s = g(), t =
|
|
926
|
+
const s = g(), t = O.searchSuggest(e);
|
|
911
927
|
return v({
|
|
912
928
|
queryKey: t,
|
|
913
929
|
queryFn: async ({ signal: n }) => {
|
|
@@ -924,7 +940,7 @@ function tn(e) {
|
|
|
924
940
|
}
|
|
925
941
|
const st = "readProduct post /product";
|
|
926
942
|
function rt(e) {
|
|
927
|
-
const s = g(), t =
|
|
943
|
+
const s = g(), t = O.headlessDetail(e);
|
|
928
944
|
return v({
|
|
929
945
|
queryKey: t,
|
|
930
946
|
queryFn: async ({ signal: n }) => {
|
|
@@ -941,7 +957,7 @@ function nn(e) {
|
|
|
941
957
|
}
|
|
942
958
|
const at = "readProductDetail post /product/{productId}";
|
|
943
959
|
function ut(e, s) {
|
|
944
|
-
const t = g(), n =
|
|
960
|
+
const t = g(), n = O.detail(e, s);
|
|
945
961
|
return v({
|
|
946
962
|
queryKey: n,
|
|
947
963
|
queryFn: async ({ signal: r }) => {
|
|
@@ -994,7 +1010,7 @@ function an(e) {
|
|
|
994
1010
|
}
|
|
995
1011
|
const dt = "readShippingMethod post /shipping-method";
|
|
996
1012
|
function yt(e) {
|
|
997
|
-
const s = g(), t =
|
|
1013
|
+
const s = g(), t = D.list(c(() => {
|
|
998
1014
|
var n;
|
|
999
1015
|
return (n = y(e)) == null ? void 0 : n.body;
|
|
1000
1016
|
}));
|
|
@@ -1010,7 +1026,7 @@ function pt(e) {
|
|
|
1010
1026
|
return q(yt(e));
|
|
1011
1027
|
}
|
|
1012
1028
|
function un() {
|
|
1013
|
-
const e =
|
|
1029
|
+
const e = B(), s = $(), t = $e({
|
|
1014
1030
|
query: {
|
|
1015
1031
|
onlyAvailable: !0
|
|
1016
1032
|
}
|
|
@@ -1034,7 +1050,7 @@ function un() {
|
|
|
1034
1050
|
};
|
|
1035
1051
|
}
|
|
1036
1052
|
function on() {
|
|
1037
|
-
const e =
|
|
1053
|
+
const e = B(), s = $(), t = pt({
|
|
1038
1054
|
query: {
|
|
1039
1055
|
onlyAvailable: !0
|
|
1040
1056
|
}
|
|
@@ -1066,7 +1082,7 @@ const gt = (e, s) => {
|
|
|
1066
1082
|
}
|
|
1067
1083
|
return (t == null ? void 0 : t[s]) ?? "";
|
|
1068
1084
|
}, cn = () => {
|
|
1069
|
-
const e =
|
|
1085
|
+
const e = B(), s = c(() => {
|
|
1070
1086
|
var t, n, r;
|
|
1071
1087
|
return ((r = (n = (t = e.data) == null ? void 0 : t.value) == null ? void 0 : n.context) == null ? void 0 : r.languageIdChain) ?? [];
|
|
1072
1088
|
});
|
|
@@ -1085,22 +1101,22 @@ function ln(e) {
|
|
|
1085
1101
|
get() {
|
|
1086
1102
|
return a.page;
|
|
1087
1103
|
},
|
|
1088
|
-
set(
|
|
1089
|
-
a.page = Math.max(1, Math.min(o(u),
|
|
1104
|
+
set(K) {
|
|
1105
|
+
a.page = Math.max(1, Math.min(o(u), K));
|
|
1090
1106
|
}
|
|
1091
1107
|
});
|
|
1092
1108
|
H(
|
|
1093
1109
|
[() => o(u), () => a],
|
|
1094
|
-
([
|
|
1095
|
-
a.page = Math.min(
|
|
1110
|
+
([K, p]) => {
|
|
1111
|
+
a.page = Math.min(K, a.page), a.total = p.total ?? 0, a.limit = p.limit;
|
|
1096
1112
|
}
|
|
1097
1113
|
);
|
|
1098
1114
|
const f = c(() => a.page === o(u)), P = c(() => a.page === 1), d = c(() => ({
|
|
1099
1115
|
p: a.page,
|
|
1100
1116
|
limit: a.limit,
|
|
1101
1117
|
"total-count-mode": a.totalCountMode ?? "none"
|
|
1102
|
-
})), M = (
|
|
1103
|
-
H(() => o(
|
|
1118
|
+
})), M = (K) => {
|
|
1119
|
+
H(() => o(K), (p) => {
|
|
1104
1120
|
p && (a.total = (p == null ? void 0 : p.total) ?? 0, a.limit = (p == null ? void 0 : p.limit) ?? 0);
|
|
1105
1121
|
});
|
|
1106
1122
|
};
|
|
@@ -1172,14 +1188,14 @@ function dn(e) {
|
|
|
1172
1188
|
var p, S, w;
|
|
1173
1189
|
return (w = (S = (p = e.value) == null ? void 0 : p.calculatedPrice) == null ? void 0 : S.regulationPrice) == null ? void 0 : w.price;
|
|
1174
1190
|
}
|
|
1175
|
-
),
|
|
1191
|
+
), K = c(() => X(e.value));
|
|
1176
1192
|
return {
|
|
1177
1193
|
price: P,
|
|
1178
1194
|
totalPrice: f,
|
|
1179
1195
|
unitPrice: i,
|
|
1180
1196
|
displayFromVariants: a,
|
|
1181
1197
|
displayFrom: r,
|
|
1182
|
-
tierPrices:
|
|
1198
|
+
tierPrices: K,
|
|
1183
1199
|
referencePrice: n,
|
|
1184
1200
|
isListPrice: d,
|
|
1185
1201
|
regulationPrice: M
|
|
@@ -1261,22 +1277,22 @@ export {
|
|
|
1261
1277
|
St as absolutizeSeoUrl,
|
|
1262
1278
|
F as addressKeys,
|
|
1263
1279
|
L as cartKeys,
|
|
1264
|
-
|
|
1280
|
+
N as categoryKeys,
|
|
1265
1281
|
A as contextKeys,
|
|
1266
1282
|
j as countryKeys,
|
|
1267
1283
|
I as customerKeys,
|
|
1268
1284
|
mt as getProductVariantForOptions,
|
|
1269
1285
|
ee as languageKey,
|
|
1270
|
-
|
|
1286
|
+
k as navigationKeys,
|
|
1271
1287
|
U as orderKeys,
|
|
1272
1288
|
b as paymentKeys,
|
|
1273
|
-
|
|
1289
|
+
O as productKeys,
|
|
1274
1290
|
je as readPaymentMethodOperation,
|
|
1275
1291
|
dt as readShippingMethodOperation,
|
|
1276
1292
|
V as relativizeSeoUrl,
|
|
1277
1293
|
E as salutationKeys,
|
|
1278
1294
|
T as seoUrlKeys,
|
|
1279
|
-
|
|
1295
|
+
D as shippingKeys,
|
|
1280
1296
|
_ as shopwareClientKey,
|
|
1281
1297
|
y as unrefOptions,
|
|
1282
1298
|
At as useAddLineItemMutation,
|
|
@@ -1284,11 +1300,11 @@ export {
|
|
|
1284
1300
|
zt as useChangePasswordMutation,
|
|
1285
1301
|
bt as useChangeProfileMutation,
|
|
1286
1302
|
Qt as useCheckoutAddresses,
|
|
1287
|
-
|
|
1303
|
+
Kt as useCreateCustomerAddressMutation,
|
|
1288
1304
|
It as useCreateOrderMutation,
|
|
1289
1305
|
Tt as useDefaultBillingAddressMutation,
|
|
1290
1306
|
Et as useDefaultShippingAddressMutation,
|
|
1291
|
-
|
|
1307
|
+
Ot as useDeleteCustomerAddressMutation,
|
|
1292
1308
|
jt as useDeleteCustomerMutation,
|
|
1293
1309
|
Jt as useHandlePaymentMutation,
|
|
1294
1310
|
Gt as useImitateCustomerLoginQuery,
|
|
@@ -1312,7 +1328,7 @@ export {
|
|
|
1312
1328
|
We as useReadCategoryListQueryOptions,
|
|
1313
1329
|
Zt as useReadCompactProductListingQuery,
|
|
1314
1330
|
Xe as useReadCompactProductListingQueryOptions,
|
|
1315
|
-
|
|
1331
|
+
B as useReadContextQuery,
|
|
1316
1332
|
ae as useReadContextQueryOptions,
|
|
1317
1333
|
Ut as useReadCountryQuery,
|
|
1318
1334
|
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
|
}
|
|
@@ -2,7 +2,7 @@ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/
|
|
|
2
2
|
import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
|
|
3
3
|
import { unref } from 'vue'
|
|
4
4
|
import { useShopwareQueryClient } from '../../inject'
|
|
5
|
-
import { cartKeys, contextKeys } from '../../keys'
|
|
5
|
+
import { cartKeys, contextKeys, paymentKeys, shippingKeys } from '../../keys'
|
|
6
6
|
import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
|
|
7
7
|
|
|
8
8
|
const updateContextOperation = 'updateContext patch /context' satisfies OperationKey
|
|
@@ -32,6 +32,8 @@ export function useUpdateContextMutation(
|
|
|
32
32
|
await Promise.all([
|
|
33
33
|
queryClient.invalidateQueries({ queryKey: contextKeys.all() }),
|
|
34
34
|
queryClient.invalidateQueries({ queryKey: cartKeys.get() }),
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: paymentKeys.lists() }),
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: shippingKeys.lists() }),
|
|
35
37
|
])
|
|
36
38
|
|
|
37
39
|
await unref(unref(mutationOptions)?.onSuccess)?.(newContext, variables, context)
|