@teamnovu/kit-shopware-composables 0.0.24 → 0.0.26

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/keys.d.ts CHANGED
@@ -46,6 +46,9 @@ export declare const productKeys: {
46
46
  search: (body: MaybeRef<unknown>) => readonly ["product", "search", {
47
47
  readonly body: unknown;
48
48
  }];
49
+ searchSuggest: (body: MaybeRef<unknown>) => readonly ["product", "searchSuggest", {
50
+ readonly body: unknown;
51
+ }];
49
52
  };
50
53
  export declare const cartKeys: {
51
54
  get: () => readonly ["cart"];
@@ -2,5 +2,6 @@ export * from './useReadCategoryListQuery';
2
2
  export * from './useReadCompactProductListingQuery';
3
3
  export * from './useReadCustomProductDetailQuery';
4
4
  export * from './useSearchPageQuery';
5
+ export * from './useSearchSuggestQuery';
5
6
  export * from './useReadProductQuery';
6
7
  export * from './useReadProductDetailQuery';
@@ -0,0 +1,17 @@
1
+ import { OperationOptions } from '../types/query';
2
+ import { UndefinedInitialQueryOptions, UseQueryReturnType } from '@tanstack/vue-query';
3
+ import { BrandedResponse } from '@teamnovu/kit-shopware-api-client';
4
+ import { Operations } from '..';
5
+ declare const searchSuggestOperation = "searchSuggest post /search-suggest";
6
+ export declare function useSearchSuggestQueryOptions(body?: OperationOptions<typeof searchSuggestOperation, 'params'>): UndefinedInitialQueryOptions<BrandedResponse<Operations, "searchSuggest post /search-suggest">, Error, BrandedResponse<Operations, "searchSuggest post /search-suggest">, readonly ["product", "searchSuggest", {
7
+ readonly body: unknown;
8
+ }]> & {
9
+ queryKey: readonly ["product", "searchSuggest", {
10
+ readonly body: unknown;
11
+ }] & {
12
+ [dataTagSymbol]: BrandedResponse<Operations, "searchSuggest post /search-suggest">;
13
+ [dataTagErrorSymbol]: Error;
14
+ };
15
+ };
16
+ export declare function useSearchSuggestQuery(body?: OperationOptions<typeof searchSuggestOperation, 'params'>): UseQueryReturnType<BrandedResponse<Operations, "searchSuggest post /search-suggest">, Error>;
17
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-shopware-composables",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "A collection of composables for the Shopware API",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
package/src/keys.ts CHANGED
@@ -89,6 +89,14 @@ export const productKeys = {
89
89
  body,
90
90
  },
91
91
  ] as const,
92
+ searchSuggest: (body: MaybeRef<unknown>) =>
93
+ [
94
+ ...productKeys.all(),
95
+ 'searchSuggest',
96
+ {
97
+ body,
98
+ },
99
+ ] as const,
92
100
  }
93
101
 
94
102
  export const cartKeys = {
@@ -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 { customerKeys } from '../../keys'
5
+ import { contextKeys, customerKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
7
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
8
8
 
@@ -24,7 +24,10 @@ export function useRegisterCustomerMutation(
24
24
  return client.query(registerOperation, unrefOptions(options))
25
25
  },
26
26
  onSuccess: async (data, variables, context) => {
27
- await queryClient.invalidateQueries({ queryKey: customerKeys.all() })
27
+ await Promise.all([
28
+ queryClient.resetQueries({ queryKey: contextKeys.all() }),
29
+ queryClient.invalidateQueries({ queryKey: customerKeys.all() }),
30
+ ])
28
31
 
29
32
  await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
30
33
  },
@@ -2,5 +2,6 @@ export * from './useReadCategoryListQuery'
2
2
  export * from './useReadCompactProductListingQuery'
3
3
  export * from './useReadCustomProductDetailQuery'
4
4
  export * from './useSearchPageQuery'
5
+ export * from './useSearchSuggestQuery'
5
6
  export * from './useReadProductQuery'
6
7
  export * from './useReadProductDetailQuery'
@@ -0,0 +1,31 @@
1
+ import { queryOptions, useQuery } from '@tanstack/vue-query'
2
+ import { useShopwareQueryClient } from '../../inject'
3
+ import { productKeys } from '../../keys'
4
+ import { unrefOptions } from '../../util/unrefOptions'
5
+ import type { OperationKey, OperationOptions } from '../types/query'
6
+
7
+ const searchSuggestOperation = 'searchSuggest post /search-suggest' satisfies OperationKey
8
+
9
+ export function useSearchSuggestQueryOptions(
10
+ body?: OperationOptions<typeof searchSuggestOperation, 'params'>,
11
+ ) {
12
+ const client = useShopwareQueryClient()
13
+ const queryKey = productKeys.searchSuggest(body)
14
+
15
+ return queryOptions({
16
+ queryKey,
17
+ queryFn: async ({ signal }) => {
18
+ const opts = unrefOptions(body)
19
+ return client.query(searchSuggestOperation, {
20
+ ...opts,
21
+ signal,
22
+ })
23
+ },
24
+ })
25
+ }
26
+
27
+ export function useSearchSuggestQuery(
28
+ body?: OperationOptions<typeof searchSuggestOperation, 'params'>,
29
+ ) {
30
+ return useQuery(useSearchSuggestQueryOptions(body))
31
+ }