diff --git a/app/(app)/dashboard/column/Column.tsx b/app/(app)/dashboard/column/Column.tsx index 1b4d9f1..660ae11 100644 --- a/app/(app)/dashboard/column/Column.tsx +++ b/app/(app)/dashboard/column/Column.tsx @@ -86,6 +86,7 @@ export default function Column(props: ColumnProps) { }`} >
@@ -42,8 +49,12 @@ export default function ColumnHeader({ {count}
- ); diff --git a/app/(app)/dashboard/header/NewTaskButton.tsx b/app/(app)/dashboard/header/NewTaskButton.tsx index 895974b..0251331 100644 --- a/app/(app)/dashboard/header/NewTaskButton.tsx +++ b/app/(app)/dashboard/header/NewTaskButton.tsx @@ -1,11 +1,12 @@ /** - * @file dasboard/header/NewTaskButton.tsx + * @file dashboard/header/NewTaskButton.tsx * @description Client component rendering an interactive trigger button for creating new tasks. */ "use client"; import { Plus } from "lucide-react"; +import { useRouter } from "next/navigation"; /** * Renders a stylized button component with an icon and active state animations to initiate task creation. @@ -13,10 +14,15 @@ import { Plus } from "lucide-react"; * @returns {JSX.Element} The rendered new task button component. */ export default function NewTaskButton() { + const router = useRouter(); + return ( - ); } diff --git a/app/(app)/dashboard/header/TrashLink.tsx b/app/(app)/dashboard/header/TrashLink.tsx index a0a9c99..4578a00 100644 --- a/app/(app)/dashboard/header/TrashLink.tsx +++ b/app/(app)/dashboard/header/TrashLink.tsx @@ -34,11 +34,11 @@ export default function TrashLink() { return ( {count > 0 && ( diff --git a/app/(app)/tasks/TaskForm.tsx b/app/(app)/tasks/TaskForm.tsx index 57fef31..59c95d2 100644 --- a/app/(app)/tasks/TaskForm.tsx +++ b/app/(app)/tasks/TaskForm.tsx @@ -7,7 +7,7 @@ import { AlertCircle } from "lucide-react"; import Link from "next/link"; -import { DbTask } from "@/types/task"; +import { DbTask, TaskStatus } from "@/types/task"; import { useTaskForm } from "./useTaskForm"; import TaskHeader from "./task/TaskHeader"; import TaskBasicInfo from "./task/TaskBasicInfo"; @@ -22,12 +22,15 @@ import TaskDateTime from "./task/TaskDateTime"; * @property {{ id: string; email: string }[]} users - The list of available users who can be assigned to the task. * @property {DbTask & { assignees?: { id: string }[] }} [initialData] - Optional initial task data for editing an existing task. * @property {string} [mode] - Optional mode indicator (e.g., create or edit). + * @property {string | null} [serverError] - Optional server-side error message. + * @property {TaskStatus} [defaultStatus] - Optional default status for new tasks. */ interface TaskFormProps { users: { id: string; email: string }[]; initialData?: DbTask & { assignees?: { id: string }[] }; mode?: string; serverError?: string | null; + defaultStatus?: TaskStatus; } /** @@ -37,7 +40,12 @@ interface TaskFormProps { * @param {TaskFormProps} props - The component props. * @returns {JSX.Element} The rendered task form component. */ -export default function TaskForm({ users, initialData, mode }: TaskFormProps) { +export default function TaskForm({ + users, + initialData, + mode, + defaultStatus, +}: TaskFormProps) { const { form, error, @@ -46,7 +54,7 @@ export default function TaskForm({ users, initialData, mode }: TaskFormProps) { updateField, handleAssigneeToggle, handleSubmit, - } = useTaskForm(initialData, mode); + } = useTaskForm(initialData, mode, defaultStatus); return (
diff --git a/app/(app)/tasks/page.tsx b/app/(app)/tasks/page.tsx index 9a22ff5..b7f3ffc 100644 --- a/app/(app)/tasks/page.tsx +++ b/app/(app)/tasks/page.tsx @@ -10,17 +10,19 @@ import { redirect } from "next/navigation"; import TaskForm from "./TaskForm"; import { not, eq } from "drizzle-orm"; import { TaskService } from "@/services/task.service"; +import { TaskStatus } from "@/types/task"; /** * Properties for the TaskPage component. * * @interface TaskPageProps - * @property {Promise<{ task?: string; id?: string; }>} searchParams - A promise resolving to the search parameters containing mode and task ID. + * @property {Promise<{ task?: string; id?: string; status?: string; }>} searchParams - A promise resolving to the search parameters containing mode, task ID, and status. */ interface TaskPageProps { searchParams: Promise<{ task?: string; id?: string; + status?: string; }>; } @@ -63,6 +65,7 @@ export default async function TaskPage({ searchParams }: TaskPageProps) { users={users} initialData={initialData} mode={params.task} + defaultStatus={params.status as TaskStatus} /> ); diff --git a/app/(app)/tasks/useTaskForm.ts b/app/(app)/tasks/useTaskForm.ts index 4d8ee07..be6a1d6 100644 --- a/app/(app)/tasks/useTaskForm.ts +++ b/app/(app)/tasks/useTaskForm.ts @@ -11,13 +11,15 @@ import { TaskPriority, TaskStatus, DbTask } from "@/types/task"; * Custom React hook that encapsulates form state management, field updates, assignee toggling, * validation rules, and network submission logic for both task creation and editing workflows. * - * @param {DbTask & { assignees?: { id: string }[] }} [initialData] - Optional initial task data for editing workflows. - * @param {string} [mode] - Operation mode indicator (e.g., "edit"). - * @returns An object containing form state values, error states, and event handler functions. + * @param {DbTask & { assignees?: { id: string }[] }} [initialData] - Initial task data loaded for editing workflows. + * @param {string} [mode] - The current operating mode (e.g., "edit"). + * @param {TaskStatus} [defaultStatus] - The fallback status applied when creating new tasks. + * @returns {Object} An object containing form state values, error states, and event handling functions. */ export function useTaskForm( initialData?: DbTask & { assignees?: { id: string }[] }, mode?: string, + defaultStatus?: TaskStatus, ) { const router = useRouter(); const [, startTransition] = useTransition(); @@ -32,7 +34,7 @@ export function useTaskForm( title: initialData?.title ?? "", description: initialData?.description ?? "", priority: (initialData?.priority ?? "medium") as TaskPriority, - status: (initialData?.status ?? "todo") as TaskStatus, + status: (initialData?.status ?? defaultStatus ?? "todo") as TaskStatus, assignees: initialData?.assignees?.map((a) => a.id) ?? [], dueDate: dueDateObj ? dueDateObj.toISOString().split("T")[0] : todayString, dueTime: dueDateObj ? dueDateObj.toTimeString().slice(0, 5) : "23:59",