-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
476 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/v2/gui/src/sak/fagsakSøk/FagsakSokSakIndex.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
BehandlingAksjonspunktDtoBehandlingType as behandlingType, | ||
BehandlingAksjonspunktDtoFagsakStatus as fagsakStatus, | ||
MatchFagsakYtelseType as fagsakYtelseType, | ||
} from '@k9-sak-web/backend/k9sak/generated'; | ||
import { KodeverkProvider } from '@k9-sak-web/gui/kodeverk/index.js'; | ||
import alleKodeverkV2 from '@k9-sak-web/lib/kodeverk/mocks/alleKodeverkV2.json'; | ||
import { action } from '@storybook/addon-actions'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { expect } from '@storybook/test'; | ||
import FagsakSøkSakIndexV2 from './FagsakSøkSakIndex'; | ||
|
||
const fagsaker = [ | ||
{ | ||
saksnummer: '1', | ||
sakstype: fagsakYtelseType.PLEIEPENGER_SYKT_BARN, | ||
status: fagsakStatus.OPPRETTET, | ||
opprettet: '2017-08-02T00:54:25.455', | ||
endret: '', | ||
}, | ||
{ | ||
saksnummer: '2', | ||
sakstype: fagsakYtelseType.OMSORGSPENGER, | ||
status: fagsakStatus.OPPRETTET, | ||
opprettet: '2017-08-02T00:54:25.455', | ||
endret: '', | ||
}, | ||
]; | ||
const meta = { | ||
title: 'gui/sak/sok', | ||
component: FagsakSøkSakIndexV2, | ||
decorators: [ | ||
Story => ( | ||
<KodeverkProvider | ||
behandlingType={behandlingType.FØRSTEGANGSSØKNAD} | ||
kodeverk={alleKodeverkV2} | ||
klageKodeverk={{}} | ||
tilbakeKodeverk={{}} | ||
> | ||
<Story /> | ||
</KodeverkProvider> | ||
), | ||
], | ||
} satisfies Meta<typeof FagsakSøkSakIndexV2>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
fagsaker, | ||
searchFagsakCallback: action('button-click'), | ||
selectFagsakCallback: action('button-click'), | ||
searchResultReceived: false, | ||
searchStarted: false, | ||
}, | ||
play: async ({ canvas }) => { | ||
expect(canvas.getByLabelText('Saksnummer eller fødselsnummer/D-nummer')).toBeInTheDocument(); | ||
expect(canvas.getByRole('button', { name: 'Søk' })).toBeInTheDocument(); | ||
expect(canvas.getByText('Pleiepenger sykt barn')).toBeInTheDocument(); | ||
expect(canvas.getByText('Omsorgspenger')).toBeInTheDocument(); | ||
}, | ||
}; | ||
|
||
export const SøkUtenTreff: Story = { | ||
args: { | ||
fagsaker: [], | ||
searchFagsakCallback: action('button-click'), | ||
selectFagsakCallback: action('button-click'), | ||
searchResultReceived: true, | ||
searchStarted: true, | ||
}, | ||
play: async ({ canvas }) => { | ||
expect(canvas.getByText('Søket ga ingen treff')).toBeInTheDocument(); | ||
}, | ||
}; | ||
|
||
export const SøkDerEnIkkeHarAdgang: Story = { | ||
args: { | ||
fagsaker: [], | ||
searchFagsakCallback: action('button-click'), | ||
selectFagsakCallback: action('button-click'), | ||
searchResultReceived: false, | ||
searchStarted: false, | ||
searchResultAccessDenied: { | ||
feilmelding: 'Har ikke adgang', | ||
}, | ||
}, | ||
play: async ({ canvas }) => { | ||
expect(canvas.getByText('Har ikke adgang')).toBeInTheDocument(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import FagsakSearch from './components/FagsakSearch'; | ||
import type { Fagsak } from './types/Fagsak'; | ||
|
||
interface OwnProps { | ||
fagsaker?: Fagsak[]; | ||
searchFagsakCallback: () => void; | ||
searchResultReceived: boolean; | ||
selectFagsakCallback: (e: React.SyntheticEvent, saksnummer: string) => void; | ||
searchStarted?: boolean; | ||
searchResultAccessDenied?: { | ||
feilmelding: string; | ||
}; | ||
} | ||
|
||
/* | ||
* NB! Denne komponenten blir kun brukt lokalt. I alle andre miljø brukes K9LOS | ||
*/ | ||
const FagsakSøkSakIndexV2 = ({ | ||
fagsaker = [], | ||
searchFagsakCallback, | ||
searchResultReceived, | ||
selectFagsakCallback, | ||
searchStarted = false, | ||
searchResultAccessDenied, | ||
}: OwnProps) => ( | ||
<FagsakSearch | ||
fagsaker={fagsaker} | ||
searchFagsakCallback={searchFagsakCallback} | ||
searchResultReceived={searchResultReceived} | ||
selectFagsakCallback={selectFagsakCallback} | ||
searchStarted={searchStarted} | ||
searchResultAccessDenied={searchResultAccessDenied} | ||
/> | ||
); | ||
|
||
export default FagsakSøkSakIndexV2; |
38 changes: 38 additions & 0 deletions
38
packages/v2/gui/src/sak/fagsakSøk/components/FagsakList.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
BehandlingAksjonspunktDtoFagsakStatus as fagsakStatus, | ||
MatchFagsakYtelseType as fagsakYtelseType, | ||
} from '@k9-sak-web/backend/k9sak/generated'; | ||
import { sortFagsaker } from './FagsakList'; | ||
|
||
describe('<FagsakList>', () => { | ||
it('skal sortere søkeresultat der avsluttede skal vises sist, mens sist endrede skal vises først', () => { | ||
const fagsak = { | ||
saksnummer: '12345', | ||
sakstype: fagsakYtelseType.PLEIEPENGER_SYKT_BARN, | ||
status: fagsakStatus.UNDER_BEHANDLING, | ||
opprettet: '2019-02-17T13:49:18.645', | ||
endret: '2019-02-17T13:49:18.645', | ||
}; | ||
const fagsak2 = { | ||
saksnummer: '23456', | ||
sakstype: fagsakYtelseType.PLEIEPENGER_SYKT_BARN, | ||
status: fagsakStatus.UNDER_BEHANDLING, | ||
opprettet: '2019-02-18T13:49:18.645', | ||
endret: '2019-02-18T13:49:18.645', | ||
}; | ||
|
||
const fagsak3 = { | ||
saksnummer: '34567', | ||
sakstype: fagsakYtelseType.PLEIEPENGER_SYKT_BARN, | ||
status: fagsakStatus.AVSLUTTET, | ||
opprettet: '2019-02-18T13:49:18.645', | ||
endret: '2019-02-18T13:49:18.645', | ||
}; | ||
|
||
const fagsaker = [fagsak, fagsak2, fagsak3]; | ||
const sorterteFagsaker = sortFagsaker(fagsaker); | ||
expect(sorterteFagsaker[0]).toEqual(fagsaker[1]); | ||
expect(sorterteFagsaker[1]).toEqual(fagsaker[0]); | ||
expect(sorterteFagsaker[2]).toEqual(fagsaker[2]); | ||
}); | ||
}); |
80 changes: 80 additions & 0 deletions
80
packages/v2/gui/src/sak/fagsakSøk/components/FagsakList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { BehandlingAksjonspunktDtoFagsakStatus as fagsakStatus } from '@k9-sak-web/backend/k9sak/generated'; | ||
import { useKodeverkContext } from '@k9-sak-web/gui/kodeverk/index.js'; | ||
import { KodeverkType } from '@k9-sak-web/lib/kodeverk/types.js'; | ||
import { Table } from '@navikt/ds-react'; | ||
import React from 'react'; | ||
import type { Fagsak } from '../types/Fagsak'; | ||
import styles from './fagsakList.module.css'; | ||
|
||
const headerTextCodes = ['Saksnummer', 'Sakstype', 'Status']; | ||
const lagFagsakSortObj = (fagsak: Fagsak) => ({ | ||
avsluttet: fagsak.status === fagsakStatus.AVSLUTTET, | ||
endret: fagsak.endret ? fagsak.endret : fagsak.opprettet, | ||
}); | ||
|
||
export const sortFagsaker = (fagsaker: Fagsak[]) => | ||
fagsaker.toSorted((fagsak1, fagsak2) => { | ||
const a = lagFagsakSortObj(fagsak1); | ||
const b = lagFagsakSortObj(fagsak2); | ||
if (a.avsluttet && !b.avsluttet) { | ||
return 1; | ||
} | ||
if (!a.avsluttet && b.avsluttet) { | ||
return -1; | ||
} | ||
if (a.endret && b.endret) { | ||
if (a.endret > b.endret) { | ||
return -1; | ||
} | ||
if (a.endret < b.endret) { | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
}); | ||
|
||
interface OwnProps { | ||
fagsaker: Fagsak[]; | ||
selectFagsakCallback: (e: React.SyntheticEvent, saksnummer: string) => void; | ||
} | ||
|
||
/** | ||
* FagsakList | ||
* | ||
* Presentasjonskomponent. Formaterer fagsak-søkeresultatet for visning i tabell. Sortering av fagsakene blir håndtert her. | ||
*/ | ||
const FagsakList = ({ fagsaker, selectFagsakCallback }: OwnProps) => { | ||
const { kodeverkNavnFraKode } = useKodeverkContext(); | ||
|
||
return ( | ||
<Table className={styles.table}> | ||
<Table.Header> | ||
<Table.Row shadeOnHover={false}> | ||
{headerTextCodes.map(text => ( | ||
<Table.HeaderCell scope="col" key={text}> | ||
{text} | ||
</Table.HeaderCell> | ||
))} | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
{sortFagsaker(fagsaker).map(fagsak => ( | ||
<Table.Row | ||
key={fagsak.saksnummer} | ||
id={fagsak.saksnummer} | ||
onClick={event => selectFagsakCallback(event, fagsak.saksnummer)} | ||
shadeOnHover={false} | ||
> | ||
<Table.DataCell>{fagsak.saksnummer}</Table.DataCell> | ||
<Table.DataCell>{kodeverkNavnFraKode(fagsak.sakstype, KodeverkType.FAGSAK_YTELSE)}</Table.DataCell> | ||
<Table.DataCell> | ||
{fagsak.status && kodeverkNavnFraKode(fagsak.status, KodeverkType.FAGSAK_STATUS)} | ||
</Table.DataCell> | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default FagsakList; |
Oops, something went wrong.