Refactor hooks to be easier to use

This commit is contained in:
Gregory Schier
2023-03-13 23:25:41 -07:00
parent aa66f957f2
commit 5f947ac983
19 changed files with 314 additions and 258 deletions

View File

@@ -4,8 +4,10 @@ import { convertDates } from '../lib/models';
import { useQuery } from '@tanstack/react-query';
export function useWorkspaces() {
return useQuery(['workspaces'], async () => {
const workspaces = (await invoke('workspaces')) as Workspace[];
return workspaces.map(convertDates);
});
return (
useQuery(['workspaces'], async () => {
const workspaces = (await invoke('workspaces')) as Workspace[];
return workspaces.map(convertDates);
}).data ?? []
);
}