mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-27 06:40:42 -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) {
|
function createTodo(title, description, dueDate, pomodoros) {
|
||||||
|
dueDate = dueDate.replaceAll('-', '/');
|
||||||
|
|
||||||
const newTodo = {
|
const newTodo = {
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
dueDate: dueDate,
|
dueDate: format(new Date(dueDate), 'MM/dd/yyyy'),
|
||||||
pomodoros: pomodoros,
|
pomodoros: pomodoros,
|
||||||
completed: false
|
completed: false
|
||||||
}
|
}
|
||||||
|
@ -46,6 +50,12 @@ class todoHandler {
|
||||||
|
|
||||||
if (!_titleExists) {
|
if (!_titleExists) {
|
||||||
this.projects[index].todos.push(new createTodo(title, description, dueDate, pomodoros));
|
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 {
|
} else {
|
||||||
alert('unable to create duplicate note');
|
alert('unable to create duplicate note');
|
||||||
return
|
return
|
||||||
|
|
|
@ -127,7 +127,7 @@ function addTodo(todoHandler) {
|
||||||
let newTodo = handleTodoInput(input.childNodes);
|
let newTodo = handleTodoInput(input.childNodes);
|
||||||
let title = newTodo[0];
|
let title = newTodo[0];
|
||||||
let description = newTodo[1];
|
let description = newTodo[1];
|
||||||
let date = new Date(newTodo[2]);
|
let date = newTodo[2]; // new Date(newTodo[2]);
|
||||||
console.log(date);
|
console.log(date);
|
||||||
todoHandler.addTodo(activeProject, title, description, date, 0);
|
todoHandler.addTodo(activeProject, title, description, date, 0);
|
||||||
div.classList.remove('todo-add-active');
|
div.classList.remove('todo-add-active');
|
||||||
|
|
|
@ -30,6 +30,7 @@ button {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
input[type="checkbox"] {
|
input[type="checkbox"] {
|
||||||
/* appearance: none; */
|
/* appearance: none; */
|
||||||
/* For iOS < 15 to remove gradient background */
|
/* For iOS < 15 to remove gradient background */
|
||||||
|
|
Loading…
Reference in a new issue