diff --git a/backend/controllers/add_task.go b/backend/controllers/add_task.go index 0bd367ef..4dfa465e 100644 --- a/backend/controllers/add_task.go +++ b/backend/controllers/add_task.go @@ -46,6 +46,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { project := requestBody.Project priority := requestBody.Priority dueDate := requestBody.DueDate + start := requestBody.Start tags := requestBody.Tags annotations := requestBody.Annotations @@ -63,7 +64,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, tags, annotations) + err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, start, 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 f62b684a..30f7dddb 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -9,6 +9,7 @@ type AddTaskRequestBody struct { Project string `json:"project"` Priority string `json:"priority"` DueDate *string `json:"due"` + Start string `json:"start"` Tags []string `json:"tags"` Annotations []Annotation `json:"annotations"` } diff --git a/backend/utils/tw/add_task.go b/backend/utils/tw/add_task.go index b4f644a8..56178fb9 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 string, tags []string, annotations []models.Annotation) error { +func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start 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) } @@ -40,6 +40,9 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p if dueDate != "" { cmdArgs = append(cmdArgs, "due:"+dueDate) } + if start != "" { + cmdArgs = append(cmdArgs, "start:"+start) + } // Add tags to the task if len(tags) > 0 { for _, tag := range tags { diff --git a/backend/utils/tw/taskwarrior_test.go b/backend/utils/tw/taskwarrior_test.go index efeba382..98a004f4 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", nil, []models.Annotation{{Description: "note"}}) + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", nil, []models.Annotation{{Description: "note"}}) if err != nil { t.Errorf("AddTaskToTaskwarrior failed: %v", err) } else { @@ -60,7 +60,7 @@ func TestCompleteTaskInTaskwarrior(t *testing.T) { } func TestAddTaskWithTags(t *testing.T) { - err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", []string{"work", "important"}, []models.Annotation{{Description: "note"}}) + err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", []string{"work", "important"}, []models.Annotation{{Description: "note"}}) if err != nil { t.Errorf("AddTaskToTaskwarrior with tags failed: %v", err) } else { diff --git a/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx b/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx index d6be7959..7ea37277 100644 --- a/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx +++ b/frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx @@ -228,6 +228,23 @@ export const AddTaskdialog = ({ /> +