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

76
src/lib/queries/tasks.js Normal file
View File

@@ -0,0 +1,76 @@
import db from "../db.js";
// Get all task templates (for dropdown selection)
export function getAllTaskTemplates() {
return db
.prepare("SELECT * FROM tasks WHERE is_standard = 1 ORDER BY name ASC")
.all();
}
// Get project tasks for a specific project
export function getProjectTasks(projectId) {
return db
.prepare(
`
SELECT
pt.*,
COALESCE(pt.custom_task_name, t.name) as task_name,
COALESCE(pt.custom_max_wait_days, t.max_wait_days) as max_wait_days,
CASE
WHEN pt.task_template_id IS NOT NULL THEN 'template'
ELSE 'custom'
END as task_type
FROM project_tasks pt
LEFT JOIN tasks t ON pt.task_template_id = t.task_id
WHERE pt.project_id = ?
ORDER BY pt.date_added DESC
`
)
.all(projectId);
}
// Create a new project task
export function createProjectTask(data) {
if (data.task_template_id) {
// Creating from template
const stmt = db.prepare(`
INSERT INTO project_tasks (project_id, task_template_id, status, priority)
VALUES (?, ?, ?, ?)
`);
return stmt.run(
data.project_id,
data.task_template_id,
data.status || "pending",
data.priority || "normal"
);
} else {
// Creating custom task
const stmt = db.prepare(`
INSERT INTO project_tasks (project_id, custom_task_name, custom_max_wait_days, status, priority)
VALUES (?, ?, ?, ?, ?)
`);
return stmt.run(
data.project_id,
data.custom_task_name,
data.custom_max_wait_days || 0,
data.status || "pending",
data.priority || "normal"
);
}
}
// Update project task status
export function updateProjectTaskStatus(taskId, status) {
const stmt = db.prepare(`
UPDATE project_tasks
SET status = ?
WHERE id = ?
`);
return stmt.run(status, taskId);
}
// Delete a project task
export function deleteProjectTask(taskId) {
const stmt = db.prepare("DELETE FROM project_tasks WHERE id = ?");
return stmt.run(taskId);
}