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 route selection and creating tasks with no asignee

Andrejae9bc8eebecc
diff --git a/apps/api/drizzle/0001_safe_green_goblin.sql b/apps/api/drizzle/0001_safe_green_goblin.sql
new file mode 100644
index 000000000..36cdaf964
--- /dev/null
+++ b/apps/api/drizzle/0001_safe_green_goblin.sql
@@ -0,0 +1,71 @@
+PRAGMA foreign_keys=OFF;--> statement-breakpoint
+CREATE TABLE `__new_project` (
+ `id` text PRIMARY KEY NOT NULL,
+ `workspace_id` text NOT NULL,
+ `slug` text NOT NULL,
+ `icon` text DEFAULT 'Layout',
+ `name` text NOT NULL,
+ `description` text,
+ `created_at` integer DEFAULT '"2025-02-11T18:12:00.369Z"' NOT NULL,
+ FOREIGN KEY (`workspace_id`) REFERENCES `workspace`(`id`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+INSERT INTO `__new_project`("id", "workspace_id", "slug", "icon", "name", "description", "created_at") SELECT "id", "workspace_id", "slug", "icon", "name", "description", "created_at" FROM `project`;--> statement-breakpoint
+DROP TABLE `project`;--> statement-breakpoint
+ALTER TABLE `__new_project` RENAME TO `project`;--> statement-breakpoint
+PRAGMA foreign_keys=ON;--> statement-breakpoint
+CREATE TABLE `__new_task` (
+ `id` text PRIMARY KEY NOT NULL,
+ `project_id` text NOT NULL,
+ `number` integer DEFAULT 1,
+ `assignee_email` text,
+ `title` text NOT NULL,
+ `description` text,
+ `status` text DEFAULT 'to-do' NOT NULL,
+ `priority` text DEFAULT 'low',
+ `due_date` integer,
+ `created_at` integer DEFAULT '"2025-02-11T18:12:00.369Z"' NOT NULL,
+ FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE cascade ON DELETE cascade,
+ FOREIGN KEY (`assignee_email`) REFERENCES `user`(`email`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+INSERT INTO `__new_task`("id", "project_id", "number", "assignee_email", "title", "description", "status", "priority", "due_date", "created_at") SELECT "id", "project_id", "number", "assignee_email", "title", "description", "status", "priority", "due_date", "created_at" FROM `task`;--> statement-breakpoint
+DROP TABLE `task`;--> statement-breakpoint
+ALTER TABLE `__new_task` RENAME TO `task`;--> statement-breakpoint
+CREATE TABLE `__new_user` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `password` text NOT NULL,
+ `email` text NOT NULL,
+ `created_at` integer DEFAULT '"2025-02-11T18:12:00.368Z"' NOT NULL
+);
+--> statement-breakpoint
+INSERT INTO `__new_user`("id", "name", "password", "email", "created_at") SELECT "id", "name", "password", "email", "created_at" FROM `user`;--> statement-breakpoint
+DROP TABLE `user`;--> statement-breakpoint
+ALTER TABLE `__new_user` RENAME TO `user`;--> statement-breakpoint
+CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
+CREATE TABLE `__new_workspace` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `description` text,
+ `owner_email` text NOT NULL,
+ `created_at` integer DEFAULT '"2025-02-11T18:12:00.368Z"' NOT NULL,
+ FOREIGN KEY (`owner_email`) REFERENCES `user`(`email`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+INSERT INTO `__new_workspace`("id", "name", "description", "owner_email", "created_at") SELECT "id", "name", "description", "owner_email", "created_at" FROM `workspace`;--> statement-breakpoint
+DROP TABLE `workspace`;--> statement-breakpoint
+ALTER TABLE `__new_workspace` RENAME TO `workspace`;--> statement-breakpoint
+CREATE TABLE `__new_workspace_member` (
+ `id` text PRIMARY KEY NOT NULL,
+ `workspace_id` text NOT NULL,
+ `user_email` text NOT NULL,
+ `role` text,
+ `joined_at` integer DEFAULT '"2025-02-11T18:12:00.369Z"' NOT NULL,
+ FOREIGN KEY (`workspace_id`) REFERENCES `workspace`(`id`) ON UPDATE cascade ON DELETE cascade,
+ FOREIGN KEY (`user_email`) REFERENCES `user`(`email`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+INSERT INTO `__new_workspace_member`("id", "workspace_id", "user_email", "role", "joined_at") SELECT "id", "workspace_id", "user_email", "role", "joined_at" FROM `workspace_member`;--> statement-breakpoint
+DROP TABLE `workspace_member`;--> statement-breakpoint
+ALTER TABLE `__new_workspace_member` RENAME TO `workspace_member`;
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/0001_snapshot.json b/apps/api/drizzle/meta/0001_snapshot.json
new file mode 100644
index 000000000..93f020d46
--- /dev/null
+++ b/apps/api/drizzle/meta/0001_snapshot.json
@@ -0,0 +1,406 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "e2e57331-358c-4168-862a-fcbeb44be8b0",
+ "prevId": "49787b32-4e2b-4274-a0e2-d2784a178329",
+ "tables": {
+ "project": {
+ "name": "project",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'Layout'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2025-02-11T18:12:00.369Z\"'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_workspace_id_workspace_id_fk": {
+ "name": "project_workspace_id_workspace_id_fk",
+ "tableFrom": "project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "task": {
+ "name": "task",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "assignee_email": {
+ "name": "assignee_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'to-do'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'low'"
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2025-02-11T18:12:00.369Z\"'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "task_project_id_project_id_fk": {
+ "name": "task_project_id_project_id_fk",
+ "tableFrom": "task",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_assignee_email_user_email_fk": {
+ "name": "task_assignee_email_user_email_fk",
+ "tableFrom": "task",
+ "tableTo": "user",
+ "columnsFrom": ["assignee_email"],
+ "columnsTo": ["email"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2025-02-11T18:12:00.368Z\"'"
+ }
+ },
+ "indexes": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": ["email"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "workspace": {
+ "name": "workspace",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "owner_email": {
+ "name": "owner_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2025-02-11T18:12:00.368Z\"'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_owner_email_user_email_fk": {
+ "name": "workspace_owner_email_user_email_fk",
+ "tableFrom": "workspace",
+ "tableTo": "user",
+ "columnsFrom": ["owner_email"],
+ "columnsTo": ["email"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "workspace_member": {
+ "name": "workspace_member",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_email": {
+ "name": "user_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2025-02-11T18:12:00.369Z\"'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_member_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "workspace_member_user_email_user_email_fk": {
+ "name": "workspace_member_user_email_user_email_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_email"],
+ "columnsTo": ["email"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json
index fe2414e5c..2d7338614 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -8,6 +8,13 @@
"when": 1739135000822,
"tag": "0000_conscious_golden_guardian",
"breakpoints": true
+ },
+ {
+ "idx": 1,
+ "version": "6",
+ "when": 1739297520379,
+ "tag": "0001_safe_green_goblin",
+ "breakpoints": true
}
]
}
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index 0da51f7b6..5b4f13001 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -95,12 +95,10 @@ export const taskTable = sqliteTable("task", {
onUpdate: "cascade",
}),
number: int().default(1),
- userEmail: text("assignee_email")
- .notNull()
- .references(() => userTable.email, {
- onDelete: "cascade",
- onUpdate: "cascade",
- }),
+ userEmail: text("assignee_email").references(() => userTable.email, {
+ onDelete: "cascade",
+ onUpdate: "cascade",
+ }),
title: text("title").notNull(),
description: text("description"),
status: text("status").notNull().default("to-do"),
diff --git a/apps/api/src/task/controllers/create-task.ts b/apps/api/src/task/controllers/create-task.ts
index 5f95d029a..482ce0e57 100644
--- a/apps/api/src/task/controllers/create-task.ts
+++ b/apps/api/src/task/controllers/create-task.ts
@@ -25,10 +25,6 @@ async function createTask(body: {
.from(userTable)
.where(eq(userTable.email, body.userEmail));
- if (!assignee) {
- throw new Error("Assignee not found");
- }
-
const nextTaskNumber = await getNextTaskNumber(body.projectId);
const [createdTask] = await db
@@ -41,7 +37,7 @@ async function createTask(body: {
return {
...createdTask,
- assigneeName: assignee.name,
+ assigneeName: assignee?.name,
};
}
diff --git a/apps/web/src/components/common/sidebar/sections/manage-teams/index.tsx b/apps/web/src/components/common/sidebar/sections/manage-teams/index.tsx
index 083185606..70d88ee46 100644
--- a/apps/web/src/components/common/sidebar/sections/manage-teams/index.tsx
+++ b/apps/web/src/components/common/sidebar/sections/manage-teams/index.tsx
@@ -1,13 +1,27 @@
import { cn } from "@/lib/cn";
import { Route } from "@/routes/dashboard/workspace/$workspaceId";
+import useProjectStore from "@/store/project";
import { useUserPreferencesStore } from "@/store/user-preferences";
-import { useNavigate } from "@tanstack/react-router";
+import { useNavigate, useRouterState } from "@tanstack/react-router";
import { Users } from "lucide-react";
function ManageTeams() {
const { isSidebarOpened } = useUserPreferencesStore();
const navigate = useNavigate();
const { workspaceId } = Route.useParams();
+ const { setProject } = useProjectStore();
+ const location = useRouterState({ select: (s) => s.location });
+ const isOnTeamsRoute = location.pathname.includes("/team");
+
+ const onManageTeams = () => {
+ setProject(undefined);
+ navigate({
+ to: "/dashboard/workspace/$workspaceId/team",
+ params: {
+ workspaceId,
+ },
+ });
+ };
return (
<div>
@@ -26,16 +40,11 @@ function ManageTeams() {
isSidebarOpened && "px-3",
!isSidebarOpened && "justify-center px-2",
"text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800",
+ isOnTeamsRoute &&
+ "bg-indigo-51 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400",
)}
title={!isSidebarOpened ? "Manage Team" : undefined}
- onClick={() =>
- navigate({
- to: "/dashboard/workspace/$workspaceId/team",
- params: {
- workspaceId,
- },
- })
- }
+ onClick={() => onManageTeams()}
>
<Users
className={cn(
diff --git a/apps/web/src/types/project/index.ts b/apps/web/src/types/project/index.ts
index 1b1ae128d..02a68a667 100644
--- a/apps/web/src/types/project/index.ts
+++ b/apps/web/src/types/project/index.ts
@@ -19,7 +19,7 @@ export type Task = {
number: number | null;
description: string | null;
projectId: string;
- userEmail: string;
+ userEmail: string | null;
title: string;
status: string;
dueDate: Date | null;