Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

legge til arbeidssøker søknad i ny modernisert flyt. med feturetoggle #1827

Merged
merged 10 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/arbeidssøkerskjema/SkjemaApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import { SkjemaProvider } from './SkjemaContext';
import RedirectArbeidssoker from './routes/RedirectArbeidssoker';
import { Loader } from '@navikt/ds-react';
import { useToggles } from '../context/TogglesContext';
import hentToggles from '../toggles/api';

const App = () => {
const [autentisert, settAutentisering] = useState<boolean>(false);
Expand All @@ -25,9 +27,16 @@
ident,
visningsnavn,
};
const { settToggles } = useToggles();

autentiseringsInterceptor();

const fetchToggles = () => {
return hentToggles(settToggles).catch(() => {
settError(true);
});
};

useEffect(() => {
verifiserAtBrukerErAutentisert(settAutentisering);
}, [autentisert]);
Expand All @@ -39,6 +48,9 @@
.then((response) => {
settIdent(response.ident);
settVisningsnavn(response.visningsnavn);
})
.then(() => {
fetchToggles();

settError(false);
settFeilmelding('');
Expand All @@ -52,7 +64,7 @@
settFetching(false);
};
fetchData();
}, []);

Check warning on line 67 in src/arbeidssøkerskjema/SkjemaApp.tsx

View workflow job for this annotation

GitHub Actions / Build and test

React Hook useEffect has a missing dependency: 'fetchToggles'. Either include it or remove the dependency array

Check warning on line 67 in src/arbeidssøkerskjema/SkjemaApp.tsx

View workflow job for this annotation

GitHub Actions / Build and test

React Hook useEffect has a missing dependency: 'fetchToggles'. Either include it or remove the dependency array

Check warning on line 67 in src/arbeidssøkerskjema/SkjemaApp.tsx

View workflow job for this annotation

GitHub Actions / Build and push Docker container

React Hook useEffect has a missing dependency: 'fetchToggles'. Either include it or remove the dependency array

Check warning on line 67 in src/arbeidssøkerskjema/SkjemaApp.tsx

View workflow job for this annotation

GitHub Actions / Build and push Docker container

React Hook useEffect has a missing dependency: 'fetchToggles'. Either include it or remove the dependency array

if (!fetching && autentisert) {
if (!error) {
Expand Down
12 changes: 12 additions & 0 deletions src/arbeidssøkerskjema/innsending/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ export const sendInnSkjema = async (skjema: object) => {
);
return response.data;
};

export const sendInnArbeidssøkerSkjema = async (skjema: object) => {
marcuasc marked this conversation as resolved.
Show resolved Hide resolved
const response = await axios.post(
`${Environment().apiProxyUrl}/api/soknadskvittering/arbeidssoker`,
skjema,
{
headers: { 'Content-Type': 'application/json;charset=utf-8' },
withCredentials: true,
}
);
return response.data;
};
59 changes: 35 additions & 24 deletions src/arbeidssøkerskjema/steg/2-Oppsummering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useSkjema } from '../SkjemaContext';
import { VisLabelOgSvar } from '../../utils/visning';
import { IArbeidssøker } from '../../models/steg/aktivitet/arbeidssøker';
import LenkeMedIkon from '../../components/knapper/LenkeMedIkon';
import { sendInnSkjema } from '../innsending/api';
import { sendInnArbeidssøkerSkjema, sendInnSkjema } from '../innsending/api';
import { IStatus } from '../innsending/typer';
import LocaleTekst from '../../language/LocaleTekst';
import SeksjonGruppe from '../../components/gruppe/SeksjonGruppe';
Expand All @@ -28,6 +28,8 @@ import { logSidevisningArbeidssokerskjema } from '../../utils/amplitude';
import { useMount } from '../../utils/hooks';
import { useLokalIntlContext } from '../../context/LokalIntlContext';
import { Alert, BodyShort, Button, Heading } from '@navikt/ds-react';
import { useToggles } from '../../context/TogglesContext';
import { ToggleName } from '../../models/søknad/toggles';

interface Innsending {
status: IStatus;
Expand All @@ -37,6 +39,7 @@ interface Innsending {

const Oppsummering: React.FC = () => {
const location = useLocation();
const { toggles } = useToggles();
const navigate = useNavigate();
const intl = useLokalIntlContext();
const { skjema, settSkjema } = useSkjema();
Expand All @@ -57,32 +60,40 @@ const Oppsummering: React.FC = () => {

useMount(() => logSidevisningArbeidssokerskjema('Oppsummering'));

const sendInnArbeidsøkerSkjemaOgNavigerVidere = async (
mappetSkjema: Record<string, object>
) => {
try {
const brukModernisertFlyt = toggles[ToggleName.visNyInnsendingsknapp];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pirk: utenfor try-catch

const kvittering = brukModernisertFlyt
? await sendInnArbeidssøkerSkjema(mappetSkjema)
: await sendInnSkjema(mappetSkjema);

settinnsendingState({
...innsendingState,
status: IStatus.SUKSESS,
melding: `Vi har kontakt: ${kvittering.text}`,
venter: false,
});
settSkjema({
...skjema,
innsendingsdato: parseISO(kvittering.mottattDato),
});
navigate(nesteRoute.path);
} catch (e) {
settinnsendingState({
...innsendingState,
status: IStatus.FEILET,
melding: `Noe gikk galt: ${e}`,
venter: false,
});
}
};

const sendSkjema = (arbeidssøker: IArbeidssøker) => {
const mappetSkjema = mapDataTilLabelOgVerdiTyper(arbeidssøker);

settinnsendingState({ ...innsendingState, venter: true });
sendInnSkjema(mappetSkjema)
.then((kvittering) => {
settinnsendingState({
...innsendingState,
status: IStatus.SUKSESS,
melding: `Vi har kontakt: ${kvittering.text}`,
venter: false,
});
settSkjema({
...skjema,
innsendingsdato: parseISO(kvittering.mottattDato),
});
navigate(nesteRoute.path);
})
.catch((e) =>
settinnsendingState({
...innsendingState,
status: IStatus.FEILET,
melding: `Noe gikk galt: ${e}`,
venter: false,
})
);
sendInnArbeidsøkerSkjemaOgNavigerVidere(mappetSkjema);
marcuasc marked this conversation as resolved.
Show resolved Hide resolved
};

return (
Expand Down
Loading