Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/controllers/add_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) {
priority := requestBody.Priority
dueDate := requestBody.DueDate
start := requestBody.Start
end := requestBody.End
recur := requestBody.Recur
tags := requestBody.Tags
annotations := requestBody.Annotations
Expand All @@ -65,7 +66,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, recur, tags, annotations)
err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDateStr, start, end, recur, tags, annotations)
if err != nil {
logStore.AddLog("ERROR", fmt.Sprintf("Failed to add task: %v", err), uuid, "Add Task")
return err
Expand Down
1 change: 1 addition & 0 deletions backend/models/request_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type AddTaskRequestBody struct {
Priority string `json:"priority"`
DueDate *string `json:"due"`
Start string `json:"start"`
End string `json:"end"`
Recur string `json:"recur"`
Tags []string `json:"tags"`
Annotations []Annotation `json:"annotations"`
Expand Down
5 changes: 4 additions & 1 deletion backend/utils/tw/add_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// add task to the user's tw client
func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, recur string, tags []string, annotations []models.Annotation) error {
func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, 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)
}
Expand Down Expand Up @@ -43,6 +43,9 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p
if start != "" {
cmdArgs = append(cmdArgs, "start:"+start)
}
if end != "" {
cmdArgs = append(cmdArgs, "end:"+end)
}
// Note: Taskwarrior requires a due date to be set before recur can be set
// Only add recur if dueDate is also provided
if recur != "" && dueDate != "" {
Expand Down
4 changes: 2 additions & 2 deletions backend/utils/tw/taskwarrior_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "daily", nil, []models.Annotation{{Description: "note"}})
err := AddTaskToTaskwarrior("email", "encryption_secret", "clientId", "description", "", "H", "2025-03-03", "2025-03-01", "2025-03-03", "daily", nil, []models.Annotation{{Description: "note"}})
if err != nil {
t.Errorf("AddTaskToTaskwarrior failed: %v", err)
} else {
Expand All @@ -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", "2025-03-01", "daily", []string{"work", "important"}, []models.Annotation{{Description: "note"}})
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"}})
if err != nil {
t.Errorf("AddTaskToTaskwarrior with tags failed: %v", err)
} else {
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const AddTaskdialog = ({
Fill in the details below to add a new task.
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<div className="space-y-4 h-96 overflow-auto p-4">
<div className="grid grid-cols-8 items-center gap-4">
<Label htmlFor="description" className="text-right col-span-2">
Description
Expand Down Expand Up @@ -253,6 +253,23 @@ export const AddTaskdialog = ({
/>
</div>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="end" className="text-right">
End
</Label>
<div className="col-span-3">
<DatePicker
date={newTask.end ? new Date(newTask.end) : undefined}
onDateChange={(date) => {
setNewTask({
...newTask,
end: date ? format(date, 'yyyy-MM-dd') : '',
});
}}
placeholder="Select an end date"
/>
</div>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="recur" className="text-right">
Recur
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/HomeComponents/Tasks/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const Tasks = (
project: '',
due: '',
start: '',
end: '',
recur: '',
tags: [],
annotations: [],
Expand Down Expand Up @@ -309,6 +310,7 @@ export const Tasks = (
priority: task.priority,
due: task.due || undefined,
start: task.start || '',
end: task.end || '',
recur: task.recur || '',
tags: task.tags,
annotations: task.annotations,
Expand All @@ -322,6 +324,7 @@ export const Tasks = (
project: '',
due: '',
start: '',
end: '',
recur: '',
tags: [],
annotations: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('AddTaskDialog Component', () => {
project: '',
due: '',
start: '',
end: '',
recur: '',
tags: [],
annotations: [],
Expand Down Expand Up @@ -222,6 +223,7 @@ describe('AddTaskDialog Component', () => {
project: 'Work',
due: '2024-12-25',
start: '',
end: '',
recur: '',
tags: ['urgent'],
annotations: [],
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/components/HomeComponents/Tasks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const addTaskToBackend = async ({
priority,
due,
start,
end,
recur,
tags,
annotations,
Expand All @@ -56,6 +57,7 @@ export const addTaskToBackend = async ({
priority: string;
due?: string;
start: string;
end?: string;
recur: string;
tags: string[];
annotations: { entry: string; description: string }[];
Expand All @@ -81,6 +83,10 @@ export const addTaskToBackend = async ({
requestBody.start = start;
}

if (end !== undefined && end !== '') {
requestBody.end = end;
}

// Only include recur if it's provided
if (recur !== undefined && recur !== '') {
requestBody.recur = recur;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface TaskFormData {
project: string;
due: string;
start: string;
end: string;
recur: string;
tags: string[];
annotations: Annotation[];
Expand Down
Loading