Skip to content

Commit

Permalink
Skal ha med datobegrensninger i hentDatobegrensninger. Skal ikke ha d…
Browse files Browse the repository at this point in the history
…ropdownCaption hvis begrensinger minDate eller maxDate mangler. (#1662)
  • Loading branch information
gunnsteingarmo authored Apr 9, 2024
1 parent 9388233 commit c6f05b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/dato/MånedÅrVelger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const MånedÅrVelger: React.FC<Props> = ({
{...monthpickerProps}
id={datolabelid}
locale={locale}
dropdownCaption={true}
dropdownCaption={
begrensninger.minDate && begrensninger.maxDate ? true : false
}
fromDate={begrensninger?.minDate}
toDate={begrensninger?.maxDate}
>
Expand Down
13 changes: 13 additions & 0 deletions src/utils/dato.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { subMonths } from 'date-fns';
import { nb } from 'date-fns/locale';
import { IPeriode } from '../models/felles/periode';
import { DatoBegrensning } from '../components/dato/Datovelger';
import { min } from 'lodash';

export const STANDARD_DATOFORMAT = 'dd.MM.yyyy';
export const FØDSELSNUMMER_DATOFORMAT = 'ddMMyy';
Expand Down Expand Up @@ -137,5 +138,17 @@ export const hentDatobegrensninger = (datobegrensning: DatoBegrensning) => {
minDate: subYears(new Date(), 100),
maxDate: addMonths(new Date(), 6),
};

case DatoBegrensning.FemÅrTidligereOgSeksMånederFrem:
return {
minDate: subYears(new Date(), 5),
maxDate: addMonths(new Date(), 6),
};

case DatoBegrensning.FemtiÅrTidligereOgSeksMånederFrem:
return {
minDate: subYears(new Date(), 50),
maxDate: addMonths(new Date(), 6),
};
}
};

0 comments on commit c6f05b0

Please sign in to comment.