Skip to content

Commit f000783

Browse files
retter no-floating-promises i ung-sak-web
1 parent ee21170 commit f000783

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

packages/ung/sak-app/app/components/DashboardResolver.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const DashboardResolver = ({ intl }: WrappedComponentProps) => {
4040
addErrorMessage(intl.formatMessage({ id: 'DashboardResolver.FpLosErNede' }));
4141
}
4242
};
43-
gotoLosOrSetErrorMsg();
43+
void gotoLosOrSetErrorMsg();
4444
}, []);
4545

4646
return !isDevelopment() && isLoading ? <LoadingPanel /> : <FagsakSearchIndex />;

packages/ung/sak-app/behandling/BehandlingIndex.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const getOppdaterProsessStegOgFaktaPanelIUrl =
4949
newLocation = getFaktaLocation(newLocation)(null);
5050
}
5151

52-
navigate(newLocation);
52+
void navigate(newLocation);
5353
};
5454

5555
interface OwnProps {

packages/ung/sak-app/behandlingmenu/BehandlingMenuIndex.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,16 @@ export const BehandlingMenuIndex = ({
104104

105105
const ref = useRef<number>(undefined);
106106
useEffect(() => {
107-
// Når antallet har endret seg er det laget en ny behandling og denne må da velges
108-
if (ref.current > 0) {
109-
const pathname = pathToBehandling(fagsak.saksnummer, findNewBehandlingId(alleBehandlinger));
110-
navigate(getLocationWithDefaultProsessStegAndFakta({ ...location, pathname }));
111-
}
107+
const asyncEffect = async () => {
108+
// Når antallet har endret seg er det laget en ny behandling og denne må da velges
109+
if (ref.current > 0) {
110+
const pathname = pathToBehandling(fagsak.saksnummer, findNewBehandlingId(alleBehandlinger));
111+
await navigate(getLocationWithDefaultProsessStegAndFakta({ ...location, pathname }));
112+
}
112113

113-
ref.current = alleBehandlinger.length;
114+
ref.current = alleBehandlinger.length;
115+
};
116+
void asyncEffect();
114117
}, [alleBehandlinger.length]);
115118

116119
const { startRequest: sjekkTilbakeKanOpprettes, data: kanBehandlingOpprettes = false } =
@@ -147,9 +150,10 @@ export const BehandlingMenuIndex = ({
147150

148151
const fagsakPerson = restApiHooks.useGlobalStateRestApiData<FagsakPerson>(UngSakApiKeys.SAK_BRUKER);
149152

150-
const lagNyBehandling = useCallback((bTypeKode: string, params: any) => {
153+
const lagNyBehandling = useCallback(async (bTypeKode: string, params: any) => {
151154
const lagNy = lagNyBehandlingUngSak;
152-
lagNy(params).then(() => oppfriskBehandlinger());
155+
await lagNy(params);
156+
oppfriskBehandlinger();
153157
}, []);
154158

155159
const uuidForSistLukkede = useMemo(

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ const BehandlingSupportIndex = ({
224224
: defaultSupportPanel;
225225

226226
const changeRouteCallback = useCallback(
227-
index => {
227+
async index => {
228228
const supportPanel = synligeSupportPaneler[index];
229229
const getSupportPanelLocation = getSupportPanelLocationCreator(location);
230-
navigate(getSupportPanelLocation(supportPanel));
230+
await navigate(getSupportPanelLocation(supportPanel));
231231
},
232232
[location, synligeSupportPaneler],
233233
);
@@ -258,8 +258,8 @@ const BehandlingSupportIndex = ({
258258
})}
259259
</Tooltip>
260260
}
261-
onClick={() => {
262-
changeRouteCallback(index);
261+
onClick={async () => {
262+
await changeRouteCallback(index);
263263
}}
264264
className={styles.tabButton}
265265
/>

packages/ung/sak-app/data/useVisForhandsvisningAvMelding.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ export const useVisForhandsvisningAvMelding = (behandling: BehandlingInfo, fagsa
2323

2424
const { startRequest: forhandsvisMelding } = restApiHooks.useRestApiRunner(UngSakApiKeys.PREVIEW_MESSAGE_FORMIDLING);
2525

26-
return (erHenleggelse: boolean, data: any): void => {
26+
return async (erHenleggelse: boolean, data: any): Promise<void> => {
2727
if (erTilbakekreving && erHenleggelse) {
28-
forhandsvisTilbakekrevingHenleggelse({ behandlingUuid: behandling.uuid, ...data }).then(response =>
29-
forhandsvis(response),
30-
);
28+
const response = await forhandsvisTilbakekrevingHenleggelse({ behandlingUuid: behandling.uuid, ...data });
29+
forhandsvis(response);
3130
} else if (erTilbakekreving) {
32-
forhandsvisTilbakekreving({ behandlingUuid: behandling.uuid, ...data }).then(response => forhandsvis(response));
31+
const response = await forhandsvisTilbakekreving({ behandlingUuid: behandling.uuid, ...data });
32+
forhandsvis(response);
3333
} else {
3434
const req = { ...lagForhåndsvisRequest(behandling, fagsak, fagsak.person, data) };
35-
forhandsvisMelding(req).then(response => forhandsvis(response));
35+
const response = await forhandsvisMelding(req);
36+
forhandsvis(response);
3637
}
3738
};
3839
};

packages/ung/sak-app/fagsakSearch/FagsakSearchIndex.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ const FagsakSearchIndex = () => {
2626

2727
const navigate = useNavigate();
2828
const { removeErrorMessages } = useRestApiErrorDispatcher();
29-
const goToFagsak = (saksnummer: string) => {
29+
const goToFagsak = async (saksnummer: string) => {
3030
removeErrorMessages();
31-
navigate(pathToFagsak(saksnummer));
31+
await navigate(pathToFagsak(saksnummer));
3232
};
3333

3434
const {
@@ -47,7 +47,7 @@ const FagsakSearchIndex = () => {
4747

4848
useEffect(() => {
4949
if (sokFerdig && fagsaker.length === 1) {
50-
goToFagsak(fagsaker[0].saksnummer);
50+
void goToFagsak(fagsaker[0].saksnummer);
5151
}
5252
}, [sokFerdig, fagsaker]);
5353

packages/v2/gui/src/prosess/ung-vedtak/UngVedtak.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const UngVedtak = ({ api, behandling, aksjonspunkter, submitCallback, vil
6262

6363
const transformValues = () => aksjonspunkter.filter(ap => ap.kanLoses).map(ap => ({ kode: ap.definisjon }));
6464
const handleSubmit = () => {
65-
submitCallback(transformValues());
65+
void submitCallback(transformValues());
6666
};
6767

6868
return (

0 commit comments

Comments
 (0)