Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added internal customer name and filtered on that for alert icons #551

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 5 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,20 @@ 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";
Loading