Skip to content

Commit

Permalink
feat(forderung): add templated subheading
Browse files Browse the repository at this point in the history
Co-Authored-By: Frederike Ramin <[email protected]>
Co-Authored-By: SannyNguyenHung <[email protected]>
  • Loading branch information
3 people committed Oct 16, 2023
1 parent 9847abc commit 574dae4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/routes/geld-einklagen.formular.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { buildStepValidator } from "~/models/flows/common";
import { CSRFKey } from "~/services/security/csrfKey";
import Heading from "~/components/Heading";
import { fillTemplate } from "~/util/fillTemplate";
export { action, loader } from "~/routes/shared/step";

export default function Step() {
Expand All @@ -21,6 +22,7 @@ export default function Step() {
defaultValues,
commonContent,
heading,
preHeading,
content,
formContent,
isLast,
Expand All @@ -43,6 +45,14 @@ export default function Step() {
<Container paddingTop="24">
<div className="ds-stack-16">
<div className="ds-stack-40">
{preHeading && (
<p>
{fillTemplate({
template: preHeading,
replacements: templateReplacements,
})}
</p>
)}
<Heading text={heading} look="ds-heading-02-reg" />
<PageContent
content={content}
Expand Down
15 changes: 15 additions & 0 deletions app/routes/shared/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@ export const loader = async ({
getVerfuegbaresEinkommenFreibetrag(data);
const gerichtskostenvorschuss = getGerichtskostenvorschuss(data);

const forderungReplacements =
"forderung" in data
? {
forderung1Betrag: data.forderung.forderung1.betrag,

Check warning on line 62 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe assignment of an `any` value

Check warning on line 62 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe member access .forderung1 on an `any` value
forderung1Title: data.forderung.forderung1.title,

Check warning on line 63 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe assignment of an `any` value

Check warning on line 63 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe member access .forderung1 on an `any` value
forderung2Betrag: data.forderung.forderung2.betrag,

Check warning on line 64 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe assignment of an `any` value

Check warning on line 64 in app/routes/shared/step.tsx

View workflow job for this annotation

GitHub Actions / code-quality / npm run eslint:check

Unsafe member access .forderung2 on an `any` value
forderung2Title: data.forderung.forderung2.title,
}
: {};

const templateReplacements = {
verfuegbaresEinkommenFreibetrag: verfuegbaresEinkommenFreibetrag.toString(),
gerichtskostenvorschuss: gerichtskostenvorschuss.toString(),
...forderungReplacements,
};

const [commonContent, formPageContent, parentMeta] = await Promise.all([
Expand Down Expand Up @@ -107,6 +118,10 @@ export const loader = async ({
commonContent,
heading:
"heading" in formPageContent ? formPageContent.heading : undefined,
preHeading:
"preHeading" in formPageContent
? formPageContent.preHeading
: undefined,
content: formPageContent.pre_form,
formContent: formPageContent.form,
meta,
Expand Down
1 change: 1 addition & 0 deletions app/services/cms/models/StrapiFormFlowPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { HasStrapiTimestampsSchema } from "./HasStrapiTimestamps";
export const StrapiFormFlowPageSchema = z
.object({
heading: z.string(),
preHeading: z.string().nullable(),
// eslint-disable-next-line camelcase
pre_form: z.array(StrapiContentSchema),
form: z.array(StrapiFormComponentSchema),
Expand Down

0 comments on commit 574dae4

Please sign in to comment.