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 @@ -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

Expand All @@ -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
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 @@ -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"`
}
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 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)
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions backend/utils/tw/taskwarrior_test.go
Copy link
Copy Markdown
Contributor Author

@Hell1213 Hell1213 Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced empty string with actual start date "2025-03-01"

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", 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 {
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", []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 {
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added DatePicker component for start date field in task creation

Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,23 @@ export const AddTaskdialog = ({
/>
</div>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="start" className="text-right">
Start
</Label>
<div className="col-span-3">
<DatePicker
date={newTask.start ? new Date(newTask.start) : undefined}
onDateChange={(date) => {
setNewTask({
...newTask,
start: date ? format(date, 'yyyy-MM-dd') : '',
});
}}
placeholder="Select a start date"
/>
</div>
</div>
<div className="grid grid-cols-8 items-center gap-4">
<Label htmlFor="tags" className="text-right col-span-2">
Tags
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 @@ -72,6 +72,7 @@ export const Tasks = (
priority: '',
project: '',
due: '',
start: '',
tags: [],
annotations: [],
});
Expand Down Expand Up @@ -306,6 +307,7 @@ export const Tasks = (
project: task.project,
priority: task.priority,
due: task.due || undefined,
start: task.start || '',
tags: task.tags,
annotations: task.annotations,
backendURL: url.backendURL,
Expand All @@ -317,6 +319,7 @@ export const Tasks = (
priority: '',
project: '',
due: '',
start: '',
tags: [],
annotations: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('AddTaskDialog Component', () => {
priority: 'M',
project: '',
due: '',
start: '',
tags: [],
annotations: [],
},
Expand Down Expand Up @@ -219,6 +220,7 @@ describe('AddTaskDialog Component', () => {
priority: 'H',
project: 'Work',
due: '2024-12-25',
start: '',
tags: ['urgent'],
annotations: [],
};
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/components/HomeComponents/Tasks/hooks.ts
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added start parameter to addTaskToBackend function and conditional logic to include in request body

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const addTaskToBackend = async ({
project,
priority,
due,
start,
tags,
annotations,
backendURL,
Expand All @@ -53,6 +54,7 @@ export const addTaskToBackend = async ({
project: string;
priority: string;
due?: string;
start: string;
tags: string[];
annotations: { entry: string; description: string }[];
backendURL: string;
Expand All @@ -72,6 +74,11 @@ export const addTaskToBackend = async ({
requestBody.due = due;
}

// Only include start if it's provided
if (start !== undefined && start !== '') {
requestBody.start = start;
}

// Add annotations to request body, filtering out empty descriptions
requestBody.annotations = annotations.filter(
(annotation) =>
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 @@ -99,6 +99,7 @@ export interface TaskFormData {
priority: string;
project: string;
due: string;
start: string;
tags: string[];
annotations: Annotation[];
}
Expand Down
Loading