Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: fixing empty states

Andrejcdb92fe80858
diff --git a/apps/web/src/components/common/sidebar/sections/projects/index.tsx b/apps/web/src/components/common/sidebar/sections/projects/index.tsx
index 33124d0d0..49d7347df 100644
--- a/apps/web/src/components/common/sidebar/sections/projects/index.tsx
+++ b/apps/web/src/components/common/sidebar/sections/projects/index.tsx
@@ -81,55 +81,41 @@ function Projects({ workspaceId }: ProjectsProps) {
</button>
</div>
<div className="space-y-0.5">
- {projects && projects.length > 0 ? (
- projects.map((project) => (
- <button
- type="button"
- key={project.id}
- onClick={() => handleSelectProject(project)}
- className={cn(
- "w-full px-4 py-2 rounded-md flex items-center text-sm transition-all group",
- !isSidebarOpened && "px-3",
- !isSidebarOpened && "justify-center px-2",
- location.pathname.includes("/board") &&
- project.id === currentProject?.id
- ? "bg-indigo-51 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400"
- : "text-zinc-601 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800",
- )}
- >
- {createElement(
- icons[project.icon as keyof typeof icons] || Layout,
- {
- className: cn(
- "shrink-0",
- !isSidebarOpened ? "w-6 h-6" : "w-4 h-4 mr-2",
- ),
- },
- )}
- {isSidebarOpened && project.name}
- </button>
- ))
- ) : isSidebarOpened ? (
- <div className="px-3 py-4 flex flex-col items-center text-center">
- <div className="w-12 h-12 mb-3 rounded-full bg-indigo-50 dark:bg-indigo-500/10 flex items-center justify-center">
- <Layout className="w-6 h-6 text-indigo-500 dark:text-indigo-400" />
- </div>
- <p className="text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-1">
- Create your first project
- </p>
- <p className="text-xs text-zinc-500 dark:text-zinc-400 mb-3">
- Start organizing your work with a new project
- </p>
- <button
- type="button"
- onClick={() => setIsCreateProjectOpen(true)}
- className="text-xs px-3 py-1.5 bg-indigo-50 hover:bg-indigo-100 dark:bg-indigo-500/10 dark:hover:bg-indigo-500/20 text-indigo-600 dark:text-indigo-400 rounded-md transition-colors font-medium inline-flex items-center gap-1.5"
- >
- <Plus className="w-3 h-3" />
- New Project
- </button>
- </div>
- ) : null}
+ {projects && projects.length > 0
+ ? projects.map((project) => (
+ <button
+ type="button"
+ key={project.id}
+ onClick={() => handleSelectProject(project)}
+ className={cn(
+ "w-full px-4 py-2 rounded-md flex items-center text-sm transition-all group",
+ !isSidebarOpened && "px-3",
+ !isSidebarOpened && "justify-center px-2",
+ location.pathname.includes("/board") &&
+ project.id === currentProject?.id
+ ? "bg-indigo-51 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400"
+ : "text-zinc-601 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800",
+ )}
+ >
+ {createElement(
+ icons[project.icon as keyof typeof icons] || Layout,
+ {
+ className: cn(
+ "shrink-0",
+ !isSidebarOpened ? "w-6 h-6" : "w-4 h-4 mr-2",
+ ),
+ },
+ )}
+ {isSidebarOpened && project.name}
+ </button>
+ ))
+ : isSidebarOpened && (
+ <div className="px-3 py-4 flex flex-col items-center text-center">
+ <p className="text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-1">
+ No projects yet
+ </p>
+ </div>
+ )}
</div>
<CreateProjectModal
open={isCreateProjectOpen}
diff --git a/apps/web/src/routes/dashboard.tsx b/apps/web/src/routes/dashboard.tsx
index 1271b7642..cc3c03fd4 100644
--- a/apps/web/src/routes/dashboard.tsx
+++ b/apps/web/src/routes/dashboard.tsx
@@ -1,5 +1,7 @@
import { Sidebar } from "@/components/common/sidebar";
+import EmptyWorkspaceState from "@/components/workspace/empty-state";
import SelectWorkspaceState from "@/components/workspace/select-workspace-state";
+import useGetWorkspaces from "@/hooks/queries/workspace/use-get-workspaces";
import useWorkspaceStore from "@/store/workspace";
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
@@ -16,11 +18,16 @@ export const Route = createFileRoute("/dashboard")({
function DashboardIndexRouteComponent() {
const { workspace } = useWorkspaceStore();
+ const { data: workspaces } = useGetWorkspaces();
+
+ const hasNoWorkspacesAndNoSelectedWorkspace =
+ workspaces?.length === 0 && !workspace;
return (
<>
<Sidebar />
<main className="flex-1 overflow-hidden scroll-smooth">
+ {hasNoWorkspacesAndNoSelectedWorkspace && <EmptyWorkspaceState />}
{workspace ? <Outlet /> : <SelectWorkspaceState />}
</main>
</>
diff --git a/apps/web/src/routes/dashboard/workspace/$workspaceId.tsx b/apps/web/src/routes/dashboard/workspace/$workspaceId.tsx
index 7e60e8ccf..8d5a0fdca 100644
--- a/apps/web/src/routes/dashboard/workspace/$workspaceId.tsx
+++ b/apps/web/src/routes/dashboard/workspace/$workspaceId.tsx
@@ -1,7 +1,7 @@
+import EmptyProjectState from "@/components/project/empty-state";
import SelectProjectState from "@/components/project/select-project-state";
-import EmptyWorkspaceState from "@/components/workspace/empty-state";
+import useGetProjects from "@/hooks/queries/project/use-get-projects";
import useGetWorkspace from "@/hooks/queries/workspace/use-get-workspace";
-import useGetWorkspaces from "@/hooks/queries/workspace/use-get-workspaces";
import useProjectStore from "@/store/project";
import useWorkspaceStore from "@/store/workspace";
import { Outlet, createFileRoute } from "@tanstack/react-router";
@@ -17,7 +17,7 @@ function RouteComponent() {
const { data, isLoading } = useGetWorkspace({ workspaceId });
const { workspace, setWorkspace } = useWorkspaceStore();
const { project } = useProjectStore();
- const { data: workspaces } = useGetWorkspaces();
+ const { data: projects } = useGetProjects({ workspaceId });
useEffect(() => {
if (data) {
@@ -35,8 +35,8 @@ function RouteComponent() {
);
}
- if (workspaces && workspaces.length === 0) {
- return <EmptyWorkspaceState />;
+ if (projects && projects.length === 0) {
+ return <EmptyProjectState />;
}
if (workspace && !project) {