From b082671dea55fe84c85ac5a00377dfc80c851a6f Mon Sep 17 00:00:00 2001 From: Shiva Gupta Date: Fri, 12 Dec 2025 22:47:50 +0530 Subject: [PATCH] feat(AddTask): Add wait date field to Add Task dialog - Add wait date field to backend request body and Taskwarrior CLI - Implement wait date picker in AddTaskDialog frontend component - Update type definitions and hooks to support wait field - Add comprehensive frontend and backend tests for the new field Issue: #188 --- backend/controllers/add_task.go | 3 +- backend/models/request_body.go | 1 + backend/utils/tw/add_task.go | 5 +- backend/utils/tw/taskwarrior_test.go | 22 ++++++++- .../HomeComponents/Tasks/AddTaskDialog.tsx | 17 +++++++ .../components/HomeComponents/Tasks/Tasks.tsx | 3 ++ .../Tasks/__tests__/AddTaskDialog.test.tsx | 49 +++++++++++++++++++ .../components/HomeComponents/Tasks/hooks.ts | 3 ++ frontend/src/components/utils/types.ts | 1 + 9 files changed, 100 insertions(+), 4 deletions(-) diff --git a/backend/controllers/add_task.go b/backend/controllers/add_task.go index cf84c82b..9918ad00 100644 --- a/backend/controllers/add_task.go +++ b/backend/controllers/add_task.go @@ -47,6 +47,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { priority := requestBody.Priority dueDate := requestBody.DueDate start := requestBody.Start + waitDate := requestBody.WaitDate end := requestBody.End recur := requestBody.Recur tags := requestBody.Tags @@ -66,7 +67,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { Name: "Add Task", Execute: func() error { logStore.AddLog("INFO", fmt.Sprintf("Adding task: %s", description), uuid, "Add Task") - err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, start, end, recur, tags, annotations) + err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, start, waitDate, end, recur, tags, annotations) if err != nil { logStore.AddLog("ERROR", fmt.Sprintf("Failed to add task: %v", err), uuid, "Add Task") return err diff --git a/backend/models/request_body.go b/backend/models/request_body.go index 9e88880c..b12d84d9 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -10,6 +10,7 @@ type AddTaskRequestBody struct { Priority string `json:"priority"` DueDate *string `json:"due"` Start string `json:"start"` + WaitDate string `json:"wait"` End string `json:"end"` Recur string `json:"recur"` Tags []string `json:"tags"` diff --git a/backend/utils/tw/add_task.go b/backend/utils/tw/add_task.go index e16878b8..ef587349 100644 --- a/backend/utils/tw/add_task.go +++ b/backend/utils/tw/add_task.go @@ -10,7 +10,7 @@ import ( ) // add task to the user's tw client -func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, end, recur string, tags []string, annotations []models.Annotation) error { +func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, waitDate string, end, recur string, tags []string, annotations []models.Annotation) error { if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil { return fmt.Errorf("error deleting Taskwarrior data: %v", err) } @@ -43,6 +43,9 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p if start != "" { cmdArgs = append(cmdArgs, "start:"+start) } + if waitDate != "" { + cmdArgs = append(cmdArgs, "wait:"+waitDate) + } if end != "" { cmdArgs = append(cmdArgs, "end:"+end) } diff --git a/backend/utils/tw/taskwarrior_test.go b/backend/utils/tw/taskwarrior_test.go index 1f0f39f8..aad8cff6 100644 --- a/backend/utils/tw/taskwarrior_test.go +++ b/backend/utils/tw/taskwarrior_test.go @@ -42,7 +42,7 @@ func TestExportTasks(t *testing.T) { } func TestAddTaskToTaskwarrior(t *testing.T) { - err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", "2025-03-03", "daily", nil, []models.Annotation{{Description: "note"}}) + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", "2025-03-01", "2025-03-03", "daily", nil, []models.Annotation{{Description: "note"}}) if err != nil { t.Errorf("AddTaskToTaskwarrior failed: %v", err) } else { @@ -50,6 +50,15 @@ func TestAddTaskToTaskwarrior(t *testing.T) { } } +func TestAddTaskToTaskwarriorWithWaitDate(t *testing.T) { + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "project", "H", "2025-03-03", "2025-03-04", "2025-03-04", "2025-03-04", "", nil, nil) + if err != nil { + t.Errorf("AddTaskToTaskwarrior with wait date failed: %v", err) + } else { + fmt.Println("Add task with wait date passed") + } +} + func TestCompleteTaskInTaskwarrior(t *testing.T) { err := CompleteTaskInTaskwarrior("email", "encryptionSecret", "client_id", "taskuuid") if err != nil { @@ -60,7 +69,7 @@ func TestCompleteTaskInTaskwarrior(t *testing.T) { } func TestAddTaskWithTags(t *testing.T) { - err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", "2025-03-03", "daily", []string{"work", "important"}, []models.Annotation{{Description: "note"}}) + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", "2025-03-01", "2025-03-03", "daily", []string{"work", "important"}, []models.Annotation{{Description: "note"}}) if err != nil { t.Errorf("AddTaskToTaskwarrior with tags failed: %v", err) } else { @@ -68,6 +77,15 @@ func TestAddTaskWithTags(t *testing.T) { } } +func TestAddTaskToTaskwarriorWithWaitDateWithTags(t *testing.T) { + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "project", "H", "2025-03-03", "2025-03-04", "2025-03-04", "2025-03-04", "", []string{"work", "important"}, nil) + if err != nil { + t.Errorf("AddTaskToTaskwarrior with wait date failed: %v", err) + } else { + fmt.Println("Add task with wait date and tags passed") + } +} + func TestEditTaskWithTagAddition(t *testing.T) { err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "+important"}, "project", "2025-11-29T18:30:00.000Z", "2025-11-29T18:30:00.000Z", "2025-11-29T18:30:00.000Z", "2025-11-30T18:30:00.000Z", nil, "2025-12-01T18:30:00.000Z", "daily") if err != nil { diff --git a/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx b/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx index 88b361b1..8aa9dc84 100644 --- a/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx +++ b/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx @@ -270,6 +270,23 @@ export const AddTaskdialog = ({ /> +
+ +
+ { + setNewTask({ + ...newTask, + wait: date ? format(date, 'yyyy-MM-dd') : '', + }); + }} + placeholder="Select a wait date" + /> +
+