feat: Add NoteForm, ProjectForm, and ProjectTaskForm components

- Implemented NoteForm for adding notes to projects.
- Created ProjectForm for managing project details with contract selection.
- Developed ProjectTaskForm for adding tasks to projects, supporting both templates and custom tasks.

feat: Add ProjectTasksSection component

- Introduced ProjectTasksSection to display and manage tasks for a specific project.
- Includes functionality for adding, updating, and deleting tasks.

feat: Create TaskTemplateForm for managing task templates

- Added TaskTemplateForm for creating new task templates with required wait days.

feat: Implement UI components

- Created reusable UI components: Badge, Button, Card, Input, Loading, Navigation.
- Enhanced user experience with consistent styling and functionality.

feat: Set up database and queries

- Initialized SQLite database with tables for contracts, projects, tasks, project tasks, and notes.
- Implemented queries for managing contracts, projects, tasks, and notes.

chore: Add error handling and loading states

- Improved error handling in forms and data fetching.
- Added loading states for better user feedback during data operations.
This commit is contained in:
Chop
2025-06-02 22:07:05 +02:00
parent aa1eb99ce9
commit d0586f2876
43 changed files with 3272 additions and 137 deletions

View File

@@ -0,0 +1,52 @@
import {
getAllTaskTemplates,
getProjectTasks,
createProjectTask,
} from "@/lib/queries/tasks";
import { NextResponse } from "next/server";
// GET: Get all project tasks or task templates based on query params
export async function GET(req) {
const { searchParams } = new URL(req.url);
const projectId = searchParams.get("project_id");
if (projectId) {
// Get tasks for a specific project
const tasks = getProjectTasks(projectId);
return NextResponse.json(tasks);
} else {
// Default: return all task templates
const templates = getAllTaskTemplates();
return NextResponse.json(templates);
}
}
// POST: Create a new project task
export async function POST(req) {
try {
const data = await req.json();
if (!data.project_id) {
return NextResponse.json(
{ error: "project_id is required" },
{ status: 400 }
);
}
// Check if it's a template task or custom task
if (!data.task_template_id && !data.custom_task_name) {
return NextResponse.json(
{ error: "Either task_template_id or custom_task_name is required" },
{ status: 400 }
);
}
const result = createProjectTask(data);
return NextResponse.json({ success: true, id: result.lastInsertRowid });
} catch (error) {
return NextResponse.json(
{ error: "Failed to create project task" },
{ status: 500 }
);
}
}