Typesafe routing and CM line height issue

This commit is contained in:
Gregory Schier
2023-03-20 16:47:36 -07:00
parent 66fa7ac419
commit 184bbb01c5
20 changed files with 202 additions and 77 deletions

View File

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