diff --git a/apps/fp-avdelingsleder/src/app/Dekorator.tsx b/apps/fp-avdelingsleder/src/app/Dekorator.tsx index 618a87cf36c..1106be0e116 100644 --- a/apps/fp-avdelingsleder/src/app/Dekorator.tsx +++ b/apps/fp-avdelingsleder/src/app/Dekorator.tsx @@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'; import type { Theme } from '@navikt/ds-react'; import { FellesDekorator, type QueryStrings } from '@navikt/fp-app-felles'; -import { AVDELINGSLEDER_URL_NAME, FPSAK_URL_NAME } from '@navikt/fp-konstanter'; +import { getFpSakLenke } from '@navikt/fp-konstanter'; import { type DekoratorLenke } from '@navikt/fp-sak-dekorator'; interface Props { @@ -24,8 +24,7 @@ export const Dekorator = (props: Props) => { const interneLenker: DekoratorLenke[] = [ { tekst: intl.formatMessage({ id: 'Dekorator.Foreldrepenger' }), - callback: () => - (globalThis.location.href = globalThis.location.href.replace(AVDELINGSLEDER_URL_NAME, FPSAK_URL_NAME)), + callback: () => (globalThis.location.href = getFpSakLenke()), }, ]; diff --git a/apps/fp-frontend/src/app/components/Dekorator.tsx b/apps/fp-frontend/src/app/components/Dekorator.tsx index 2aab9bb7ac0..8a4756a0c3c 100644 --- a/apps/fp-frontend/src/app/components/Dekorator.tsx +++ b/apps/fp-frontend/src/app/components/Dekorator.tsx @@ -6,7 +6,7 @@ import type { Theme } from '@navikt/ds-react'; import { useQuery } from '@tanstack/react-query'; import { FellesDekorator, type QueryStrings } from '@navikt/fp-app-felles'; -import { AVDELINGSLEDER_URL_NAME, FPSAK_URL_NAME, JOURNALFORING_URL_NAME } from '@navikt/fp-konstanter'; +import { getAvdelingslederLenke, getJournalføringLenke } from '@navikt/fp-konstanter'; import { type DekoratorLenke } from '@navikt/fp-sak-dekorator'; import { notEmpty } from '@navikt/fp-utils'; @@ -44,15 +44,13 @@ export const Dekorator = (props: Props) => { if (kanOppgavestyre) { interneLenker.push({ tekst: intl.formatMessage({ id: 'Dekorator.Avdelingsleder' }), - callback: () => - (globalThis.location.href = globalThis.location.href.replace(FPSAK_URL_NAME, AVDELINGSLEDER_URL_NAME)), + callback: () => (globalThis.location.href = getAvdelingslederLenke()), }); } if (kanSaksbehandle) { interneLenker.push({ tekst: intl.formatMessage({ id: 'Dekorator.Journalforing' }), - callback: () => - (globalThis.location.href = globalThis.location.href.replace(FPSAK_URL_NAME, JOURNALFORING_URL_NAME)), + callback: () => (globalThis.location.href = getJournalføringLenke()), }); } interneLenker.push({ diff --git a/apps/fp-journalforing/src/app/Dekorator.tsx b/apps/fp-journalforing/src/app/Dekorator.tsx index 2d92e3d741a..b6b1d59e667 100644 --- a/apps/fp-journalforing/src/app/Dekorator.tsx +++ b/apps/fp-journalforing/src/app/Dekorator.tsx @@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'; import type { Theme } from '@navikt/ds-react'; import { FellesDekorator, type QueryStrings } from '@navikt/fp-app-felles'; -import { FPSAK_URL_NAME, JOURNALFORING_URL_NAME } from '@navikt/fp-konstanter'; +import { getFpSakLenke } from '@navikt/fp-konstanter'; import { type DekoratorLenke } from '@navikt/fp-sak-dekorator'; interface Props { @@ -24,8 +24,7 @@ export const Dekorator = (props: Props) => { const interneLenker: DekoratorLenke[] = [ { tekst: intl.formatMessage({ id: 'Dekorator.Foreldrepenger' }), - callback: () => - (globalThis.location.href = globalThis.location.href.replace(JOURNALFORING_URL_NAME, FPSAK_URL_NAME)), + callback: () => (globalThis.location.href = getFpSakLenke()), }, ]; diff --git a/apps/fp-journalforing/src/components/journalpost/innhold/SakDetaljer.tsx b/apps/fp-journalforing/src/components/journalpost/innhold/SakDetaljer.tsx index 7db1c2d3a6b..56987c785bc 100644 --- a/apps/fp-journalforing/src/components/journalpost/innhold/SakDetaljer.tsx +++ b/apps/fp-journalforing/src/components/journalpost/innhold/SakDetaljer.tsx @@ -5,6 +5,7 @@ import { ExternalLinkIcon } from '@navikt/aksel-icons'; import { Button, CopyButton, Detail, HStack, Label, Spacer, Tag, type TagProps, VStack } from '@navikt/ds-react'; import { dateFormat } from '@navikt/ft-utils'; +import { getFpSakLenke } from '@navikt/fp-konstanter'; import type { FagsakStatus, FamilieHendelseType } from '@navikt/fp-types'; import type { FamilieHendelse, JournalFagsak } from '../../../typer/journalFagsakTsType'; @@ -74,7 +75,7 @@ export const SakDetaljer = ({ sak }: Props) => { ); }; -const velgSakLenke = (saksnummer: string): string => `/fagsak/${saksnummer}/`; +const velgSakLenke = (saksnummer: string): string => `${getFpSakLenke()}/fagsak/${saksnummer}/`; const finnTagProps = (statusKode: FagsakStatus): TagProps | null => { switch (statusKode) { diff --git "a/apps/fp-journalforing/src/components/journalpost/modal/Journalf\303\270rtSubmitModal.tsx" "b/apps/fp-journalforing/src/components/journalpost/modal/Journalf\303\270rtSubmitModal.tsx" index a6b259c9044..8e40ea6f1fa 100644 --- "a/apps/fp-journalforing/src/components/journalpost/modal/Journalf\303\270rtSubmitModal.tsx" +++ "b/apps/fp-journalforing/src/components/journalpost/modal/Journalf\303\270rtSubmitModal.tsx" @@ -4,11 +4,13 @@ import { CheckmarkCircleIcon } from '@navikt/aksel-icons'; import { BodyShort, Button, HStack, Link, Modal, VStack } from '@navikt/ds-react'; import { LoadingPanel } from '@navikt/ft-ui-komponenter'; +import { getFpSakLenke } from '@navikt/fp-konstanter'; + import type { SaksnummerType } from '../../../typer/saksnummerTsType'; import styles from './journalførtSubmitModal.module.css'; -const velgSakLenke = (saksnummer: string): string => `/fagsak/${saksnummer}/`; +const velgSakLenke = (saksnummer: string): string => `${getFpSakLenke()}/fagsak/${saksnummer}/`; type Props = Readonly<{ saksnummer?: SaksnummerType; diff --git a/packages/konstanter/index.ts b/packages/konstanter/index.ts index ace52328194..8ad9267384f 100644 --- a/packages/konstanter/index.ts +++ b/packages/konstanter/index.ts @@ -2,7 +2,6 @@ export { ProsessStegCode } from './src/prosessStegCodes'; export { FaktaPanelCode } from './src/faktaPanelCodes'; export { ApiPollingStatus } from './src/apiPollingStatus'; export { skjermlenkeCodes, skjermlenkeCodesFpTilbake } from './src/skjermlenkeCodes'; -export { JOURNALFORING_URL_NAME, FPSAK_URL_NAME, AVDELINGSLEDER_URL_NAME } from './src/appnavn'; export { LINK_TIL_BESTE_BEREGNING_REGNEARK, @@ -15,4 +14,7 @@ export { getModiaUrl, hentDokumentLenke, hentVedtakDokumentLenke, + getFpSakLenke, + getJournalføringLenke, + getAvdelingslederLenke, } from './src/eksterneLenker'; diff --git a/packages/konstanter/src/appnavn.ts b/packages/konstanter/src/appnavn.ts deleted file mode 100644 index da68ad086e4..00000000000 --- a/packages/konstanter/src/appnavn.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const FPSAK_URL_NAME = 'fpsak'; -export const AVDELINGSLEDER_URL_NAME = 'fpavdelingsleder'; -export const JOURNALFORING_URL_NAME = 'fpjournalforing'; diff --git a/packages/konstanter/src/eksterneLenker.ts b/packages/konstanter/src/eksterneLenker.ts index 4f6d7533dad..e47e82d2c81 100644 --- a/packages/konstanter/src/eksterneLenker.ts +++ b/packages/konstanter/src/eksterneLenker.ts @@ -22,3 +22,25 @@ export const hentDokumentLenke = (saksnummer: string, journalpostId: string, dok export const hentVedtakDokumentLenke = (behandlingUuid: string): string => `/fpsak/api/vedtak/hent-vedtaksdokument?behandlingId=${behandlingUuid}`; + +const FPSAK_URL_NAME = 'fpsak'; +const AVDELINGSLEDER_URL_NAME = 'fpavdelingsleder'; +const JOURNALFORING_URL_NAME = 'fpjournalforing'; + +export const getAvdelingslederLenke = () => + removePathAndQuery(globalThis.location.href.replace(FPSAK_URL_NAME, AVDELINGSLEDER_URL_NAME)); + +export const getJournalføringLenke = () => + removePathAndQuery(globalThis.location.href.replace(FPSAK_URL_NAME, JOURNALFORING_URL_NAME)); + +export const getFpSakLenke = () => + removePathAndQuery( + globalThis.location.href + .replace(JOURNALFORING_URL_NAME, FPSAK_URL_NAME) + .replace(AVDELINGSLEDER_URL_NAME, FPSAK_URL_NAME), + ); + +const removePathAndQuery = (url: string): string => { + const urlObj = new URL(url); + return `${urlObj.protocol}//${urlObj.host}`; +};