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

Ny fradrag #274

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7f617ae
new fradragsinput
hestad Sep 24, 2020
03a182c
better handling of Utlandsinntekt
RamziAbuQassim Sep 28, 2020
86bd32e
handleChange maps to correct object in fradrag
RamziAbuQassim Sep 28, 2020
4884cc6
better handling of date for delerAvPeriode
RamziAbuQassim Sep 28, 2020
8659d0d
fix context.consumer error
RamziAbuQassim Sep 28, 2020
85d18b5
remove console.log
RamziAbuQassim Sep 28, 2020
79bb4cc
fradrag no longer has beskrivelse
RamziAbuQassim Sep 28, 2020
c347728
valuta to be validated as string
RamziAbuQassim Sep 28, 2020
a7fe8be
using Feilmelding instead of a styled p for error tekst
RamziAbuQassim Sep 29, 2020
4e86c67
refactor and updated VisBeregning to reflect new fradrag changes
RamziAbuQassim Sep 29, 2020
850cc49
reset fields -> checking off checkbox & rm defaults & null check in …
RamziAbuQassim Sep 30, 2020
5552493
mapping data between front and back-end
RamziAbuQassim Sep 30, 2020
ad22eb4
removed duplicate import
RamziAbuQassim Sep 30, 2020
d0f5585
better file management and cleaned up styles
RamziAbuQassim Sep 30, 2020
cc599c8
removed duplicate style
RamziAbuQassim Sep 30, 2020
6b4c87b
better typing for fradrag-input id's
RamziAbuQassim Sep 30, 2020
7f1cfbb
better conditional handling of feilmelding
RamziAbuQassim Sep 30, 2020
59984c2
remove console.log
RamziAbuQassim Sep 30, 2020
34d32ba
fiks date formatting
RamziAbuQassim Sep 30, 2020
418e33a
refactoring of names
RamziAbuQassim Oct 1, 2020
aebaba5
fix what dates available to pick from
RamziAbuQassim Oct 1, 2020
1e73861
ValidateStringAsNumber takes only >= 0
RamziAbuQassim Oct 1, 2020
678012f
Using types directly from keys on Fradragsinput
RamziAbuQassim Oct 1, 2020
b65fd53
moved types to its corresponding file
RamziAbuQassim Oct 1, 2020
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
7 changes: 7 additions & 0 deletions src/api/utbetalingApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Utbetaling } from '~types/Utbetaling';

import apiClient, { ApiClientResult } from './apiClient';

export async function stansUtbetalinger(sakId: string): Promise<ApiClientResult<Utbetaling>> {
return apiClient({ url: `/saker/${sakId}/utbetalinger/stans`, method: 'POST' });
}
8 changes: 8 additions & 0 deletions src/assets/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,11 @@ export const PencilIcon = (props: { width: string; height: string }) => (
</g>
</svg>
);

export const TrashBin = (props: { width: string; height: string }) => (
<svg xmlns="http://www.w3.org/2000/svg" width={props.width} height={props.height} viewBox="0 0 24 24">
<g stroke="#000" strokeLinecap="round" strokeLinejoin="round" strokeMiterlimit="10" fill="none">
<path d="M3.516 3.5h16v20h-16zM7.516.5h8v3h-8zM1.016 3.5h22M7.516 7v12M11.516 7v12M15.516 7v12" />
</g>
</svg>
);
26 changes: 0 additions & 26 deletions src/features/beregning/beregning-nb.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/features/beregning/beregning.module.less

This file was deleted.

131 changes: 0 additions & 131 deletions src/features/beregning/index.tsx

This file was deleted.

31 changes: 29 additions & 2 deletions src/features/saksoversikt/sak.slice.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as RemoteData from '@devexperts/remote-data-ts';
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';

import { ErrorCode, ApiError } from '~api/apiClient';
import { ApiError, ErrorCode } from '~api/apiClient';
import * as behandlingApi from '~api/behandlingApi';
import * as sakApi from '~api/sakApi';
import * as utbetalingApi from '~api/utbetalingApi';
import { pipe } from '~lib/fp';
import { handleAsyncThunk, simpleRejectedActionToRemoteData } from '~redux/utils';
import { Behandling } from '~types/Behandling';
Expand All @@ -12,6 +13,7 @@ import { UtledetSatsInfo } from '~types/Beregning';
import { Fradrag } from '~types/Fradrag';
import { Sak } from '~types/Sak';
import { Sats } from '~types/Sats';
import { Utbetaling } from '~types/Utbetaling';
import { Vilkårtype, VilkårVurderingStatus } from '~types/Vilkårsvurdering';

export const fetchSak = createAsyncThunk<Sak, { fnr: string } | { sakId: string }, { rejectValue: ApiError }>(
Expand All @@ -25,6 +27,17 @@ export const fetchSak = createAsyncThunk<Sak, { fnr: string } | { sakId: string
}
);

