feat: Add start date and completion date fields to project model and forms

This commit is contained in:
2026-01-22 20:22:27 +01:00
parent 3d2065d8fb
commit d49bea8f15
6 changed files with 69 additions and 10 deletions

View File

@@ -463,7 +463,17 @@ export default function ProjectViewPage() {
<p className="text-gray-900 font-medium">
{project.unit || "N/A"}
</p>
</div>{" "}
</div>
{project.start_date && (
<div>
<span className="text-sm font-medium text-gray-500 block mb-1">
Data wpływu
</span>
<p className="text-gray-900 font-medium">
{formatDate(project.start_date)}
</p>
</div>
)}
<FieldWithHistory
tableName="projects"
recordId={project.project_id}
@@ -474,7 +484,7 @@ export default function ProjectViewPage() {
{project.completion_date && (
<div>
<span className="text-sm font-medium text-gray-500 block mb-1">
Data zakończenia projektu
Data odbioru
</span>
<p className="text-gray-900 font-medium">
{formatDate(project.completion_date)}

View File

@@ -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)
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
{t('projects.finishDate')}
Data wpływu
</label>
<Input
type="date"
name="start_date"
value={formatDateForInput(form.start_date)}
onChange={handleChange}
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
Termin zakończenia
</label>
<Input
type="date"
@@ -304,7 +321,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
Data zakończenia projektu
Data odbioru
</label>
<Input
type="date"

View File

@@ -289,6 +289,14 @@ export default function initializeDatabase() {
// Column already exists, ignore error
}
try {
db.exec(`
ALTER TABLE projects ADD COLUMN start_date TEXT;
`);
} catch (e) {
// Column already exists, ignore error
}
// Migration: Update task status system - add 'not_started' status
// DISABLED: This migration was running on every init and converting legitimate
// 'pending' tasks back to 'not_started'. The initial migration has been completed.

View File

@@ -75,9 +75,9 @@ export function createProject(data, userId = null) {
const stmt = db.prepare(`
INSERT INTO projects (
contract_id, project_name, project_number, address, plot, district, unit, city, investment_number, finish_date, completion_date,
contract_id, project_name, project_number, address, plot, district, unit, city, investment_number, start_date, finish_date, completion_date,
wp, contact, notes, wartosc_zlecenia, project_type, project_status, coordinates, created_by, assigned_to, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now', 'localtime'), datetime('now', 'localtime'))
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now', 'localtime'), datetime('now', 'localtime'))
`);
const result = stmt.run(
@@ -90,6 +90,7 @@ export function createProject(data, userId = null) {
data.unit,
data.city,
data.investment_number,
data.start_date || null,
data.finish_date,
data.completion_date,
data.wp,
@@ -110,7 +111,7 @@ export function updateProject(id, data, userId = null) {
const stmt = db.prepare(`
UPDATE projects SET
contract_id = ?, project_name = ?, project_number = ?, address = ?, plot = ?, district = ?, unit = ?, city = ?,
investment_number = ?, finish_date = ?, completion_date = ?, wp = ?, contact = ?, notes = ?, wartosc_zlecenia = ?, project_type = ?, project_status = ?,
investment_number = ?, start_date = ?, finish_date = ?, completion_date = ?, wp = ?, contact = ?, notes = ?, wartosc_zlecenia = ?, project_type = ?, project_status = ?,
coordinates = ?, assigned_to = ?, updated_at = CURRENT_TIMESTAMP
WHERE project_id = ?
`);
@@ -124,6 +125,7 @@ export function updateProject(id, data, userId = null) {
data.unit,
data.city,
data.investment_number,
data.start_date || null,
data.finish_date,
data.completion_date,
data.wp,