mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 10:12:17 +01:00
add dynamic loading of paginated endpoints above page_limit
add request classes and fix collection typing for clients, tasks and tags
This commit is contained in:
@@ -3,6 +3,16 @@ import { api } from '@/packages/api/src';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import type { Project } from '@/packages/api/src';
|
||||
import { computed } from 'vue';
|
||||
import { fetchAllPages } from '@/utils/fetchAllPages';
|
||||
|
||||
export async function fetchAllProjects(organizationId: string): Promise<Project[]> {
|
||||
return fetchAllPages((page) =>
|
||||
api.getProjects({
|
||||
params: { organization: organizationId },
|
||||
queries: { archived: 'all', page },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function useProjectsQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -12,10 +22,8 @@ export function useProjectsQuery() {
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
return api.getProjects({
|
||||
params: { organization: organizationId },
|
||||
queries: { archived: 'all' },
|
||||
});
|
||||
const data = await fetchAllProjects(organizationId);
|
||||
return { data };
|
||||
},
|
||||
enabled: () => !!getCurrentOrganizationId(),
|
||||
staleTime: 1000 * 30, // 30 seconds
|
||||
|
||||
Reference in New Issue
Block a user