Files
automatisch/packages/web/src/hooks/useApps.js
2024-04-05 10:48:49 +01:00

28 lines
585 B
JavaScript

import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useApps(variables) {
const trueOnlyVariables =
variables &&
Object.fromEntries(
Object.entries(variables).filter(
([key, value]) => value === true || key === 'name',
),
);
const query = useQuery({
queryKey: ['apps', trueOnlyVariables],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/apps', {
params: trueOnlyVariables,
signal,
});
return data;
},
});
return query;
}