Create new workspace, and more optimizations

This commit is contained in:
Gregory Schier
2023-03-18 19:36:31 -07:00
parent b1835561a8
commit 9ac5572094
20 changed files with 272 additions and 133 deletions

View File

@@ -0,0 +1,18 @@
import { useMutation } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import { useNavigate } from 'react-router-dom';
import type { Workspace } from '../lib/models';
export function useCreateWorkspace({ navigateAfter }: { navigateAfter: boolean }) {
const navigate = useNavigate();
return useMutation<string, unknown, Pick<Workspace, 'name'>>({
mutationFn: (patch) => {
return invoke('create_workspace', patch);
},
onSuccess: async (workspaceId) => {
if (navigateAfter) {
navigate(`/workspaces/${workspaceId}`);
}
},
});
}