Skip to content

Commit

Permalink
driftpunkt for å ferdigstille vedtak
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnav990 committed May 15, 2023
1 parent e69478f commit 369f0a0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/api/driftApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ export async function resendSpesifikkVedtakstatistikk(args: {
},
});
}

export async function ferdigstillVedtak(args: { vedtakId: string }): Promise<ApiClientResult<{ status: string }>> {
return apiClient({
url: `/drift/vedtak/${args.vedtakId}/ferdigstill`,
method: 'POST',
request: { headers: new Headers({ Accept: 'application/json' }) },
});
}
36 changes: 35 additions & 1 deletion src/pages/drift/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as RemoteData from '@devexperts/remote-data-ts';
import { Alert, Button, Heading, Label, Loader, Modal, Select, Textarea } from '@navikt/ds-react';
import { Alert, Button, Heading, Label, Loader, Modal, Select, Textarea, TextField } from '@navikt/ds-react';
import * as React from 'react';
import { useState } from 'react';
import DatePicker from 'react-datepicker';
Expand All @@ -14,6 +14,7 @@ import {
stønadsmottakere,
resendstatistikkSøknadsbehandlingVedtak,
resendSpesifikkVedtakstatistikk,
ferdigstillVedtak,
} from '~src/api/driftApi';
import ApiErrorAlert from '~src/components/apiErrorAlert/ApiErrorAlert';
import { useApiCall } from '~src/lib/hooks';
Expand Down Expand Up @@ -52,6 +53,7 @@ const Drift = () => {
}, []);

const [vilResendeStatistikk, setVilResendeStatistikk] = useState<boolean>(false);
const [vilFikseVedtak, setVilFikseVedtak] = useState<boolean>(false);

const [stønadsmottakereModal, setStønadsmottakereModal] = useState<boolean>(false);
const [visReguleringModal, setVisReguleringModal] = React.useState(false);
Expand Down Expand Up @@ -88,6 +90,8 @@ const Drift = () => {
{vilResendeStatistikk && (
<ResendStatistikkModal open={vilResendeStatistikk} onClose={() => setVilResendeStatistikk(false)} />
)}
{vilFikseVedtak && <VilFikseVedtakModal open={vilFikseVedtak} onClose={() => setVilFikseVedtak(false)} />}

<div>
<h1>Drift</h1>
</div>
Expand Down Expand Up @@ -278,6 +282,15 @@ const Drift = () => {
>
Resend statistikk
</Button>

<Button
variant="secondary"
className={styles.knapp}
type="button"
onClick={() => setVilFikseVedtak(true)}
>
Fiks vedtak
</Button>
</div>
{knappTrykket === Knapp.FIX_SØKNADER && RemoteData.isFailure(fixSøknaderResponse) && (
<Alert className={styles.alert} variant="error">
Expand Down Expand Up @@ -307,6 +320,27 @@ const Drift = () => {
);
};

const VilFikseVedtakModal = (props: { open: boolean; onClose: () => void }) => {
const [ferdigstillStatus, ferdigstill] = useApiCall(ferdigstillVedtak);
const [vedtakId, setVedtakId] = useState<string>('');
return (
<Modal open={props.open} onClose={props.onClose}>
<Modal.Content>
<div>
<Heading size="medium" spacing>
Ferdigstill
</Heading>
<TextField label={'vedtak id'} onChange={(v) => setVedtakId(v.target.value)} />
<Button onClick={() => ferdigstill({ vedtakId: vedtakId })}>Ferdigstill vedtak</Button>
{RemoteData.isSuccess(ferdigstillStatus) && <p>Nice 👍🤌</p>}

{RemoteData.isFailure(ferdigstillStatus) && <ApiErrorAlert error={ferdigstillStatus.error} />}
</div>
</Modal.Content>
</Modal>
);
};

const ResendStatistikkModal = (props: { open: boolean; onClose: () => void }) => {
const [søknadsbehandlingVedtakStatistikkStatus, resendSøknadsbehandlingVedtak] = useApiCall(
resendstatistikkSøknadsbehandlingVedtak
Expand Down

0 comments on commit 369f0a0

Please sign in to comment.