mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 14:20:43 -05:00
feat: add sorting by dates
This commit is contained in:
parent
1fc78a7879
commit
83112555b7
3 changed files with 13 additions and 2 deletions
|
@ -1,8 +1,12 @@
|
|||
import { format, compareAsc } from "date-fns";
|
||||
|
||||
function createTodo(title, description, dueDate, pomodoros) {
|
||||
dueDate = dueDate.replaceAll('-', '/');
|
||||
|
||||
const newTodo = {
|
||||
title: title,
|
||||
description: description,
|
||||
dueDate: dueDate,
|
||||
dueDate: format(new Date(dueDate), 'MM/dd/yyyy'),
|
||||
pomodoros: pomodoros,
|
||||
completed: false
|
||||
}
|
||||
|
@ -46,6 +50,12 @@ class todoHandler {
|
|||
|
||||
if (!_titleExists) {
|
||||
this.projects[index].todos.push(new createTodo(title, description, dueDate, pomodoros));
|
||||
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})
|
||||
} else {
|
||||
alert('unable to create duplicate note');
|
||||
return
|
||||
|
|
|
@ -127,7 +127,7 @@ function addTodo(todoHandler) {
|
|||
let newTodo = handleTodoInput(input.childNodes);
|
||||
let title = newTodo[0];
|
||||
let description = newTodo[1];
|
||||
let date = new Date(newTodo[2]);
|
||||
let date = newTodo[2]; // new Date(newTodo[2]);
|
||||
console.log(date);
|
||||
todoHandler.addTodo(activeProject, title, description, date, 0);
|
||||
div.classList.remove('todo-add-active');
|
||||
|
|
|
@ -30,6 +30,7 @@ button {
|
|||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
input[type="checkbox"] {
|
||||
/* appearance: none; */
|
||||
/* For iOS < 15 to remove gradient background */
|
||||
|
|
Loading…
Reference in a new issue