Skip to content

Commit

Permalink
mapped enum to correct types to fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
md committed Nov 20, 2024
1 parent 0a78cdb commit 688737d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions frontend/src/components/Staffing/ConsultantRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,31 @@ export default function ConsultantRows({
const organisationUrl = usePathname().split("/")[1];

function getStatusConsultant(consultant: ConsultantReadModel) {
const statuses = consultant.detailedBooking.map(
(e) => e.bookingDetails.agreementStatus,
const statuses = consultant.detailedBooking.map((e) =>
stringToAgreementStatus(e.bookingDetails.agreementStatus),
);
const mapped = statuses
.filter((e) => e !== undefined)
.map((el: string) => AgreementStatus[el as keyof typeof AgreementStatus]);

if (statuses) {
if (mapped.includes(AgreementStatus.None)) {
if (statuses.includes(AgreementStatus.None)) {
return "red";
} else if (mapped.includes(AgreementStatus.Expired)) {
} else if (statuses.includes(AgreementStatus.Expired)) {
return "orange";
} else {
return null;
}
}
}

function stringToAgreementStatus(status: string | undefined) {
if (status === "Active") {
return AgreementStatus.Active;
} else if (status === "Expired") {
return AgreementStatus.Expired;
} else {
return AgreementStatus.None;
}
}

useEffect(() => {
async function fetchProject() {
const url = `/${organisationUrl}/bemanning/api/projects?projectId=${selectedProjectId}`;
Expand Down

0 comments on commit 688737d

Please sign in to comment.