diff --git a/src/lib/actions.ts b/src/lib/actions.ts index ead9407..b6dd962 100644 --- a/src/lib/actions.ts +++ b/src/lib/actions.ts @@ -9,7 +9,9 @@ export async function createTaskAction(formData: FormData) { const title = formData.get('title') as string; const description = formData.get('description') 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; if (!title || !description || !topic || !due_date) { throw new Error('All fields are required'); diff --git a/src/lib/db.ts b/src/lib/db.ts index 0d458e9..5f71a37 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -3,17 +3,19 @@ import path from 'path'; const dbPath = path.join(process.cwd(), 'todo.db'); const db = new Database(dbPath); -// initialise the database schema .. + +// Initialise the database schema db.exec( ` - CREATE TABLE IF NOT EXISTS tasks( - id INTEGER PRIMARY KEY AUTOINCREMENT, - title TEXT NOT NULL, - due_date TEXT NOT NULL, - topic TEXT NOT NULL, - status TEXT CHECK(status IN ('To-Do','In-Progress','Complete')) NOT NULL DEFAULT 'to-do', - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - is_Archived BOOLEAN NOT NULL DEFAULT 0 + CREATE TABLE IF NOT EXISTS tasks ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + description TEXT, + due_date TEXT NOT NULL, + topic TEXT NOT NULL, + status TEXT CHECK(status IN ('Todo','In-Progress','Complete')) NOT NULL DEFAULT 'Todo', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + is_archived BOOLEAN NOT NULL DEFAULT 0 ) ` );