Skip to content

Commit

Permalink
feat. korrige komma i desimaltall flere steder
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikv committed Dec 19, 2024
1 parent 0c99b75 commit 4727797
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/AvtaleSide/steg/BeregningTilskudd/Arbeidsgiveravgift.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { Column, Row } from '@/komponenter/NavGrid/Grid';
import SelectInput from '@/komponenter/form/SelectInput';
import { parseFloatIfFloatable } from '@/utils';
import { formaterNorskeTall, parseFloatIfFloatable } from '@/utils';
import { BEMWrapper } from '@/utils/bem';
import { AvtaleContext } from '@/AvtaleProvider';

Expand All @@ -17,7 +17,7 @@ const Arbeidsgiveravgift: React.FC<Props> = ({ cls }: Props) => {
const satserVerdier = [{ label: 'Velg', value: '' }];
satser.forEach((sats: number) =>
satserVerdier.push({
label: (sats * 100).toFixed(1) + ' %',
label: formaterNorskeTall(sats * 100) + ' %',
value: sats.toString(),
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/AvtaleSide/steg/BeregningTilskudd/Feriepenger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Column, Row } from '@/komponenter/NavGrid/Grid';
import { BEMWrapper } from '@/utils/bem';
import { AvtaleContext } from '@/AvtaleProvider';
import SelectInput from '@/komponenter/form/SelectInput';
import { parseFloatIfFloatable } from '@/utils';
import { formaterNorskeTall, parseFloatIfFloatable } from '@/utils';

interface Props {
cls: BEMWrapper;
Expand All @@ -13,7 +13,7 @@ const Feriepenger: React.FC<Props> = ({ cls }: Props) => {

const feriepengeAlternativer = [{ label: 'Velg', value: '' }].concat(
[0, 0.102, 0.12, 0.125, 0.143].map((sats: number) => ({
label: (sats * 100).toFixed(1) + ' %',
label: formaterNorskeTall(sats * 100) + ' %',
value: sats.toString(),
})),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Column, Row } from '@/komponenter/NavGrid/Grid';
import ProsentInput from '@/komponenter/form/ProsentInput';
import { BEMWrapper } from '@/utils/bem';
import { AvtaleContext } from '@/AvtaleProvider';
import { formaterNorskeTall } from '@/utils';

interface Props {
cls: BEMWrapper;
Expand All @@ -22,7 +23,7 @@ const ObligatoriskTjenestepensjon: React.FC<Props> = ({ cls }: Props) => {
autoComplete={'off'}
value={
avtale.gjeldendeInnhold.otpSats !== undefined && avtale.gjeldendeInnhold.otpSats !== null
? (avtale.gjeldendeInnhold.otpSats * 100).toFixed(2)
? formaterNorskeTall(avtale.gjeldendeInnhold.otpSats * 100)
: ''
}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import EtikettStatus from '@/BeslutterSide/EtikettStatus';
import { TilskuddsPeriode } from '@/types/avtale';
import BEMHelper from '@/utils/bem';
import { formatterPeriode } from '@/utils/datoUtils';
import { formatterProsent } from '@/utils/formatterProsent';
import { formaterProsent } from '@/utils/formaterProsent';
import { formaterPenger } from '@/utils/PengeUtils';
import { FunctionComponent } from 'react';
import './tilskuddsPerioder.less';
Expand Down Expand Up @@ -36,7 +36,7 @@ const TilskuddsPerioderVeileder: FunctionComponent<Props> = (props) => {
<td aria-label={`Startdato ${periode.startDato} og sluttdato ${periode.sluttDato}`}>
{formatterPeriode(periode.startDato, periode.sluttDato)}
</td>
<td>{formatterProsent(periode.lonnstilskuddProsent)}</td>
<td>{formaterProsent(periode.lonnstilskuddProsent)}</td>
<td>{formaterPenger(periode.beløp)}</td>
<td>
<EtikettStatus tilskuddsperiodestatus={periode.status} size="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import StillingsTittelVelger, { StillingOptions } from '@/AvtaleSide/steg/Stilli
import useStilling from '@/AvtaleSide/steg/StillingSteg/useStilling';
import StillingsprosentInput from '@/AvtaleSide/steg/VarighetSteg/StillingsprosentInput/StillingsprosentInput';
import BekreftelseModal from '@/komponenter/modal/BekreftelseModal';
import PakrevdInput from '@/komponenter/PakrevdInput/PakrevdInput';
import PakrevdTextarea from '@/komponenter/PakrevdTextarea/PakrevdTextarea';
import { EndreStilling, oppdatereStillingbeskrivelse } from '@/services/rest-service';
import BEMHelper from '@/utils/bem';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Task } from '@navikt/ds-icons/cjs';
import { BodyShort, Link } from '@navikt/ds-react';
import React, { FunctionComponent, useContext, useState } from 'react';
import './EndreTilskuddsberegning.less';
import { formaterNorskeTall } from '@/utils';

export type EndreBeregning = Pick<
Beregningsgrunnlag & Varighet,
Expand Down Expand Up @@ -123,7 +124,7 @@ const EndreTilskuddsberegning: FunctionComponent = () => {
autoComplete={'off'}
value={
nyBeregning.otpSats !== undefined && nyBeregning.otpSats !== null
? (nyBeregning.otpSats * 100).toFixed(0)
? formaterNorskeTall(nyBeregning.otpSats * 100)
: ''
}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AvtaleContext, Context } from '@/AvtaleProvider';
import { formatterDato, formatterPeriode, NORSK_DATO_FORMAT } from '@/utils/datoUtils';
import { formatterProsent } from '@/utils/formatterProsent';
import { formaterProsent } from '@/utils/formaterProsent';
import { formaterPenger } from '@/utils/PengeUtils';
import React, { FunctionComponent, useContext, useRef, useState, useEffect } from 'react';
import EtikettStatus from '../EtikettStatus';
Expand Down Expand Up @@ -100,7 +100,7 @@ const BeslutterTilskuddsPerioder: FunctionComponent<Props> = (props) => {
{formatterPeriode(periode.startDato, periode.sluttDato, 'DD.MM.YY')}
</td>
<td>{formaterPenger(periode.beløp)}</td>
<td>{formatterProsent(periode.lonnstilskuddProsent)}</td>
<td>{formaterProsent(periode.lonnstilskuddProsent)}</td>
<td>{formatterDato(periode.kanBesluttesFom, NORSK_DATO_FORMAT)}</td>
<td>{periode.status === 'GODKJENT' ? periode.enhet : enhet}</td>
<td>
Expand Down
8 changes: 4 additions & 4 deletions src/komponenter/form/ProsentInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FormattedNumberInput from '@/komponenter/form/FormattedNumberInput';
import { formatterProsent } from '@/utils/formatterProsent';
import { formaterProsent } from '@/utils/formaterProsent';
import React, { PropsWithChildren } from 'react';
import { TextFieldProps } from '@navikt/ds-react';

Expand All @@ -25,12 +25,12 @@ const ProsentInput: React.FunctionComponent<InputProps> = (props: PropsWithChild
},
(v: any) => {
if (v && min && v < min) {
return 'Må være over ' + formatterProsent(min);
return 'Må være over ' + formaterProsent(min);
}
},
(v: any) => {
if (v && max && v > max) {
return 'Må være under ' + formatterProsent(max);
return 'Må være under ' + formaterProsent(max);
}
},
];
Expand All @@ -41,7 +41,7 @@ const ProsentInput: React.FunctionComponent<InputProps> = (props: PropsWithChild
step={step}
validatorer={validatorer}
maxLength={3}
toFormatted={formatterProsent}
toFormatted={formaterProsent}
max={max}
min={min}
{...other}
Expand Down
9 changes: 9 additions & 0 deletions src/utils/formaterProsent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { formaterNorskeTall, parseNorskeTallFraInput } from '@/utils/tallUtils';

export const formaterProsent = <T>(value: T): string => {
const valueSomTall = parseNorskeTallFraInput(value);
if (!valueSomTall && valueSomTall !== 0) {
return '';
}
return `${formaterNorskeTall(valueSomTall)} %`;
};
6 changes: 0 additions & 6 deletions src/utils/formatterProsent.ts

This file was deleted.

0 comments on commit 4727797

Please sign in to comment.