mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +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;
|
||||
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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user