diff --git a/frontend/composables/partials/use-actions-factory.ts b/frontend/composables/partials/use-actions-factory.ts index e0a48693c954..80b73d28af3b 100644 --- a/frontend/composables/partials/use-actions-factory.ts +++ b/frontend/composables/partials/use-actions-factory.ts @@ -7,7 +7,7 @@ type BoundT = { }; interface StoreActions { - getAll(): Ref; + getAll(page?: number, perPage?: number, params?: any): Ref; refresh(): Promise; createOne(createData: T): Promise; updateOne(updateData: T): Promise; @@ -25,10 +25,13 @@ export function useStoreActions( allRef: Ref | null, loading: Ref ): StoreActions { - function getAll() { + function getAll(page = 1, perPage = -1, params = {} as any) { + params.orderBy ??= "name"; + params.orderDirection ??= "asc"; + loading.value = true; const allItems = useAsync(async () => { - const { data } = await api.getAll(); + const { data } = await api.getAll(page, perPage, params); if (data && allRef) { allRef.value = data.items;