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.

feat: enhance task retrieval and display with assignee details

Andrej Acevski18c5cb28685c
diff --git a/apps/api/src/task/controllers/get-task.ts b/apps/api/src/task/controllers/get-task.ts
index 8c55c501e..38d276858 100644
--- a/apps/api/src/task/controllers/get-task.ts
+++ b/apps/api/src/task/controllers/get-task.ts
@@ -1,20 +1,37 @@
import { eq } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db from "../../database";
-import { taskTable } from "../../database/schema";
+import { taskTable, userTable } from "../../database/schema";
async function getTask(taskId: string) {
- const task = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, taskId),
- });
+ const task = await db
+ .select({
+ id: taskTable.id,
+ title: taskTable.title,
+ number: taskTable.number,
+ description: taskTable.description,
+ status: taskTable.status,
+ priority: taskTable.priority,
+ dueDate: taskTable.dueDate,
+ position: taskTable.position,
+ createdAt: taskTable.createdAt,
+ userEmail: taskTable.userEmail,
+ assigneeName: userTable.name,
+ assigneeEmail: userTable.email,
+ projectId: taskTable.projectId,
+ })
+ .from(taskTable)
+ .leftJoin(userTable, eq(taskTable.userEmail, userTable.email))
+ .where(eq(taskTable.id, taskId))
+ .limit(1);
- if (!task) {
+ if (!task.length || !task[0]) {
throw new HTTPException(404, {
message: "Task not found",
});
}
- return task;
+ return task[0];
}
export default getTask;
diff --git a/apps/web/src/components/kanban-board/task-card.tsx b/apps/web/src/components/kanban-board/task-card.tsx
index ff1ad8bdb..1f4d7c04d 100644
--- a/apps/web/src/components/kanban-board/task-card.tsx
+++ b/apps/web/src/components/kanban-board/task-card.tsx
@@ -75,10 +75,10 @@ function TaskCard({ task }: TaskCardProps) {
{task.userEmail ? (
<div
className="flex items-center gap-1.5 px-2 py-1 rounded-md bg-zinc-100/50 dark:bg-zinc-800/50 group-hover:bg-zinc-100 dark:group-hover:bg-zinc-800/80 transition-colors"
- title={task.userEmail}
+ title={task.assigneeName ?? ""}
>
<span className="text-xs text-zinc-600 dark:text-zinc-400 truncate max-w-[100px]">
- {task.userEmail}
+ {task.assigneeName}
</span>
</div>
) : (
diff --git a/apps/web/src/components/shared/modals/create-task-modal.tsx b/apps/web/src/components/shared/modals/create-task-modal.tsx
index beab421b3..c60c2c7c3 100644
--- a/apps/web/src/components/shared/modals/create-task-modal.tsx
+++ b/apps/web/src/components/shared/modals/create-task-modal.tsx
@@ -150,7 +150,7 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
});
setProject(updatedProject);
- updateTask({ ...newTask, position: 0 });
+ updateTask({ ...newTask, position: 0, assigneeEmail: assigneeEmail });
toast.success("Task created successfully");
if (createMore) {
diff --git a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
index 9346d3f49..91e674e8f 100644
--- a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
+++ b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
@@ -172,7 +172,7 @@ function RouteComponent() {
description: task.description ?? null,
assigneeEmail: task.userEmail ?? null,
projectId: task.projectId,
- assigneeName: task.userEmail ?? null,
+ assigneeName: task.assigneeName ?? null,
})),
})) ?? [],
}
diff --git a/apps/web/src/types/task/index.ts b/apps/web/src/types/task/index.ts
index c15e4992d..c861de2b2 100644
--- a/apps/web/src/types/task/index.ts
+++ b/apps/web/src/types/task/index.ts
@@ -2,7 +2,9 @@ import type { client } from "@kaneo/libs";
import type { InferResponseType } from "hono/client";
type Task = Extract<
- InferResponseType<(typeof client)["task"][":id"]["$get"]>,
+ InferResponseType<
+ (typeof client)["task"]["tasks"][":projectId"]["$get"]
+ >["columns"][number]["tasks"][number],
{ id: string }
>;