Skip to content

Commit

Permalink
Merge branch 'main' into add-new-flow-for-annulierung-klage
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschlote authored Jan 10, 2025
2 parents 297383c + 9237cbf commit 624312d
Show file tree
Hide file tree
Showing 78 changed files with 252 additions and 241 deletions.
2 changes: 1 addition & 1 deletion app/components/BoxWithImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BoxWithImage = ({
content,
}: BoxWithImageProps) => {
const shouldWrapByDefault = variant === "XL" || variant === "XXL";
const hasTextContent = Boolean(heading || content);
const hasTextContent = Boolean(heading ?? content);
return (
<div
id={identifier}
Expand Down
2 changes: 1 addition & 1 deletion app/components/LinkListBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type LinkListBoxProps = {
identifier?: string;
label?: HeadingProps;
heading?: HeadingProps;
links?: { text?: string; url?: string }[];
links?: Array<{ text?: string; url?: string }>;
buttons?: ButtonProps[];
};

Expand Down
2 changes: 1 addition & 1 deletion app/components/PageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function cmsToReact(strapiContent: StrapiContentComponent) {
}

type PageContentProps = {
readonly content: Array<StrapiContentComponent>;
readonly content: StrapiContentComponent[];
readonly fullScreen?: boolean;
readonly className?: string;
};
Expand Down
28 changes: 12 additions & 16 deletions app/components/__test__/MigrationDataOverview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("MigrationDataOverview", () => {
);

expect(container).not.toBeEmptyDOMElement();
expect(getByText(translations["bereich"])).toBeInTheDocument();
expect(getByText(translations.bereich)).toBeInTheDocument();
expect(getByText(translations["bereich.verspaetet"])).toBeInTheDocument();
});

Expand All @@ -52,7 +52,7 @@ describe("MigrationDataOverview", () => {
);

expect(container).not.toBeEmptyDOMElement();
expect(getByText(translations["startAirport"])).toBeInTheDocument();
expect(getByText(translations.startAirport)).toBeInTheDocument();
expect(getByText(translations["startAirport.value"])).toBeInTheDocument();
});

Expand All @@ -77,19 +77,15 @@ describe("MigrationDataOverview", () => {
);

expect(container).not.toBeEmptyDOMElement();
expect(getByText(translations.zustaendigesAmtsgericht)).toBeInTheDocument();
expect(
getByText(translations["zustaendigesAmtsgericht"]),
getByText(migrationUserData.zustaendigesAmtsgericht.bezeichnung),
).toBeInTheDocument();
expect(
getByText(migrationUserData["zustaendigesAmtsgericht"].bezeichnung),
getByText(migrationUserData.zustaendigesAmtsgericht.strasseMitHausnummer),
).toBeInTheDocument();
expect(
getByText(
migrationUserData["zustaendigesAmtsgericht"].strasseMitHausnummer,
),
).toBeInTheDocument();
expect(
getByText(migrationUserData["zustaendigesAmtsgericht"].plzUndStadt),
getByText(migrationUserData.zustaendigesAmtsgericht.plzUndStadt),
).toBeInTheDocument();
});

Expand Down Expand Up @@ -118,15 +114,15 @@ describe("MigrationDataOverview", () => {
);

expect(queryAllByTestId("migration-field-value")[0].textContent).toEqual(
translations["startAirport"],
translations.startAirport,
);

expect(queryAllByTestId("migration-field-value")[1].textContent).toEqual(
translations["endAirport"],
translations.endAirport,
);

expect(queryAllByTestId("migration-field-value")[2].textContent).toEqual(
translations["bereich"],
translations.bereich,
);
});

Expand Down Expand Up @@ -155,15 +151,15 @@ describe("MigrationDataOverview", () => {
);

expect(queryAllByTestId("migration-field-value")[0].textContent).toEqual(
translations["bereich"],
translations.bereich,
);

expect(queryAllByTestId("migration-field-value")[1].textContent).toEqual(
translations["startAirport"],
translations.startAirport,
);

expect(queryAllByTestId("migration-field-value")[2].textContent).toEqual(
translations["endAirport"],
translations.endAirport,
);
});

