Skip to content

Commit

Permalink
Creation of a task with a specific id, pushing the task onto taskStac…
Browse files Browse the repository at this point in the history
…k and returning to displayCurrentTask
  • Loading branch information
AndyHubert committed Jul 27, 2024
1 parent 2a82b43 commit 52eceef
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions sarah/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const historyList = [] //array of history of completed tasks
let currentTask = 1 //this will always be holding the id of the current task

const displayCurrentTask = () => {

console.log("taskStack = ", taskStack.length)
if(taskStack.length === 0){
editTask()
}
console.log("first task created: task", taskStack) //STOPPED HERE: task is created, pushed onto taskStack and returning to displayCurrent Task - how do I display the current task?
/*
Display the task with id = currentTask
when back arrow selected -> view previous task according to stack array
Expand All @@ -32,19 +34,24 @@ const editTask = () => {

//generateTask function
const generateTask = () => {
console.log("into generateTask") //STOPPED HERE! 1)generate a new task. 2)save new task. 3)what do when edit task instead of new?
//create new task and give it ID
// if (newTask) {
// let task = {
// title: titleText,
// description: descriptionText,
// date: new Date(),
// notes: ``,
// id: currentTask,
// }
// currentTask++
// console.log("Current Task after task creation and increment -", currentTask)
// }
console.log("into generateTask")
//create new task and give it ID
let task = {
title: titleText,
description: descriptionText,
date: new Date(),
notes: ``,
id: currentTask,
}
console.log("task =", task)
taskStack.push(task)
currentTask++
console.log("Current Task after task creation and increment -", currentTask)

//hide editTask and show displayCurrent task and return to displayCurrent task
document.querySelector(`#screen-edit-task`).classList.add(`hide`)
document.querySelector(`#screen-main`).classList.remove(`hide`)
displayCurrentTask()
}

//hide displayCurrentTask and show editTask
Expand Down

0 comments on commit 52eceef

Please sign in to comment.