Fix workspace deletion

This commit is contained in:
Gregory Schier
2023-03-21 09:32:15 -07:00
parent 67925e18b2
commit 39223e8d89
7 changed files with 21 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
import { useNavigate } from 'react-router-dom';
export type RouteParamsWorkspace = {
workspaceId: string;
};
@@ -24,15 +26,18 @@ export const routePaths = {
};
export function useRoutes() {
const navigate = useNavigate();
return {
navigate<T extends keyof typeof routePaths>(
path: T,
params: Parameters<(typeof routePaths)[T]>[0],
...params: Parameters<(typeof routePaths)[T]>
) {
// Not sure how to make TS work here, but it's good from the
// outside caller perspective.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
routePaths[path](params as any);
const resolvedPath = routePaths[path](...(params as any));
console.log('NAVIGATE TO', resolvedPath, 'WITH PARAMS', params, 'AND PATH', path);
navigate(resolvedPath);
},
paths: routePaths,
};