diff --git a/packages/v2/backend/package.json b/packages/v2/backend/package.json index c7030da4b0..fa4311f464 100644 --- a/packages/v2/backend/package.json +++ b/packages/v2/backend/package.json @@ -19,6 +19,6 @@ "dependencies": { "@navikt/k9-klage-typescript-client": "1.0.20240513162434-997f3da", "@navikt/k9-sak-typescript-client": "1.0.20241028110915", - "@navikt/ung-sak-typescript-client": "0.1.20241220134118" + "@navikt/ung-sak-typescript-client": "0.1.20250103103622" } } diff --git a/packages/v2/gui/src/prosess/ung-vedtak/UngVedtak.tsx b/packages/v2/gui/src/prosess/ung-vedtak/UngVedtak.tsx index c289a20853..8941e7b644 100644 --- a/packages/v2/gui/src/prosess/ung-vedtak/UngVedtak.tsx +++ b/packages/v2/gui/src/prosess/ung-vedtak/UngVedtak.tsx @@ -1,8 +1,4 @@ -import { - behandlingResultatType, - type AksjonspunktDto, - type ForhåndsvisVedtaksbrevResponse, -} from '@k9-sak-web/backend/ungsak/generated'; +import { behandlingResultatType, type AksjonspunktDto } from '@k9-sak-web/backend/ungsak/generated'; import { FileSearchIcon } from '@navikt/aksel-icons'; import { BodyShort, Box, Button, Fieldset, HStack, Label, VStack } from '@navikt/ds-react'; import { CheckboxField, Form } from '@navikt/ft-form-hooks'; @@ -45,14 +41,13 @@ export const UngVedtak = ({ api, behandling, aksjonspunkter, submitCallback, vil const { refetch, isLoading: forhåndsvisningIsLoading } = useQuery({ queryKey: ['forhandsvisVedtaksbrev', behandling.id], - queryFn: () => - api.forhåndsvisVedtaksbrev(behandling.id).then((response: ForhåndsvisVedtaksbrevResponse) => { - // Create a URL object from the PDF blob - const fileURL = window.URL.createObjectURL(new Blob([response.data], { type: 'application/pdf' })); - - // Open the PDF in a new tab - window.open(fileURL, '_blank'); - }), + queryFn: async () => { + const response = await api.forhåndsvisVedtaksbrev(behandling.id); + // Create a URL object from the PDF blob + const fileURL = window.URL.createObjectURL(response); + // Open the PDF in a new tab + window.open(fileURL, '_blank'); + }, enabled: false, }); diff --git a/packages/v2/gui/src/prosess/ung-vedtak/UngVedtakBackendClient.ts b/packages/v2/gui/src/prosess/ung-vedtak/UngVedtakBackendClient.ts index d08e11b6ee..78c29519ee 100644 --- a/packages/v2/gui/src/prosess/ung-vedtak/UngVedtakBackendClient.ts +++ b/packages/v2/gui/src/prosess/ung-vedtak/UngVedtakBackendClient.ts @@ -1,5 +1,4 @@ import type { ForhåndsvisVedtaksbrevResponse, UngSakClient } from '@k9-sak-web/backend/ungsak/generated'; -import axios from 'axios'; export default class UngVedtakBackendClient { #ungsak: UngSakClient; @@ -9,16 +8,6 @@ export default class UngVedtakBackendClient { } async forhåndsvisVedtaksbrev(behandlingId: number): Promise { - // return this.#ungsak.formidling.forhåndsvisVedtaksbrev({ behandlingId }); - return axios.post( - 'http://localhost:9005/ung/sak/api/formidling/vedtaksbrev/forhaandsvis', - { behandlingId }, - { - headers: { - Accept: 'application/pdf', - }, - responseType: 'blob' - }, - ); + return this.#ungsak.formidling.forhåndsvisVedtaksbrev({ behandlingId }); } } diff --git a/packages/v2/gui/src/storybook/mocks/FakeUngVedtakBackendApi.ts b/packages/v2/gui/src/storybook/mocks/FakeUngVedtakBackendApi.ts index 4c1c29ec5a..02a12ad0d4 100644 --- a/packages/v2/gui/src/storybook/mocks/FakeUngVedtakBackendApi.ts +++ b/packages/v2/gui/src/storybook/mocks/FakeUngVedtakBackendApi.ts @@ -1,7 +1,8 @@ import type { ForhåndsvisVedtaksbrevResponse } from '@k9-sak-web/backend/ungsak/generated'; +import { fakePdf } from './fakePdf.js'; export class FakeUngVedtakBackendApi { async forhåndsvisVedtaksbrev(): Promise { - return; + return fakePdf(); } } diff --git a/yarn.lock b/yarn.lock index 6424857cec..120fbfe969 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3935,7 +3935,7 @@ __metadata: dependencies: "@navikt/k9-klage-typescript-client": 1.0.20240513162434-997f3da "@navikt/k9-sak-typescript-client": 1.0.20241028110915 - "@navikt/ung-sak-typescript-client": 0.1.20241220134118 + "@navikt/ung-sak-typescript-client": 0.1.20250103103622 languageName: unknown linkType: soft @@ -5451,10 +5451,10 @@ __metadata: languageName: node linkType: hard -"@navikt/ung-sak-typescript-client@npm:0.1.20241220134118": - version: 0.1.20241220134118 - resolution: "@navikt/ung-sak-typescript-client@npm:0.1.20241220134118::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40navikt%2Fung-sak-typescript-client%2F0.1.20241220134118%2F783667e56032d75cc5f1d69a86664a7e50e60d15" - checksum: 15bf6686d6b30485e90dbd113184bc75383e2e721cd772169cf9cd9e0b181d9d0a040a865bba5e321c10877d813de1ac0804c814a6efdf58663576b88c9fe1d6 +"@navikt/ung-sak-typescript-client@npm:0.1.20250103103622": + version: 0.1.20250103103622 + resolution: "@navikt/ung-sak-typescript-client@npm:0.1.20250103103622::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40navikt%2Fung-sak-typescript-client%2F0.1.20250103103622%2F553036253ddfd19e6e781ebf1da4a736dd747039" + checksum: 1e1552188bd2e9f19e355e29e97f1ee6100dc7f6eb20e474ac49b38e6c57bdbe78f7041fd9c936351fc4c9f58e3f6321c2fff8f93225146ebacbdaa8a6ffbf8a languageName: node linkType: hard