Expand Down
4 changes: 2 additions & 2 deletions app/components/form/ButtonNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ type NavigationButton = {
label: string;
};

export interface ButtonNavigationProps {
export type ButtonNavigationProps = {
readonly back?: NavigationButton;
readonly next?: NavigationButton;
}
};

export function ButtonNavigation({ back, next }: ButtonNavigationProps) {
return (
Expand Down
4 changes: 2 additions & 2 deletions app/components/form/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
interface ProgressBarProps {
type ProgressBarProps = {
readonly progress?: number;
readonly max?: number;
readonly fallback?: string;
readonly label?: string;
}
};

export function ProgressBar({
progress,
Expand Down
4 changes: 3 additions & 1 deletion app/components/form/__test__/ValidatedFlowForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ describe("ValidatedFlowForm", () => {
});
});

function renderValidatedFlowForm(formElements: Partial<StrapiFormComponent>[]) {
function renderValidatedFlowForm(
formElements: Array<Partial<StrapiFormComponent>>,
) {
const router = createMemoryRouter([
{
path: "/",
Expand Down
4 changes: 2 additions & 2 deletions app/components/inputs/HiddenInput.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useField } from "remix-validated-form";

interface Props {
type Props = {
name: string;
formId?: string;
}
};

const HiddenInput = ({ formId, name }: Props) => {
const { getInputProps } = useField(name, { formId });
Expand Down
4 changes: 2 additions & 2 deletions app/components/inputs/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import Radio from "./Radio";

type RadioGroupProps = Readonly<{
name: string;
options: {
options: Array<{
value: string;
text?: ReactNode;
}[];
}>;
label?: ReactNode;
altLabel?: string;
errorMessages?: ErrorMessageProps[];
Expand Down
2 changes: 1 addition & 1 deletion app/components/inputs/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { widthClassname } from "./width";

export type SelectProps = {
name: string;
options: { value: string; text: string }[];
options: Array<{ value: string; text: string }>;
label?: ReactNode;
altLabel?: string;
placeholder?: string;
Expand Down
4 changes: 2 additions & 2 deletions app/components/userFeedback/FeedbackFormBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export const feedbackValidator = withZod(
}),
);

export interface FeedbackBoxProps {
export type FeedbackBoxProps = {
readonly destination: string;
readonly shouldFocus: boolean;
readonly onSubmit: () => void;
}
};

export const FeedbackFormBox = ({
destination,
Expand Down
4 changes: 2 additions & 2 deletions app/components/userFeedback/PostSubmissionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useFeedbackTranslations } from "./feedbackTranslations";
import Heading from "../Heading";
import RichText from "../RichText";

interface Props {
type Props = {
readonly shouldFocus: boolean;
}
};

export const PostSubmissionBox = ({ shouldFocus }: Props) => {
const feedbackTranslations = useFeedbackTranslations();
Expand Down
4 changes: 2 additions & 2 deletions app/components/userFeedback/RatingBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import Heading from "../Heading";

export const userRatingFieldname = "wasHelpful";

export interface RatingBoxProps {
export type RatingBoxProps = {
readonly heading: string;
readonly url: string;
readonly onSubmit: () => void;
}
};

export const RatingBox = ({ heading, url, onSubmit }: RatingBoxProps) => {
const ratingFetcher = useFetcher();
Expand Down
2 changes: 1 addition & 1 deletion app/domains/__test__/TestCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export type TestCases<
| FluggastrechtVorabcheckContext
| FluggastrechtContext
| ProzesskostenhilfeFormularContext,
> = Readonly<Array<Readonly<[T, Readonly<Array<string>>]>>>;
> = Readonly<Array<Readonly<[T, readonly string[]]>>>;
2 changes: 1 addition & 1 deletion app/domains/__test__/flows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function getEnabledSteps({
machine: FlowStateMachine;
context: Context;
transitionType: "SUBMIT" | "BACK";
steps: Readonly<Array<string>>;
steps: readonly string[];
}) {
const initialStep = steps[0];
const reachableSteps = steps.slice(0, -1).map((step) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "~/domains/shared/formular/persoenlicheDaten/context";

export const beratungshilfePersoenlicheDaten = {
...omit(persoenlicheDaten, ["anrede", "title"]),
...omit(persoenlicheDaten, ["title"]),
geburtsdatum,
};

Expand Down
4 changes: 3 additions & 1 deletion app/domains/beratungshilfe/vorabcheck/isIncomeTooHigh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const isIncomeTooHigh: GenericGuard<BeratungshilfeVorabcheckContext> = ({
const miete = moneyToCents(context.miete) ?? 0;
const zahlungen = moneyToCents(context.weitereZahlungenSumme) ?? 0;
const unterhalt =
(context.unterhalt == "yes" && moneyToCents(context.unterhaltSumme)) || 0;
context.unterhalt == "yes"
? (moneyToCents(context.unterhaltSumme) ?? 0)
: 0;

const calculatedFreibetrag = calculateFreibetrag({
working: context.erwerbstaetigkeit === "yes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const machine: FlowStateMachine = createMachine(
const cases = [
[
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand All @@ -31,7 +31,7 @@ const cases = [
],
[
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand All @@ -49,7 +49,7 @@ const cases = [
],
[
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand All @@ -58,7 +58,7 @@ const cases = [
isWeiterePersonen: "yes",
weiterePersonen: [
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand All @@ -78,7 +78,7 @@ const cases = [
],
[
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand All @@ -87,7 +87,7 @@ const cases = [
isWeiterePersonen: "yes",
weiterePersonen: [
{
anrede: "mr",
anrede: "herr",
vorname: "test",
nachname: "test",
strasseHausnummer: "test",
Expand Down
11 changes: 9 additions & 2 deletions app/domains/fluggastrechte/formular/persoenlicheDaten/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@ import { optionalOrSchema } from "~/services/validation/optionalOrSchema";
import { stringOptionalSchema } from "~/services/validation/stringOptional";
import { YesNoAnswer } from "~/services/validation/YesNoAnswer";

const anredeSchema = z.enum(["herr", "frau", "none"]);

export const persoenlicheDatenSchema = {
anrede: anredeSchema,
...persoenlicheDaten,
};

export const paymentDetailsSchema = {
iban: optionalOrSchema(ibanSchema),
kontoinhaber: stringOptionalSchema,
};

export const fluggastrechtePersoenlichDaten = {
...persoenlicheDaten,
...persoenlicheDatenSchema,
isWeiterePersonen: YesNoAnswer,
hasZeugen: YesNoAnswer,
...paymentDetailsSchema,
weiterePersonen: z.array(
z
.object({
...persoenlicheDaten,
...persoenlicheDatenSchema,
buchungsnummer: optionalOrSchema(bookingNumberFlightSchema),
})
.partial(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const userDataMock = {
ersatzFlugAnkunftsZeit: "10:10",
zusaetzlicheAngaben:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
anrede: "Fr.",
anrede: "herr",
title: "",
vorname: "Test-Test",
nachname: "Test",
Expand Down
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
Expand Up @@ -21,7 +21,7 @@ describe("addPlaintiffDetails", () => {

expect(mockDoc.fontSize).toHaveBeenCalledWith(10);
expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_BOLD);
expect(mockDoc.text).toHaveBeenCalledWith("Fr. Test-test Test", {
expect(mockDoc.text).toHaveBeenCalledWith("Herr Test-test Test", {
continued: true,
});
expect(mockDoc.font).toHaveBeenCalledWith(FONTS_BUNDESSANS_REGULAR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export const getFullPlaintiffName = (
nachname?: string,
) => {
const mappedTitle = title === "dr" ? "Dr." : title;
const salutation = anrede !== "none" ? capitalize(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
Expand Up @@ -59,7 +59,7 @@ describe("createLegalAssessment", () => {
const mockDoc = mockPdfKitDocument(mockStruct);
createLegalAssessment(mockDoc, mockStruct, userDataMock);

expect(mockDoc.text).toHaveBeenCalledWith("Fr. Test-test Test");
expect(mockDoc.text).toHaveBeenCalledWith("Herr Test-test Test");
});

it("should call function addNewPageInCaseMissingVerticalSpace twice", () => {
Expand Down
Loading

0 comments on commit 624312d

Please sign in to comment.