day selectors work

main
samerbam 1 year ago
parent febb3cd3d8
commit 6e2ed5bd0b

@ -669,7 +669,7 @@ function loginAction(e) {
};
function getTodosFromAPI() {
function getTodosFromAPI(day=dayjs().format("YYYY-MM-DD")) {
document.getElementById("loginPanel").classList.add("hidden")
console.log(jToken)
// console.log(t)
@ -678,7 +678,7 @@ function getTodosFromAPI() {
// document.getElementById("testToken").innerHTML = t
fetch('/api/todos/get?' + new URLSearchParams({
date: dayjs().format("YYYY-MM-DD"),
date: day,
}), {
method: 'GET',
withCredentials: true,
@ -775,9 +775,14 @@ function switchDayListener(e) {
switch (this.id) {
case "nextDayButton":
dateView.innerHTML = dayjs(dateView.innerHTML.slice(4), "MMM D, YYYY").add(1, 'day').format("ddd MMM D, YYYY")
document.querySelectorAll('.task-row').forEach(e => e.remove());
getTodosFromAPI(dayjs(dateView.innerHTML.slice(4), "MMM D, YYYY").format("YYYY-MM-DD"))
break;
case "prevDayButton":
dateView.innerHTML = dayjs(dateView.innerHTML.slice(4), "MMM D, YYYY").subtract(1, 'day').format("ddd MMM D, YYYY")
document.querySelectorAll('.task-row').forEach(e => e.remove());
getTodosFromAPI(dayjs(dateView.innerHTML.slice(4), "MMM D, YYYY").format("YYYY-MM-DD"))
break;
}
}

Loading…
Cancel
Save