Skip to content

Commit

Permalink
added internal customer name and filtered on that for alert icons
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaBonde committed Dec 10, 2024
1 parent 956b93b commit f94108a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/src/app/[organisation]/prosjekt/[project]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { parseYearWeekFromUrlString } from "@/data/urlUtils";
import { fetchWorkHoursPerWeek } from "@/hooks/fetchWorkHoursPerDay";
import EditEngagementName from "@/components/EditEngagementName";
import { AgreementEdit } from "@/components/Agreement/AgreementEdit";
import { INTERNAL_CUSTOMER_NAME } from "@/components/Staffing/helpers/utils";

export default async function Project({
params,
Expand Down Expand Up @@ -40,7 +41,7 @@ export default async function Project({
}${weekSpan ? `${selectedWeek ? "&" : "?"}WeekSpan=${weekSpan}` : ""}`,
)) ?? [];

const isInternalProject = project?.customerName === "Variant";
const isInternalProject = project?.customerName === INTERNAL_CUSTOMER_NAME;

if (project) {
return (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/ChangeEngagementState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { useState } from "react";
import FilterButton from "./Buttons/FilterButton";
import { usePathname, useRouter } from "next/navigation";
import { INTERNAL_CUSTOMER_NAME } from "./Staffing/helpers/utils";

export default function ChangeEngagementState({
project,
Expand All @@ -22,7 +23,7 @@ export default function ChangeEngagementState({
project.bookingType,
);

const isInternalProject = project.customerName === "Variant";
const isInternalProject = project.customerName === INTERNAL_CUSTOMER_NAME;

async function handleChange(newState: EngagementState) {
setEngagementState(newState);
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/Staffing/ConsultantRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { setDetailedBookingHours } from "./NewDetailedBookingRow";
import { FilteredContext } from "@/hooks/ConsultantFilterProvider";
import { DateTime } from "luxon";
import Image from "next/image";
import { INTERNAL_CUSTOMER_NAME } from "./helpers/utils";

export default function ConsultantRows({
consultant,
Expand Down Expand Up @@ -159,7 +160,9 @@ export default function ConsultantRows({
const dates = consultant.detailedBooking
.filter(
(e) =>
e.bookingDetails.projectId > 0 && e.bookingDetails.type == "Booking",
e.bookingDetails.projectId > 0 &&
e.bookingDetails.type == "Booking" &&
e.bookingDetails.customerName != INTERNAL_CUSTOMER_NAME,
)
.map((e) => e.bookingDetails.endDateAgreement);

Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/Staffing/DetailedBookingRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React, { useContext, useEffect, useRef, useState } from "react";
import {
getColorByStaffingType,
getIconByBookingType,
INTERNAL_CUSTOMER_NAME,
updateProjects,
upsertConsultantBooking,
} from "@/components/Staffing/helpers/utils";
Expand Down Expand Up @@ -115,18 +116,19 @@ export function DetailedBookingRows(props: {
async function getColorIcon() {
const bookingType = detailedBooking.bookingDetails.type;
const endDateString = detailedBooking.bookingDetails.endDateAgreement;
const isInternal = detailedBooking.bookingDetails.customerName == INTERNAL_CUSTOMER_NAME;
if (endDateString && endDateString !== null) {
const endDate = new Date(endDateString).getTime();

const today = new Date().getTime();

if (today > endDate && bookingType == "Booking") {
if (today > endDate && bookingType == "Booking" && !isInternal) {
return setAlertColor(colors.find((c) => c.color == "orange"));
} else {
return setAlertColor(colors.find((c) => c.color == "green"));
}
} else {
if (endDateString === null && bookingType == "Booking") {
if (endDateString === null && bookingType == "Booking" && !isInternal) {
return setAlertColor(colors.find((c) => c.color == "red"));
} else {
return setAlertColor(colors.find((c) => c.color == "transparent"));
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/Staffing/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,5 @@ export function updateProjects(

return [...old];
}

export const INTERNAL_CUSTOMER_NAME = "Variant";

0 comments on commit f94108a

Please sign in to comment.