bug fixes :db configuration with the actions to connect to the backend

This commit is contained in:
mahlatseclayton
2026-07-30 17:37:19 +02:00
parent a83dcb5567
commit a845fdecda
2 changed files with 14 additions and 10 deletions

View File

@@ -9,7 +9,9 @@ export async function createTaskAction(formData: FormData) {
const title = formData.get('title') as string; const title = formData.get('title') as string;
const description = formData.get('description') as string; const description = formData.get('description') as string;
const due_date = formData.get('due_date') as string; const due_date = formData.get('due_date') as string;
const status = (formData.get('status') as TaskStatus) || 'To-Do';
const status = (formData.get('status') as TaskStatus) || 'Todo';
const topic = formData.get('topic') as string; const topic = formData.get('topic') as string;
if (!title || !description || !topic || !due_date) { if (!title || !description || !topic || !due_date) {
throw new Error('All fields are required'); throw new Error('All fields are required');

View File

@@ -3,17 +3,19 @@ import path from 'path';
const dbPath = path.join(process.cwd(), 'todo.db'); const dbPath = path.join(process.cwd(), 'todo.db');
const db = new Database(dbPath); const db = new Database(dbPath);
// initialise the database schema ..
// Initialise the database schema
db.exec( db.exec(
` `
CREATE TABLE IF NOT EXISTS tasks( CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL, title TEXT NOT NULL,
due_date TEXT NOT NULL, description TEXT,
topic TEXT NOT NULL, due_date TEXT NOT NULL,
status TEXT CHECK(status IN ('To-Do','In-Progress','Complete')) NOT NULL DEFAULT 'to-do', topic TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, status TEXT CHECK(status IN ('Todo','In-Progress','Complete')) NOT NULL DEFAULT 'Todo',
is_Archived BOOLEAN NOT NULL DEFAULT 0 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_archived BOOLEAN NOT NULL DEFAULT 0
) )
` `
); );