diff --git a/backend/controllers/add_task.go b/backend/controllers/add_task.go index 6c6a0aac..39a25e04 100644 --- a/backend/controllers/add_task.go +++ b/backend/controllers/add_task.go @@ -46,6 +46,8 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { project := requestBody.Project priority := requestBody.Priority dueDate := requestBody.DueDate + start := requestBody.Start + end := requestBody.End tags := requestBody.Tags if description == "" { @@ -62,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, dueDate, tags) + err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, end, tags) 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 725a6075..85a9937a 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -9,6 +9,8 @@ type AddTaskRequestBody struct { Project string `json:"project"` Priority string `json:"priority"` DueDate string `json:"due"` + Start string `json:"start"` + End string `json:"end"` Tags []string `json:"tags"` } type ModifyTaskRequestBody struct { diff --git a/backend/utils/tw/add_task.go b/backend/utils/tw/add_task.go index 16105f7b..f2bfc664 100644 --- a/backend/utils/tw/add_task.go +++ b/backend/utils/tw/add_task.go @@ -8,7 +8,7 @@ import ( ) // add task to the user's tw client -func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate string, tags []string) error { +func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, end string, tags []string) error { if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil { return fmt.Errorf("error deleting Taskwarrior data: %v", err) } @@ -38,6 +38,12 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p if dueDate != "" { cmdArgs = append(cmdArgs, "due:"+dueDate) } + if start != "" { + cmdArgs = append(cmdArgs, "scheduled:"+start) + } + if end != "" { + cmdArgs = append(cmdArgs, "end:"+end) + } // Add tags to the task if len(tags) > 0 { for _, tag := range tags { diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index 140288db..e947d228 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -99,6 +99,8 @@ export const Tasks = ( priority: '', project: '', due: '', + start: '', + end: '', tags: [] as string[], }); const [isAddTaskOpen, setIsAddTaskOpen] = useState(false); @@ -280,6 +282,8 @@ export const Tasks = ( project: string, priority: string, due: string, + start: string, + end: string, tags: string[] ) { if (handleDate(newTask.due)) { @@ -292,6 +296,8 @@ export const Tasks = ( project, priority, due, + start, + end, tags, backendURL: url.backendURL, }); @@ -302,6 +308,8 @@ export const Tasks = ( priority: '', project: '', due: '', + start: '', + end: '', tags: [], }); setIsAddTaskOpen(false); @@ -738,6 +746,52 @@ export const Tasks = ( /> +