export const stansUtbetalinger = createAsyncThunk<Utbetaling, { sakId: string }, { rejectValue: ApiError }>(
'utbetalinger/stans',
async ({ sakId }, thunkApi) => {
const res = await utbetalingApi.stansUtbetalinger(sakId);
if (res.status === 'ok') {
return res.data;
}
return thunkApi.rejectWithValue(res.error);
}
);

export const startBehandling = createAsyncThunk<
Behandling,
{ sakId: string; søknadId: string },
Expand Down Expand Up @@ -164,6 +177,7 @@ interface SakState {
},
Sak
>;
stansUtbetalingerStatus: RemoteData.RemoteData<{ code: ErrorCode; message: string }, null>;
startBehandlingStatus: RemoteData.RemoteData<{ code: ErrorCode; message: string }, null>;
lagreVilkårsvurderingStatus: RemoteData.RemoteData<{ code: ErrorCode; message: string }, null>;
lagreBehandlingsinformasjonStatus: RemoteData.RemoteData<{ code: ErrorCode; message: string }, null>;
Expand All @@ -176,6 +190,7 @@ interface SakState {

const initialState: SakState = {
sak: RemoteData.initial,
stansUtbetalingerStatus: RemoteData.initial,
startBehandlingStatus: RemoteData.initial,
lagreVilkårsvurderingStatus: RemoteData.initial,
lagreBehandlingsinformasjonStatus: RemoteData.initial,
Expand Down Expand Up @@ -203,6 +218,18 @@ export default createSlice({
},
});

handleAsyncThunk(builder, stansUtbetalinger, {
pending: (state) => {
state.stansUtbetalingerStatus = RemoteData.pending;
},
fulfilled: (state) => {
state.stansUtbetalingerStatus = RemoteData.success(null);
},
rejected: (state, action) => {
state.stansUtbetalingerStatus = simpleRejectedActionToRemoteData(action);
},
});

handleAsyncThunk(builder, startBehandling, {
pending: (state) => {
state.startBehandlingStatus = RemoteData.pending;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/validering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ function label(data: Partial<yup.TestMessageParams>) {
return data.label ?? 'Feltet';
}

export const validateStringAsNumber = (yup
.number()
.required('Feltet må fylles ut')
.typeError('Feltet må være et tall') as unknown) as yup.Schema<string>;

const norskLocale: yup.LocaleObject = {
mixed: {
default: (data) => `${label(data)} er ugyldig`,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/attestering/Attestering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { mapToVilkårsinformasjon, statusIcon, vilkårTittelFormatted } from '~f
import { useI18n } from '~lib/hooks';
import { Nullable } from '~lib/types';
import yup, { formikErrorsTilFeiloppsummering, formikErrorsHarFeil } from '~lib/validering';
import VisBeregning from '~pages/saksbehandling/beregning/VisBeregning';
import { Simulering } from '~pages/saksbehandling/simulering/simulering';
import VisBeregning from '~pages/saksbehandling/steg/beregning/VisBeregning';
import { useAppSelector, useAppDispatch } from '~redux/Store';
import { Behandling } from '~types/Behandling';
import { Sak } from '~types/Sak';
Expand Down
24 changes: 24 additions & 0 deletions src/pages/attestering/attestering.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,27 @@
.sendInnAttestering {
margin-top: @spacing-s;
}

.container {
display: flex;
flex-direction: column;
}

.feiloppsummering {
margin-bottom: @spacing-l;
}

.beregningContainer {
display: flex;
flex-direction: row;

.startBeregningKnapp {
margin-right: @spacing-s;
}

margin-bottom: @spacing-xl;
}

.sats {
margin-bottom: @spacing;
}
6 changes: 1 addition & 5 deletions src/pages/saksbehandling/Saksoversikt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { useI18n } from '~lib/hooks';
import * as Routes from '~lib/routes';
import { useAppSelector, useAppDispatch } from '~redux/Store';

import Beregning from './beregning/Beregning';
import Sakintro from './sakintro/Sakintro';
import messages from './saksoversikt-nb';
import styles from './saksoversikt.module.less';
Expand All @@ -45,7 +44,7 @@ const Saksoversikt = () => {
if (RemoteData.isSuccess(sak)) {
if (RemoteData.isInitial(søker)) {
dispatch(personSlice.fetchPerson({ fnr: sak.value.fnr }));
} else if (RemoteData.isSuccess(søker)) {
} else if (RemoteData.isSuccess(søker) && !urlParams.sakId) {
rerouteToSak(sak.value.id);
}
}
Expand Down Expand Up @@ -105,9 +104,6 @@ const Saksoversikt = () => {
<Route path={Routes.saksoversiktValgtBehandling.path}>
<div className={styles.mainContent}>
<Switch>
<Route path={Routes.saksbehandlingBeregning.path}>
<Beregning sak={sak} />
</Route>
<Route path={Routes.saksbehandlingVedtak.path}>
<Vedtak sak={sak} />
</Route>
Expand Down
Loading