diff --git a/backend/Api/Consultants/ConsultantController.cs b/backend/Api/Consultants/ConsultantController.cs index 76a2830b..525194fc 100644 --- a/backend/Api/Consultants/ConsultantController.cs +++ b/backend/Api/Consultants/ConsultantController.cs @@ -9,7 +9,7 @@ namespace Api.Consultants; -[Route("v0/variants")] +[Route("v0/consultants")] [ApiController] public class ConsultantController : ControllerBase { @@ -42,23 +42,23 @@ public ActionResult> Get( [HttpPost] public async Task, ProblemHttpResult, ValidationProblem>> AddBasicConsultant( - [FromBody] ConsultantWriteModel basicVariant) + [FromBody] ConsultantWriteModel basicConsultant) { try { - var selectedDepartment = await GetDepartmentByIdAsync(basicVariant.DepartmentId); + var selectedDepartment = await GetDepartmentByIdAsync(basicConsultant.DepartmentId); if (selectedDepartment == null) return TypedResults.Problem("Department does not exist", statusCode: 400); var consultantList = await GetAllConsultantsAsync(_context); - var validationResults = ConsultantValidators.ValidateUniqueness(consultantList, basicVariant); + var validationResults = ConsultantValidators.ValidateUniqueness(consultantList, basicConsultant); if (validationResults.Count > 0) return TypedResults.ValidationProblem(validationResults); - var newConsultant = CreateConsultantFromModel(basicVariant, selectedDepartment); + var newConsultant = CreateConsultantFromModel(basicConsultant, selectedDepartment); await AddConsultantToDatabaseAsync(_context, newConsultant); ClearConsultantCache(); - return TypedResults.Created($"/variant/{newConsultant.Id}", basicVariant); + return TypedResults.Created($"/consultant/{newConsultant.Id}", basicConsultant); } catch { @@ -137,13 +137,13 @@ private static async Task> GetAllConsultantsAsync(ApplicationCo return await db.Consultant.ToListAsync(); } - private static Consultant CreateConsultantFromModel(ConsultantWriteModel basicVariant, + private static Consultant CreateConsultantFromModel(ConsultantWriteModel basicConsultant, Department selectedDepartment) { return new Consultant { - Name = basicVariant.Name, - Email = basicVariant.Email, + Name = basicConsultant.Name, + Email = basicConsultant.Email, Department = selectedDepartment }; } diff --git a/frontend/mockdata/mockConsultants.ts b/frontend/mockdata/mockConsultants.ts index 33b5bced..1a7a52d0 100644 --- a/frontend/mockdata/mockConsultants.ts +++ b/frontend/mockdata/mockConsultants.ts @@ -1,6 +1,6 @@ -import { Variant } from "@/types"; +import { Consultant } from "@/types"; -export const MockConsultants: Variant[] = [ +export const MockConsultants: Consultant[] = [ { id: "id", name: "Test Consultant", diff --git a/frontend/mockdata/mockDepartments.ts b/frontend/mockdata/mockDepartments.ts index 7a0120bb..aa2d3db0 100644 --- a/frontend/mockdata/mockDepartments.ts +++ b/frontend/mockdata/mockDepartments.ts @@ -1,4 +1,4 @@ -import { Department, Variant } from "@/types"; +import { Department, Consultant } from "@/types"; export const MockDepartments: Department[] = [ { diff --git a/frontend/src/app/bemanning/page.tsx b/frontend/src/app/bemanning/page.tsx index 1dde0df2..2901efb0 100644 --- a/frontend/src/app/bemanning/page.tsx +++ b/frontend/src/app/bemanning/page.tsx @@ -1,9 +1,9 @@ import FilteredConsultantsList from "@/components/FilteredConsultantsList"; import { fetchWithToken } from "@/data/fetchWithToken"; -import { Variant } from "@/types"; +import { Consultant } from "@/types"; export default async function Bemanning() { - const consultants = (await fetchWithToken("variants")) ?? []; + const consultants = (await fetchWithToken("consultants")) ?? []; return (
diff --git a/frontend/src/components/ConsultantListElement.tsx b/frontend/src/components/ConsultantListElement.tsx index 80316e05..87e99e0f 100644 --- a/frontend/src/components/ConsultantListElement.tsx +++ b/frontend/src/components/ConsultantListElement.tsx @@ -1,10 +1,10 @@ "use client"; -import { Variant } from "@/types"; +import { Consultant } from "@/types"; import { useState } from "react"; import { ChevronDown } from "react-feather"; interface ConsultantListElementProps { - consultant: Variant; + consultant: Consultant; } export default function ConsultantListElement({ diff --git a/frontend/src/components/FilteredConsultantsList.tsx b/frontend/src/components/FilteredConsultantsList.tsx index f615f262..7232d0a5 100644 --- a/frontend/src/components/FilteredConsultantsList.tsx +++ b/frontend/src/components/FilteredConsultantsList.tsx @@ -1,13 +1,13 @@ "use client"; import { useEffect, useState } from "react"; import ConsultantListElement from "./ConsultantListElement"; -import { Variant } from "@/types"; +import { Consultant } from "@/types"; import { useSearchParams } from "next/navigation"; export default function FilteredConsultantList({ consultants, }: { - consultants: Variant[]; + consultants: Consultant[]; }) { const searchParams = useSearchParams(); const search = searchParams.get("search"); diff --git a/frontend/src/data/fetchWithToken.ts b/frontend/src/data/fetchWithToken.ts index 41591fbd..55fb36f6 100644 --- a/frontend/src/data/fetchWithToken.ts +++ b/frontend/src/data/fetchWithToken.ts @@ -32,7 +32,7 @@ export async function fetchWithToken(path: string): Promise { function mockedCall(path: string): Promise { return new Promise((resolve) => { - if (path.includes("variants")) { + if (path.includes("consultants")) { resolve(MockConsultants as T); } if (path.includes("departments")) { diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 1310ea7a..923ca1d8 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -1,6 +1,6 @@ import { PopoverVirtualElement } from "@mui/material"; -export type Variant = { +export type Consultant = { id: string; name: string; email: string;