@@ -66,9 +66,12 @@ export function createCategoryHooks<
6666 ( ( input : TDetailInput ) => input as unknown as TDetailParams )
6767
6868 function useCategories ( input : TListInput ) : UseCategoriesResult < TCategory > {
69- const listParams = buildList ( input )
69+ const { enabled : inputEnabled , ...listInput } = input as TListInput & {
70+ enabled ?: boolean
71+ }
72+ const listParams = buildList ( listInput as TListInput )
7073 const queryKey = resolvedQueryKeys . list ( listParams )
71- const enabled = input . enabled ?? true
74+ const enabled = inputEnabled ?? true
7275
7376 const { data, isLoading, isFetching, isSuccess, error } = useQuery ( {
7477 queryKey,
@@ -109,7 +112,10 @@ export function createCategoryHooks<
109112 }
110113
111114 function useSuspenseCategories ( input : TListInput ) {
112- const listParams = buildList ( input )
115+ const { enabled : _inputEnabled , ...listInput } = input as TListInput & {
116+ enabled ?: boolean
117+ }
118+ const listParams = buildList ( listInput as TListInput )
113119 const { data, isFetching } = useSuspenseQuery ( {
114120 queryKey : resolvedQueryKeys . list ( listParams ) ,
115121 queryFn : ( { signal } ) => service . getCategories ( listParams , signal ) ,
@@ -144,9 +150,12 @@ export function createCategoryHooks<
144150 }
145151
146152 function useCategory ( input : TDetailInput ) {
147- const detailParams = buildDetail ( input )
153+ const { enabled : inputEnabled , ...detailInput } = input as TDetailInput & {
154+ enabled ?: boolean
155+ }
156+ const detailParams = buildDetail ( detailInput as TDetailInput )
148157 const queryKey = resolvedQueryKeys . detail ( detailParams )
149- const enabled = input . enabled ?? Boolean ( input . id )
158+ const enabled = inputEnabled ?? Boolean ( input . id )
150159
151160 return useQuery ( {
152161 queryKey,
@@ -157,10 +166,13 @@ export function createCategoryHooks<
157166 }
158167
159168 function useSuspenseCategory ( input : TDetailInput ) {
169+ const { enabled : _inputEnabled , ...detailInput } = input as TDetailInput & {
170+ enabled ?: boolean
171+ }
160172 if ( ! input . id ) {
161173 throw new Error ( "Category id is required for category queries" )
162174 }
163- const detailParams = buildDetail ( input )
175+ const detailParams = buildDetail ( detailInput as TDetailInput )
164176 return useSuspenseQuery ( {
165177 queryKey : resolvedQueryKeys . detail ( detailParams ) ,
166178 queryFn : ( ) => service . getCategory ( detailParams ) ,
@@ -182,7 +194,10 @@ export function createCategoryHooks<
182194 const skipIfCached = options ?. skipIfCached ?? true
183195
184196 const prefetchCategories = async ( input : TListInput ) => {
185- const listParams = buildList ( input )
197+ const { enabled : _inputEnabled , ...listInput } = input as TListInput & {
198+ enabled ?: boolean
199+ }
200+ const listParams = buildList ( listInput as TListInput )
186201 const queryKey = resolvedQueryKeys . list ( listParams )
187202 const cached = queryClient . getQueryData ( queryKey )
188203 if ( skipIfCached && cached ) {
@@ -201,7 +216,10 @@ export function createCategoryHooks<
201216 delay = defaultDelay ,
202217 prefetchId ?: string
203218 ) => {
204- const listParams = buildList ( input )
219+ const { enabled : _inputEnabled , ...listInput } = input as TListInput & {
220+ enabled ?: boolean
221+ }
222+ const listParams = buildList ( listInput as TListInput )
205223 const queryKey = resolvedQueryKeys . list ( listParams )
206224 const id = prefetchId ?? JSON . stringify ( queryKey )
207225 const existing = timeoutsRef . current . get ( id )
@@ -250,7 +268,10 @@ export function createCategoryHooks<
250268 if ( ! input . id ) {
251269 return
252270 }
253- const detailParams = buildDetail ( input )
271+ const { enabled : _inputEnabled , ...detailInput } = input as TDetailInput & {
272+ enabled ?: boolean
273+ }
274+ const detailParams = buildDetail ( detailInput as TDetailInput )
254275 const queryKey = resolvedQueryKeys . detail ( detailParams )
255276 const cached = queryClient . getQueryData ( queryKey )
256277 if ( skipIfCached && cached ) {
@@ -269,7 +290,10 @@ export function createCategoryHooks<
269290 delay = defaultDelay ,
270291 prefetchId ?: string
271292 ) => {
272- const detailParams = buildDetail ( input )
293+ const { enabled : _inputEnabled , ...detailInput } = input as TDetailInput & {
294+ enabled ?: boolean
295+ }
296+ const detailParams = buildDetail ( detailInput as TDetailInput )
273297 const queryKey = resolvedQueryKeys . detail ( detailParams )
274298 const id = prefetchId ?? JSON . stringify ( queryKey )
275299 const existing = timeoutsRef . current . get ( id )
0 commit comments