mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Recent requests/workspaces. Closes #1
This commit is contained in:
@@ -2,15 +2,23 @@ import { Navigate } from 'react-router-dom';
|
||||
import { useAppRoutes } from '../hooks/useAppRoutes';
|
||||
import { useWorkspaces } from '../hooks/useWorkspaces';
|
||||
import { Heading } from './core/Heading';
|
||||
import { useRecentWorkspaces } from '../hooks/useRecentWorkspaces';
|
||||
|
||||
export default function Workspaces() {
|
||||
const routes = useAppRoutes();
|
||||
const recentWorkspaceIds = useRecentWorkspaces();
|
||||
const workspaces = useWorkspaces();
|
||||
const workspace = workspaces[0];
|
||||
|
||||
if (workspace === undefined) {
|
||||
const loading = workspaces.length === 0 && recentWorkspaceIds.length === 0;
|
||||
if (loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const workspaceId = recentWorkspaceIds[0] ?? workspaces[0]?.id ?? null;
|
||||
|
||||
if (workspaceId === null) {
|
||||
return <Heading>There are no workspaces</Heading>;
|
||||
}
|
||||
|
||||
return <Navigate to={routes.paths.workspace({ workspaceId: workspace.id })} />;
|
||||
return <Navigate to={routes.paths.workspace({ workspaceId })} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user