feat: Add support for project cancellation status across the application

This commit is contained in:
2025-09-11 16:19:46 +02:00
parent 2735d46552
commit 95ef139843
13 changed files with 116 additions and 50 deletions

View File

@@ -105,6 +105,7 @@ const translations = {
in_progress_design: "W realizacji (projektowanie)",
in_progress_construction: "W realizacji (realizacja)",
fulfilled: "Zakończony",
cancelled: "Wycofany",
unknown: "Nieznany"
},
@@ -541,6 +542,7 @@ const translations = {
in_progress_design: "In Progress (Design)",
in_progress_construction: "In Progress (Construction)",
fulfilled: "Completed",
cancelled: "Cancelled",
unknown: "Unknown"
},

View File

@@ -31,7 +31,7 @@ export default function initializeDatabase() {
contact TEXT,
notes TEXT,
project_type TEXT CHECK(project_type IN ('design', 'construction', 'design+construction')) DEFAULT 'design',
project_status TEXT CHECK(project_status IN ('registered', 'in_progress_design', 'in_progress_construction', 'fulfilled')) DEFAULT 'registered',
project_status TEXT CHECK(project_status IN ('registered', 'in_progress_design', 'in_progress_construction', 'fulfilled', 'cancelled')) DEFAULT 'registered',
FOREIGN KEY (contract_id) REFERENCES contracts(contract_id)
);
@@ -113,7 +113,7 @@ export default function initializeDatabase() {
// Migration: Add project_status column to projects table
try {
db.exec(`
ALTER TABLE projects ADD COLUMN project_status TEXT CHECK(project_status IN ('registered', 'in_progress_design', 'in_progress_construction', 'fulfilled')) DEFAULT 'registered';
ALTER TABLE projects ADD COLUMN project_status TEXT CHECK(project_status IN ('registered', 'in_progress_design', 'in_progress_construction', 'fulfilled', 'cancelled')) DEFAULT 'registered';
`);
} catch (e) {
// Column already exists, ignore error

View File

@@ -16,13 +16,13 @@ export function getNotesByProjectId(project_id) {
.all(project_id);
}
export function addNoteToProject(project_id, note, created_by = null) {
export function addNoteToProject(project_id, note, created_by = null, is_system = false) {
db.prepare(
`
INSERT INTO notes (project_id, note, created_by, note_date)
VALUES (?, ?, ?, CURRENT_TIMESTAMP)
INSERT INTO notes (project_id, note, created_by, is_system, note_date)
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
`
).run(project_id, note, created_by);
).run(project_id, note, created_by, is_system ? 1 : 0);
}
export function getNotesByTaskId(task_id) {

View File

@@ -110,7 +110,7 @@ export function updateProject(id, data, userId = null) {
coordinates = ?, assigned_to = ?, updated_at = CURRENT_TIMESTAMP
WHERE project_id = ?
`);
stmt.run(
const result = stmt.run(
data.contract_id,
data.project_name,
data.project_number,
@@ -130,6 +130,9 @@ export function updateProject(id, data, userId = null) {
data.assigned_to || null,
id
);
console.log('Update result:', result);
return result;
}
export function deleteProject(id) {

View File

@@ -15,6 +15,8 @@ export const formatProjectStatus = (status) => {
return "W realizacji (realizacja)";
case "fulfilled":
return "Zakończony";
case "cancelled":
return "Wycofany";
default:
return "-";
}