feat: add completion_date field to projects and update related functionalities in forms and queries
This commit is contained in:
@@ -405,6 +405,16 @@ export default function ProjectViewPage() {
|
||||
currentValue={project.finish_date}
|
||||
label="Termin zakończenia"
|
||||
/>
|
||||
{project.completion_date && (
|
||||
<div>
|
||||
<span className="text-sm font-medium text-gray-500 block mb-1">
|
||||
Data zakończenia projektu
|
||||
</span>
|
||||
<p className="text-gray-900 font-medium">
|
||||
{formatDate(project.completion_date)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<span className="text-sm font-medium text-gray-500 block mb-1">
|
||||
WP
|
||||
|
||||
@@ -22,6 +22,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
|
||||
city: "",
|
||||
investment_number: "",
|
||||
finish_date: "",
|
||||
completion_date: "",
|
||||
wp: "",
|
||||
contact: "",
|
||||
notes: "",
|
||||
@@ -62,6 +63,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
|
||||
city: "",
|
||||
investment_number: "",
|
||||
finish_date: "",
|
||||
completion_date: "",
|
||||
wp: "",
|
||||
contact: "",
|
||||
notes: "",
|
||||
@@ -74,10 +76,13 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
|
||||
project_type: initialData.project_type || "design",
|
||||
assigned_to: initialData.assigned_to || "",
|
||||
wartosc_zlecenia: initialData.wartosc_zlecenia || "",
|
||||
// Format finish_date for input if it exists
|
||||
// Format dates for input if they exist
|
||||
finish_date: initialData.finish_date
|
||||
? formatDateForInput(initialData.finish_date)
|
||||
: "",
|
||||
completion_date: initialData.completion_date
|
||||
? formatDateForInput(initialData.completion_date)
|
||||
: "",
|
||||
});
|
||||
}
|
||||
}, [initialData]);
|
||||
@@ -295,6 +300,18 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
Data zakończenia projektu
|
||||
</label>
|
||||
<Input
|
||||
type="date"
|
||||
name="completion_date"
|
||||
value={formatDateForInput(form.completion_date)}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export default function initializeDatabase() {
|
||||
city TEXT,
|
||||
investment_number TEXT,
|
||||
finish_date TEXT,
|
||||
completion_date TEXT,
|
||||
wp TEXT,
|
||||
contact TEXT,
|
||||
notes TEXT,
|
||||
@@ -280,6 +281,14 @@ export default function initializeDatabase() {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE projects ADD COLUMN completion_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.
|
||||
|
||||
@@ -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,
|
||||
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, 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(
|
||||
@@ -91,6 +91,7 @@ export function createProject(data, userId = null) {
|
||||
data.city,
|
||||
data.investment_number,
|
||||
data.finish_date,
|
||||
data.completion_date,
|
||||
data.wp,
|
||||
data.contact,
|
||||
data.notes,
|
||||
@@ -109,7 +110,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 = ?, wp = ?, contact = ?, notes = ?, wartosc_zlecenia = ?, project_type = ?, project_status = ?,
|
||||
investment_number = ?, 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.city,
|
||||
data.investment_number,
|
||||
data.finish_date,
|
||||
data.completion_date,
|
||||
data.wp,
|
||||
data.contact,
|
||||
data.notes,
|
||||
|
||||
Reference in New Issue
Block a user