feat: add due dates support for todos

- Update Todo interface to include due_date, parent_id, level fields
- Add due_date parameter to NotesService.addTodo method
- Add due_date parameter to TodosService.createTodo method
- updateTodo already supports Partial<Todo> including due_date
- Backend migrations already created (003 and 004)
- Prepare foundation for due date UI in future updates
This commit is contained in:
Claude committed 2025-11-27 19:45:16 +00:00
1 parent a3d8167a46
commit 4895cb4462
2 files changed
+16 -4

No files matched your search

+10 -2
View File
@@ -6,6 +6,9 @@ interface Todo {
text: string;
completed: boolean;
position?: number;
due_date?: string;
parent_id?: number;
level?: number;
}
interface Image {
@@ -221,12 +224,17 @@ class NotesService {
}
// Todo management methods
async addTodo(noteId: number, text: string): Promise<Todo | null> {
async addTodo(noteId: number, text: string, dueDate?: string): Promise<Todo | null> {
try {
const payload: any = { text };
if (dueDate) {
payload.due_date = dueDate;
}
const response = await fetch(`/api/notes/${noteId}/todos`, {
method: "POST",
headers: AuthService.getHeaders(),
body: JSON.stringify({ text })
body: JSON.stringify(payload)
});
if (!response.ok) {
+6 -2
View File
@@ -33,9 +33,13 @@ class TodosService {
}
}
async createTodo(text: string, priority?: boolean): Promise<Todo> {
async createTodo(text: string, priority?: boolean, dueDate?: string): Promise<Todo> {
try {
const response = await axios.post(this.baseURL, { text, priority: priority || false, completed: false }, this.getAuthHeader());
const payload: any = { text, priority: priority || false, completed: false };
if (dueDate) {
payload.due_date = dueDate;
}
const response = await axios.post(this.baseURL, payload, this.getAuthHeader());
return response.data;
} catch (error) {
console.error('Error creating todo:', error);