From 7eb4f96f3afc1b2dc0dc155e08abb1c55a20d2fa Mon Sep 17 00:00:00 2001 From: Mike Smith <89040888+smiggiddy@users.noreply.github.com> Date: Mon, 8 Jan 2024 21:10:06 -0500 Subject: [PATCH] style: formatting with prettier --- todo/.eslintrc.js | 3 ++- todo/src/components/todo.js | 34 +++++++++++++++++----------------- todo/src/index.js | 18 +++++++++--------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/todo/.eslintrc.js b/todo/.eslintrc.js index 9ab3bd8..0917815 100644 --- a/todo/.eslintrc.js +++ b/todo/.eslintrc.js @@ -2,7 +2,8 @@ module.exports = { "env": { "browser": true, - "es2021": true + "es2021": true, + node: true }, "extends": "eslint:recommended", "parserOptions": { diff --git a/todo/src/components/todo.js b/todo/src/components/todo.js index 9604061..7781787 100644 --- a/todo/src/components/todo.js +++ b/todo/src/components/todo.js @@ -2,7 +2,7 @@ import { format, compareAsc } from "date-fns"; function createTodo(title, description, dueDate, pomodoros) { dueDate = dueDate.replaceAll('-', '/'); - + const newTodo = { title: title, description: description, @@ -25,7 +25,7 @@ function createProject(name) { class todoHandler { // Create default project during construction - constructor(projects=null) { + constructor(projects = null) { if (projects) { this.projects = projects; } else if (!this.projects) { @@ -38,24 +38,24 @@ class todoHandler { getTodos() { return this.projects.map(item => item.todos); - } + } getTodosFromProject(project) { return this.projects.find((item) => item.name === project).todos; } - + addTodo(project = 'default', title, description, dueDate, pomodoros) { let index = this.projects.findIndex(x => x.name === project); let _titleExists = this.titleExists(title, this.projects[index].todos); if (!_titleExists) { this.projects[index].todos.push(new createTodo(title, description, dueDate, pomodoros)); - this.projects[index].todos.sort((a,b) => { - + this.projects[index].todos.sort((a, b) => { + return compareAsc(new Date(a.dueDate), new Date(b.dueDate)); }); // console.log(this.projects[index]); - //(itemA, itemB) => {return itemA.dueDate - itemB.dueDate}) + //(itemA, itemB) => {return itemA.dueDate - itemB.dueDate}) } else { alert('unable to create duplicate note'); return @@ -68,7 +68,7 @@ class todoHandler { let projectIndex = this.projects.findIndex(x => x.name === project); let todo = this.projects[projectIndex].todos.find(t => t.title === title) - if (todo){ + if (todo) { todo.completed = !todo.completed; // if(description) todo.description = description; // if(dueDate) todo.dueDate = dueDate; @@ -79,9 +79,9 @@ class todoHandler { deleteTodo(project, title) { let projectIndex = this.projects.findIndex(x => x.name === project); let tempArr = this.projects[projectIndex].todos.filter(item => { - if (item.title !== title){ - return item; - }; + if (item.title !== title) { + return item; + } }); this.projects[projectIndex].todos = tempArr; } @@ -98,24 +98,24 @@ class todoHandler { } alert(`Project ${name} already exists!`); - } + } - getProjects () { + getProjects() { return this.projects; } delProject(name) { let index = this.projects.findIndex(proj => proj.name === name); let tempArr = this.projects.filter(item => { - if (item !== this.projects[index] || name === 'default' ){ + if (item !== this.projects[index] || name === 'default') { return item; - }; + } }); this.projects = tempArr; } // return { getTodos, addTodo, editTodo, deleteTodo, addProject, getProjects, delProject } - + } -export { todoHandler }; +export { todoHandler }; diff --git a/todo/src/index.js b/todo/src/index.js index ad1bc2c..0875dc7 100644 --- a/todo/src/index.js +++ b/todo/src/index.js @@ -1,14 +1,14 @@ -import { +import { addTodo, deleteTodo, - addProject, - deleteProject, - projectComponent, - todoTableComponent, + addProject, + deleteProject, + projectComponent, + todoTableComponent, getTodoFromActiveProject, addTodoComponent, handleCompletedTodo - } from "./components/todoComponent"; +} from "./components/todoComponent"; import { navbar } from "./components/navbar"; import { save, load } from "./components/storage"; import './style.css'; @@ -22,7 +22,7 @@ todos = data ? new todoManager(JSON.parse(data)) : new todoManager(); let activeProject = 'default'; function setActiveProject(value) { - activeProject = value; + activeProject = value; } function getActiveProject() { @@ -47,9 +47,9 @@ function website() { function updateDisplay() { const div = document.querySelector('.container'); if (div) div.innerHTML = ''; - + // ensure grabbing latest projects - let projects = todos.getProjects(); + let projects = todos.getProjects(); let currentActiveProject = activeProject; let todosToRender = todos.getTodosFromProject(currentActiveProject);