@teamnovu/kit-shopware-composables 0.0.18 → 0.0.20

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
@@ -1,6 +1,6 @@
1
1
  import { inject as Y, unref as i, computed as c, reactive as Z, watch as H, toRef as W } from "vue";
2
2
  import { until as J } from "@vueuse/core";
3
- import { queryOptions as P, useQuery as Q, useQueryClient as C, useMutation as h } from "@tanstack/vue-query";
3
+ import { queryOptions as S, useQuery as P, useQueryClient as Q, useMutation as h } from "@tanstack/vue-query";
4
4
  import "@teamnovu/kit-shopware-api-client";
5
5
  const _ = Symbol("shopwareClient");
6
6
  function g() {
@@ -170,7 +170,7 @@ function ne(e) {
170
170
  var n;
171
171
  return (n = p(e)) == null ? void 0 : n.body;
172
172
  }));
173
- return P({
173
+ return S({
174
174
  queryKey: t,
175
175
  queryFn: ({ signal: n }) => s.query(te, {
176
176
  ...p(e),
@@ -179,14 +179,14 @@ function ne(e) {
179
179
  });
180
180
  }
181
181
  function se(e) {
182
- return Q(ne(e));
182
+ return P(ne(e));
183
183
  }
184
184
  const V = (e) => {
185
185
  const s = e.replace(/\/?$/, "");
186
186
  return s.startsWith("/") ? s.slice(1) : s;
187
187
  }, ft = (e) => `/${V(e)}`;
188
188
  function ht(e, s, t) {
189
- const n = C();
189
+ const n = Q();
190
190
  return {
191
191
  onMutate: async (r) => {
192
192
  await n.cancelQueries({ queryKey: e });
@@ -214,7 +214,7 @@ function ht(e, s, t) {
214
214
  const re = "readContext get /context";
215
215
  function ae(e) {
216
216
  const s = g();
217
- return P({
217
+ return S({
218
218
  queryKey: F.all(),
219
219
  queryFn: ({ signal: t }) => s.query(re, {
220
220
  ...p(e),
@@ -223,11 +223,11 @@ function ae(e) {
223
223
  });
224
224
  }
225
225
  function k(e) {
226
- return Q(ae(e));
226
+ return P(ae(e));
227
227
  }
228
228
  const ue = "updateContext patch /context";
229
229
  function $(e) {
230
- const s = g(), t = C();
230
+ const s = g(), t = Q();
231
231
  return h({
232
232
  ...e,
233
233
  mutationFn: async (n) => (t.cancelQueries({ queryKey: F.all() }), s.query(ue, {
@@ -262,7 +262,7 @@ function vt() {
262
262
  return M.id !== ((O = u.value) == null ? void 0 : O.id);
263
263
  }
264
264
  )) ?? [];
265
- }), S = c(() => {
265
+ }), C = c(() => {
266
266
  var d;
267
267
  return ((d = t.data.value) == null ? void 0 : d.elements.filter(
268
268
  (M) => {
@@ -281,13 +281,13 @@ function vt() {
281
281
  activeBillingAddress: u,
282
282
  activeShippingAddress: o,
283
283
  inactiveBillingAddresses: f,
284
- inactiveShippingAddresses: S
284
+ inactiveShippingAddresses: C
285
285
  };
286
286
  }
287
287
  const oe = "readOrder post /order";
288
288
  function ie(e) {
289
289
  const s = g(), t = U.detail(e);
290
- return P({
290
+ return S({
291
291
  queryKey: t,
292
292
  queryFn: async ({ signal: n }) => {
293
293
  const r = p(e);
@@ -299,7 +299,7 @@ function ie(e) {
299
299
  });
300
300
  }
301
301
  function ce(e) {
302
- return Q(ie(e));
302
+ return P(ie(e));
303
303
  }
304
304
  function qt(e, s) {
305
305
  const t = c(() => {
@@ -333,7 +333,7 @@ function qt(e, s) {
333
333
  }), f = c(() => {
334
334
  var l, m;
335
335
  return (m = (l = r.value) == null ? void 0 : l.price) == null ? void 0 : m.totalPrice;
336
- }), S = c(() => {
336
+ }), C = c(() => {
337
337
  var l, m;
338
338
  return (m = (l = r.value) == null ? void 0 : l.price) == null ? void 0 : m.positionPrice;
339
339
  }), d = c(() => {
@@ -379,7 +379,7 @@ function qt(e, s) {
379
379
  status: u,
380
380
  statusTechnicalName: o,
381
381
  total: f,
382
- subtotal: S,
382
+ subtotal: C,
383
383
  shippingCosts: d,
384
384
  shippingAddress: y,
385
385
  billingAddress: O,
@@ -412,7 +412,7 @@ function Ct(e) {
412
412
  }
413
413
  const le = "createCustomerAddress post /account/address";
414
414
  function St(e) {
415
- const s = g(), t = C();
415
+ const s = g(), t = Q();
416
416
  return h({
417
417
  ...e,
418
418
  mutationFn: async (n) => s.query(le, p(n)),
@@ -424,7 +424,7 @@ function St(e) {
424
424
  }
425
425
  const de = "deleteCustomerAddress delete /account/address/{addressId}";
426
426
  function Pt(e) {
427
- const s = g(), t = C();
427
+ const s = g(), t = Q();
428
428
  return h({
429
429
  ...e,
430
430
  mutationFn: async (n) => s.query(de, p(n)),
@@ -436,7 +436,7 @@ function Pt(e) {
436
436
  }
437
437
  const ye = "updateCustomerAddress patch /account/address/{addressId}";
438
438
  function Qt(e) {
439
- const s = g(), t = C();
439
+ const s = g(), t = Q();
440
440
  return h({
441
441
  ...e,
442
442
  mutationFn: async (n) => s.query(ye, p(n)),
@@ -447,7 +447,7 @@ function Qt(e) {
447
447
  t.invalidateQueries({ queryKey: R.lists() }),
448
448
  t.invalidateQueries({
449
449
  queryKey: R.detail(p(r).params.addressId),
450
- predicate: (S) => S.queryKey.at(-1) !== u
450
+ predicate: (C) => C.queryKey.at(-1) !== u
451
451
  })
452
452
  ]), await ((f = i((o = i(e)) == null ? void 0 : o.onSuccess)) == null ? void 0 : f(n, r, a));
453
453
  }
@@ -455,7 +455,7 @@ function Qt(e) {
455
455
  }
456
456
  const pe = "addLineItem post /checkout/cart/line-item";
457
457
  function Mt(e) {
458
- const s = g(), t = C();
458
+ const s = g(), t = Q();
459
459
  return h({
460
460
  ...e,
461
461
  mutationFn: async (n) => s.query(pe, {
@@ -470,7 +470,7 @@ function Mt(e) {
470
470
  const ge = "readCart get /checkout/cart";
471
471
  function me(e) {
472
472
  const s = g(), t = x.get();
473
- return P({
473
+ return S({
474
474
  queryKey: t,
475
475
  queryFn: async ({ signal: n }) => s.query(ge, {
476
476
  ...p(e),
@@ -479,11 +479,11 @@ function me(e) {
479
479
  });
480
480
  }
481
481
  function Ot() {
482
- return Q(me());
482
+ return P(me());
483
483
  }
484
484
  const fe = "removeLineItem post /checkout/cart/line-item/delete";
485
485
  function Kt(e) {
486
- const s = g(), t = C();
486
+ const s = g(), t = Q();
487
487
  return h({
488
488
  ...e,
489
489
  mutationFn: async (n) => s.query(fe, {
@@ -497,7 +497,7 @@ function Kt(e) {
497
497
  }
498
498
  const he = "updateLineItem patch /checkout/cart/line-item";
499
499
  function At(e) {
500
- const s = g(), t = C();
500
+ const s = g(), t = Q();
501
501
  return h({
502
502
  ...e,
503
503
  mutationFn: async (n) => s.query(he, {
@@ -511,13 +511,15 @@ function At(e) {
511
511
  }
512
512
  const ve = "createOrder post /checkout/order";
513
513
  function wt(e) {
514
- const s = g(), t = C();
514
+ const s = g(), t = Q();
515
515
  return h({
516
516
  ...e,
517
517
  mutationFn: async (n) => s.query(ve, p(n)),
518
518
  onSuccess: async (n, r, a) => {
519
519
  var u, o;
520
520
  await Promise.all([
521
+ // Clear cart after successful order creation
522
+ t.invalidateQueries({ queryKey: x.get() }),
521
523
  // Invalidate order list to refetch data
522
524
  t.invalidateQueries({ queryKey: U.lists() })
523
525
  ]), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
@@ -527,7 +529,7 @@ function wt(e) {
527
529
  const qe = "readLanguages post /language";
528
530
  function Ce(e) {
529
531
  const s = g();
530
- return P({
532
+ return S({
531
533
  queryKey: ee.all(),
532
534
  queryFn: ({ signal: t }) => s.query(qe, {
533
535
  ...p(e),
@@ -536,11 +538,11 @@ function Ce(e) {
536
538
  });
537
539
  }
538
540
  function Rt(e) {
539
- return Q(Ce(e));
541
+ return P(Ce(e));
540
542
  }
541
543
  const Se = "readCountry post /country", Pe = function(s) {
542
544
  const t = g(), n = j.list(s);
543
- return P({
545
+ return S({
544
546
  queryKey: n,
545
547
  queryFn: async ({ signal: r }) => {
546
548
  const a = p(s);
@@ -552,11 +554,11 @@ const Se = "readCountry post /country", Pe = function(s) {
552
554
  });
553
555
  };
554
556
  function Ft(e) {
555
- return Q(Pe(e));
557
+ return P(Pe(e));
556
558
  }
557
559
  const Qe = "changeEmail post /account/change-email";
558
560
  function Lt(e) {
559
- const s = g(), t = C();
561
+ const s = g(), t = Q();
560
562
  return h({
561
563
  ...e,
562
564
  mutationFn: async (n) => s.query(Qe, p(n)),
@@ -568,7 +570,7 @@ function Lt(e) {
568
570
  }
569
571
  const Me = "changeProfile post /account/change-profile";
570
572
  function It(e) {
571
- const s = g(), t = C();
573
+ const s = g(), t = Q();
572
574
  return h({
573
575
  ...e,
574
576
  mutationFn: async (n) => s.query(Me, p(n)),
@@ -583,7 +585,7 @@ function It(e) {
583
585
  }
584
586
  const Oe = "loginCustomer post /account/login";
585
587
  function xt(e) {
586
- const s = g(), t = C();
588
+ const s = g(), t = Q();
587
589
  return h({
588
590
  ...e,
589
591
  mutationFn: async (n) => {
@@ -604,7 +606,7 @@ function xt(e) {
604
606
  }
605
607
  const Ke = "logoutCustomer post /account/logout";
606
608
  function Ut(e) {
607
- const s = g(), t = C();
609
+ const s = g(), t = Q();
608
610
  return h({
609
611
  ...e,
610
612
  mutationFn: async (n) => s.query(Ke, p(n)),
@@ -621,17 +623,17 @@ function Ut(e) {
621
623
  const Ae = "readCustomer post /account/customer";
622
624
  function we(e) {
623
625
  const s = g(), t = L.detail(c(() => p(e).body ?? {}));
624
- return P({
626
+ return S({
625
627
  queryKey: t,
626
628
  queryFn: async () => s.query(Ae, p(e))
627
629
  });
628
630
  }
629
631
  function Re(e) {
630
- return Q(we(e));
632
+ return P(we(e));
631
633
  }
632
634
  const Fe = "register post /account/register";
633
635
  function bt(e) {
634
- const s = g(), t = C();
636
+ const s = g(), t = Q();
635
637
  return h({
636
638
  ...e,
637
639
  mutationFn: async (n) => s.query(Fe, p(n)),
@@ -643,7 +645,7 @@ function bt(e) {
643
645
  }
644
646
  const Le = "defaultBillingAddress patch /account/address/default-billing/{addressId}";
645
647
  function kt(e) {
646
- const s = g(), t = C();
648
+ const s = g(), t = Q();
647
649
  return h({
648
650
  ...e,
649
651
  mutationFn: async (n) => s.query(Le, p(n)),
@@ -658,7 +660,7 @@ function kt(e) {
658
660
  }
659
661
  const Ie = "defaultShippingAddress patch /account/address/default-shipping/{addressId}";
660
662
  function Bt(e) {
661
- const s = g(), t = C();
663
+ const s = g(), t = Q();
662
664
  return h({
663
665
  ...e,
664
666
  mutationFn: async (n) => s.query(Ie, p(n)),
@@ -673,7 +675,7 @@ function Bt(e) {
673
675
  }
674
676
  const xe = "deleteCustomer delete /account/customer";
675
677
  function Dt(e) {
676
- const s = g(), t = C();
678
+ const s = g(), t = Q();
677
679
  return h({
678
680
  ...e,
679
681
  mutationFn: async (n) => s.query(xe, p(n)),
@@ -731,13 +733,13 @@ function Et(e) {
731
733
  const Be = "imitateCustomerLogin post /account/login/imitate-customer";
732
734
  function De(e) {
733
735
  const s = g(), t = L.imitateLogin(c(() => p(e).body ?? {}));
734
- return P({
736
+ return S({
735
737
  queryKey: t,
736
738
  queryFn: async () => s.query(Be, p(e))
737
739
  });
738
740
  }
739
741
  function jt(e) {
740
- return Q(De(e));
742
+ return P(De(e));
741
743
  }
742
744
  const Ne = "recoveryPassword post /account/recovery-password-confirm";
743
745
  function Vt(e) {
@@ -753,12 +755,12 @@ function Vt(e) {
753
755
  }
754
756
  const Te = "readNavigation post /navigation/{activeId}/{rootId}", Ee = function(s, t, n) {
755
757
  const r = g(), a = b.detail(s, t, n);
756
- return P({
758
+ return S({
757
759
  queryKey: a,
758
760
  queryFn: async ({ signal: u }) => {
759
- const o = i(s), f = i(t), S = p(n);
761
+ const o = i(s), f = i(t), C = p(n);
760
762
  return r.query(Te, {
761
- ...S,
763
+ ...C,
762
764
  params: {
763
765
  activeId: o,
764
766
  rootId: f
@@ -769,7 +771,7 @@ const Te = "readNavigation post /navigation/{activeId}/{rootId}", Ee = function(
769
771
  });
770
772
  };
771
773
  function $t(e, s, t) {
772
- return Q(Ee(e, s, t));
774
+ return P(Ee(e, s, t));
773
775
  }
774
776
  const je = "readPaymentMethod post /payment-method";
775
777
  function Ve(e) {
@@ -777,7 +779,7 @@ function Ve(e) {
777
779
  var n;
778
780
  return (n = p(e)) == null ? void 0 : n.body;
779
781
  }));
780
- return P({
782
+ return S({
781
783
  queryKey: t,
782
784
  queryFn: ({ signal: n }) => s.query(je, {
783
785
  ...p(e),
@@ -786,23 +788,23 @@ function Ve(e) {
786
788
  });
787
789
  }
788
790
  function $e(e) {
789
- return Q(Ve(e));
791
+ return P(Ve(e));
790
792
  }
791
793
  const ze = "handlePaymentMethod post /handle-payment";
792
794
  function zt(e) {
793
- const s = g(), t = C();
795
+ const s = g();
794
796
  return h({
795
797
  ...e,
796
- mutationFn: async (n) => s.query(ze, p(n)),
797
- onSuccess: async (n, r, a) => {
798
- var u, o;
799
- await t.invalidateQueries({ queryKey: x.get() }), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
798
+ mutationFn: async (t) => s.query(ze, p(t)),
799
+ onSuccess: async (t, n, r) => {
800
+ var a, u;
801
+ await ((u = i((a = i(e)) == null ? void 0 : a.onSuccess)) == null ? void 0 : u(t, n, r));
800
802
  }
801
803
  });
802
804
  }
803
805
  const Ge = "orderSetPayment post /order/payment";
804
806
  function Gt(e) {
805
- const s = g(), t = C();
807
+ const s = g(), t = Q();
806
808
  return h({
807
809
  ...e,
808
810
  mutationFn: async (n) => s.query(Ge, p(n)),
@@ -814,7 +816,7 @@ function Gt(e) {
814
816
  }
815
817
  const He = "readCategoryList post /category", We = function(s) {
816
818
  const t = g(), n = B.list(s);
817
- return P({
819
+ return S({
818
820
  queryKey: n,
819
821
  queryFn: async ({ signal: r }) => t.query(He, {
820
822
  ...p(s),
@@ -823,12 +825,12 @@ const He = "readCategoryList post /category", We = function(s) {
823
825
  });
824
826
  };
825
827
  function Ht(e) {
826
- return Q(We(e));
828
+ return P(We(e));
827
829
  }
828
830
  const Je = "readCompactProductListing post /novu/headless/product-listing/{seoUrl}";
829
831
  function Xe(e, s) {
830
832
  const t = g(), n = w.list(e, s);
831
- return P({
833
+ return S({
832
834
  queryKey: n,
833
835
  queryFn: async ({ signal: r }) => {
834
836
  const a = p(s);
@@ -844,12 +846,12 @@ function Xe(e, s) {
844
846
  });
845
847
  }
846
848
  function Wt(e, s) {
847
- return Q(Xe(e, s));
849
+ return P(Xe(e, s));
848
850
  }
849
851
  const Ye = "readCustomProductDetail post /novu/headless/product/{seoUrl}";
850
852
  function Ze(e, s) {
851
853
  const t = g(), n = w.customDetail(e, s);
852
- return P({
854
+ return S({
853
855
  queryKey: n,
854
856
  queryFn: async ({ signal: r }) => {
855
857
  const a = p(s);
@@ -865,12 +867,12 @@ function Ze(e, s) {
865
867
  });
866
868
  }
867
869
  function Jt(e, s) {
868
- return Q(Ze(e, s));
870
+ return P(Ze(e, s));
869
871
  }
870
872
  const _e = "searchPage post /search";
871
873
  function et(e) {
872
874
  const s = g(), t = w.search(e);
873
- return P({
875
+ return S({
874
876
  queryKey: t,
875
877
  queryFn: async ({ signal: n }) => {
876
878
  const r = p(e);
@@ -882,12 +884,12 @@ function et(e) {
882
884
  });
883
885
  }
884
886
  function Xt(e) {
885
- return Q(et(e));
887
+ return P(et(e));
886
888
  }
887
889
  const tt = "readProduct post /product";
888
890
  function nt(e) {
889
891
  const s = g(), t = w.detail(e);
890
- return P({
892
+ return S({
891
893
  queryKey: t,
892
894
  queryFn: async ({ signal: n }) => {
893
895
  const r = p(e);
@@ -899,11 +901,11 @@ function nt(e) {
899
901
  });
900
902
  }
901
903
  function Yt(e) {
902
- return Q(nt(e));
904
+ return P(nt(e));
903
905
  }
904
906
  const st = "readSalutation post /salutation", rt = function(s) {
905
907
  const t = g(), n = E.list(s);
906
- return P({
908
+ return S({
907
909
  queryKey: n,
908
910
  queryFn: async ({ signal: r }) => {
909
911
  const a = p(s);
@@ -915,11 +917,11 @@ const st = "readSalutation post /salutation", rt = function(s) {
915
917
  });
916
918
  };
917
919
  function Zt(e) {
918
- return Q(rt(e));
920
+ return P(rt(e));
919
921
  }
920
922
  const at = "readSeoUrl post /seo-url", ut = function(s) {
921
923
  const t = g(), n = T.list(s);
922
- return P({
924
+ return S({
923
925
  queryKey: n,
924
926
  queryFn: async ({ signal: r }) => {
925
927
  const a = p(s);
@@ -931,7 +933,7 @@ const at = "readSeoUrl post /seo-url", ut = function(s) {
931
933
  });
932
934
  };
933
935
  function _t(e) {
934
- return Q(ut(e));
936
+ return P(ut(e));
935
937
  }
936
938
  const ot = "readShippingMethod post /shipping-method";
937
939
  function it(e) {
@@ -939,7 +941,7 @@ function it(e) {
939
941
  var n;
940
942
  return (n = p(e)) == null ? void 0 : n.body;
941
943
  }));
942
- return P({
944
+ return S({
943
945
  queryKey: t,
944
946
  queryFn: ({ signal: n }) => s.query(ot, {
945
947
  ...p(e),
@@ -948,7 +950,7 @@ function it(e) {
948
950
  });
949
951
  }
950
952
  function ct(e) {
951
- return Q(it(e));
953
+ return P(it(e));
952
954
  }
953
955
  function en() {
954
956
  const e = k(), s = $(), t = $e({
@@ -961,8 +963,8 @@ function en() {
961
963
  var o, f;
962
964
  return (f = (o = e.data) == null ? void 0 : o.value) == null ? void 0 : f.paymentMethod;
963
965
  }), u = c(() => {
964
- var o, f, S;
965
- return ((S = (f = (o = t.data) == null ? void 0 : o.value) == null ? void 0 : f.elements) == null ? void 0 : S.sort((d, M) => (d.position ?? 0) - (M.position ?? 0))) ?? [];
966
+ var o, f, C;
967
+ return ((C = (f = (o = t.data) == null ? void 0 : o.value) == null ? void 0 : f.elements) == null ? void 0 : C.sort((d, M) => (d.position ?? 0) - (M.position ?? 0))) ?? [];
966
968
  });
967
969
  return {
968
970
  contextUpdateMutation: s,
@@ -986,7 +988,7 @@ function tn() {
986
988
  return (f = (o = e.data) == null ? void 0 : o.value) == null ? void 0 : f.shippingMethod;
987
989
  }), u = c(() => {
988
990
  var o, f;
989
- return ((f = (o = t.data) == null ? void 0 : o.value) == null ? void 0 : f.elements.sort((S, d) => (S.position ?? 0) - (d.position ?? 0))) ?? [];
991
+ return ((f = (o = t.data) == null ? void 0 : o.value) == null ? void 0 : f.elements.sort((C, d) => (C.position ?? 0) - (d.position ?? 0))) ?? [];
990
992
  });
991
993
  return {
992
994
  contextUpdateMutation: s,
@@ -1036,7 +1038,7 @@ function sn(e) {
1036
1038
  a.page = Math.min(O, a.page), a.total = y.total ?? 0, a.limit = y.limit;
1037
1039
  }
1038
1040
  );
1039
- const f = c(() => a.page === i(u)), S = c(() => a.page === 1), d = c(() => ({
1041
+ const f = c(() => a.page === i(u)), C = c(() => a.page === 1), d = c(() => ({
1040
1042
  p: a.page,
1041
1043
  limit: a.limit,
1042
1044
  "total-count-mode": a.totalCountMode ?? "none"
@@ -1051,7 +1053,7 @@ function sn(e) {
1051
1053
  limit: W(a, "limit"),
1052
1054
  pageCount: u,
1053
1055
  isLastPage: f,
1054
- isFirstPage: S,
1056
+ isFirstPage: C,
1055
1057
  usePaginationSync: M,
1056
1058
  // This can be used to pass the pagination options directly to the query options
1057
1059
  queryOptions: d
@@ -1103,7 +1105,7 @@ function rn(e) {
1103
1105
  var y;
1104
1106
  return (y = u.value) == null ? void 0 : y.totalPrice;
1105
1107
  }
1106
- ), S = c(
1108
+ ), C = c(
1107
1109
  () => u.value
1108
1110
  ), d = c(() => {
1109
1111
  var y, v;
@@ -1115,7 +1117,7 @@ function rn(e) {
1115
1117
  }
1116
1118
  ), O = c(() => X(e.value));
1117
1119
  return {
1118
- price: S,
1120
+ price: C,
1119
1121
  totalPrice: f,
1120
1122
  unitPrice: o,
1121
1123
  displayFromVariants: a,
@@ -1178,7 +1180,7 @@ function on(e) {
1178
1180
  var d;
1179
1181
  return ((d = t.value) == null ? void 0 : d.defaultBillingAddress) || null;
1180
1182
  }
1181
- ), S = c(
1183
+ ), C = c(
1182
1184
  () => {
1183
1185
  var d;
1184
1186
  return ((d = t.value) == null ? void 0 : d.defaultShippingAddress) || null;
@@ -1193,7 +1195,7 @@ function on(e) {
1193
1195
  defaultBillingAddressId: u,
1194
1196
  defaultShippingAddressId: o,
1195
1197
  userDefaultBillingAddress: f,
1196
- userDefaultShippingAddress: S,
1198
+ userDefaultShippingAddress: C,
1197
1199
  // Expose queries and mutations directly
1198
1200
  customerQuery: s
1199
1201
  };
@@ -1,5 +1,5 @@
1
- import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client';
2
1
  import { UseMutationOptions, UseMutationReturnType, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult } from '@tanstack/vue-query';
2
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client';
3
3
  import { OperationOptions, OperationResponse } from '../types/query';
4
4
  declare const handlePaymentOperation = "handlePaymentMethod post /handle-payment";
5
5
  export declare function useHandlePaymentMutation(mutationOptions?: UseMutationOptions<OperationResponse<typeof handlePaymentOperation>, ShopwareApiError | Error, OperationOptions<typeof handlePaymentOperation>>): UseMutationReturnType<OperationResponse<"handlePaymentMethod post /handle-payment">, Error | ShopwareApiError, OperationOptions<"handlePaymentMethod post /handle-payment">, unknown, Omit< MutationObserverIdleResult<OperationResponse<"handlePaymentMethod post /handle-payment">, Error | ShopwareApiError, OperationOptions<"handlePaymentMethod post /handle-payment">, unknown>, "mutate" | "reset"> | Omit< MutationObserverLoadingResult<OperationResponse<"handlePaymentMethod post /handle-payment">, Error | ShopwareApiError, OperationOptions<"handlePaymentMethod post /handle-payment">, unknown>, "mutate" | "reset"> | Omit< MutationObserverErrorResult<OperationResponse<"handlePaymentMethod post /handle-payment">, Error | ShopwareApiError, OperationOptions<"handlePaymentMethod post /handle-payment">, unknown>, "mutate" | "reset"> | Omit< MutationObserverSuccessResult<OperationResponse<"handlePaymentMethod post /handle-payment">, Error | ShopwareApiError, OperationOptions<"handlePaymentMethod post /handle-payment">, unknown>, "mutate" | "reset">>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-shopware-composables",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "A collection of composables for the Shopware API",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient, type UseMutationOptions } 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 { orderKeys } from '../../keys'
5
+ import { cartKeys, orderKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
7
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
8
8
 
@@ -25,6 +25,9 @@ export function useCreateOrderMutation(
25
25
  },
26
26
  onSuccess: async (data, variables, context) => {
27
27
  await Promise.all([
28
+ // Clear cart after successful order creation
29
+ queryClient.invalidateQueries({ queryKey: cartKeys.get() }),
30
+
28
31
  // Invalidate order list to refetch data
29
32
  queryClient.invalidateQueries({ queryKey: orderKeys.lists() }),
30
33
  ])
@@ -1,10 +1,9 @@
1
+ import { useMutation, type UseMutationOptions } from '@tanstack/vue-query'
1
2
  import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
- import { useMutation, useQueryClient, type UseMutationOptions } from '@tanstack/vue-query'
3
3
  import { unref } from 'vue'
4
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
5
4
  import { useShopwareQueryClient } from '../../inject'
6
5
  import { unrefOptions } from '../../util/unrefOptions'
7
- import { cartKeys } from '../../keys'
6
+ import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
8
7
 
9
8
  const handlePaymentOperation = 'handlePaymentMethod post /handle-payment' satisfies OperationKey
10
9
 
@@ -16,7 +15,6 @@ export function useHandlePaymentMutation(
16
15
  >,
17
16
  ) {
18
17
  const client = useShopwareQueryClient()
19
- const queryClient = useQueryClient()
20
18
 
21
19
  return useMutation({
22
20
  ...mutationOptions,
@@ -24,8 +22,6 @@ export function useHandlePaymentMutation(
24
22
  return client.query(handlePaymentOperation, unrefOptions(options))
25
23
  },
26
24
  onSuccess: async (data, variables, context) => {
27
- await queryClient.invalidateQueries({ queryKey: cartKeys.get() })
28
-
29
25
  await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
30
26
  },
31
27
  })