Skip to content

Commit

Permalink
Show options just for new project (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
oddsve authored May 6, 2024
1 parent f2f9713 commit 8a3f1ba
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 30 deletions.
2 changes: 0 additions & 2 deletions backend/Api/Projects/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ public ActionResult<ProjectWithCustomerModel> 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)
Expand Down
10 changes: 6 additions & 4 deletions backend/Tests/AbsenceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -51,9 +54,8 @@ public void AvailabilityCalculation(int vacationDays, double plannedAbsenceHours
Id = 1,
Name = "Test Variant",
Email = "[email protected]",
Department = department,
GraduationYear = 2010,

Department = department
};

var mondayDateOnly = numberOfHolidays switch
Expand Down Expand Up @@ -151,8 +153,8 @@ public void MultiplePlannedAbsences()
Id = 1,
Name = "Test Variant",
Email = "[email protected]",
Department = department,
GraduationYear = 2010,
Department = department
};

var week = new Week(2000, 1);
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/Staffing/AddEngagementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function AddEngagementForm({
useState<SelectOption | null>(null);

const [_, setProject] = useState<ProjectWithCustomerModel | undefined>();
const [isNewProject, setIsNewProject] = useState(false);

const customerOptions = customers.map(
(c) =>
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -172,7 +178,7 @@ export function AddEngagementForm({
</div>
</div>

{!isAbsence && (
{isNewProject && (
<>
{/* Radio Button Group */}

Expand Down
50 changes: 27 additions & 23 deletions frontend/src/components/Staffing/ConsultantRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ export default function ConsultantRows({
: "border-l-primary/5"
} `}
></td>
<AddEngagementForm
closeEngagementModal={handleNewEngagement}
consultant={currentConsultant}
/>
<td>
<AddEngagementForm
closeEngagementModal={handleNewEngagement}
consultant={currentConsultant}
/>
</td>
</tr>
)}

Expand All @@ -247,27 +249,29 @@ export default function ConsultantRows({
: "border-l-primary/5"
} `}
></td>
{!addNewRow && (
<button
onClick={() => {
setAddNewRow(true);
setIsDisabledHotkeys(true);
}}
className="flex flex-row items-center min-w-max gap-2 h-[52px]"
onMouseEnter={() => setIsAddStaffingHovered(true)}
onMouseLeave={() => setIsAddStaffingHovered(false)}
>
<span
className={`w-8 h-8 flex justify-center items-center rounded bg-primary/0 ${
isAddStaffingHovered && "bg-primary/10"
}`}
<td>
{!addNewRow && (
<button
onClick={() => {
setAddNewRow(true);
setIsDisabledHotkeys(true);
}}
className="flex flex-row items-center min-w-max gap-2 h-[52px]"
onMouseEnter={() => setIsAddStaffingHovered(true)}
onMouseLeave={() => setIsAddStaffingHovered(false)}
>
<Plus size={16} className="text-primary" />
</span>
<span
className={`w-8 h-8 flex justify-center items-center rounded bg-primary/0 ${
isAddStaffingHovered && "bg-primary/10"
}`}
>
<Plus size={16} className="text-primary" />
</span>

<p className="small text-primary">Legg til bemanning</p>
</button>
)}
<p className="small text-primary">Legg til bemanning</p>
</button>
)}
</td>
</tr>
)}
</>
Expand Down

0 comments on commit 8a3f1ba

Please sign in to comment.