From 0b6028b9bbf3eb1178222a3d4883cfe8be35d145 Mon Sep 17 00:00:00 2001 From: Ankit-69k Date: Mon, 17 Nov 2025 00:58:22 +0530 Subject: [PATCH 1/2] make wait field editable --- backend/controllers/edit_task.go | 3 +- backend/models/request_body.go | 1 + backend/utils/tw/edit_task.go | 12 ++- backend/utils/tw/taskwarrior_test.go | 8 +- .../components/HomeComponents/Tasks/Tasks.tsx | 92 ++++++++++++++++++- .../components/HomeComponents/Tasks/hooks.ts | 3 + 6 files changed, 108 insertions(+), 11 deletions(-) diff --git a/backend/controllers/edit_task.go b/backend/controllers/edit_task.go index 6402bbe..60c81e1 100644 --- a/backend/controllers/edit_task.go +++ b/backend/controllers/edit_task.go @@ -46,6 +46,7 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { description := requestBody.Description tags := requestBody.Tags project := requestBody.Project + wait := requestBody.Wait if taskID == "" { http.Error(w, "taskID is required", http.StatusBadRequest) @@ -62,7 +63,7 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { Name: "Edit Task", Execute: func() error { logStore.AddLog("INFO", fmt.Sprintf("Editing task ID: %s", taskID), uuid, "Edit Task") - err := tw.EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID, tags, project) + err := tw.EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID, tags, project, wait) if err != nil { logStore.AddLog("ERROR", fmt.Sprintf("Failed to edit task ID %s: %v", taskID, err), uuid, "Edit Task") return err diff --git a/backend/models/request_body.go b/backend/models/request_body.go index 725a607..396ae0a 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -31,6 +31,7 @@ type EditTaskRequestBody struct { Description string `json:"description"` Tags []string `json:"tags"` Project string `json:"project"` + Wait string `json:"wait"` } type CompleteTaskRequestBody struct { Email string `json:"email"` diff --git a/backend/utils/tw/edit_task.go b/backend/utils/tw/edit_task.go index a9b8faf..5ac737e 100644 --- a/backend/utils/tw/edit_task.go +++ b/backend/utils/tw/edit_task.go @@ -7,7 +7,7 @@ import ( "strings" ) -func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID string, tags []string, project string) error { +func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID string, tags []string, project string, wait string) error { if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil { return fmt.Errorf("error deleting Taskwarrior data: %v", err) } @@ -39,6 +39,16 @@ func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID st } } + // Handle wait date + if wait != "" { + // Convert `2025-11-29` -> `2025-11-29T00:00:00` + formattedWait := wait + "T00:00:00" + + if err := utils.ExecCommand("task", taskID, "modify", "wait:"+formattedWait); err != nil { + return fmt.Errorf("failed to set wait date %s: %v", formattedWait, err) + } + } + // Handle tags 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 04ab28a..e858f9c 100644 --- a/backend/utils/tw/taskwarrior_test.go +++ b/backend/utils/tw/taskwarrior_test.go @@ -23,7 +23,7 @@ func TestSyncTaskwarrior(t *testing.T) { } func TestEditTaskInATaskwarrior(t *testing.T) { - err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil, "project") + err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil, "project", "2025-11-29T18:30:00.000Z") if err != nil { t.Errorf("EditTaskInTaskwarrior() failed: %v", err) } else { @@ -68,7 +68,7 @@ func TestAddTaskWithTags(t *testing.T) { } func TestEditTaskWithTagAddition(t *testing.T) { - err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "+important"}, "project") + err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "+important"}, "project", "2025-11-29T18:30:00.000Z") if err != nil { t.Errorf("EditTaskInTaskwarrior with tag addition failed: %v", err) } else { @@ -77,7 +77,7 @@ func TestEditTaskWithTagAddition(t *testing.T) { } func TestEditTaskWithTagRemoval(t *testing.T) { - err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"-work", "-lowpriority"}, "project") + err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"-work", "-lowpriority"}, "project", "2025-11-29T18:30:00.000Z") if err != nil { t.Errorf("EditTaskInTaskwarrior with tag removal failed: %v", err) } else { @@ -86,7 +86,7 @@ func TestEditTaskWithTagRemoval(t *testing.T) { } func TestEditTaskWithMixedTagOperations(t *testing.T) { - err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "-work", "normal"}, "project") + err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", []string{"+urgent", "-work", "normal"}, "project", "2025-11-29T18:30:00.000Z") if err != nil { t.Errorf("EditTaskInTaskwarrior with mixed tag operations failed: %v", err) } else { diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index 140288d..4586e24 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -118,6 +118,8 @@ export const Tasks = ( const [editedProject, setEditedProject] = useState( _selectedTask?.project || '' ); + const [isEditingWaitDate, setIsEditingWaitDate] = useState(false); + const [editedWaitDate, setEditedWaitDate] = useState(''); const [searchTerm, setSearchTerm] = useState(''); const [lastSyncTime, setLastSyncTime] = useState(null); @@ -318,7 +320,8 @@ export const Tasks = ( description: string, tags: string[], taskID: string, - project: string + project: string, + wait: string ) { try { await editTaskOnBackend({ @@ -330,6 +333,7 @@ export const Tasks = ( taskID, backendURL: url.backendURL, project, + wait, }); console.log('Task edited successfully!'); @@ -372,7 +376,8 @@ export const Tasks = ( task.description, task.tags, task.id.toString(), - task.project + task.project, + task.end ); setIsEditing(false); }; @@ -386,11 +391,29 @@ export const Tasks = ( task.description, task.tags, task.id.toString(), - task.project + task.project, + task.end ); setIsEditingProject(false); }; + const handleWaitDateSaveClick = (task: Task) => { + task.wait = editedWaitDate; + + handleEditTaskOnBackend( + props.email, + props.encryptionSecret, + props.UUID, + task.description, + task.tags, + task.id.toString(), + task.project, + task.wait + ); + + setIsEditingWaitDate(false); + }; + const handleCancelClick = () => { setIsEditing(false); }; @@ -475,7 +498,8 @@ export const Tasks = ( task.description, finalTags, task.id.toString(), - task.project + task.project, + task.end ); setIsEditingTags(false); // Exit editing mode @@ -1015,7 +1039,65 @@ export const Tasks = ( Wait: - {formattedDate(task.wait)} + {isEditingWaitDate ? ( +
+ + setEditedWaitDate( + date + ? format( + date, + 'yyyy-MM-dd' + ) + : '' + ) + } + /> + + + + +
+ ) : ( + <> + + {formattedDate(task.wait)} + + + + )}
diff --git a/frontend/src/components/HomeComponents/Tasks/hooks.ts b/frontend/src/components/HomeComponents/Tasks/hooks.ts index e529993..4f86c1b 100644 --- a/frontend/src/components/HomeComponents/Tasks/hooks.ts +++ b/frontend/src/components/HomeComponents/Tasks/hooks.ts @@ -89,6 +89,7 @@ export const editTaskOnBackend = async ({ taskID, backendURL, project, + wait, }: { email: string; encryptionSecret: string; @@ -98,6 +99,7 @@ export const editTaskOnBackend = async ({ taskID: string; backendURL: string; project: string; + wait: string; }) => { const response = await fetch(`${backendURL}edit-task`, { method: 'POST', @@ -109,6 +111,7 @@ export const editTaskOnBackend = async ({ description, tags, project, + wait, }), headers: { 'Content-Type': 'application/json', From df76bba98526765a9452536f3f16aa57bcf43be1 Mon Sep 17 00:00:00 2001 From: Ankit-69k Date: Mon, 17 Nov 2025 22:51:23 +0530 Subject: [PATCH 2/2] fixed merge issue --- backend/controllers/edit_task.go | 2 +- backend/models/request_body.go | 2 +- backend/utils/tw/taskwarrior_test.go | 2 +- .../components/HomeComponents/Tasks/Tasks.tsx | 19 ++++++------------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/backend/controllers/edit_task.go b/backend/controllers/edit_task.go index 4201aba..3c55c50 100644 --- a/backend/controllers/edit_task.go +++ b/backend/controllers/edit_task.go @@ -46,9 +46,9 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { description := requestBody.Description tags := requestBody.Tags project := requestBody.Project - wait := requestBody.Wait start := requestBody.Start entry := requestBody.Entry + wait := requestBody.Wait if taskID == "" { http.Error(w, "taskID is required", http.StatusBadRequest) diff --git a/backend/models/request_body.go b/backend/models/request_body.go index c68c139..87edaf0 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -31,9 +31,9 @@ type EditTaskRequestBody struct { Description string `json:"description"` Tags []string `json:"tags"` Project string `json:"project"` - Wait string `json:"wait"` Start string `json:"start"` Entry string `json:"entry"` + Wait string `json:"wait"` } type CompleteTaskRequestBody struct { Email string `json:"email"` diff --git a/backend/utils/tw/taskwarrior_test.go b/backend/utils/tw/taskwarrior_test.go index d6d7621..e4d378b 100644 --- a/backend/utils/tw/taskwarrior_test.go +++ b/backend/utils/tw/taskwarrior_test.go @@ -23,7 +23,7 @@ func TestSyncTaskwarrior(t *testing.T) { } func TestEditTaskInATaskwarrior(t *testing.T) { - err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil, "project", "2025-11-29T18:30:00.000Z", "2025-11-29T18:30:00.000Z", , "2025-11-29T18:30:00.000Z") + err := EditTaskInTaskwarrior("uuid", "description", "email", "encryptionSecret", "taskuuid", nil, "project", "2025-11-29T18:30:00.000Z", "2025-11-29T18:30:00.000Z", "2025-11-29T18:30:00.000Z") if err != nil { t.Errorf("EditTaskInTaskwarrior() failed: %v", err) } else { diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index a673c0b..125e7fa 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -341,7 +341,7 @@ export const Tasks = ( project, start, entry, - wait + wait, }); console.log('Task edited successfully!'); @@ -387,7 +387,6 @@ export const Tasks = ( task.project, task.start, task.entry || '', - task.end, task.wait ); setIsEditing(false); @@ -412,7 +411,7 @@ export const Tasks = ( const handleWaitDateSaveClick = (task: Task) => { task.wait = editedWaitDate; - + handleEditTaskOnBackend( props.email, props.encryptionSecret, @@ -425,11 +424,10 @@ export const Tasks = ( task.entry || '', task.wait ); - + setIsEditingWaitDate(false); - - } - + }; + const handleStartDateSaveClick = (task: Task) => { task.start = editedStartDate; @@ -446,13 +444,8 @@ export const Tasks = ( task.wait ); - setIsEditingStartDate(false); - - ); - - - + }; const handleEntryDateSaveClick = (task: Task) => { task.entry = editedEntryDate;