refactor: introduce useApps hook

This commit is contained in:
Kasia
2023-09-22 09:59:22 +02:00
committed by Ali BARIN
parent c77e12edbb
commit a04b933161
4 changed files with 46 additions and 20 deletions

View File

@@ -0,0 +1,26 @@
import { useQuery } from '@apollo/client';
import { IApp } from '@automatisch/types';
import { GET_APPS } from 'graphql/queries/get-apps';
type QueryResponse = {
getApps: IApp[];
};
type UseAppsVariables = {
name?: string;
onlyWithTriggers?: boolean;
onlyWithActions?: boolean;
};
export default function useApps(variables?: UseAppsVariables) {
const { data, loading } = useQuery<QueryResponse>(GET_APPS, {
variables,
});
const apps = data?.getApps;
return {
apps,
loading,
};
}