bug fixes :db configuration with the actions to connect to the backend
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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,
|
||||
description TEXT,
|
||||
due_date TEXT NOT NULL,
|
||||
topic TEXT NOT NULL,
|
||||
status TEXT CHECK(status IN ('To-Do','In-Progress','Complete')) NOT NULL DEFAULT 'to-do',
|
||||
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
|
||||
is_archived BOOLEAN NOT NULL DEFAULT 0
|
||||
)
|
||||
`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user