Skip to content
Closed
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
4 changes: 3 additions & 1 deletion backend/controllers/add_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backend/models/request_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion backend/utils/tw/add_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
142 changes: 142 additions & 0 deletions frontend/src/components/HomeComponents/Tasks/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export const Tasks = (
priority: '',
project: '',
due: '',
start: '',
end: '',
tags: [] as string[],
});
const [isAddTaskOpen, setIsAddTaskOpen] = useState(false);
Expand Down Expand Up @@ -280,6 +282,8 @@ export const Tasks = (
project: string,
priority: string,
due: string,
start: string,
end: string,
tags: string[]
) {
if (handleDate(newTask.due)) {
Expand All @@ -292,6 +296,8 @@ export const Tasks = (
project,
priority,
due,
start,
end,
tags,
backendURL: url.backendURL,
});
Expand All @@ -302,6 +308,8 @@ export const Tasks = (
priority: '',
project: '',
due: '',
start: '',
end: '',
tags: [],
});
setIsAddTaskOpen(false);
Expand Down Expand Up @@ -738,6 +746,52 @@ export const Tasks = (
/>
</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-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="description"
Expand Down Expand Up @@ -797,6 +851,8 @@ export const Tasks = (
newTask.project,
newTask.priority,
newTask.due,
newTask.start,
newTask.end,
newTask.tags
)
}
Expand Down Expand Up @@ -1524,6 +1580,90 @@ export const Tasks = (
/>
</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-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="description"
className="text-right"
>
Tags
</Label>
<Input
id="tags"
name="tags"
placeholder="Add a tag"
value={tagInput}
onChange={(e) => setTagInput(e.target.value)}
onKeyDown={(e) =>
e.key === 'Enter' && handleAddTag()
} // Allow adding tag on pressing Enter
className="col-span-3"
/>
</div>

<div className="mt-2">
{newTask.tags.length > 0 && (
<div className="flex flex-wrap gap-2">
{newTask.tags.map((tag, index) => (
<Badge key={index}>
<span>{tag}</span>
<button
type="button"
className="ml-2 text-red-500"
onClick={() => handleRemoveTag(tag)}
>
</button>
</Badge>
))}
</div>
)}
</div>
</div>
<DialogFooter>
<Button
Expand All @@ -1544,6 +1684,8 @@ export const Tasks = (
newTask.project,
newTask.priority,
newTask.due,
newTask.start,
newTask.end,
newTask.tags
)
}
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 @@ -42,6 +42,8 @@ export const addTaskToBackend = async ({
project,
priority,
due,
start,
end,
tags,
backendURL,
}: {
Expand All @@ -52,6 +54,8 @@ export const addTaskToBackend = async ({
project: string;
priority: string;
due: string;
start: string;
end: string;
tags: string[];
backendURL: string;
}) => {
Expand All @@ -65,6 +69,8 @@ export const addTaskToBackend = async ({
project,
priority,
due,
start,
end,
tags,
}),
headers: {
Expand Down
Loading