Skip to content

Commit

Permalink
feat: change anrede text field to dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dh4x committed Jan 10, 2025
1 parent cc074e6 commit f404c27
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ describe("getFullPlaintiffName", () => {
});

it("should return the full plaintiff name given the anrede, vorname and nachname", () => {
const actual = getFullPlaintiffName("Herr", undefined, "Test", "Test");
const actual = getFullPlaintiffName("herr", undefined, "Test", "Test");

expect(actual).toEqual("Herr Test Test");
});

it("should return the full plaintiff name without anrede if anrede is none, vorname and nachname", () => {
const actual = getFullPlaintiffName("none", undefined, "Test", "Test");

expect(actual).toEqual("Test Test");
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import capitalize from "lodash/capitalize";
import { uppercaseFirstLetter } from "~/util/strings";

export const getFullPlaintiffName = (
anrede?: string,
Expand All @@ -7,9 +8,10 @@ export const getFullPlaintiffName = (
nachname?: string,
) => {
const mappedTitle = title === "dr" ? "Dr." : title;
const salutation = anrede !== "none" ? uppercaseFirstLetter(anrede) : "";
const capitalizedVorname = capitalize(vorname);

return [anrede, mappedTitle, capitalizedVorname, nachname]
return [salutation, mappedTitle, capitalizedVorname, nachname]
.filter(Boolean)
.join(" ");
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { uppercaseFirstLetter } from "~/util/strings";
import { getStringWithSpaceIfStringExists } from "./getStringWithSpaceIfStringExists";
import { type FluggastrechtContext } from "../../formular/context";

export const NO_SPECIFICATION = "Keine Angabe";
export const FLOW_ID = "/fluggastrechte/formular";

export const getPersonData = (userData: FluggastrechtContext) => {
const address = `${getStringWithSpaceIfStringExists(userData.anrede) + getStringWithSpaceIfStringExists(userData.title) + getStringWithSpaceIfStringExists(userData.vorname) + getStringWithSpaceIfStringExists(userData.nachname)}\n${userData.strasseHausnummer}\n${userData.plz} ${userData.ort}`;
const anrede =
userData.anrede !== "none" ? uppercaseFirstLetter(userData.anrede) : "";
const address = `${getStringWithSpaceIfStringExists(anrede) + getStringWithSpaceIfStringExists(userData.title) + getStringWithSpaceIfStringExists(userData.vorname) + getStringWithSpaceIfStringExists(userData.nachname)}\n${userData.strasseHausnummer}\n${userData.plz} ${userData.ort}`;
return {
person: address,
telefonnummer: userData.telefonnummer || NO_SPECIFICATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function startFluggastrechteFormular(
await formular.clickNext();

// /fluggastrechte/formular/persoenliche-daten/person/daten
await formular.fillInput("anrede", "Herr");
await formular.fillDropdown("anrede", "herr");
await formular.fillDropdown("title", "");
await formular.fillInput("nachname", "Donatello");
await formular.fillInput("vorname", "Cowabunga");
Expand Down

0 comments on commit f404c27

Please sign in to comment.