feat: updated componenets

This commit is contained in:
Mike 2024-01-01 11:44:33 -05:00
parent 68e4283a49
commit e4a5c24ff0
3 changed files with 7 additions and 14 deletions

View file

@ -24,6 +24,8 @@ function projectButtons(projects) {
let btn = document.createElement('button'); let btn = document.createElement('button');
btn.classList.add(['btn', 'project-btn']); btn.classList.add(['btn', 'project-btn']);
btn.textContent = e.name; btn.textContent = e.name;
btn.dataset.projectName = e.name;
// btn.addEventListener('click', e => console.log(e.target.dataset.projectName));
projectsDiv.append(btn); projectsDiv.append(btn);
}); });
return projectsDiv; return projectsDiv;

View file

@ -37,7 +37,7 @@ class todoHandler {
} }
getTodosFromProject(project) { 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) { addTodo(project = 'default', title, description, dueDate, pomodoros) {

View file

@ -18,17 +18,17 @@ let projects = todos.getProjects();
// starter test data to remove // starter test data to remove
todos.addProject('job'); todos.addProject('job');
todos.addTodo('default', 'test default 2', 'some stuff', 'today', 5); todos.addTodo('default', 'test default 3', 'some stuff', 'today', 5);
todos.addTodo('default', 'default 2', 'some stuff', 'today', 5); todos.addTodo('job', 'default 5', 'some stuff', 'today', 5);
const defaultProject = todos.getTodosFromProject('default');
function website() { function website() {
const currentProject = todos.getTodosFromProject('default');
const div = document.createElement('div'); const div = document.createElement('div');
div.classList.add('container'); div.classList.add('container');
const _navbar = navbar(projects); const _navbar = navbar(projects);
const _todos = todoTableComponent(defaultProject); const _todos = todoTableComponent(currentProject);
div.appendChild(_navbar); div.appendChild(_navbar);
div.appendChild(_todos); div.appendChild(_todos);
@ -38,13 +38,4 @@ function website() {
} }
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()); save(todos.getEverything());