Skip to content

Commit

Permalink
🚸 sorter barn
Browse files Browse the repository at this point in the history
  • Loading branch information
tidnav committed May 2, 2024
1 parent c36a115 commit 686e555
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mock/søker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const mockSøker: SokerOppslagState = {
},
fødselsdato: formatDate(sub(new Date(), { years: 1 }), 'yyyy-MM-dd')!,
},
{
fnr: '789',
navn: {
fornavn: 'Jørgen',
mellomnavn: 'Hatt',
etternavn: 'Emaker',
},
fødselsdato: formatDate(sub(new Date(), { years: 4 }), 'yyyy-MM-dd')!,
},
{
fnr: '456',
navn: {
Expand Down
6 changes: 6 additions & 0 deletions pages/[step].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { formatNavn } from 'utils/StringFormatters';
import { hentMellomlagring } from 'pages/api/mellomlagring/les';
import { RequiredVedlegg } from 'types/SoknadContext';
import { logError, logInfo, logWarning } from '@navikt/aap-felles-utils';
import { parse } from 'date-fns';

interface PageProps {
søker: SokerOppslagState;
Expand Down Expand Up @@ -248,6 +249,11 @@ export const getServerSideProps = beskyttetSide(
} catch (e) {
logError('Noe gikk galt i kallet mot barn fra aap-oppslag', e);
}
barn.sort((barnA, barnB) => {
const a = parse(barnA.fødselsdato, 'yyyy-MM-dd', new Date() as any);
const b = parse(barnB.fødselsdato, 'yyyy-MM-dd', new Date() as any);
return a - b;
});

stopTimer();

Expand Down

0 comments on commit 686e555

Please sign in to comment.