Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fikser bug der variabel i søknads-api-tekstene ikke ble erstattet #760

Merged
merged 4 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {replaceNavkontor} from "./BehandlingAvPersonopplysningerModal";

describe("regex for modal", () => {
siljee marked this conversation as resolved.
Show resolved Hide resolved
it("skal rendre 'NAV-kontoret ditt'", () => {
const tekst = "{navkontor:NAV-kontoret ditt}";
expect(replaceNavkontor(tekst)).toEqual("NAV-kontoret ditt");
});

it("skal rendre valgt enhetsnavn", () => {
const tekst = "{navkontor:NAV-kontoret ditt}";
expect(replaceNavkontor(tekst, "NAV Oslo")).toEqual("NAV Oslo");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import {Soknadsdata} from "../redux/soknadsdata/soknadsdataReducer";
import {State} from "../redux/reducers";
import {visSamtykkeInfo} from "../redux/soknad/soknadActions";

export const replaceNavkontor = (text: string, valgtEnhetsNavn?: string) => {
// Hvis ikke valgtEnhetsNavn finnes, erstattes søkestrengen med capture-gruppa ([\w\s-]*)
// som er 1 eller fler bokstaver, whitespace eller '-', feks "NAV-kontoret ditt" fra søknads-api-tekstene
return text.replace(/{navkontor:([\w\s-]*)}/g, valgtEnhetsNavn ? valgtEnhetsNavn : "$1");
};
const getText = (soknadsdata: Soknadsdata, text: string) => {
const valgtEnhetsNavn = finnValgtEnhetsNavn(soknadsdata);
return text.replace(/{navkontor:(.*)}/g, valgtEnhetsNavn ? valgtEnhetsNavn : "$1");
return replaceNavkontor(text, valgtEnhetsNavn);
};

const BehandlingAvPersonopplysningerModal = () => {
Expand Down