Lägger till loggning av todos

This commit is contained in:
2025-01-23 19:31:06 +01:00
parent b2cd55ff64
commit 6eff6e7e77
2 changed files with 17 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task Input App</title>
<title>Fredriks todos</title>
<link rel="stylesheet" href="style.css">
<!-- Flatpickr for dates -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">

View File

@@ -12,12 +12,26 @@ app.use(express.static('public'));
// Endpoint to receive task data and append to file
app.post('/add-task', (req, res) => {
const { subject, description, scheduled } = req.body;
const currentDateTime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
const orgFormattedData = `
let orgFormattedData = `
* TODO ${subject}
SCHEDULED: <${scheduled}>
:LOGBOOK:
- State "TODO" from [${currentDateTime}]
:END:
`;
if (description) {
orgFormattedData = `
* TODO ${subject}
${description}
SCHEDULED: <${scheduled}>
`;
:LOGBOOK:
- State "TODO" from [${currentDateTime}]
:END:
`;
}
const filePath = path.join(__dirname, 'tasks.org');
fs.appendFile(filePath, orgFormattedData, (err) => {