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

85
src/lib/init-db.js Normal file
View File

@@ -0,0 +1,85 @@
import db from "./db";
export default function initializeDatabase() {
db.exec(`
-- Table: contracts
CREATE TABLE IF NOT EXISTS contracts (
contract_id INTEGER PRIMARY KEY AUTOINCREMENT,
contract_number TEXT NOT NULL,
contract_name TEXT,
customer_contract_number TEXT,
customer TEXT,
investor TEXT,
date_signed TEXT,
finish_date TEXT
);
-- Table: projects
CREATE TABLE IF NOT EXISTS projects (
project_id INTEGER PRIMARY KEY AUTOINCREMENT,
contract_id INTEGER,
project_name TEXT NOT NULL,
project_number TEXT NOT NULL,
address TEXT,
plot TEXT,
district TEXT,
unit TEXT,
city TEXT,
investment_number TEXT,
finish_date TEXT,
wp TEXT,
contact TEXT,
notes TEXT,
FOREIGN KEY (contract_id) REFERENCES contracts(contract_id)
);
-- Table: tasks
CREATE TABLE IF NOT EXISTS tasks (
task_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
max_wait_days INTEGER DEFAULT 0,
is_standard INTEGER NOT NULL DEFAULT 0
); -- Table: project_tasks
CREATE TABLE IF NOT EXISTS project_tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
project_id INTEGER NOT NULL,
task_template_id INTEGER,
custom_task_name TEXT,
custom_max_wait_days INTEGER DEFAULT 0,
status TEXT NOT NULL DEFAULT 'pending',
date_added TEXT DEFAULT CURRENT_TIMESTAMP,
priority TEXT DEFAULT 'normal',
FOREIGN KEY (project_id) REFERENCES projects(project_id),
FOREIGN KEY (task_template_id) REFERENCES tasks(task_id)
);
-- Table: notes
CREATE TABLE IF NOT EXISTS notes (
note_id INTEGER PRIMARY KEY AUTOINCREMENT,
project_id INTEGER,
task_id INTEGER,
note TEXT NOT NULL,
note_date TEXT DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (project_id) REFERENCES projects(project_id),
FOREIGN KEY (task_id) REFERENCES project_tasks(id)
);
`);
// Migration: Add custom task columns if they don't exist
try {
db.exec(`
ALTER TABLE project_tasks ADD COLUMN custom_task_name TEXT;
`);
} catch (e) {
// Column already exists, ignore error
}
try {
db.exec(`
ALTER TABLE project_tasks ADD COLUMN custom_max_wait_days INTEGER DEFAULT 0;
`);
} catch (e) {
// Column already exists, ignore error
}
}