refactor: introduce useApps hook
This commit is contained in:
26
packages/web/src/hooks/useApps.ts
Normal file
26
packages/web/src/hooks/useApps.ts
Normal 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,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user