Refactor hooks to be easier to use

This commit is contained in:
Gregory Schier
2023-03-13 23:25:41 -07:00
parent 4bf22d8a60
commit 7d4e9894c3
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 ?? []
);
}