Skip to content

Commit

Permalink
Renamed endpoints and variables in code to "consultant" for generic u… (
Browse files Browse the repository at this point in the history
  • Loading branch information
yelodevopsi authored Oct 16, 2023
1 parent 5121a98 commit 6511984
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions backend/Api/Consultants/ConsultantController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Api.Consultants;

[Route("v0/variants")]
[Route("v0/consultants")]
[ApiController]
public class ConsultantController : ControllerBase
{
Expand Down Expand Up @@ -42,23 +42,23 @@ public ActionResult<List<ConsultantReadModel>> Get(

[HttpPost]
public async Task<Results<Created<ConsultantWriteModel>, 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
{
Expand Down Expand Up @@ -137,13 +137,13 @@ private static async Task<List<Consultant>> 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
};
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/mockdata/mockConsultants.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion frontend/mockdata/mockDepartments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Department, Variant } from "@/types";
import { Department, Consultant } from "@/types";

export const MockDepartments: Department[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/bemanning/page.tsx
Original file line number Diff line number Diff line change
@@ -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<Variant[]>("variants")) ?? [];
const consultants = (await fetchWithToken<Consultant[]>("consultants")) ?? [];

return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/ConsultantListElement.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/FilteredConsultantsList.tsx
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/data/fetchWithToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function fetchWithToken<T>(path: string): Promise<T | undefined> {

function mockedCall<T>(path: string): Promise<T> {
return new Promise((resolve) => {
if (path.includes("variants")) {
if (path.includes("consultants")) {
resolve(MockConsultants as T);
}
if (path.includes("departments")) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PopoverVirtualElement } from "@mui/material";

export type Variant = {
export type Consultant = {
id: string;
name: string;
email: string;
Expand Down

0 comments on commit 6511984

Please sign in to comment.