diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ff7529 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +backend\node_modules diff --git a/frontend/dashboard.html b/frontend/dashboard.html index d1ae6b8..a65e849 100644 --- a/frontend/dashboard.html +++ b/frontend/dashboard.html @@ -1,174 +1,120 @@ - - - - To Do App | Dashboard - - - - - +
+ -
-
-
-
-
-

Your Dashboard

-

New Task

- - - - -
- - -
-
-
-

To Do

-
    -
    -
    -

    Completed

    -
      -
      -
      -
      +
      -
      - - - - - - +
      + + + + + + \ No newline at end of file diff --git a/frontend/features.html b/frontend/features.html index 9c428b0..a7f19fd 100644 --- a/frontend/features.html +++ b/frontend/features.html @@ -1,131 +1,94 @@ - - - - To Do App | Features - - - - - +
      + - -
      -
      - Under Construction - -

      Page under construction. Check back later!

      - -
      - Go Home -
      -
      -
      - - - - - - - +
      + Privacy Policy +

      |

      + Terms of Service +

      |

      +

      BucketLisk © 2025 All Rights Reserved

      +
      +
      + + + + + + \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 0303886..b93a5c7 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,125 +1,91 @@ - - - - To Do App | Home - - - - - +
      + - -
      -

      - Stay origansed with BucketList -

      - -
      - - - - - - - +
      + Privacy Policy +

      |

      + Terms of Service +

      |

      +

      BucketLisk © 2025 All Rights Reserved

      +
      +
      + + + + + + \ No newline at end of file diff --git a/frontend/js/api.js b/frontend/js/api.js index c763eab..9a043ad 100644 --- a/frontend/js/api.js +++ b/frontend/js/api.js @@ -1,38 +1,3 @@ -const tasks = [ - { - id: 1, - completed: false, - title: "Buy groceries for the week", - description: "Pick up vegetables, fruits, milk, eggs, and bread from the supermarket.", - dueDate: "14/03/2026", - dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") - }, - { - id: 2, - completed: false, - title: "Clean the apartment", - description: "Vacuum the floors, wipe kitchen surfaces, and take out the trash.", - dueDate: "16/03/2026", - dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") - }, - { - id: 3, - completed: false, - title: "Call the dentist for appointment", - description: "Book a routine checkup and confirm available time slots for next week.", - dueDate: "17/03/2026", - dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") - }, - { - id: 4, - completed: true, - title: "Do laundry and fold clothes", - description: "Wash dark and light loads separately, then fold and organize clean clothes.", - dueDate: "21/03/2026", - dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") - } -]; - // GLOBALS const $taskForm = document.getElementById('taskForm'); @@ -68,66 +33,117 @@ $taskForm.addEventListener("submit", (event) => { } }); }); - -// DISPLAY TASKS - -function displayTasks() { - - function formatTask(task) { - const li = document.createElement("li"); - - li.classList.add('card', 'p-3', 'mt-2'); - const done = task.completed - ? "text-decoration-line-through opacity-50" - : ""; - li.innerHTML = ` -
      -

      ${task.title}

      - -
      -

      ${task.description}

      -

      Due: ${task.dueDate}

      -
      -
      - ${task.completed - ? `` - : ` - - - ` - } -
      -

      Created on: ${task.dateCreated}

      -
      - `; - - return li; - - } - - $toDoList.innerHTML = ""; - $completedList.innerHTML = ""; - - tasks.forEach(task => { - const formattedTask = formatTask(task); - task.completed - ? $completedList.appendChild(formattedTask) - : $toDoList.appendChild(formattedTask) - }) - resetForm(); +// EXAMPLE API +async function exampleAPI() { + const response = await fetch("http://localhost:3001/test"); + const data = await response.text(); + console.log(data); } -function createNewTask() { - const taskDetails = { - id: tasks.length + 1, - completed: false, - title: $taskForm.taskName.value, - description: $taskForm.taskDescription.value, - dueDate: convertDate($taskForm.dueDate.value), - dateCreated: convertDate(Date.now()), +exampleAPI(); +// DISPLAY TASKS + +async function displayTasks() { + + const response = await fetch("http://localhost:3001/api/tasks") + + if (!response.ok) { + throw new Error(`Failed to get tasks: ${response.status}`); } - tasks.push(taskDetails); - displayTasks(); + + const data = await response.json(); + + try { + function formatTask(task) { + const li = document.createElement("li"); + + li.classList.add('card', 'p-3', 'mt-2'); + const done = task.completed + ? "text-decoration-line-through opacity-50" + : ""; + li.innerHTML = ` +
      +

      ${task.title}

      + +
      +

      ${task.description}

      +

      Due: ${task.dueDate}

      +
      +
      + ${task.completed + ? `` + : ` + + + ` + } +
      +

      Created on: ${task.dateCreated}

      +
      + `; + + return li; + + } + + $toDoList.innerHTML = ""; + $completedList.innerHTML = ""; + + const tasks = Array.isArray(data) ? data : []; + + if (!Array.isArray(data)) { + console.error("ERROR: Expected an array of tasks from /api/tasks", data); + } + + tasks.forEach(task => { + const formattedTask = formatTask(task); + task.completed + ? $completedList.appendChild(formattedTask) + : $toDoList.appendChild(formattedTask) + }) + resetForm(); + + } catch (error) { + console.error(`ERROR: ${error}`); + } + + +} + +async function createNewTask() { + const taskDetails = { + title: $taskForm.taskName.value.trim(), + description: $taskForm.taskDescription.value.trim(), + dueDate: $taskForm.dueDate.value, + } + if (!taskDetails.title || !taskDetails.description || !taskDetails.dueDate) { + alert("Please fill in all fields"); + return; + } + + try { + const response = await fetch("http://localhost:3001/api/tasks/todo", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(taskDetails) + }); + + if (!response.ok) { + throw new Error(`Failed to create task: ${response.status}`); + } + + const data = await response.json(); + console.log("Task created:", data); + displayTasks(); + + + } + catch (error) { + console.error(`ERROR: ${error}`); + } + }; function toggleTaskStatus(taskId) { diff --git a/frontend/login.html b/frontend/login.html index 0cca4e8..00bf2bd 100644 --- a/frontend/login.html +++ b/frontend/login.html @@ -81,7 +81,7 @@

      |

      Terms of Service

      |

      -

      BucketList © 2025 All Rights Reserved

      +

      BucketLisk © 2025 All Rights Reserved

      diff --git a/frontend/pricing.html b/frontend/pricing.html index e9da3fc..42f6f82 100644 --- a/frontend/pricing.html +++ b/frontend/pricing.html @@ -81,7 +81,7 @@

      |

      Terms of Service

      |

      -

      BucketList © 2025 All Rights Reserved

      +

      BucketLisk © 2025 All Rights Reserved

      diff --git a/frontend/signup.html b/frontend/signup.html index f619833..dd2a932 100644 --- a/frontend/signup.html +++ b/frontend/signup.html @@ -1,131 +1,94 @@ - - - - To Do App | Signup - - - - - +
      + - -
      -
      - Under Construction - -

      Page under construction. Check back later!

      - -
      - Go Home -
      -
      -
      - - - - - - - +
      + Privacy Policy +

      |

      + Terms of Service +

      |

      +

      BucketLisk © 2025 All Rights Reserved

      +
      +
      + + + + + + \ No newline at end of file diff --git a/frontend/support.html b/frontend/support.html index f07cef4..958b322 100644 --- a/frontend/support.html +++ b/frontend/support.html @@ -81,7 +81,7 @@

      |

      Terms of Service

      |

      -

      BucketList © 2025 All Rights Reserved

      +

      BucketLisk © 2025 All Rights Reserved