void} onTaskDelete - Callback function triggered when a task is dropped into the delete zone.
+ */
+interface HeaderProps {
+ onTaskDelete: (taskId: string) => void;
+}
/**
* Renders the dashboard header section featuring title text, a task deletion drop zone,
- * a new task action button, and a link to the trash bin.
+ * and conditionally displays the new task action button and trash link based on the drag state.
*
* @param {HeaderProps} props - The component props.
* @returns {JSX.Element} The rendered dashboard header component.
*/
-export default function Header({
- onTaskDelete,
-}: {
- onTaskDelete: (taskId: string) => void;
-}) {
+export default function Header({ onTaskDelete }: HeaderProps) {
+ const [isDraggingActive, setIsDraggingActive] = useState(false);
+
return (
@@ -36,11 +45,16 @@ export default function Header({
-
-
-
-
-
+
+ {!isDraggingActive && (
+
+
+
+
+ )}
);
diff --git a/app/(app)/dashboard/page.tsx b/app/(app)/dashboard/page.tsx
index 17707aa..541290d 100644
--- a/app/(app)/dashboard/page.tsx
+++ b/app/(app)/dashboard/page.tsx
@@ -4,17 +4,8 @@
*/
import { db } from "@/db";
-import { tasksTable, taskAssigneesTable, usersTable } from "@/db/schema";
-import {
- and,
- count,
- eq,
- inArray,
- isNotNull,
- isNull,
- or,
- exists,
-} from "drizzle-orm";
+import { taskAssigneesTable, usersTable } from "@/db/schema";
+import { eq, inArray } from "drizzle-orm";
import { auth } from "@/auth";
import { redirect } from "next/navigation";
import Board from "./Board";
@@ -65,8 +56,7 @@ export default async function Dashboard() {
...task,
creator: creatorEmail,
assignees: assigneesMap.get(task.id) || [],
- tags: [],
- commentsCount: 0,
+ isCreator: task.userId === currentUserId,
}));
return (
diff --git a/app/(app)/trash/page.tsx b/app/(app)/trash/page.tsx
index f9091b4..0243c7e 100644
--- a/app/(app)/trash/page.tsx
+++ b/app/(app)/trash/page.tsx
@@ -4,7 +4,7 @@
*/
import { db } from "@/db";
-import { tasksTable } from "@/db/schema";
+import { Task, tasksTable, usersTable } from "@/db/schema";
import { eq, and, isNotNull } from "drizzle-orm";
import { auth } from "@/auth";
import { redirect } from "next/navigation";
@@ -22,20 +22,31 @@ export default async function TrashPage() {
const session = await auth();
if (!session?.user?.id) redirect("/login");
- const trashedTasks = await db
- .select()
+ const currentUserId = session.user.id;
+
+ const rawTrashedTasks = await db
+ .select({
+ task: tasksTable,
+ creatorEmail: usersTable.email,
+ })
.from(tasksTable)
+ .innerJoin(usersTable, eq(tasksTable.userId, usersTable.id))
.where(
and(
- eq(tasksTable.userId, session.user.id),
+ eq(tasksTable.userId, currentUserId),
isNotNull(tasksTable.deletedAt),
),
);
+ const tasks: Task[] = rawTrashedTasks.map(({ task }) => ({
+ ...task,
+ isCreator: task.userId === currentUserId,
+ }));
+
return (
-
+
);
}
diff --git a/types/tasks.ts b/types/tasks.ts
index fbeb282..6e0adbb 100644
--- a/types/tasks.ts
+++ b/types/tasks.ts
@@ -21,9 +21,9 @@ export type TaskPriority = (typeof taskPriorityEnum.enumValues)[number];
// ==========================================
export interface Task extends Omit
{
- dueDate?: Date | null;
assignees?: string[];
creator?: string;
+ isCreator?: boolean;
}
export interface RouteContext {