mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix: improve type safety and defensive guard in useOnboarding hook
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f4303f5e22
commit
ba0ed492c4
2 changed files with 22 additions and 4 deletions
|
|
@ -21,7 +21,12 @@ describe("useOnboardingCredentials", () => {
|
|||
let queryClient: QueryClient;
|
||||
|
||||
beforeEach(() => {
|
||||
queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
});
|
||||
vi.clearAllMocks();
|
||||
mockUseUIConfig.mockReturnValue({ isLoading: false });
|
||||
});
|
||||
|
|
@ -77,7 +82,12 @@ describe("useClaimOnboardingToken", () => {
|
|||
let queryClient: QueryClient;
|
||||
|
||||
beforeEach(() => {
|
||||
queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
});
|
||||
vi.clearAllMocks();
|
||||
mockUseUIConfig.mockReturnValue({ isLoading: false });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,11 +5,19 @@ import { createQueryKeys } from "../common/queryKeysFactory";
|
|||
|
||||
const onboardingKeys = createQueryKeys("onboarding");
|
||||
|
||||
export interface OnboardingCredentials {
|
||||
token: string;
|
||||
login_url: string;
|
||||
}
|
||||
|
||||
export const useOnboardingCredentials = (inviteId: string | null) => {
|
||||
const { isLoading: isUIConfigLoading } = useUIConfig();
|
||||
return useQuery({
|
||||
return useQuery<OnboardingCredentials>({
|
||||
queryKey: onboardingKeys.detail(inviteId ?? ""),
|
||||
queryFn: async () => await getOnboardingCredentials(inviteId!),
|
||||
queryFn: async () => {
|
||||
if (!inviteId) throw new Error("inviteId is required");
|
||||
return getOnboardingCredentials(inviteId);
|
||||
},
|
||||
enabled: Boolean(inviteId) && !isUIConfigLoading,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue