feat: add wartosc_zlecenia field to projects table and update related functionalities
This commit is contained in:
@@ -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)
|
||||
/>
|
||||
</div>
|
||||
|
||||
{session?.user?.role === 'team_lead' && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
Wartość zlecenia
|
||||
</label>
|
||||
<Input
|
||||
type="number"
|
||||
name="wartosc_zlecenia"
|
||||
value={form.wartosc_zlecenia || ""}
|
||||
onChange={handleChange}
|
||||
placeholder="0.00"
|
||||
step="0.01"
|
||||
min="0"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
{t('projects.contact')}
|
||||
|
||||
Reference in New Issue
Block a user