|
1 |
| -import { List, Skeleton } from '@navikt/ds-react' |
| 1 | +import { Label, List, Skeleton } from '@navikt/ds-react' |
2 | 2 | import moment from 'moment'
|
| 3 | +import { useEffect, useState } from 'react' |
| 4 | +import { getAllPvkDokumentListItem } from '../../api/PvkDokumentApi' |
3 | 5 | import { EPVO, IPvkDokumentListItem } from '../../constants'
|
4 | 6 | import PvoStatusView from '../PvoTilbakemelding/common/PvoStatusView'
|
5 | 7 | import { ListLayout } from '../common/ListLayout'
|
6 | 8 |
|
7 |
| -interface IProps { |
8 |
| - allPvkDocumentListItem: IPvkDokumentListItem[] |
9 |
| - isLoading: boolean |
10 |
| -} |
| 9 | +export const PvoTilbakemeldingsList = () => { |
| 10 | + const [allPvkDocumentListItem, setAllPvkDocumentListItem] = useState<IPvkDokumentListItem[]>([]) |
| 11 | + const [isLoading, setIsLoading] = useState(false) |
| 12 | + useEffect(() => { |
| 13 | + ;(async () => { |
| 14 | + setIsLoading(true) |
| 15 | + await getAllPvkDokumentListItem().then((response) => { |
| 16 | + setAllPvkDocumentListItem(response) |
| 17 | + setIsLoading(false) |
| 18 | + }) |
| 19 | + })() |
| 20 | + }, []) |
11 | 21 |
|
12 |
| -export const PvoTilbakemeldingsList = ({ allPvkDocumentListItem, isLoading }: IProps) => ( |
13 |
| - <div> |
14 |
| - {isLoading && <Skeleton variant='rectangle' />} |
15 |
| - {!isLoading && ( |
16 |
| - <List className='mb-2.5 flex flex-col gap-2'> |
17 |
| - {allPvkDocumentListItem && |
18 |
| - allPvkDocumentListItem.map((pvkDokument: IPvkDokumentListItem) => ( |
19 |
| - <ListLayout |
20 |
| - key={pvkDokument.id} |
21 |
| - id={pvkDokument.id} |
22 |
| - url={`/pvkdokument/${pvkDokument.id}${EPVO.tilbakemelding}/1`} |
23 |
| - documentNumber={`E${pvkDokument.etterlevelseNummer}`} |
24 |
| - title={pvkDokument.title} |
25 |
| - status={<PvoStatusView status={pvkDokument.status} />} |
26 |
| - upperRightField='PVK dokument ble' |
27 |
| - changeStamp={ |
28 |
| - pvkDokument.changeStamp.lastModifiedDate !== undefined && |
29 |
| - pvkDokument.changeStamp.lastModifiedDate !== '' |
30 |
| - ? `sist endret: ${moment(pvkDokument.changeStamp.lastModifiedDate).format('ll')}` |
31 |
| - : '' |
32 |
| - } |
33 |
| - /> |
34 |
| - ))} |
35 |
| - </List> |
36 |
| - )} |
37 |
| - </div> |
38 |
| -) |
| 22 | + return ( |
| 23 | + <div> |
| 24 | + {isLoading && <Skeleton variant='rectangle' />} |
| 25 | + {!isLoading && ( |
| 26 | + <div> |
| 27 | + <div className='w-full justify-center my-4'> |
| 28 | + <div className='flex justify-center content-center w-full'> |
| 29 | + <div className='flex justify-start align-middle w-full'> |
| 30 | + <Label size='medium'> |
| 31 | + {/* {kravene.totalElements ? kravene.totalElements : 0} */} |
| 32 | + {allPvkDocumentListItem.length} PVK dokumenter |
| 33 | + </Label> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + </div> |
| 37 | + <List className='mb-2.5 flex flex-col gap-2'> |
| 38 | + {allPvkDocumentListItem && |
| 39 | + allPvkDocumentListItem.map((pvkDokument: IPvkDokumentListItem) => ( |
| 40 | + <ListLayout |
| 41 | + key={pvkDokument.id} |
| 42 | + id={pvkDokument.id} |
| 43 | + url={`/pvkdokument/${pvkDokument.id}${EPVO.tilbakemelding}/1`} |
| 44 | + documentNumber={`E${pvkDokument.etterlevelseNummer}`} |
| 45 | + title={pvkDokument.title} |
| 46 | + status={<PvoStatusView status={pvkDokument.status} />} |
| 47 | + upperRightField='PVK dokument ble' |
| 48 | + changeStamp={ |
| 49 | + pvkDokument.changeStamp.lastModifiedDate !== undefined && |
| 50 | + pvkDokument.changeStamp.lastModifiedDate !== '' |
| 51 | + ? `sist endret: ${moment(pvkDokument.changeStamp.lastModifiedDate).format('ll')}` |
| 52 | + : '' |
| 53 | + } |
| 54 | + /> |
| 55 | + ))} |
| 56 | + </List> |
| 57 | + </div> |
| 58 | + )} |
| 59 | + </div> |
| 60 | + ) |
| 61 | +} |
0 commit comments