diff --git a/migrate-add-wartosc-zlecenia.mjs b/migrate-add-wartosc-zlecenia.mjs
new file mode 100644
index 0000000..4478a6b
--- /dev/null
+++ b/migrate-add-wartosc-zlecenia.mjs
@@ -0,0 +1,36 @@
+import db from './src/lib/db.js';
+
+console.log('Starting migration to add wartosc_zlecenia field to projects table...');
+
+try {
+ // Check if wartosc_zlecenia column already exists
+ const schema = db.prepare("PRAGMA table_info(projects)").all();
+ const hasWartoscZleceniaColumn = schema.some(column => column.name === 'wartosc_zlecenia');
+
+ if (hasWartoscZleceniaColumn) {
+ console.log("✅ wartosc_zlecenia column already exists in projects table");
+ } else {
+ // Add the wartosc_zlecenia column
+ db.prepare("ALTER TABLE projects ADD COLUMN wartosc_zlecenia REAL").run();
+ console.log("✅ Added 'wartosc_zlecenia' column to projects table");
+ }
+
+ // Verify the column was added
+ const updatedSchema = db.prepare("PRAGMA table_info(projects)").all();
+ const wartoscZleceniaColumn = updatedSchema.find(column => column.name === 'wartosc_zlecenia');
+
+ if (wartoscZleceniaColumn) {
+ console.log("✅ Migration completed successfully");
+ console.log(`Column details: ${JSON.stringify(wartoscZleceniaColumn, null, 2)}`);
+ } else {
+ console.error("❌ Migration failed - wartosc_zlecenia column not found");
+ process.exit(1);
+ }
+
+ db.close();
+ console.log("Database connection closed");
+
+} catch (error) {
+ console.error("❌ Migration failed:", error.message);
+ process.exit(1);
+}
\ No newline at end of file
diff --git a/run-migrations.sh b/run-migrations.sh
index 4c05ad5..e186b6e 100644
--- a/run-migrations.sh
+++ b/run-migrations.sh
@@ -8,6 +8,7 @@ echo "🔄 Running database migrations..."
# List of migration scripts to run (in order)
MIGRATIONS=(
"migrate-add-team-lead-role.mjs"
+ "migrate-add-wartosc-zlecenia.mjs"
)
for migration in "${MIGRATIONS[@]}"; do
diff --git a/src/app/projects/[id]/page.js b/src/app/projects/[id]/page.js
index 29db470..7a8e38b 100644
--- a/src/app/projects/[id]/page.js
+++ b/src/app/projects/[id]/page.js
@@ -421,6 +421,19 @@ export default function ProjectViewPage() {
{project.investment_number || "N/A"}
+ {session?.user?.role === 'team_lead' && project.wartosc_zlecenia && (
+
+
+ Wartość zlecenia
+
+
+ {parseFloat(project.wartosc_zlecenia).toLocaleString('pl-PL', {
+ style: 'currency',
+ currency: 'PLN'
+ })}
+
+
+ )}
{project.contact && (
diff --git a/src/components/ProjectForm.js b/src/components/ProjectForm.js
index e0373d4..3fa325b 100644
--- a/src/components/ProjectForm.js
+++ b/src/components/ProjectForm.js
@@ -2,6 +2,7 @@
import { useState, useEffect, forwardRef, useImperativeHandle } from "react";
import { useRouter } from "next/navigation";
+import { useSession } from "next-auth/react";
import { Card, CardHeader, CardContent } from "@/components/ui/Card";
import Button from "@/components/ui/Button";
import { Input } from "@/components/ui/Input";
@@ -10,6 +11,7 @@ import { useTranslation } from "@/lib/i18n";
const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref) {
const { t } = useTranslation();
+ const { data: session } = useSession();
const [form, setForm] = useState({
contract_id: "",
project_name: "",
@@ -24,6 +26,7 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
contact: "",
notes: "",
coordinates: "",
+ wartosc_zlecenia: "",
project_type: "design",
assigned_to: "",
});
@@ -63,12 +66,14 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
contact: "",
notes: "",
coordinates: "",
+ wartosc_zlecenia: "",
project_type: "design",
assigned_to: "",
...initialData,
// Ensure these defaults are preserved if not in initialData
project_type: initialData.project_type || "design",
assigned_to: initialData.assigned_to || "",
+ wartosc_zlecenia: initialData.wartosc_zlecenia || "",
// Format finish_date for input if it exists
finish_date: initialData.finish_date
? formatDateForInput(initialData.finish_date)
@@ -325,6 +330,23 @@ const ProjectForm = forwardRef(function ProjectForm({ initialData = null }, ref)
/>
+ {session?.user?.role === 'team_lead' && (
+
+
+
+
+ )}
+