From 8a3f1baf5689e0754e9581db37b99cc854e65963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Morten=20Sve=C3=A5s?= Date: Mon, 6 May 2024 12:27:19 +0200 Subject: [PATCH] Show options just for new project (#462) --- backend/Api/Projects/ProjectController.cs | 2 - backend/Tests/AbsenceTest.cs | 10 ++-- .../components/Staffing/AddEngagementForm.tsx | 8 ++- .../src/components/Staffing/ConsultantRow.tsx | 50 ++++++++++--------- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/backend/Api/Projects/ProjectController.cs b/backend/Api/Projects/ProjectController.cs index 8a689957..792fdc86 100644 --- a/backend/Api/Projects/ProjectController.cs +++ b/backend/Api/Projects/ProjectController.cs @@ -228,9 +228,7 @@ public ActionResult Put([FromRoute] string orgUrlKey, var project = _context.Project .Include(p => p.Customer) .SingleOrDefault(p => p.Customer.Name == body.CustomerName - && p.IsBillable == body.IsBillable && p.Name == body.ProjectName - && p.State == body.BookingType ); if (project is null) diff --git a/backend/Tests/AbsenceTest.cs b/backend/Tests/AbsenceTest.cs index c14c23fe..b664a486 100644 --- a/backend/Tests/AbsenceTest.cs +++ b/backend/Tests/AbsenceTest.cs @@ -19,7 +19,10 @@ public class Tests [TestCase(0, 0, 0, 37.5, 0)] [TestCase(0, 0, 0, 30, 7.5)] [TestCase(0, 7.5, 0, 22.5, 7.5)] - public void AvailabilityCalculation(int vacationDays, double plannedAbsenceHours, int numberOfHolidays, + public void AvailabilityCalculation( + int vacationDays, + double plannedAbsenceHours, + int numberOfHolidays, double staffedHours, double expectedSellableHours) { @@ -51,9 +54,8 @@ public void AvailabilityCalculation(int vacationDays, double plannedAbsenceHours Id = 1, Name = "Test Variant", Email = "tv@v.no", - Department = department, GraduationYear = 2010, - + Department = department }; var mondayDateOnly = numberOfHolidays switch @@ -151,8 +153,8 @@ public void MultiplePlannedAbsences() Id = 1, Name = "Test Variant", Email = "tv@v.no", - Department = department, GraduationYear = 2010, + Department = department }; var week = new Week(2000, 1); diff --git a/frontend/src/components/Staffing/AddEngagementForm.tsx b/frontend/src/components/Staffing/AddEngagementForm.tsx index c2e7f1a6..38126e1a 100644 --- a/frontend/src/components/Staffing/AddEngagementForm.tsx +++ b/frontend/src/components/Staffing/AddEngagementForm.tsx @@ -34,6 +34,7 @@ export function AddEngagementForm({ useState(null); const [_, setProject] = useState(); + const [isNewProject, setIsNewProject] = useState(false); const customerOptions = customers.map( (c) => @@ -73,6 +74,11 @@ export function AddEngagementForm({ } function handleSelectedEngagementChange(newValue: SelectOption) { + console.log(projectOptions); + console.log(newValue); + if (!projectOptions.map((o) => o.label).includes(newValue.label)) { + setIsNewProject(true); + } setSelectedEngagement(newValue); } @@ -172,7 +178,7 @@ export function AddEngagementForm({ - {!isAbsence && ( + {isNewProject && ( <> {/* Radio Button Group */} diff --git a/frontend/src/components/Staffing/ConsultantRow.tsx b/frontend/src/components/Staffing/ConsultantRow.tsx index 586d60dd..a028f554 100644 --- a/frontend/src/components/Staffing/ConsultantRow.tsx +++ b/frontend/src/components/Staffing/ConsultantRow.tsx @@ -229,10 +229,12 @@ export default function ConsultantRows({ : "border-l-primary/5" } `} > - + + + )} @@ -247,27 +249,29 @@ export default function ConsultantRows({ : "border-l-primary/5" } `} > - {!addNewRow && ( - - )} +

Legg til bemanning

+ + )} + )}