mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-24 15:48:16 +02:00
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:
2 files changed
+16
-4
No files matched your search
@@ -6,6 +6,9 @@ interface Todo {
|
|||||||
text: string;
|
text: string;
|
||||||
completed: boolean;
|
completed: boolean;
|
||||||
position?: number;
|
position?: number;
|
||||||
|
due_date?: string;
|
||||||
|
parent_id?: number;
|
||||||
|
level?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Image {
|
interface Image {
|
||||||
@@ -221,12 +224,17 @@ class NotesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Todo management methods
|
// Todo management methods
|
||||||
async addTodo(noteId: number, text: string): Promise<Todo | null> {
|
async addTodo(noteId: number, text: string, dueDate?: string): Promise<Todo | null> {
|
||||||
try {
|
try {
|
||||||
|
const payload: any = { text };
|
||||||
|
if (dueDate) {
|
||||||
|
payload.due_date = dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch(`/api/notes/${noteId}/todos`, {
|
const response = await fetch(`/api/notes/${noteId}/todos`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: AuthService.getHeaders(),
|
headers: AuthService.getHeaders(),
|
||||||
body: JSON.stringify({ text })
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -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 {
|
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;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating todo:', error);
|
console.error('Error creating todo:', error);
|
||||||
|
|||||||
Reference in new issue
Block a user