mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
27 lines
750 B
TypeScript
27 lines
750 B
TypeScript
'use client';
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { AdminService } from '@/lib/api/services/admin';
|
|
|
|
export const modelsWithProvidersQueryKey = ['models-with-providers'] as const;
|
|
|
|
/**
|
|
* Shared catalog read for every models view, so the page shell and the
|
|
* selector panel share one request instead of each fanning out to providers.
|
|
*/
|
|
export function useModelsWithProviders() {
|
|
const query = useQuery({
|
|
queryKey: modelsWithProvidersQueryKey,
|
|
queryFn: () => AdminService.getModelsWithProviders(),
|
|
refetchOnWindowFocus: false,
|
|
});
|
|
|
|
return {
|
|
models: query.data?.models ?? [],
|
|
groups: query.data?.groups ?? [],
|
|
isLoading: query.isLoading,
|
|
error: query.error,
|
|
refetch: query.refetch,
|
|
};
|
|
}
|