@@ -45,17 +45,17 @@ export function createCommercePaginatedHook<TResource extends ClerkResource, TPa
45
45
options,
46
46
} : CommerceHookConfig < TResource , TParams > ) {
47
47
type HookParams = PaginatedHookConfig < PagesOrInfiniteOptions > & {
48
- for : ForPayerType ;
48
+ for ? : ForPayerType ;
49
49
} ;
50
50
51
51
return function useCommerceHook < T extends HookParams > (
52
52
params ?: T ,
53
53
) : PaginatedResources < TResource , T extends { infinite : true } ? true : false > {
54
- const { for : _for , ...paginationParams } = params || ( { for : 'user' } as T ) ;
54
+ const { for : _for , ...paginationParams } = params || ( { } as Partial < T > ) ;
55
55
56
56
useAssertWrappedByClerkProvider ( hookName ) ;
57
57
58
- const fetchFn = useFetcher ( _for ) ;
58
+ const fetchFn = useFetcher ( _for || 'user' ) ;
59
59
60
60
const safeValues = useWithSafeValues ( paginationParams , {
61
61
initialPage : 1 ,
@@ -83,14 +83,12 @@ export function createCommercePaginatedHook<TResource extends ClerkResource, TPa
83
83
...( _for === 'organization' ? { orgId : organization ?. id } : { } ) ,
84
84
} as TParams ) ;
85
85
86
- const isClerkLoaded = ! ! ( clerk . loaded && ( options ?. unauthenticated ? true : user ) ) ;
87
-
88
86
const isOrganization = _for === 'organization' ;
89
87
const billingEnabled = isOrganization
90
88
? environment ?. commerceSettings . billing . organization . enabled
91
89
: environment ?. commerceSettings . billing . user . enabled ;
92
90
93
- const isEnabled = ! ! hookParams && isClerkLoaded && ! ! billingEnabled ;
91
+ const isEnabled = ! ! hookParams && clerk . loaded && ! ! billingEnabled ;
94
92
95
93
const result = usePagesOrInfinite < TParams , ClerkPaginatedResponse < TResource > > (
96
94
( hookParams || { } ) as TParams ,
@@ -99,6 +97,7 @@ export function createCommercePaginatedHook<TResource extends ClerkResource, TPa
99
97
keepPreviousData : safeValues . keepPreviousData ,
100
98
infinite : safeValues . infinite ,
101
99
enabled : isEnabled ,
100
+ ...( options ?. unauthenticated ? { } : { isSignedIn : Boolean ( user ) } ) ,
102
101
__experimental_mode : safeValues . __experimental_mode ,
103
102
} ,
104
103
{
0 commit comments