From e4a5c24ff05c0f77c7ffd72f4e96370c00493213 Mon Sep 17 00:00:00 2001 From: Mike Smith <89040888+smiggiddy@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:44:33 -0500 Subject: [PATCH] feat: updated componenets --- todo/src/components/navbar.js | 2 ++ todo/src/components/todo.js | 2 +- todo/src/index.js | 17 ++++------------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/todo/src/components/navbar.js b/todo/src/components/navbar.js index 698fb4f..2ab6b21 100644 --- a/todo/src/components/navbar.js +++ b/todo/src/components/navbar.js @@ -24,6 +24,8 @@ function projectButtons(projects) { let btn = document.createElement('button'); btn.classList.add(['btn', 'project-btn']); btn.textContent = e.name; + btn.dataset.projectName = e.name; + // btn.addEventListener('click', e => console.log(e.target.dataset.projectName)); projectsDiv.append(btn); }); return projectsDiv; diff --git a/todo/src/components/todo.js b/todo/src/components/todo.js index fb0064f..10d5079 100644 --- a/todo/src/components/todo.js +++ b/todo/src/components/todo.js @@ -37,7 +37,7 @@ class todoHandler { } getTodosFromProject(project) { - return this.projects.filter((item) => item.name === project)[0].todos; + return this.projects.find((item) => item.name === project).todos; } addTodo(project = 'default', title, description, dueDate, pomodoros) { diff --git a/todo/src/index.js b/todo/src/index.js index 6df0112..471c6f4 100644 --- a/todo/src/index.js +++ b/todo/src/index.js @@ -18,17 +18,17 @@ let projects = todos.getProjects(); // starter test data to remove todos.addProject('job'); -todos.addTodo('default', 'test default 2', 'some stuff', 'today', 5); -todos.addTodo('default', 'default 2', 'some stuff', 'today', 5); +todos.addTodo('default', 'test default 3', 'some stuff', 'today', 5); +todos.addTodo('job', 'default 5', 'some stuff', 'today', 5); -const defaultProject = todos.getTodosFromProject('default'); function website() { + const currentProject = todos.getTodosFromProject('default'); const div = document.createElement('div'); div.classList.add('container'); const _navbar = navbar(projects); - const _todos = todoTableComponent(defaultProject); + const _todos = todoTableComponent(currentProject); div.appendChild(_navbar); div.appendChild(_todos); @@ -38,13 +38,4 @@ function website() { } website(); - -// todos.addTodo('chores', 'choretest', 'some stuff', 'today', 5); -// todos.delProject('de'); -// todos.editTodo('default', 'test', 'stuffing', 'tomorrow', 4); -// console.log(todos.getTodos()); -// todos.deleteTodo('chores', 'choretest'); -// console.log(todos.getTodos()); -// -// save(todos.getEverything());