2025-01-23 19:41:31 +03:00
|
|
|
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
|
|
|
2025-01-29 23:18:08 +03:00
|
|
|
import { queryClient } from '@/backend/queryClient';
|
|
|
|
|
2025-01-23 19:41:31 +03:00
|
|
|
import { libraryApi } from './api';
|
|
|
|
|
|
|
|
export function useTemplatesSuspense() {
|
|
|
|
const { data: templates } = useSuspenseQuery({
|
|
|
|
...libraryApi.getTemplatesQueryOptions()
|
|
|
|
});
|
|
|
|
return { templates };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useTemplates() {
|
|
|
|
const { data: templates } = useQuery({
|
|
|
|
...libraryApi.getTemplatesQueryOptions()
|
|
|
|
});
|
|
|
|
return { templates: templates ?? [] };
|
|
|
|
}
|
2025-01-29 23:18:08 +03:00
|
|
|
|
|
|
|
export function prefetchTemplates() {
|
|
|
|
return queryClient.prefetchQuery(libraryApi.getTemplatesQueryOptions());
|
|
|
|
}
|