Första incheckningen. Protyp för PWA för att skapa todos

This commit is contained in:
2025-01-23 16:51:16 +01:00
parent 1edf21dc50
commit 47dd4c8332
6 changed files with 200 additions and 0 deletions

31
public/app.js Normal file
View File

@@ -0,0 +1,31 @@
document.getElementById('taskForm').addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const subject = document.getElementById('subject').value;
const description = document.getElementById('description').value;
const deadline = document.getElementById('deadline').value;
// Structure data for Org mode
const taskData = {
subject,
description,
deadline
};
// Send data to backend using fetch
fetch('/add-task', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(taskData)
})
.then(response => response.json())
.then(data => {
document.getElementById('responseMessage').textContent = data.message;
})
.catch(error => {
document.getElementById('responseMessage').textContent = "Error saving task!";
});
});