export const useInfiniteCustomers = ({
companyId,
ucId,
role,
cancel = false,
}: {
companyId: string
ucId: string
role: string
exclusiveStartKey?: string
cancel?: boolean
}) => {
return useInfiniteQuery({
queryKey: ['getInfiniteCustomers', { companyId, ucId, role }],
queryFn: async ({ pageParam }) => {
const { data } = await CustomersAPI.getInfiniteCustomers({
companyId,
ucId,
role,
...(pageParam && pageParam !== undefined && { exclusiveStartKey: pageParam }),
cancel,
})
return data.listCustomerReferencesByRole
},
// enabled: !!companyId && !!ucId && !!role,
getNextPageParam: (lastPage: any, allPages) => {
console.log('lastPage', lastPage)
return lastPage?.nextExclusiveStartKey ?? undefined
},
staleTime: Infinity,
})
}
export const useInfiniteCustomers = ({
companyId,
ucId,
role,
cancel = false,
}: {
companyId: string
ucId: string
role: string
exclusiveStartKey?: string
cancel?: boolean
}) => {
return useInfiniteQuery({
queryKey: ['getInfiniteCustomers', { companyId, ucId, role }],
queryFn: async ({ pageParam }) => {
const { data } = await CustomersAPI.getInfiniteCustomers({
companyId,
ucId,
role,
...(pageParam && pageParam !== undefined && { exclusiveStartKey: pageParam }),
cancel,
})
return data.listCustomerReferencesByRole
},
// enabled: !!companyId && !!ucId && !!role,
getNextPageParam: (lastPage: any, allPages) => {
console.log('lastPage', lastPage)
return lastPage?.nextExclusiveStartKey ?? undefined
},
staleTime: Infinity,
})
}