Skip to content

Commit 7373392

Browse files
Flytter notat i sak inn i v2 (#7014)
* Flytter notat i sak inn i v2 Gjør nødvendige justeringer * Fiks * Oppdaterer loosely type * Oppdaterer importer fra generert ts-typer * Bruker genererte endepunkter for kommunikasjon med backend * Fikser refetching * Tar bort ubrukt kode * Bruker den genererte backendklienten et sted til * Oppdateringer etter code review --------- Co-authored-by: Thomas H. Wiberg <[email protected]>
1 parent ec80255 commit 7373392

29 files changed

+443
-480
lines changed

loosely-type-checked-files.json

-2
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,6 @@
500500
"packages/sak-meny-sett-pa-vent/src/MenySettPaVentIndex.tsx",
501501
"packages/sak-meny-ta-av-vent/src/MenyTaAvVentIndex.tsx",
502502
"packages/sak-meny-verge/src/MenyVergeIndex.tsx",
503-
"packages/sak-notat/src/NotatISakIndex.stories.tsx",
504-
"packages/sak-notat/src/NotaterIndex.tsx",
505503
"packages/sak-sok/src/components/FagsakList.spec.tsx",
506504
"packages/sak-sok/src/components/FagsakList.tsx",
507505
"packages/sak-sok/src/components/SearchForm.spec.tsx",

packages/rest-api/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import RequestApiMock from './src/requestApi/RequestApiMock';
55
import RequestConfig from './src/RequestConfig';
66

77
export { default as AbstractRequestApi } from './src/requestApi/AbstractRequestApi';
8-
export { default as apiPaths } from './src/requestApi/apiPaths';
98
export type { default as ErrorType } from './src/requestApi/error/errorTsType';
109
export { ErrorTypes, errorOfType, getErrorResponseData } from './src/requestApi/error/ErrorTypes';
1110
export type { default as Link } from './src/requestApi/LinkTsType';

packages/rest-api/src/requestApi/apiPaths.ts

-5
This file was deleted.

packages/sak-app/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@k9-sak-web/sak-behandling-velger": "1.0.0",
3939
"@k9-sak-web/sak-meldinger": "1.0.0",
4040
"@k9-sak-web/sak-meny-marker-behandling": "1.0.0",
41-
"@k9-sak-web/sak-notat": "1.0.0",
4241
"@k9-sak-web/types": "1.0.0",
4342
"@navikt/ds-react": "7.10.0",
4443
"@navikt/ft-fakta-beregning": "^8.2.2",

packages/sak-app/src/behandlingsupport/BehandlingSupportIndex.tsx

+6-23
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import { httpErrorHandler } from '@fpsak-frontend/utils';
1+
import { kjønn } from '@k9-sak-web/backend/k9sak/kodeverk/Kjønn.js';
22
import { FormidlingClientContext } from '@k9-sak-web/gui/app/FormidlingClientContext.js';
33
import { K9SakClientContext } from '@k9-sak-web/gui/app/K9SakClientContext.js';
44
import MeldingerBackendClient from '@k9-sak-web/gui/sak/meldinger/MeldingerBackendClient.js';
5-
import { apiPaths } from '@k9-sak-web/rest-api';
6-
import { useRestApiErrorDispatcher } from '@k9-sak-web/rest-api-hooks';
5+
import NotatBackendClient from '@k9-sak-web/gui/sak/notat/NotatBackendClient.js';
76
import {
87
ArbeidsgiverOpplysningerWrapper,
98
BehandlingAppKontekst,
109
Fagsak,
1110
FeatureToggles,
1211
NavAnsatt,
13-
NotatResponse,
1412
Personopplysninger,
1513
} from '@k9-sak-web/types';
1614
import {
@@ -27,7 +25,6 @@ import {
2725
} from '@navikt/aksel-icons';
2826
import { BodyShort, Tabs, Tooltip } from '@navikt/ds-react';
2927
import { useQuery } from '@tanstack/react-query';
30-
import axios from 'axios';
3128
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
3229
import { useNavigate } from 'react-router';
3330
import { getSupportPanelLocationCreator } from '../app/paths';
@@ -37,10 +34,9 @@ import styles from './behandlingSupportIndex.module.css';
3734
import DokumentIndex from './dokument/DokumentIndex';
3835
import HistorikkIndex from './historikk/HistorikkIndex';
3936
import MeldingIndex from './melding/MeldingIndex';
40-
import NotaterIndex from './notater/NotaterIndex';
37+
import Notater from './notater/Notater';
4138
import SupportTabs from './supportTabs';
4239
import TotrinnskontrollIndex from './totrinnskontroll/TotrinnskontrollIndex';
43-
import { kjønn } from '@k9-sak-web/backend/k9sak/kodeverk/Kjønn.js';
4440

4541
export const hentSynligePaneler = (behandlingRettigheter?: BehandlingRettigheter): string[] =>
4642
Object.values(SupportTabs).filter(supportPanel => {
@@ -160,12 +156,12 @@ const BehandlingSupportIndex = ({
160156
navAnsatt,
161157
featureToggles,
162158
}: OwnProps) => {
163-
const { addErrorMessage } = useRestApiErrorDispatcher();
164159
const [antallUlesteNotater, setAntallUlesteNotater] = useState(0);
165160

166161
const k9SakClient = useContext(K9SakClientContext);
167162
const formidlingClient = useContext(FormidlingClientContext);
168163
const meldingerBackendClient = new MeldingerBackendClient(k9SakClient, formidlingClient);
164+
const notatBackendClient = new NotatBackendClient(k9SakClient);
169165
const [toTrinnskontrollFormState, setToTrinnskontrollFormState] = useState(undefined);
170166

171167
const currentResetValue = `${fagsak.saksnummer}-${behandlingId}-${personopplysninger?.aktoerId}`;
@@ -178,23 +174,10 @@ const BehandlingSupportIndex = ({
178174
prevResetValue.current = currentResetValue;
179175
}, [currentResetValue]);
180176

181-
const getNotater = (signal: AbortSignal) =>
182-
axios
183-
.get<NotatResponse[]>(apiPaths.notatISak, {
184-
signal,
185-
params: {
186-
saksnummer: fagsak.saksnummer,
187-
},
188-
})
189-
.then(({ data }) => data)
190-
.catch(error => {
191-
httpErrorHandler(error?.response?.status, addErrorMessage, error?.response?.headers?.location);
192-
});
193-
194177
const notaterQueryKey = ['notater', fagsak?.saksnummer];
195178
const { data: notater } = useQuery({
196179
queryKey: notaterQueryKey,
197-
queryFn: ({ signal }) => getNotater(signal),
180+
queryFn: () => notatBackendClient.getNotater(fagsak.saksnummer),
198181
enabled: !!fagsak,
199182
refetchOnWindowFocus: false,
200183
});
@@ -337,7 +320,7 @@ const BehandlingSupportIndex = ({
337320
/>
338321
</Tabs.Panel>
339322
<Tabs.Panel value={SupportTabs.NOTATER}>
340-
<NotaterIndex navAnsatt={navAnsatt} fagsak={fagsak} />
323+
<Notater navAnsatt={navAnsatt} fagsak={fagsak} />
341324
</Tabs.Panel>
342325
</div>
343326
</div>
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
import { LoadingPanel, requireProps } from '@fpsak-frontend/shared-components';
2-
import Notater from '@k9-sak-web/sak-notat';
3-
import { Fagsak, NavAnsatt } from '@k9-sak-web/types';
4-
import React from 'react';
5-
import ErrorBoundary from '@k9-sak-web/sak-app/src/app/ErrorBoundary';
1+
import { LoadingPanel } from '@fpsak-frontend/shared-components';
2+
import NotaterIndex from '@k9-sak-web/gui/sak/notat/NotaterIndex.js';
63
import { useRestApiErrorDispatcher } from '@k9-sak-web/rest-api-hooks';
4+
import ErrorBoundary from '@k9-sak-web/sak-app/src/app/ErrorBoundary';
5+
import { Fagsak } from '@k9-sak-web/types';
6+
import { InnloggetAnsattDto } from '@navikt/k9-sak-typescript-client';
77

88
interface OwnProps {
9-
navAnsatt: NavAnsatt;
9+
navAnsatt: Pick<InnloggetAnsattDto, 'brukernavn'>;
1010
fagsak: Fagsak;
1111
}
1212

1313
/**
14-
* NotaterIndex
14+
* Notater
1515
*
1616
* Container komponent. Har ansvar for å vise notater i saken.
1717
*/
18-
export const NotaterIndex = ({ fagsak, navAnsatt }: OwnProps) => {
18+
const Notater = ({ fagsak, navAnsatt }: OwnProps) => {
1919
const { addErrorMessage } = useRestApiErrorDispatcher();
20-
20+
if (!fagsak) {
21+
return <LoadingPanel />;
22+
}
2123
return (
2224
<ErrorBoundary errorMessageCallback={addErrorMessage}>
23-
<Notater
25+
<NotaterIndex
2426
fagsakId={fagsak.saksnummer}
2527
navAnsatt={navAnsatt}
2628
fagsakHarPleietrengende={!!fagsak.pleietrengendeAktørId}
2729
/>
2830
</ErrorBoundary>
2931
);
3032
};
31-
export default requireProps(['fagsak'], <LoadingPanel />)(NotaterIndex);
33+
export default Notater;

packages/sak-notat/i18n/nb_NO.json

-17
This file was deleted.

packages/sak-notat/index.ts

-1
This file was deleted.

packages/sak-notat/package.json

-20
This file was deleted.

packages/sak-notat/src/NotatISakIndex.stories.tsx

-123
This file was deleted.

0 commit comments

Comments
 (0)