From d49bea8f157e74735439d4fb2ed259bbaec95388 Mon Sep 17 00:00:00 2001 From: chop Date: Thu, 22 Jan 2026 20:22:27 +0100 Subject: [PATCH] feat: Add start date and completion date fields to project model and forms --- export-projects-to-excel.mjs | 4 +++- scripts/create-sample-projects.js | 24 ++++++++++++++++++++++-- src/app/projects/[id]/page.js | 14 ++++++++++++-- src/components/ProjectForm.js | 21 +++++++++++++++++++-- src/lib/init-db.js | 8 ++++++++ src/lib/queries/projects.js | 8 +++++--- 6 files changed, 69 insertions(+), 10 deletions(-) diff --git a/export-projects-to-excel.mjs b/export-projects-to-excel.mjs index 923c9f5..4721840 100644 --- a/export-projects-to-excel.mjs +++ b/export-projects-to-excel.mjs @@ -17,7 +17,9 @@ function exportProjectsToExcel() { 'Adres': project.address || '', 'Działka': project.plot || '', 'WP': project.wp || '', - 'Data zakończenia': project.finish_date || '' + 'Data wpływu': project.start_date || '', + 'Termin zakończenia': project.finish_date || '', + 'Data odbioru': project.completion_date || '' }); return acc; }, {}); diff --git a/scripts/create-sample-projects.js b/scripts/create-sample-projects.js index 46d3728..16d3cd6 100644 --- a/scripts/create-sample-projects.js +++ b/scripts/create-sample-projects.js @@ -15,7 +15,9 @@ const sampleProjects = [ unit: 'Unit A', city: 'Warszawa', investment_number: 'INV-2025-001', + start_date: '2025-01-15', finish_date: '2025-06-30', + completion_date: null, wp: 'WP-001', contact: 'Jan Kowalski, tel. 123-456-789', notes: 'Modern residential building with 50 apartments', @@ -32,7 +34,9 @@ const sampleProjects = [ unit: 'Unit B', city: 'Warszawa', investment_number: 'INV-2025-002', + start_date: '2025-02-01', finish_date: '2025-09-15', + completion_date: null, wp: 'WP-002', contact: 'Anna Nowak, tel. 987-654-321', notes: 'Commercial office space, 10 floors', @@ -49,7 +53,9 @@ const sampleProjects = [ unit: 'Unit C', city: 'Kraków', investment_number: 'INV-2025-003', + start_date: '2025-01-10', finish_date: '2025-12-20', + completion_date: null, wp: 'WP-003', contact: 'Piotr Wiśniewski, tel. 555-123-456', notes: 'Large shopping center with parking', @@ -66,7 +72,9 @@ const sampleProjects = [ unit: 'Unit D', city: 'Łódź', investment_number: 'INV-2025-004', + start_date: '2024-11-01', finish_date: '2025-08-10', + completion_date: '2025-08-05', wp: 'WP-004', contact: 'Maria Lewandowska, tel. 444-789-012', notes: 'Logistics warehouse facility', @@ -83,7 +91,9 @@ const sampleProjects = [ unit: 'Unit E', city: 'Gdańsk', investment_number: 'INV-2025-005', + start_date: '2025-01-20', finish_date: '2025-11-05', + completion_date: null, wp: 'WP-005', contact: 'Tomasz Malinowski, tel. 333-456-789', notes: 'Luxury hotel with conference facilities', @@ -100,7 +110,9 @@ const sampleProjects = [ unit: 'Unit F', city: 'Poznań', investment_number: 'INV-2025-006', + start_date: '2025-02-10', finish_date: '2025-07-20', + completion_date: null, wp: 'WP-006', contact: 'Ewa Dombrowska, tel. 222-333-444', notes: 'Modern educational facility with sports complex', @@ -117,7 +129,9 @@ const sampleProjects = [ unit: 'Unit G', city: 'Wrocław', investment_number: 'INV-2025-007', + start_date: '2024-12-15', finish_date: '2025-10-30', + completion_date: null, wp: 'WP-007', contact: 'Dr. Marek Szymankowski, tel. 111-222-333', notes: 'Specialized medical center with emergency department', @@ -134,7 +148,9 @@ const sampleProjects = [ unit: 'Unit H', city: 'Szczecin', investment_number: 'INV-2025-008', + start_date: '2024-09-01', finish_date: '2025-05-15', + completion_date: '2025-05-12', wp: 'WP-008', contact: 'Katarzyna Wojcik, tel. 999-888-777', notes: 'Multi-purpose sports stadium with seating for 20,000', @@ -151,7 +167,9 @@ const sampleProjects = [ unit: 'Unit I', city: 'Lublin', investment_number: 'INV-2025-009', + start_date: '2025-01-05', finish_date: '2025-08-25', + completion_date: null, wp: 'WP-009', contact: 'Prof. Andrzej Kowalewski, tel. 777-666-555', notes: 'Modern library with digital archives and community spaces', @@ -174,9 +192,9 @@ sampleProjects.forEach((projectData, index) => { const result = db.prepare(` INSERT INTO projects ( contract_id, project_name, project_number, address, plot, district, unit, city, - investment_number, finish_date, wp, contact, notes, coordinates, + investment_number, start_date, finish_date, completion_date, wp, contact, notes, coordinates, project_type, project_status, created_at, updated_at - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) `).run( projectData.contract_id, projectData.project_name, @@ -187,7 +205,9 @@ sampleProjects.forEach((projectData, index) => { projectData.unit, projectData.city, projectData.investment_number, + projectData.start_date, projectData.finish_date, + projectData.completion_date, projectData.wp, projectData.contact, projectData.notes, diff --git a/src/app/projects/[id]/page.js b/src/app/projects/[id]/page.js index fb5ab0c..ab36305 100644 --- a/src/app/projects/[id]/page.js +++ b/src/app/projects/[id]/page.js @@ -463,7 +463,17 @@ export default function ProjectViewPage() {

{project.unit || "N/A"}

- {" "} + + {project.start_date && ( +
+ + Data wpływu + +

+ {formatDate(project.start_date)} +

+
+ )} - Data zakończenia projektu + Data odbioru

{formatDate(project.completion_date)} diff --git a/src/components/ProjectForm.js b/src/components/ProjectForm.js index dd73bdc..26f1570 100644 --- a/src/components/ProjectForm.js +++ b/src/components/ProjectForm.js @@ -22,6 +22,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref) unit: "", city: "", investment_number: "", + start_date: "", finish_date: "", completion_date: "", wp: "", @@ -63,6 +64,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref) unit: "", city: "", investment_number: "", + start_date: "", finish_date: "", completion_date: "", wp: "", @@ -78,6 +80,9 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref) assigned_to: initialData.assigned_to || "", wartosc_zlecenia: initialData.wartosc_zlecenia || "", // Format dates for input if they exist + start_date: initialData.start_date + ? formatDateForInput(initialData.start_date) + : "", finish_date: initialData.finish_date ? formatDateForInput(initialData.finish_date) : "", @@ -292,7 +297,19 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)

+ +
+ +
+